akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
#define endl "\n"
using namespace std;
 
 

 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 

 
ll mul_inv(ll a, ll b) {
    ll b0 = b, t, q;
    ll x0 = 0ll, x1 = 1ll;
    if (b == 1ll) return 1ll;
    while (a > 1ll) {
        q = a / b;
        t = b, b = a % b, a = t;
        t = x0, x0 = x1 - q * x0, x1 = t;
    }
    if (x1 < 0ll) x1 += b0;
    return x1;
}
 
 
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()
#define vpi std::vector<pll>
#include <array>
#include <stack>
#define arr2 array<ll,2>
#define arr3 array<ll,3>
#define varr2 vector<array<ll,2> >
#define varr3 vector<array<ll,3> >
//include<bits/stdc++.h>
 
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second>y.second;}
bool f2(pll &x,pll &y){
    return x.first>y.first;
}
 
 
bool f3(ll &x,ll &y){
    return x>y; 
    }


const ll maxn=2e5+2;





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

string a;cin>>a;
string s=a;
if(a[a.S-1]=='s'){

s+="es";
}
else{
s+='s';
}
p1(s);

  







return 0;
}





  







Measured memory_bytes: 3616
N, M = map(int, input().split())

t = (N - M) * 100 + M * 1900
a = 1/2**M
b = 1 - a

ans = 0.
for i in range(1, 1000):
    ans += t * i * a * b**(i-1)
ans = int(ans)
if ans % 10 != 0:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>

using namespace std;

int main(){
  long long n,ans = 0,max = 0;
  vector<long long> a;
  cin >> n;
  a.resize(n);
  for(long long i = 0; i < n;i++){
    cin >> a[i];
  }
  
  for(long long i = 0; i < n;i++){
    if(max < a[i]){
      max = a[i];
    }
    ans += max - a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4820
k = gets.to_i
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
p a[k-1]

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int main(){
  ll a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a);
  vector<ll> t(b);
  vector<ll> x(q);
  for (int i = 0; i < a; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < b; i++) {
    cin >> t[i];
  }
  for (int i = 0; i < q; i++) {
    cin >> x[i];
  }

  for (int i = 0; i < q; i++) {
    ll res = 0;
    ll s_index = lower_bound(all(s), x[i]) - s.begin();
    vector<ll> hikaku;
    if(s_index == a) s_index = a-1;
    // hikaku.push_back(abs(x[i] - s[s_index]));
    // if(s_index != 0) hikaku.push_back(abs(x[i] - s[s_index-1]));
    // if(s_index != a-1) hikaku.push_back(abs(x[i] - s[s_index+1]));
    hikaku.push_back(abs( - s[s_index]));
    if(s_index != 0) hikaku.push_back(abs( - s[s_index-1]));
    if(s_index != a-1) hikaku.push_back(abs( - s[s_index+1]));

    ll t_index = lower_bound(all(t), x[i]) - t.begin();
    vector<ll> hikaku2;
    if(t_index == b) t_index = b-1;
    // hikaku2.push_back(abs(x[i] - t[t_index]));
    // if(t_index != 0) hikaku2.push_back(abs(x[i] - t[t_index-1]));
    // if(t_index != b-1) hikaku2.push_back(abs(x[i] - t[t_index+1]));
    hikaku2.push_back(abs( - t[t_index]));
    if(t_index != 0) hikaku2.push_back(abs( - t[t_index-1]));
    if(t_index != b-1) hikaku2.push_back(abs( - t[t_index+1]));

    ll minv = LLONG_MAX;
    for(ll tmp : hikaku){
      for(ll tmp2 : hikaku2){
        ll now = x[i];
        minv = min(minv, (abs(tmp - now) + abs(tmp - tmp2)));
        minv = min(minv, (abs(tmp2 - now) + abs(tmp2 - tmp)));
      }
    }
    res += minv;
    // res += *min_element(all(hikaku2));
    // cout << x[i] << endl;
    // print(hikaku);
    // print(hikaku2);
    cout << res << endl;
    // cout << endl;
  }


}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
const double PI = acos(-1);
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	double a, b, x; cin >> a >> b >> x;
	double angle;
	if (2 * x > a * a * b) {
		angle = atan(2 * (a*a*b - x) / (a*a*a)) * (180/PI);
	} else {
		angle = (PI/2 - atan(2*x / (b*b*a))) * (180/PI);
	}
	cout << setprecision(10) << angle << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int a[100001];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int pos=0;
    for (int i=1;i<=n;++i)
    {
        scanf("%d",a+i);
        if (a[i]==1)
            pos=i;
    }
    int ans=(pos-1)/(k-1)+(n-pos)/(k-1),tmp=(pos-1)%(k-1)+(n-pos)%(k-1)+1;
    if (tmp>1&&tmp<=k)
        ++ans;
    else if (tmp>k)
        ans+=2;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
long long a[100000];
int main(){
	int n;
	cin>>n;
	a[0]=2;
	a[1]=1;
	for(long long i=2;i<=n;i++){
		a[i]=a[i-1]+a[i-2];
	//	printf("%d,%d\n",a[i],i);
	}
	printf("%lld\n",a[n]);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int BOARD[100][100] = {0};

bool isPaintable(int y, int x) {
  if(BOARD[y][x + 1] > 0) {
    return true;
  } else if(BOARD[y][x - 1] > 0) {
    return true;
  } else if(BOARD[y + 1][x] > 0) {
    return true;
  } else if(BOARD[y - 1][x] > 0) {
    return true;
  }
  return false;
}

int main() {
  int H, W;
  cin >> H >> W;
  {
    string s;
    for(int h = 1; h <= H; ++h) {
      cin >> s;
      for(int i = 0; i < W; ++i) {
        int val = (s[i] == '#') ? 1 : 0;
        int w = i + 1;
        BOARD[h][w] = val;
      }
    }
  }
  for(int h = 1; h <= H; ++h) {
    for(int w = 1; w <= W; ++w) {
      if(BOARD[h][w] > 0 && !isPaintable(h, w)) {
        // cout << "no at : " << h << "," << w << endl;
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int m, f, b;
  int sum;

  scanf("%d %d %d", &m, &f, &b);
  sum = b - m;
  if (m > b){
    printf("0\n");
  } else if(sum > f){
    printf("NA\n");
  } else if (sum <= f ){
    printf("%d\n", sum);
  }
  return 0;
}



Measured memory_bytes: 2100
#include<cstdio>
int n,c[510],s[510],f[510],i,a,j;main(){for(scanf("%d",&n);j<n-1;)scanf("%d%d%d",c+j++,s+j,f+j);for(f[j]=1;i<n;a=0)for(j=i++;j<n||!printf("%d\n",a);)a=(a<s[j]?s[j]:(~-a/f[j]+1)*f[j])+c[j++];}

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

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

    if (a >= 3200)
        cout << s << endl;
    else
        puts("red");
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    s = SS()

    idx_a = s.index('A')
    idx_z = len(s) - s[::-1].index('Z') - 1

    print(idx_z - idx_a + 1)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10136
n = int(input())
l = []
ans = 0
for i in range(n):
  s = "".join(sorted(list(input())))
  l.append(s)
l.sort()
cnt = 1
for i in range(1, n):
  if l[i] != l[i-1]:
    ans += cnt*(cnt-1)//2
    cnt = 1
  else:
    cnt += 1
ans += cnt*(cnt-1)//2
print(ans)

Measured memory_bytes: 10612
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int chk[5];
char s[100005];
int main(){
    int n,i;
    scanf("%s",s);
    n=strlen(s);
    for(i=0;i<n;i++)    chk[s[i]-'a']++;
    sort(chk,chk+3);
    if(chk[2]-1>chk[0]){
        printf("NO\n");
    }else{
        printf("YES\n");
    }
    return 0;
}


Measured memory_bytes: 256
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define WAIT system ("pause")
#define rt0 return 0
using namespace std;
int main()
{
    int n,k,i,j,m,sv,s[5];
    bool jug;
    cin>>n>>k;
    vector <int> d(k,0);
    for(i=0;i<k;i++) cin>>d[i];
    for(i=n;i<99999;i++)
    {
        sv=i;
        j=0;
        jug=true;
        while(sv>0)
        {
            s[j]=sv%10;
            sv/=10;
            for(m=0;m<k;m++)
                if(s[j]==d[m])
                {
                    jug=false;
                    break;
                    sv=0;
                }
        }
        if(jug)
        {
            cout<<i;
            WAIT;
            rt0;
        }
    }
    WAIT;
    rt0;
}


Measured memory_bytes: 504
a, b = gets.split.map(&:to_i)

if a == b
  print 0
else
  if (a+b).even?
    k = (a+b)/2
    if (a-k<0 && b-k>0) || (a-k>0 && b-k<0)
      print k
    else
      print "IMPOSSIBLE"
    end
  else
    print "IMPOSSIBLE"
  end
end

Measured memory_bytes: 1788
ss = input()
s1, s2 = [], []
for i, s in enumerate(ss):
  if i % 2 == 0:
    s2.append(int(s))
  else:
    s1.append(int(s))

s1_0, s1_1 = len(s1) - sum(s1), sum(s1)
s2_0, s2_1 = len(s2) - sum(s2), sum(s2)

print(min(s1_0 + s2_1, s1_1 + s2_0))

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

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    rep(i, 3) {
        if (S[i] == T[i]) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007



int main() {
    string s, t; cin >> s >> t;
    int x = s.size(), y = t.size();
    if (x < y) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    bool g = false;
    vector<char> S;

    for (int i = x - y ; i >= 0 ; i--) {
        bool f = true;
        for (int j = 0; j < y; j++) {
            if (s[i + j] != t[j] && s[i + j] != '?') {
                f = false;
                break;
            }
        }
        if (f) {
            int k;
            for (k = 0 ; k < i ; k++) {
                if (s[k] == '?') S.pb('a');
                else S.pb(s[k]);
            }
            for (k = i ; k < i + y ; k++) {
                S.pb(t[k - i]);
            }
            for (k = i + y; k < x; k++) {
                if (s[k] == '?') S.pb('a');
                else S.pb(s[k]);
            }
            g  = true;
            break;
        }
    }

    if (g) {
        rep(i, x) cout << S[i];
        cout << endl;
    }
    else {
        cout << "UNRESTORABLE" << endl;
    }


}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

struct cond{
    int x;
    int s;
    int t;
};

void Main(){
    int n, q; cin >> n >> q;
    vector<cond> COND;
    rep(i, n){
        int s, t, x; cin >> s >> t >> x;
        COND.pb({x, s, t});
    }
    sort(all(COND), [&](cond a, cond b){
        return a.x == b.x ? a.s < b.s : a.x < b.x;    
    });
    
    set<P> S;
    vi d(q), ans(q, -1);
    rep(i, q) {
        cin >> d[i];
        S.insert({d[i], i});
    }
    
    for(auto [x, s, t] : COND){
        s -= x;
        t -= x;
        // s <= d[i] < t となる d[i] をすべて求める
        auto it = S.lower_bound({s, -1});
        while(it != S.end()){
            if(it->fi >= t) break;
            ans[it->se] = x;
            S.erase(it++);
        }
    }
    
    rep(i, q) cout << ans[i] << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 16660
#include <stdio.h>

int main(){    

int a, b;    

scanf("%d %d" ,&a ,&b);    

if(a < b){      

printf("a < b\n");     

}    

else if(a > b){      

printf("a > b\n");     

}    

else{      

printf("a == b\n");     

}  

return 0;  

}
  

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

int main(){
 int N,tem; int i=0; bool jj=true; int k=0; int te=0; int te2=0; int i1=0; int i2=0;
 cin >> N;
 vector<int> p(N);
 while(i<N){
     cin >> p.at(i++);
 }
for(i=0; i<N; i++){
    if(p.at(i) != i+1){
        if(te==0){
        te = p.at(i);
        i1 = i+1;
        k++;
        }else{
        te2 = p.at(i);
        i2=i+1;
        k++;
        }
    }
    if(k>=3){
        break;
    }
}

if(k<=2 && te==i2){
    cout << "YES" << endl;
}else{
    cout << "NO" << endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K,S;cin>>N>>K>>S;
    if(S==1000000000){
        vector<int> ans(N);
        for(int i=0;i<K;i++){
            ans[i]=S;
        }
        for(int i=K;i<N;i++){
            ans[i]=S-1;
        }
        for(int i=0;i<N;i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;
    }else{
        vector<int> ans(N);
        for(int i=0;i<K;i++){
            ans[i]=S;
        }
        for(int i=K;i<N;i++){
            ans[i]=S+1;
        }
        
        for(int i=0;i<N;i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;
    }
}



Measured memory_bytes: 1792
import math

N = int(input())

for n in range(1, N + 1):
    count = 0
    ub = int(math.sqrt(n))
    for x in range(1, ub + 1):
        for y in range(x, ub + 1):
            r = 4 * n - 3 * x * x - 2 * x * y - 3 * y * y
            if r < 0:
                break
            z = (math.sqrt(r) - x - y) / 2
            if z - int(z) < 1e-9:
                z = int(z)
            elif z - int(z + 1) < 1e-9:
                z = int(z + 1)
            else:
                break

            if y > z or z > ub:
                break
            if abs(x * x + y * y + z * z + x * y + y * z + z * x - n) < 1e-9:
                #print(x, y, round(z), z)
                s = len(set([x, y, round(z)]))
                if s == 1:
                    count += 1
                elif s == 2:
                    count += 3
                else:
                    count += 6

    print(count)


Measured memory_bytes: 69716
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)

	x := 9999999
	for i := 0; i < len(s)-2; i++ {
		tmp, _ := strconv.Atoi(s[i : i+3])
		tmpx := abs(tmp - 753)
		if tmpx < x {
			x = tmpx
		}
	}
	fmt.Println(x)
}

func abs(n int) int {
	if n < 0 {
		n = 0 - n
	}
	return n
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cin >> s ;
	n = s.size();
	//Sが出てくるたびに消そ
	//sのあとに出てくるTの数を数える
	//STTのとき、２つ目のTはカウントしなくていい
	int minus = 0 ;
		int countS = 0;
		rep(i,n){
			if(s[i] =='S'){
				countS++;
			}
			else if(s[i] == 'T'){
				//Tが出てきたとき、一緒に消せるSがあるならminusにプラス１してcountSを１へらす
				if(countS > 0){
					minus ++ ;
					countS --;
				}
			}
		}
		cout << n - minus*2 << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M;
	cin >> N >> M;
	int K[10];
	int sw[10][10];
	REP(i, M) {
		
		cin >> K[i];
		REP(j, K[i]) {
			cin >> sw[i][j];
		}
	}
	VI p(M);
	REP(i, M) {
		cin >> p[i];
	}
	int ans = 0;

	REP(i, 1 << N) {
		
		int cnt[10] = { 0 };
		REP(j, N) {
			//cout << j << endl;
			

			if (i&(1 << j)) {

				//cout << i << endl;
				REP(a, M) {
					REP(b, K[a]) {
						
						if (sw[a][b] == j+1) {
							cnt[a]++;
						}
					}
				}
			}

			
	
		}
			bool F = true;
			REP(k, M) {
				if (cnt[k] % 2 != p[k])
					F = false;
			}
			if (F)ans++;
	}

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
let print_array a =
  Array.iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) a;
  print_newline ()

let insertion_sort a n =
  print_array a;
  for i = 1 to n - 1 do
    let key = a.(i) in
    let j = ref (i - 1) in
    while !j >= 0 && a.(!j) > key do
      a.(!j+1) <- a.(!j);
      decr j;
    done;
    a.(!j+1) <- key;
    print_array a;
  done

let () =
  let n = read_int () in
  let a = Array.of_list (List.map int_of_string (Str.split (Str.regexp " ") (read_line ()))) in
  insertion_sort a n

Measured memory_bytes: 4024
#include <iostream>
using namespace std;

int main(){
  long N,M; cin >> N >> M;
  
  if(N==1 && M==1){cout << 1;}
  else if(N==1){cout << M-2;}
  else if(M==1){cout << N-2;}
  else{cout << (N-2)*(M-2);}
  
  return 0;
}

Measured memory_bytes: 256
let s' = read_line () in
let t = read_line () in
let regexp =
  Array.init (String.length t) (fun i->Printf.sprintf "[%c\\?]" t.[i])
  |> Array.to_list
  |> String.concat ""
  |> Str.regexp
in
try
  let i = Str.search_backward regexp s' (String.length s') in
  let s' = Str.string_before s' i^t^Str.string_after s' (i+String.length t) in
  let s' = String.map(function '?' -> 'a' | c->c) s' in
  Printf.printf "%s\n" s'
with _ -> print_endline "UNRESTORABLE"


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main()
{
	int n,a,b,c,x;
	while(cin >> n >> a >> b >> c >> x,n)
	{
		bool flag = false;
		int count = 0,i = 0;
		int y[n];
		for(int i = 0;i < n;i++)
		{
			cin >> y[i];
		}
		
		while(1)
		{
			if(x == y[i])
			{
				i++;
			}
			
			if(i == n)
			{
				cout << count << endl;
				break;
			}
			
			if(count == 10000)
			{
				cout << -1 << endl;
				break;
			}
			x = (a * x + b) % c;
			count++;
		}
		
	}
	
	return 0;
	
}

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

using namespace std;

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

int dp[20][2];

string lltos(ll n){
	stringstream ss;
	ss << n;
	return ss.str();
}

bool allNight(string N){
	set<int> digit; digit.clear();
	int n = (int)N.length();
	rep (i, n){
		digit.insert((int)(N[i] - '0'));
	} // end rep

	set<int>::iterator it = digit.begin();
	return ((int)digit.size() == 1 && (*it) == 9);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string N; cin >> N;

	int n = (int)N.length();

	int res = 0;
	
	if (n == 1){
		res = (int)(N[0] - '0');
	}else{
		rep (i, n){
			if (i == 0){
				res += (int)(N[i] - '0') - (int)(!allNight(N.substr(1)));
			}else{
				res += 9;
			} // end if
		} // end rep
	} // end if

	cout << res << endl; 

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n,m;
    cin>>n;
    m = n;
    int s = 0;
    while(m!=0){
        s += m%10;
        m/=10;
    }
    if(n%s==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits



def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))

def update(bit,i, dp):
    bit[i] = dp
    return bit

def query(bit, i):
    lis = [bit[j] for j in range(i)]
    return max(lis)


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

n = INT()

T,A = MAP()
h = LIST()

ans = [INF, INF]
sa=INF

for i, x in enumerate(h):
    if abs(A - T + x * 0.006) < sa:
        ans = [i + 1, x]
        sa=abs(A - T + x * 0.006)

print(ans[0])
        
        


Measured memory_bytes: 3956
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();

        long ans = 0;
        for (int i = 1; i <= N; i++)
            if (i % 3 != 0 && i % 5 != 0)
                ans += i;
        out.println(ans);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 32772
a = []
for i in range(3):
    a.append(list(map(int, input().split())))

n = int(input())
for i in range(n):
    b = int(input())
    for j in a:
        if b in j:
            a[a.index(j)][j.index(b)] = 0

ans = 0
for i in range(3):
    if a[0][i] == a[1][i] == a[2][i] == 0:
        ans = 1
    elif a[i][0] == a[i][1] == a[i][2] == 0:
        ans = 1
if a[0][0] == a[1][1] == a[2][2] == 0:
    ans = 1
if a[0][2] == a[1][1] == a[2][0] == 0:
    ans = 1

if ans == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   ll n,a,b;
   cin>>n>>a>>b;
   ll s,r;
   s=n/(a+b);
   r=n%(a+b);
   if(r<=a)
   cout<<(s*a)+r;
   else
   cout<<(s*a)+a;
}




Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), sum(n), sum_(n);
    rep(i, n) {
        cin >> a[i];
        sum[i] = a[i];
        if(i) sum[i] += sum[i-1];
    }

    rep(i, n) {
        int j = n-1-i;
        sum_[j] = a[j];
        if(i) sum_[j] += sum_[j+1];
    }

    ll ans = LINF;
    rep(i, n-1) {
        ans = min(ans, abs(sum[i] - sum_[i+1]));
    }

    cout << ans << endl;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n;
	cin>>n;
	vector<P> point(n);
	rep(i,n)cin>>point[i].first>>point[i].second;

	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	int ans=INF;

	rep(i,n){
		rep(j,n){
			if(i==j)continue;

			int p = point[j].first - point[i].first;
			int q = point[j].second - point[i].second;

			// vector<int> used(n,1);
			// used[i]=0,used[j]=0;
			int res=n-1;
			rep(k,n){
				if(k==i) continue;
				rep(l,n){
					int pp = point[l].first - point[k].first;
					int qq = point[l].second - point[k].second;
					if(pp==p && qq==q) res--;
				}
			}
			// res += accumulate(all(used),0);
			ans=min(ans,res);
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

int mat[3003][3003];
int dp[3003][3003][4];
int N , M , K;

int cal(int i ,int j , int r) {
  if(i >= N) return 0;
  if(j >= M) return 0;
  if(dp[i][j][r] != -1) return dp[i][j][r];
  int ans = 0;
  ans = max({ans , cal(i , j + 1, r), cal(i+1 , j , 0)});
  int x = 0 , y = 0;
  if(r < 3) {
    x = cal(i ,j + 1, r + 1) + mat[i][j];
    y = cal(i + 1, j , 0) + mat[i][j];
  }
  return dp[i][j][r] = max({ans , x , y});
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M >> K;
  for(int i = 0; i < K; i++) {
    int r , c, v;
    cin >> r >> c >> v;
    r--,c--;
    mat[r][c] = v;
  }   
  clr(dp , -1);
  int ans = cal(0, 0, 0);
  cout << ans << '\n';
}

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



int main() {
  
  int N;
  scanf("%d", &N);
  
  vector<int> v(N);
  for(int i=0;i<N;i++){
      scanf("%d", &v[i]);
  }

  long long S = 0;

  for(int i=1;i<N;i++){
    
    if (v[i-1] > v[i]){
      S += (v[i-1]-v[i]);  
      v[i] = v[i-1];
    }

  }

  printf("%lld\n", S);

  return 0;
}




Measured memory_bytes: 4024
#include <stdio.h>

int main(void)
{
	int n;
	int i, j, k, l;
	int c;
	
	while (scanf("%d", &n) != EOF) {
		c = 0;
		for (i = 0; i < 10; i++) {
			for (j = 0; j < 10; j++) {
				for (k = 0; k < 10; k++) {
					for (l = 0; l < 10; l++) {
						if (i + j + k + l == n) {
							c++;
						}
					}
				}
			}
		}
		printf("%d\n", c);
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<double,double>,int>> ps;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

double f(double t){
    double mx_x=-9999999999;
    double mx_y=-9999999999;
    double mn_x=9999999999;
    double mn_y=9999999999;
    for(auto p:ps){
        mx_x=max(p.first.first+dx[p.second]*t,mx_x);
        mx_y=max(p.first.second+dy[p.second]*t,mx_y);
        mn_x=min(p.first.first+dx[p.second]*t,mn_x);
        mn_y=min(p.first.second+dy[p.second]*t,mn_y);
    }
    return -(mx_x-mn_x)*(mx_y-mn_y);
}

int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        double x,y;
        string c;
        cin>>x>>y>>c;
        int v;
        if (c=="R") v=0;
        if (c=="U") v=1;
        if (c=="L") v=2;
        if (c=="D") v=3;
        ps.push_back(make_pair(make_pair(x,y),v));
    }
    double l=0.0,r=200000001.0;
    int nn=200;
    while(nn){
        if(f((l*2+r)/3.0)>f((l+r*2)/3.0))
            r=(l+r*2)/3.0;
        else
            l=(l*2+r)/3.0;
        nn--;
    }
    cout<<fixed<<setprecision(10)<<-f((l+r)/2)<<endl;
}


Measured memory_bytes: 4980
#include<cstdio>
#include<algorithm>
using namespace std;

const int MOD=1e9+7;
int n,m,mmh=1;
int main(){
	scanf("%d%d",&n,&m);
	if (n<m) swap(n,m);
	if (n-m>1) return puts("0"),0;
	for (int i=1;i<=n;i++) mmh=1LL*mmh*i%MOD;
	for (int i=1;i<=m;i++) mmh=1LL*mmh*i%MOD;
	if (n==m) mmh=mmh*2%MOD;
	printf("%d\n",mmh);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
typedef unsigned long long int ull;

const ull B=1e9+7;//base of hash

bool contain(string s,string a)
{
	int sl=s.length(),al=a.length();
	if(sl<al)return false;
	
	ull t=1;
	for(int i=0;i<al;i++)t*=B;
	
	ull sh=0,ah=0;
	for(int i=0;i<al;i++)
	{
		sh=sh*B+s[i];
		ah=ah*B+a[i];
	}
	
	if(sh==ah)return true;
	
	for(int i=0;i+al<sl;i++)
	{
		sh=sh*B+s[i+al]-s[i]*t;
		if(sh==ah)return true;
	}
	
	return false;
}

vector<int> match(string s,string a)
{
	int sl=s.length(),al=a.length();
	vector<int> ans;
	if(sl<al)return ans;
	ull t=1;
	ull ah=0,sh=0;
	for(int i=0;i<al;i++)
	{
		sh=sh*B+s[i];
		ah=ah*B+a[i];
		t*=B;
	}
	
	if(sh==ah)ans.push_back(0);
	
	for(int i=0;i+al<sl;i++)
	{
		sh=sh*B+s[i+al]-s[i]*t;
		if(sh==ah)ans.push_back(i+1);
	}
	return ans;
}

int main()
{
	string s,a;
	cin>>s>>a;
	vector<int> m=match(s,a);
	for(int i=0;i<m.size();i++)
	{
		cout<<m[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 9340
a=[]
r,c=map(int,input().split())
for i in range(r):
    a.append(list(map(int,input().split())))

b=[[0]*(c+1) for i in range(r+1)]

for i in range(r):
    for j in range(c):
        b[i][j]+=a[i][j]
        b[i][c]+=a[i][j]
        
for i in range(c+1):
    for j in range(r):
        b[r][i]+=b[j][i]
for i in range(r+1):
    print(*b[i])


Measured memory_bytes: 6260
h,w=map(int,input().split())
sl=[list(input()) for i in range(h)]

#print(sl[1][1])
ans=[[] for i in range(h)]

for i in range(h) :
  for j in range(w):
    #subs=
    if sl[i][j]=="#" :
      ans[i].append("#")
    else :
      count=0
      search1=[[i-1,j],[i+1,j],[i,j-1],[i,j+1]]
      search2=[[i-1,j+1],[i+1,j+1],[i+1,j-1],[i-1,j-1]]
      for temp in search1 :
        i2=temp[0];j2=temp[1]
        if i2<0 or h-1<i2 or j2 <0 or w-1<j2 :
          continue
        if sl[i2][j2]=="#" :
          count+=1
      for temp in search2 :
        i2=temp[0];j2=temp[1]
        if i2<0 or h-1<i2 or j2 <0 or w-1<j2 :
          continue
        if sl[i2][j2]=="#" :
          count+=1
      ans[i].append(count)

#print(ans)
for i in range(h):
  print(*ans[i],sep="")


Measured memory_bytes: 3572
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};
#[fastout]
fn main() {
    input!(n: usize, x: isize,mut  nx: [isize; n]);

    nx.sort();

    let mut nnx = vec![0; n];

    for i in 0..nx.len() {
        nnx[i] = (x - nx[i]).abs();
    }

    nnx.sort();

    let mut ans = 1;

    for i in (2..=nnx[0]).rev() {
        let mut is_divdiv = true;
        for v in &nnx {
            if *v % i != 0 {
                is_divdiv = false;
                break;
            }
        }
        if is_divdiv {
            ans = i;
            break;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4684
defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.to_integer()
    |> get_mod()
    |> IO.puts()
  end

  def get_mod(mod) when mod >= 1000 do
    get_mod(mod - 1000)
  end

  def get_mod(mod) when mod > 0 do
    1000 - mod
  end
  
  def get_mod(mod) do
    mod
  end
  end

Measured memory_bytes: 30592
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iterator>
#include <random>
#include <cmath>
#include <functional>


using namespace std;
using lint = long long int;



int main() {
	lint n, a, b;
	cin >> n >> a >> b;

	auto ab = a + b;

	lint bn = n / ab * a;
	bn += min(n % ab, a);
	cout << bn;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    return mp;
}

void solve(){
    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < 4; i++) {
        if (s[i] == '2') {
            ans++;
        }
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

#define int long long
const int MAXN = 1e6 + 100 ; 

int a[MAXN] , b[MAXN] ; 

int32_t main(){

	ios_base::sync_with_stdio(0) ; 
	cout . tie(0) ; cout . tie(0) ;

	string s , t ; cin >> s >> t ; 
	for(int i = 0 ; i < s . size() ; i ++)
		a[i + 1] = a[i] + (s[i] == 'A') ; 
	for(int i = 0 ; i < t . size() ; i ++)
		b[i + 1] = b[i] + (t[i] == 'A') ;
	
	int q ; cin >> q ; 
	while(q --){
		int x , y ; cin >> x >> y ; x -- ; 
		int f , l ; cin >> f >> l ; f -- ; 
		int a1 = a[y] - a[x] ; int b1 = y - x - a1 ;
		int a2 = b[l] - b[f] ; int b2 = l - f - a2 ; 
		int ch1 = (a1 - b1 % 3 + 3) % 3 ; 
		int ch2 = (a2 - b2 % 3 + 3) % 3 ; 
		if(ch1 == ch2) cout << "YES\n" ; 
		else cout << "NO\n" ; 
	}
}

Measured memory_bytes: 5840
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        boolean flg = true;
        if (s[0] != 'A') {
            flg = false;
        }

        boolean flg2 = false;
        for (int i = 2 ; i < s.length - 1 ; i++) {
            if (s[i] == 'C') {
                flg2 = true;
            }
        }

        int large = 0;
        for (int i = 0 ; i < s.length ; i++) {
            if (s[i] >= 'A' && s[i] <= 'Z') {
                large++;
            }
        }
        System.out.println(flg && flg2 && large == 2 ? "AC" : "WA");

    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n; cin >> n;
    vector<ll> a(n), b(n);
    ll as = 0, bs = 0;
    rep(i, n){
        cin >> a[i];
        as += a[i];
    }
    rep(i, n){
        cin >> b[i];
        bs += b[i];
    }
    if(as < bs){
        cout << -1 << endl;
        return 0;
    }
    vector<pair<ll, ll>> c;
    ll cs = 0, ds = 0, cnt = 0;
    rep(i, n){
        if(a[i] < b[i]) cs += a[i], ds += b[i], cnt++;
        else c.emplace_back(a[i]-b[i], a[i]);
    }
    if(cnt == 0){
        cout << cnt << endl;
        return 0;
    }
    sort(c.rbegin(), c.rend());
    rep(i, c.size()){
        cs += c[i].second, ds += c[i].second - c[i].first;
        if(cs >= ds){
            cout << cnt + i + 1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3956
#include "bits/stdc++.h"
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  ll n;
  cin >> n;
  if (n % 2) {
    cout << 0 << endl;
    return;
  }
  ll ans = 0;
  ll a = 5;
  while (n > 0) {
    ans += (n /= a) / 2;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define lli long long
#define vi vector<int>
#define vli vector<li>
#define vlli vector<lli>
#define pi pair<int,int>
#define pli pair<li, li>
#define vpi vector<pi>

using namespace std;

int main() {

    int n;

    scanf("%d", &n);

    lli ans = 0;

    for(lli i = 0; i < n; i++) {
        lli x;
        scanf("%lld", &x);

        while(!(x & 1)) {
            ans++;
            x/=2;
        }
    }    
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	string S;
	cin >> S;

	int OK = 1;

	while (S.size()) {
		if (S.substr(0, 5) == "dream") {
			string kari = S.substr(5, 5);
			if (kari == "erase") S.erase(0, 5);
			else if (kari[0] == 'e' && kari[1] == 'r') S.erase(0, 7);
			else S.erase(0, 5);
		}
		else if (S.substr(0, 6) == "eraser") S.erase(0, 6);
		else if (S.substr(0, 5) == "erase") S.erase(0, 5);
		else {
			OK = 0;
			break;
		}
	}

	if (OK) co("YES");
	else co("NO");

	Would you please return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < W; i++) printf("#");
        printf("\n");
 
        for(int i = 1; i < H-1; i++){
            printf("#");
            for(int j = 1; j < W-1; j++) printf(".");
            printf("#\n");
        }
 
        if(H > 1){
            for(int i = 0; i < W; i++) printf("#");
            printf("\n");
        }
        printf("\n");
    }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D)
    cout << "Left" << endl;
  else if (A + B == C + D)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		scan.close();
		
		// 0がaになり、アルファベットだけの26進数にしてね
		System.out.println(convertOriginalShinsuStr(n, 'a', 26));
		
	}
	
	/**
	 * 10進数をオリジナル進数(アルファベット)文字列に変換
	 * @param dNum 変換する10進数
	 * @param origin 10進数の0をオリジナル進数で変換した後の文字
	 * @param baseNumber 何進数に変換するの
	 * @return オリジナル進数(アルファベット)文字列
	 */
	public static String convertOriginalShinsuStr(
			long dNum, final char origin, final int baseNumber) {
		
		// よくわからんワンちゃん
		if(dNum <= 0) {
			return "";
		}
		
		// 邪魔なのでオフセットは消化
		dNum--;
		
		// char型とintの足し算で文字を求める
		String ret = String.valueOf((char)(origin + dNum % baseNumber));
		// 小数点以下は切り捨てられる
		dNum /= baseNumber ; 
		
		// 次の位も頼みます
		return convertOriginalShinsuStr(dNum, origin, baseNumber) + ret;
		
	}

}


Measured memory_bytes: 39476
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]
flag = False
for i in range(N-M+1):
    for j in range(N-M+1):
        a = [x[j:j+M] for x in A[i:i+M]]
        if a == B:
            flag = True
print('Yes' if flag == True else 'No')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a[3];
    int br=0;
    cin>>a[0]>>a[1]>>a[2];
    sort(a, a+3);

    if(a[0]%2==0 && a[1]%2!=0)
        br++, a[2]++;
    else if(a[0]%2!=0 && a[1]%2==0)
        br++, a[2]++;

    br += (a[1]-a[0])/2;
    br += a[2]-a[1];

    cout<<br<<endl;
    return 0;
}


Measured memory_bytes: 256