akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
inline ll LCM(ll a, ll b){return a / GCD(a, b) * b;}
inline ll powint(ll x, ll y){ll r=1;while(y){if(y&1)r*=x;x*=x;y>>=1;}return r;}
inline ll powmod(ll x, ll y, ll m = MOD){ll r=1;while(y){if(y&1)r*=x;x*=x;r%=m;x%=m;y>>=1;}return r;}
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    string a;
    cin >> a;
    string b;
    cin >> b;
    string c;
    cin >> c;
    ll ans = 0;
    rep(i, n){
        if(a[i] == b[i] && b[i] == c[i]){
            continue;
        }else if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i]){
            ans++;
        }else{
            ans += 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    set<char> S;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) S.insert(s[i]);
    if (S.size() == 1) cout << "No" << '\n';
    else cout << "Yes" << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << a[0] + a[1] + a[2] * 10 << endl;
    return 0;
}


Measured memory_bytes: 256
//itp1_topic2_a
#include<bits/stdc++.h>

using namespace std;

int main(){

int w,h,x,y,r;
cin>>w>>h>>x>>y>>r;

if(x-r>=0 && x+r<=w && y-r>=0 && y+r<=h)
cout<<"Yes"<<endl;
else cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 3088
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// my code goes here
		
		int n = int.Parse(Console.ReadLine());
		string s = Console.ReadLine();
		string a;
		string b;
		
		
		if(n%2==1){
			Console.WriteLine("No");
		}else{
			a = s.Substring(0,n/2);
			b = s.Substring(n/2,n/2);
			
			if(a==b){
				Console.WriteLine("Yes");
			}else{
				Console.WriteLine("No");
			}
			
		}
		
		
	}
}

Measured memory_bytes: 11092
# coding: utf-8
N=int(input())
s=0
A=[]
for i in range(1,N+1):
    s+=i
    A.append(i)
    if s>=N:
        l=i
        break
d=s-N
#d_=l+1-d
#print(A)
for a in A:
    if a!=d:
        print(a)
    

Measured memory_bytes: 42456
// inputに入力データ全体が入る
function Main(input) {

  // 1行目がinput[0], 2行目がinput[1], …に入る
  var input1 = input.split("\n");
  // console.log(input1)
  var i = Number(input1[0])
  var str = input1[1]

  const alph = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]

  const v1 = str.split('')

  var v2 = v1.map(function (v) {
    var v11 = alph.findIndex(function (v2) { return v2 === v })
    var v12 = ((v11 + i) % alph.length)
    return alph[v12]
  }).join('')

  // //文字列から10進数に変換するときはparseIntを使います
  // // var a = parseInt(i[0], 10);
  // // var b = parseInt(i[1], 10);
  // // var c = parseInt(i[2], 10);
  // var i1 = i.map(v => parseInt(v, 10))


  // console.log(input1[0])
  // // console.log(input1[0], i, i1, i1.some(v => v % 2 !== 0))

  // var count1 = 0
  // while (!i1.some(v => v % 2 !== 0)) {
  //   i1 = i1.map(v => v / 2)
  //   count1++
  // }

  // console.log(a,b,a + b, (a + b) % 2)
  // var s = a + b + c

  //出力
  console.log(v2);
}



//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8508
import collections
import itertools
import operator


class UnionFind:
    def __init__(self, x):
        class KeyDict(dict):
            def __missing__(self, key):
                self[key] = key
                return key

        self.parent = KeyDict()
        self.rank = collections.defaultdict(int)
        self.size = collections.defaultdict(lambda: 1)
        if x is not None:
            for elem in range(x+1):
                _, _, _ = self.parent[elem], self.rank[elem],self.size[elem]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if not self.are_same(x,y):
            xx = self.size[x]
            yy = self.size[y]
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += xx
            else:
                self.parent[y] = x
                self.size[x] += yy
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def Size(self,x):
        return self.size[self.find(x)]

    def are_same(self, x, y):
        '''print(x,y,self.find(x),self.find(y),self.find(x) == self.find(y))'''
        return self.find(x) == self.find(y)

    def grouper(self):
        roots = [(x, self.find(x_par)) for x, x_par in self.parent.items()]
        root = operator.itemgetter(1)
        for _, group in itertools.groupby(sorted(roots, key=root), root):
            yield [x for x, _ in group]

n,m = map(int,input().split())

a = [list(map(int,input().split())) for i in range(m)]
co = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i != j:
            uf.unite(a[j][0],a[j][1])
    aa = list(uf.grouper())
    if len(aa) != 2:
        co +=1
print(co)




Measured memory_bytes: 3436
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define forn(i,n)       for(int i=0; i<n; i++)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}






int32_t main()
{
    zeus();

    int n, k; cin >> n >> k;

    int a[n + 1];
    a[0] = 0;
    forn(i, n) {
        cin >> a[i + 1];
    }
    int i = 1;

    unordered_map<int, int> visited;
    visited.insert({1, 0});
    int count = 0;

    int loop_length, loop_start, loop_start_index;

    while (true) {

        int next = a[i];
        count++;
        i = next;
        if (visited.count(next) == 0) {
            visited.insert({next, count});
        }
        else {
            auto itr = visited.find(next);
            loop_length = count - itr->second;
            loop_start = itr->second;
            loop_start_index = itr->first;
            break;
        }




    }
    //cout << loop_start_index << endl;
    if (k < loop_start) {
        int x = 1;
        forn(i, k) {
            x = a[x];
        }
        cout << x;
        return 0;
    }

    else {
        k = k - loop_start;
        k = k % loop_length;

        int x = loop_start_index;

        forn(i, k) {
            x = a[x];
        }

        cout << x;

    }



}

Measured memory_bytes: 12880
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  string s;
  cin >> s;
  
  int n = s.size();
  vector<int> a(n, 0);

  int tail = -1;
  for (int i = 0; i < n; i++){
    if (tail == -1){
      tail++;
      a[tail] = s[i];
    }
    else if (a[tail] != s[i]){
      tail--;
    }
    else {
      tail++;
      a[tail] = s[i];
    }
  }

  cout << n - tail - 1 << endl;

  return 0;
}

ll gcd(ll a, ll b){
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;
int a[1000001];

int main(void){
	scanf("%d%d",&n,&k);
	int v=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]==1)v=i;
	}
	int ans=11451419;
	for(int i=0;i<=n-k;i++){
		if(i<=v && v<i+k){
			int val=1;
			val+=(i+k-2)/(k-1);
			int right=n-i;
			right-=k;
			val+=(right+k-2)/(k-1);
			ans=min(ans,val);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
import math

n = int(input())

coords = [list(map(int, input().split())) for j in range(n)]

distance_sum = 0
for i in range(n):
    for j in range(i+1, n):
        distance_sum += math.sqrt((coords[i][0] - coords[j][0])**2 + (coords[i][1] - coords[j][1])**2)

print(distance_sum * (n-1) / (n * (n-1) // 2) )
# 完全グラフの変数は n * (n-1) // 2, うち1回の経路で使うのはn-1本。
# 約分して以下のようにもできる；
# print(distance_sum * 2 / n)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y){
    return (y != 0) ? gcd(y, x%y) : x;
}

//素因数分解はO(√n)までオーダーを落とせる
vector<pair<ll, int>> factorize(ll n){
    vector<pair<ll, int>> v;
    v.emplace_back(1, 1);
    for (ll i=2; i * i < n; i++) {
        if (n%i != 0) continue;
        v.emplace_back(i, 0);
        while (n%i == 0) {
            n /= i;
            v.back().second++;
        }
    }
    if (n != 1) v.emplace_back(n, 1);
    return v;
}

int main()
{
    ll A, B; cin >> A >> B;
    ll gcd_val = gcd(A, B);
    auto res = factorize(gcd_val);
    int ans = res.size();
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 200001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}


int main(){
  ll n,w; cin >> n >> w;
  vl weight(n); vl value(n); vvl dp(n+1,vl(w+1));
  
  rep(i,n){
    cin >> weight[i] >> value[i];
  }
  
  for(ll i=1; i <= n; i++){
    for(ll j=1; j <= w; j++){
      if(j - weight[i-1] >= 0){
        dp[i][j] = max(dp[i-1][j],
                       dp[i-1][j-weight[i-1]] + value[i-1]);
      }
      else dp[i][j] = dp[i-1][j];
    }
  }
  
  cout << dp[n][w] << endl;
 
  
}

Measured memory_bytes: 83104
n = gets.to_s.to_i
a = [0] + gets.to_s.split.map{|i| i.to_i }

(n/2).downto(1) do |i|
  a[i] = i.step(n,i).map{|j| a[j] }.reduce(0){|s,t| s+=t } & 1
end

ans = (1..n).select{ |i| a[i] == 1 }
puts ans.size, ans * " "

Measured memory_bytes: 37480
N,C,K=map(int,input().split())
T=sorted([int(input()) for _ in range(N)])
First=T[0]
bus_rider=1
bus_cnt=1
for i in range(1,N):
    if bus_rider<C and T[i]-First<=K:
        bus_rider+=1
    else:
        First=T[i]
        bus_rider=1
        bus_cnt+=1
print(bus_cnt)

Measured memory_bytes: 8276
#include<bits/stdc++.h>
#define ll long long
#define rint register int
#define Maxn 100
#define inf 1<<30
#define cmin(x,y) (x>y)&&(x=y)
#define cmax(x,y) (x<y)&&(x=y)
using namespace std;
inline int read(){int s=0,w=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();return s*w;}
void write(int v){if(v<0){putchar('-');v=-v;}if(v>9)write(v/10);putchar(v%10+'0');}
int main()
{
	//freopen("xxx.in", "r", stdin);
    //freopen("xxx.out", "w", stdout);
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(max(max(b*d,a*d),a*c),b*c);
	return 0;
}
/*
 * ┌───┐   ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┐
 * │Esc│   │ F1│ F2│ F3│ F4│ │ F5│ F6│ F7│ F8│ │ F9│F10│F11│F12│ │P/S│S L│P/B│  ┌┐    ┌┐    ┌┐
 * └───┘   └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┘  └┘    └┘    └┘
 * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ ┌───┬───┬───┐ ┌───┬───┬───┬───┐
 * │~ `│! 1│@ 2│# 3│$ 4│% 5│^ 6│& 7│* 8│( 9│) 0│_ -│+ =│ BacSp │ │Ins│Hom│PUp│ │Num│ / │ * │ - │
 * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ ├───┼───┼───┤ ├───┼───┼───┼───┤
 * │ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │{ [│} ]│ | \ │ │Del│End│PDn│ │ 7 │ 8 │ 9 │   │
 * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ └───┴───┴───┘ ├───┼───┼───┤ + │
 * │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │: ;│" '│ Enter  │               │ 4 │ 5 │ 6 │   │
 * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤     ┌───┐     ├───┼───┼───┼───┤
 * │ Shift  │ Z │ X │ C │ V │ B │ N │ M │< ,│> .│? /│  Shift   │     │ ↑ │     │ 1 │ 2 │ 3 │   │
 * ├─────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ ┌───┼───┼───┐ ├───┴───┼───┤ E││
 * │ Ctrl│ Win│ Alt│         Space         │ Alt│ Win│Menu│Ctrl│ │ ← │ ↓ │ → │ │   0   │ . │←─┘│
 * └─────┴────┴────┴───────────────────────┴────┴────┴────┴────┘ └───┴───┴───┘ └───────┴───┴───┘
 */


Measured memory_bytes: 3632
# B - ROT N
n = (int)(input())
s = list(input())

def translate(s, n):
    alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

    for i in range(0, 26):
        if alphabet[i] == s:
            return alphabet[(i + n) % 26]



for c in s:
    print(translate(c, n), end="")




Measured memory_bytes: 4596
N = int(input())
A = list(map(int, input().split()))

total = sum(A)
half = total/2

aa = 0

for i in range(N):
    aa += A[i]
    if aa > half:
        check_num = i
        break

cost = 0 
OK = False
        
if sum(A[:check_num+1]) < sum(A[check_num:]):
    B = A[:check_num+1]
    C = A[check_num+1:]
else:
    B = A[:check_num]
    C = A[check_num:]


print(abs(sum(B)-sum(C)))

 

Measured memory_bytes: 26764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int>data(n);
  for(int i=0; i<n; i++)
    cin >> data.at(i);
  vector<bool>mochi(n, true);
  for(int i=1; i<n; i++){
    for(int j=0; j<i; j++){
      if(data.at(i) == data.at(j))
        mochi.at(i) = false;
      else
        continue;
    }
  }
  int count=0;
  for(int i=0; i<n; i++){
    if(mochi.at(i))
      count++;
  }
  cout << count;
}

Measured memory_bytes: 256
#import random


n = int(input())
info = [list(map(int, input().split())) for i in range(n)]
INF = 10 ** 13

#n = 15
#info = []
#for i in range(n):
#    info.append([random.randint(-10000, 10000), random.randint(-10000, 10000), random.randint(1, 1000000)])


costs = [INF] * n
for i, (x, y, c) in enumerate(info):
    costs[i] = c * min(abs(x), abs(y))

OFFSET = n
x_dir = [INF] * ((1 << n) * OFFSET)
y_dir = [INF] * ((1 << n) * OFFSET)


for bit_state in range(1 << n):
    for i, (xi, yi, c) in enumerate(info):
        x_dir[bit_state * OFFSET + i] = min(costs[i], x_dir[bit_state * OFFSET + i])
        y_dir[bit_state * OFFSET + i] = min(costs[i], y_dir[bit_state * OFFSET + i])
        if not((bit_state >> i) & 1):
            continue
        for j, (xj, yj, c) in enumerate(info):
            x_dir[bit_state * OFFSET + j] = min(x_dir[bit_state * OFFSET + j], c * abs(yi - yj))
            y_dir[bit_state * OFFSET + j] = min(y_dir[bit_state * OFFSET + j], c * abs(xi - xj))


ans = [INF] * (n + 1)
for bit_state in range((1 << n) - 1):
    x_bit = bit_state
    cnt = bin(bit_state).count("1")
    while x_bit >= 0:
        x_bit &= bit_state
        # bit_stateの下位集合sub_stateの列挙
        # 処理はじめ
        y_bit = bit_state - x_bit
        tmp = 0
        for i in range(n):
            tmp += min(x_dir[x_bit * OFFSET + i], y_dir[y_bit * OFFSET + i])
        ans[cnt] = min(ans[cnt], tmp)
        # 処理おわり
        x_bit -= 1

ans[-1] = 0
for res in ans:
    print(res)

Measured memory_bytes: 77512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define ll long long

int main(){
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a),q(b),r(c),v;
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(p.begin(),p.end(),greater<ll>());
    sort(q.begin(),q.end(),greater<ll>());
    sort(r.begin(),r.end(),greater<ll>());
    rep(i,x) v.push_back(p[i]);
    rep(i,y) v.push_back(q[i]);
    rep(i,c) v.push_back(r[i]);
    sort(v.begin(),v.end(),greater<ll>());
    ll sum = 0;
    rep(i,x+y) sum += v[i];
    cout << sum << endl;
}

Measured memory_bytes: 8816
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
#define N 100010
int a[N],dp[N];
int main()
{
    int i,j,k,n,m;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(i=2;i<=n;i++)
    {
        dp[i]=1000000000;
    for(j=max(1,i-m);j<i;j++)
        dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
    }
    printf("%d\n",dp[n]);
    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#include<string.h>
int main(){
        char s0[100], s1[200], s2[100];
        scanf("%s", s0);
        strcat(s1, s0);
        strcat(s1, s0);
        scanf("%s", s2);
        if(strstr(s1, s2) != NULL){
                printf("Yes\n");
        }else{
                printf("No\n");
        }
        return 0;
}

Measured memory_bytes: 1760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n) cin >>a[i];
    int count=0;
    rep(i,n){
        if(a[i]==count+1){
            ++count;
        }
    }
    if(count==0) cout <<-1<<endl;
    else cout << n-count <<endl;
    return 0;
}

Measured memory_bytes: 1024
/*
ID: hzhu7271 
LANG: C++
TASK: 
*/
#include <bits/stdc++.h>

using namespace std;

#define endl "\n"
#define pb push_back
#define ar array
typedef long long ll;
typedef string str;

void setIO(string filename = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if ((int)filename.size()) {
        freopen((filename+".in").c_str(), "r", stdin);
        freopen((filename+".out").c_str(), "w", stdout);
    }
}

str a,b;
int dp[3001][3001];

int main() {
    setIO("");
    cin >> a >> b;
    int n = (int)a.size();
    int m = (int)b.size();
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            if(a[i-1]==b[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else{
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
            }
        }
    }
    int sz = dp[n][m];
    if(sz==0)
        cout << "" << endl;
    else{
        str ans="";
        int i=n,j=m;
        while(i!=0 && j!=0){
            if(a[i-1]==b[j-1]){
                ans+=b[j-1];
                --i;
                --j;
            }
            else if(dp[i][j-1]>dp[i-1][j]){
                --j;
            }
            else{
                --i;
            }
        }
        reverse(ans.begin(),ans.end());
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 38840
def double_rock(field, begin ,end):
  rock = False
  for i in range(begin, end + 1):
    if field[i] == '#':
      if rock:
        #print 'NO'
        return True
        break
      rock = True
    else:
      rock = False
  return False

n, a, b, c, d = [int(v) for v in input().split()]
a -= 1
b -= 1
c -= 1
d -= 1

s = input()
field = list(s)

if c < d:
  if double_rock(field, a, d):
    ans = "No"
  else:
    ans = "Yes"
else:
  b_ok = False
  dot_count = 0
  for i in range(b-1, d+2):
    if field[i] == '.':
      dot_count += 1
    else:
      dot_count = 0
    if dot_count == 3:
      b_ok = True
  if b_ok and not double_rock(field, a, c):
    ans = "Yes"
  else:
    ans = "No"
print(ans)

Measured memory_bytes: 4924
#include <iostream>
#include <climits>
#define endl '\n'

using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N;
    string str; cin >> N >> str;
    auto west = new int[N]();
    auto east = new int[N]();
    
    for(int i = 0; i < N; i++)
    {
        if(str[i] == 'W')
        {
            west[i] = 1;
            if(i == 0) continue;
            west[i] += west[i-1];
            east[i] += east[i-1];
        }
        else
        {
            east[i] = 1;
            if(i == 0) continue;
            east[i] += east[i-1];
            west[i] += west[i-1];
        }
    }
    
    int ret = INT_MAX;
    
    for(int i = 0; i < N; i++)
    {
        int left = 0;
        int right = 0;
        if(i != 0)
        {
            left = west[i-1];
        }
        right = east[N - 1] - east[i];
        
        ret = min(ret, left + right);
    }
    
    cout << ret;
    
    return 0;
}


Measured memory_bytes: 3068
s = input()
sr = s[::-1]
d =  "dream"[::-1]
dr = "dreamer"[::-1]
e = "erase"[::-1]
er = "eraser"[::-1]

while True:
  if len(sr) == 0:
    print("YES")
    break
  elif len(sr) < 5:
    print("NO")
    break
  else:
    if sr[:5] == d:
      sr = sr.replace(d, "", 1)
    elif sr[:5] == e:
      sr = sr.replace(e, "", 1)
    elif sr[:7] == dr:
      sr = sr.replace(dr, "", 1)
    elif sr[:6] == er:
      sr = sr.replace(er, "", 1)
    else:
      print("NO")
      break
    

Measured memory_bytes: 9260
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    if((a==1&&b==2)||(a==2&&b==1))
        puts("3");
    if((a==2&&b==3)||(a==3&&b==2))
        puts("1");
    if((a==1&&b==3)||(a==3&&b==1))
        puts("2");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    int ans = N;
    for (int i = 0; i < M; i++) {
        int Ai;
        cin >> Ai;
        ans -= Ai;
    }
    cout << ( ans >= 0 ? ans : -1 ) << endl;

    return 0;
}



Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		n, _ := strconv.Atoi(line)

		var p2 = 1
		for {
			if n < 2*p2 {
				break
			}
			p2 *= 2
		}

		fmt.Printf("%v\n", p2)
	}
}



Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  int k;
  cin >> k;
  int odd = 0;
  int even = 0;
  for(int i=1;i<=k;i++){
    if(i%2) odd ++;
    else even ++;
  }
  cout << odd*even << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>

#define INF 10000000000
using namespace std;
using P = pair<long, long>;

int main(){
    string s;
	int k;
	cin >> k >> s;

	if(s.size() <= k){
		cout << s << endl;
	}else{
		cout << s.substr(0, k) + "..." << endl;
	}
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
void read(long long &x){
    char ch;bool ok;
    for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
    for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=110;
long long a,b,x,y,l,r,ans,ll,rr;
int aa[maxn],bb[maxn],lena,lenb,len,k;
int main(){
    read(a),read(b);x=a,y=b;
    while(a)aa[++lena]=a&1,a>>=1;
    while(b)bb[++lenb]=b&1,b>>=1;
    for(rg int i=max(lena,lenb);i;i--){
        if(aa[i]!=bb[i]){len=i;break;}
        x-=1ll*aa[i]<<(i-1);
        y-=1ll*bb[i]<<(i-1);
    }
    for(rg int i=len-1;i;i--)if(bb[i]){k=i;break;}
    l=x,r=(1ll<<(len-1))+(1ll<<k)-1;
    ll=(1ll<<(len-1))+x,rr=(1ll<<len)-1;
    if(ll>r)ans=r-l+1+rr-ll+1;
    else ans=rr-l+1;
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
// D - Manhattan Max Matching
#include <bits/stdc++.h>

using namespace std;

long long mincostflow(const vector<pair<pair<int, int>, pair<long long, long long> > > &e,
                      int n, int s, int t, long long d)
{
	vector<vector<int> > adj(n);
	vector<pair<pair<int, int>, pair<long long, long long> > > g;
	for (int i = 0; i < e.size(); i++) {
		int u = e[i].first.first, v = e[i].first.second;
		long long c = e[i].second.first, a = e[i].second.second;
		adj[u].push_back(g.size());
		g.push_back(make_pair(make_pair(u, v), make_pair(c, a)));
		adj[v].push_back(g.size());
		g.push_back(make_pair(make_pair(v, u), make_pair(0, -a)));
	}

	long long flow = 0, mincost = 0;
	while (flow < d) {
		// Use SPFA to find the possible flow
		vector<int> inqueue(n), parent(n, -1);
		vector<long long> dist(n, -1);
		dist[s] = 0;
		inqueue[s] = 1;
		queue<int> q;
		for (q.push(s); !q.empty(); q.pop()) {
			int u = q.front();
			inqueue[u] = 0;
			for (int i = 0; i < adj[u].size(); i++) {
				int id = adj[u][i], v = g[id].first.second;
				long long c = g[id].second.first, a = g[id].second.second;
				if (c > 0 && (dist[v] < 0 || dist[v] > dist[u] + a)) {
					dist[v] = dist[u] + a;
					parent[v] = id;
					if (!inqueue[v]) q.push(v), inqueue[v] = 1;
				}
			}
		}

		if (dist[t] < 0) break;

		long long f = d - flow;
		for (int v = t, id = parent[v]; v != s; v = g[id].first.first, id = parent[v])
			f = min(f, g[id].second.first);
		flow += f;
		mincost += f * dist[t];
		for (int v = t, id = parent[v]; v != s; v = g[id].first.first, id = parent[v])
			g[id].second.first -= f, g[id ^ 1].second.first += f;
	}

	return flow < d ? -1 : mincost;
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int n, d = 0;
	cin >> n;

	vector<pair<pair<int, int>, pair<long long, long long> > > e;
	int src = n * 2 + 4, sink = n * 2 + 4 + 1, type = n * 2;

	const long long base = 10000000000;
	for (int i = 0; i < n; i++) {
		long long x, y, c;
		cin >> x >> y >> c;
		e.push_back(make_pair(make_pair(src, i), make_pair(c, 0)));
		e.push_back(make_pair(make_pair(i, type + 0), make_pair(1 << 28, base - (x + y))));
		e.push_back(make_pair(make_pair(i, type + 1), make_pair(1 << 28, base - (-x + y))));
		e.push_back(make_pair(make_pair(i, type + 2), make_pair(1 << 28, base - (x - y))));
		e.push_back(make_pair(make_pair(i, type + 3), make_pair(1 << 28, base - (-x - y))));
		d += c;
	}
	for (int i = 0; i < n; i++) {
		long long x, y, c;
		cin >> x >> y >> c;
		e.push_back(make_pair(make_pair(n + i, sink), make_pair(c, 0)));
		e.push_back(make_pair(make_pair(type + 0, n + i), make_pair(1 << 28, base - (-x - y))));
		e.push_back(make_pair(make_pair(type + 1, n + i), make_pair(1 << 28, base - (x - y))));
		e.push_back(make_pair(make_pair(type + 2, n + i), make_pair(1 << 28, base - (-x + y))));
		e.push_back(make_pair(make_pair(type + 3, n + i), make_pair(1 << 28, base - (x + y))));
	}

	long long cost = mincostflow(e, n * 2 + 6, src, sink, d);
	cout << d * base * 2 - cost << endl;

	return 0;
}


Measured memory_bytes: 1464
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int k, a, b; cin >> k >> a >> b;
	bool ok = 0;
	rep(i, a, b + 1) if (i % k == 0) ok = 1;
	cout << (ok ? "OK" : "NG") << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
	int n, d;
	cin >> n >> d;

	int range = 2*d+1;
	cout << (n+(range-1))/range << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  char res[100][101];
  int A,B,a=1,b=1;
  cin >> A >> B;
  for(int i =0 ;i<50;i++)
    for(int j=0;j<100;j++)
      res[i][j] = '.';
  for(int i =50 ;i<100;i++)
    for(int j=0;j<100;j++)
      res[i][j] = '#';
  REP(i,100)res[i][100] = '\0';
  
  for(int i =0 ;i<49;i+=2)
    for(int j=0;j<100;j+=2){
      if(B == b){
        i = 49;
        j = 100;
      }else{
        res[i][j] = '#';
        b++;
      }
    }
  for(int i =51 ;i<100;i+=2)
    for(int j=0;j<100;j+=2){
      if(A == a){
        i = 100;
        j = 100;
      }else{
        res[i][j] = '.';
        a++;
      }
      
    }
  cout << 100 << " " << 100 << endl;
  REP(i,100)cout << res[i] << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
import sys
s=input()
t=input()
for c in ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]:
    if s+c==t:
        print("Yes")
        sys.exit(0)
print("No")


Measured memory_bytes: 9124
#include<iostream>
using namespace std;
#include <vector>  
#include<algorithm>

int main()
{
	int H,W,N;


	 int result = 1;


	cin >> H >> W >>N;

	int high, low;

	if (H > W) {
		high = H;
		low = W;
	}
	else {
		high = W;
		low = H;
	}

	if (N % high == 0) {
		result = N / high;
	}
	else {
		result = (N / high) + 1;
	}

	

	cout << result << endl;
	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++){
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  int m = 2e9;
  for (int i = 0; i < N - K + 1; i++){
    m = min(m, h[i + K - 1] - h[i]);
  }
  cout << m << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    if(X < Y){
        swap(A, B);
        swap(X, Y);
    }

    int res = min(A + B, 2 * C) * Y;
    X -= Y, Y = 0;
    res += min(A, 2 * C) * X;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;



//defines...
#define ll long long
#define tata return;
#define pb push_back
#define mp make_pair
#define in insert
#define run ios_base::sync_with_stdio(false);cin.tie(NULL);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define vec vector<ll>
#define setl set<ll>
#define mapl map<ll,ll>
#define shunno cout<<0<<endl;
#define ek cout<<1<<endl;
#define pi 2*acos(0.0)1
#define hobena cout<<-1<<endl;




//typedefs...
typedef pair<ll,ll>pll;

//const..
//const ll fx[]={0,1,0,-1};
//const ll fy[]={1,0,-1,0};
const ll mod=1e9+7;

/*ll ncr(ll n, ll k)
{
    ll res = 1;


    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
*/

void oka()
{

        ll f=0,s=0,i;
        ll a[3];
        for(i=0;i<3;i++)
        {
            cin>>a[i];
            if(a[i]==5) f++;
            if(a[i]==7) s++;
        }
        if(f==2&&s==1)
        {
            yes
        }
        else
            no

}












int main()
{
  // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    run
    ll t;
    t=1;
  //cin>>t;
    while(t--){

    oka();
    }



}


Measured memory_bytes: 3636
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	string A,B,C;
	cin>>A>>B>>C;
	char next='a';
	while(1){
		switch(next){
			case 'a':
				if(A.empty()){
					puts("A");
					return 0;
				}
				next=A[0];
				A.erase(A.begin());
			break;
			
			case 'b':
				if(B.empty()){
					puts("B");
					return 0;
				}
				next=B[0];
				B.erase(B.begin());
			break;

			case 'c':
				if(C.empty()){
					puts("C");
					return 0;
				}
				next=C[0];
				C.erase(C.begin());
			break;
		}
	}
	return 0; 
}



Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;
vector<int>ord(256, -1);

long long int Calc(const string& s, int l=0, int r=N) {
//	cout << l << " " << r << endl;
	bool flag = true;
	for (int i = l; i < r; i++) {
		if (s[i] > '9' || s[i] < '0')flag = false;
	}
	if (flag) {
		long long int num = 0;
		for (int i = l; i < r; i++) {
			num *= 10;
			num += s[i] - '0';
		}
		return num;
	}
	int m = MOD;
	int st = 0;
	for (int i = l; i < r - 1; i++) {
		if (s[i] == '(')st++;
		if (s[i] == ')')st--;
		m = min(m, st);
	}
	if (m == 1 && s[r - 1] == ')') {
		return Calc(s, l + 1, r - 1);
	}
	st = 0;
	for (int i = r-1; i >=l; i--) {
		if (s[i] == '(')st++;
		if (s[i] == ')')st--;
		if (st == 0 && ord[s[i]] == 0) {
			if (s[i] == '+')return Calc(s, l, i) + Calc(s, i + 1, r);
			if (s[i] == '-')return Calc(s, l, i) - Calc(s, i + 1, r);
			if (s[i] == '*')return Calc(s, l, i) * Calc(s, i + 1, r);
		}
	}
	for (int i = r - 1; i >= l; i--) {
		if (s[i] == '(')st++;
		if (s[i] == ')')st--;
		if (st == 0 && ord[s[i]] == 1) {
			if (s[i] == '+')return Calc(s, l, i) + Calc(s, i + 1, r);
			if (s[i] == '-')return Calc(s, l, i) - Calc(s, i + 1, r);
			if (s[i] == '*')return Calc(s, l, i) * Calc(s, i + 1, r);
		}
	}
	for (int i = r - 1; i >= l; i--) {
		if (s[i] == '(')st++;
		if (s[i] == ')')st--;
		if (st == 0 && ord[s[i]] == 2) {
			if (s[i] == '+')return Calc(s, l, i) + Calc(s, i + 1, r);
			if (s[i] == '-')return Calc(s, l, i) - Calc(s, i + 1, r);
			if (s[i] == '*')return Calc(s, l, i) * Calc(s, i + 1, r);
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;
	N = s.size();
	string op = "+-*";
	for (auto i : op)ord[i] = 0;
	long long int ans = LLONG_MIN;
	while (ord['*'] < 3) {
		//for (auto i : op) {
		//	cout << i << " " << ord[i] << endl;
		//}
		//cout << Calc(s) << endl;
		ans = max(ans, Calc(s));
		ord['+']++;
		for (int i = 0; i < 2; i++) {
			if (ord[op[i]] == 3) {
				ord[op[i + 1]]++;
				ord[op[i]] = 0;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int NIL = -2e9;
struct Node { int key, l = NIL, r = NIL; };
vector<Node> T(1e6);
inline void insert(int z) {
	if(z == 0) return;
	int y = NIL;
	int x = 0;
	while(x != NIL) {
		y = x;
		x = (T[z].key < T[x].key ? T[x].l : T[x].r);
	}
	(T[z].key < T[y].key ? T[y].l : T[y].r) = z;
}
inline void inorder(int x) {
	if(x == NIL) return;
	inorder(T[x].l);
	cout << ' ' << T[x].key;
	inorder(T[x].r);
}
inline void preorder(int x) {
	if(x == NIL) return;
	cout << ' ' << T[x].key;
	preorder(T[x].l);
	preorder(T[x].r);
}
int main() {
	int n; cin >> n;
	string s;
	int x;
	rep(i, 0, n) {
		cin >> s;
		if(s == "insert") {
			cin >> x;
			T[i].key = x;
			insert(i);
		} else {
			inorder(0);
			P("");
			preorder(0);
			P("");
		}
	}
	return 0;
}

Measured memory_bytes: 14324
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF=1000000007;

int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> AC(n);
  for(int i=1; i<n; i++) {
    AC[i]=AC[i-1];
    if(s[i-1]=='A'&&s[i]=='C') AC[i]++;
  }
  vector<int> ans(q);
  rep(i,q) {
    int l, r;
    cin >> l >> r;
    l--; r--;
    ans[i]=AC[r]-AC[l];
  }

  rep(i,q) cout << ans[i] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int MAX_N = (1<<18)-1;

vector<ll> x;
vector<ll> dat[MAX_N];

void init(int k, int l, int r)
{
    if (r - l == 1) {
        dat[k].push_back(x[l]);
    } else {
        int lch = k * 2 + 1, rch = k * 2 + 2;
        init(lch, l, (l + r) / 2);
        init(rch, (l + r) / 2, r);
        dat[k].resize(r - l);

        merge(dat[lch].begin(), dat[lch].end(),
              dat[rch].begin(), dat[rch].end(),
              dat[k].begin());
    }
}

int query(int i, int j, ll x, int k, int l, int r)
{
    if (j <= l || r <= i) {
        return 0;
    } else if (i <= l && r <= j) {
        return upper_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
    } else {
        int lc = query(i, j, x, k * 2 + 1, l, (l + r) / 2);
        int rc = query(i, j, x, k * 2 + 2, (l + r) / 2, r);
        return lc + rc;
    }
}

int main()
{
    ll D, Q, l, r, e;
    cin >> D;
    x.resize(D);
    for (int i = 0; i < D; i++) {
        cin >> x[i];
    }    
    
    init(0, 0, D);
    
    cin >> Q;
    while (Q--) {
        cin >> l >> r >> e;
        l--; r--;
        ll a = min(x[l], x[r]) - e, b = max(x[l], x[r]) + e;        
        cout << query(l, r+1, a-1, 0, 0, D) + (r - l + 1) - query(l, r+1, b, 0, 0, D) << endl;
    }
    return 0;
}

Measured memory_bytes: 27176
#include<stdio.h>
int main(void){
    int S;
    scanf("%d",&S);
    if(S>=0&&S<=86400){
        int h,m,s;
        for(h=0;S>=3600;h++){
            S = S-3600;
        }
        for(m=0;S>=60;m++){
            S = S-60;
        }
        for(s=0;S>0;s++){
            S= S-1;
        }
        printf("%d:%d:%d\n",h,m,s);
    }
    return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
int main(void){
	int H,W;
	int i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H == 0&&W == 0)break;
		for(i = 1;i < H+1;i++){
			for(j = 1;j < W+1;j++){
				if(i % 2 == 1 && j % 2==1){
					printf("#");
				}else if(i % 2 != 1&& j % 2 != 1){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
    return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define INT INT_MAX
#define LONG LLONG_MAX
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define int long long
typedef long long ll;
using namespace std;

ll GCD(ll a, ll b) {
	if (b == 0)return a;
	return GCD(b, a%b);
}

ll LCM(ll a, ll b) {
	return a / GCD(a, b)*b;
}

ll mypow(ll a, ll b, ll c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	else return mypow(a, b / 2, c)*mypow(a, b / 2, c) % c;
}

ll longmax(ll a,ll b){
	if(a>b) return a;
	else return b;
}

ll longmin(ll a,ll b){
	if(a<b) return a;
	else return b;
}

signed main(){
	int a;
	cin>>a;
	if(a/100*111<a) cout<<a/100*111+111<<endl;
	else cout<<a/100*111<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
      
      
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int W = sc.nextInt();
			int Q = sc.nextInt();
			if(W == 0 && Q == 0) break;
			int[] list = new int[W];
			boolean[] use = new boolean[W];
			for(int i = 0; i < Q; i++) {
				char in = sc.next().charAt(0);
				if(in == 's') {
					int id = sc.nextInt();
					int w  = sc.nextInt();
					boolean ok = false;
					int b = 0;
					for(int j = 0; j < W; j++) {
						boolean check = true;
						for(int k = 0; k < w; k++) {
							if(j + k >= W) {
								check = false;
								break;
							}
							if(use[j + k]) {
								check = false;
								break;
							}
						}
						if(!check) continue;
						ok = true;
						b = j;
						for(int k = 0; k < w; k++) {
							use[j + k] = true;
							list[j + k] = id;
						}
						break;
					}
					if(!ok) {
						System.out.println("impossible");
					}
					else {
						System.out.println(b);
					}
				}
				if(in == 'w') {
					int id = sc.nextInt();
					for(int j = 0; j < W; j++) {
						if(use[j] && list[j] == id) {
							use[j] = false;
						}
					}
				}
			}
			System.out.println("END");
		}
	}
 }

Measured memory_bytes: 28152
import math
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, M = list(map(int, sys.stdin.buffer.readline().split()))


def get_divisors(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret


divs = get_divisors(M)
# M の約数を N 以上繰り返した数列を作って、N 番目より後ろの要素をどっかに加算する
divs.sort(reverse=True)
for d in divs:
    if M // d >= N:
        print(d)
        break


Measured memory_bytes: 3064