akhauriyash/Code-Regression huggingface dataset:
import org.omg.CORBA.MARSHAL;

import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int ans = 1;
        for(int A = 1; A * A <= M; A++){
            if(M % A != 0) continue;
            int B = M / A;

            if((long)A * N <= M) ans = Math.max(ans, A);
            if((long)B * N <= M) ans = Math.max(ans, B);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  for (int i = 0; i < n; i++)
    cin >> l[i];

  vector<int> d(n + 1);
  for (int i = 1; i <= n; i++) {
    d[i] = d[i - 1] + l[i - 1];
  }
  for (int i = 0; i <= n; i++) {
    if (d[i] > x) {
      cout << i << endl;
      return 0;
    }
  }
  cout << n + 1 << endl;
}

Measured memory_bytes: 256
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll l,r;
    cin>>l>>r;
    vi temp;
    rep(i,l,min(r,l+2019)){
        temp.pb(i%2019);
    }
    ll ans=INF;
    rep(i,0,sz(temp)-1){
        rep(j,i+1,sz(temp)-1){
            ans=min(ans,(temp[i]*temp[j])%2019);
        }
    }
    cout<<ans;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

long long power(long long p, int e){
  long long ret = 1;
  while(e){
    if(e & 1){
      ret *= p;
      ret %= mod;
      e--;
    }
    p *= p;
    p %= mod;
    e >>= 1;
  }
  
  return ret;
}

int main(){
  int N, K;
  cin >> N >> K;
  
  long long c[K + 1];
  for(int i = K; i > 0; i--){
    c[i] = power(K / i, N);
    
    for(int j = (i << 1); j <= K; j += i){
      c[i] -= c[j];
      c[i] %= mod;
    }
  }
  
  long long sum = 0;
  for(int i = 1; i <= K; i++){
    sum += c[i] * i % mod;
    sum %= mod;
  }
  
  if(sum < 0) sum += mod;
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 4372
package main

import (
	"fmt"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	var S string
	fmt.Scanf("%s", &S)

	var flag int = 0
	if len(S)%2 == 0 {
		for i := 0; i < len(S)/2; i++ {
			if S[i] != S[len(S)/2+i] {
				flag = 1
			}
		}
	} else {
		flag = 1
	}

	if flag == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename Iter, typename T> int gt(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L; }
template <typename Iter, typename T> int ge(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L; }
template <typename Iter, typename T> int lt(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L - 1; }
template <typename Iter, typename T> int le(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L - 1; }
template <typename Bst, typename T> typename Bst::const_iterator gt(const Bst& bst, T v) { return bst.upper_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator ge(const Bst& bst, T v) { return bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator lt(const Bst& bst, T v) { return bst.lower_bound(v) == bst.begin() ? bst.end() : --bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator le(const Bst& bst, T v) { return bst.upper_bound(v) == bst.begin() ? bst.end() : --bst.upper_bound(v); }
// NOTE: one-indexed
template <typename T> struct bit {
    const int n;
    vector<T> t;
    bit(int n) : n(n), t(n + 1) {}
    void add(int i, T value) {
        for(int j = i; j <= n; j += j & -j) {
            t[j] += value;
        }
    }
    T sum(int i) {
        T res = 0;
        for(int j = i; j > 0; j -= j & -j) {
            res += t[j];
        }
        return res;
    }
    T sum(int L, int R) {
        return sum(R) - sum(L - 1);
    }
};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    partial_sum(a.begin(), a.end(), a.begin());
    set<ll> values;
    for(int i = 0; i <= n; i++) {
        values.insert(a[i] -= k * i);
    }
    map<ll, int> comp;
    int id = 1;
    for(ll x : values) {
        comp[x] = id++;
    }
    bit<int> b(id);
    ll ans = 0;
    for(int i = 0; i <= n; i++) {
        ans += b.sum(comp[a[i]]);
        b.add(comp[a[i]], 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 24448
import sys
input = sys.stdin.readline
import bisect
N,W= map(int,input().split())
ans= [[float('inf') for e in range(10**5+1)] for f in range(N+1)]
for i in range(N):
 w,v=map(int,input().split())
 for j in range(0,v):
  ans[i+1][j]=min(ans[i][j],w)
 for j in range(v,10**5+1):
  ans[i+1][j]=min(ans[i][j],ans[i][j-v]+w)
print(bisect.bisect(ans[N],W))


Measured memory_bytes: 320112
#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){
  int a;
  cin >> a;

  if (a % 2 == 0)
    cout << a / 2 << endl;
  else
    cout << a / 2 + 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: 256
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int N;
void dfs(int depth,string str,char mc){
	if(depth==N){
		out(str);
		return;
	}
	for(char ch='a';ch<=mc+1;ch++){
		dfs(depth+1,str+ch,max(ch,mc));
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	N=in();
	dfs(1,"a",'a');
	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+5;

long long n,k,ans=1e12,l,r,mid,cnt,x;
long long a[MAXN],b[MAXN];

bool cmp(int a,int b)
{
	return a>b;
}

int main()
{
	cin >> n >> k;
	for(int i=1;i<=n;i++) cin >> a[i];
	for(int i=1;i<=n;i++) cin >> b[i];
	sort(a+1,a+n+1);
	sort(b+1,b+n+1,cmp);
	for(int i=1;i<=n;i++) r=max(r,a[i]*b[i]);
	while(l<=r)
	{
		mid=(l+r)/2;cnt=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]*b[i]>mid)
			{
				cnt+=a[i];
				x=mid/b[i];
				cnt-=x;
			}
		} 
		if(cnt<=k)
		{
			ans=min(ans,mid);
			r=mid-1;
		}
		else l=mid+1;
	}
	cout << ans << endl;
	return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

long long int vec_sum(vector<long long int> v){
  long long int n=0;
  for(long long int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int n,ans=mod,count=0,cnt=0;
  cin>>n;
  vector<long long int> v(n);
  for(long long int i=0;i<n;i++) cin>>v[i];
  count=vec_sum(v);
  
  for(long long int i=0;i<n-1;i++){
    cnt+=v[i];
    ans=min(ans,abs(cnt-(count-cnt)));
  }
  
  cout<<ans<<endl;
  
}
///////////////////////////

Measured memory_bytes: 3328
import itertools
import copy


def is_safe(qweens):
    x = []
    y = []
    for q in qweens:
        x.append(q[0])
        y.append(q[1])
    if len(set(x)) + len(set(y)) != len(qweens) * 2:
        return False
    for q1, q2 in itertools.combinations(qweens, 2):
        slope = (q1[0] - q2[0]) / (q1[1] - q2[1])
        if slope == 1 or slope == -1:
            return False
    return True


def print_boad(qweens):
    for r in range(8):
        for c in range(8):
            if (r, c) in qweens:
                print('Q', end='')
            else:
                print('.', end='')
        print('')


k = int(input())
cand = [[(r, c) for c in range(8)] for r in range(8)]
init_qweens = []
for _ in range(k):
    pos = tuple(map(int, input().split()))
    for r in range(8):
        for c in range(8):
            try:
                cand[r].remove((pos[0], c))
            except ValueError:
                pass
            try:
                cand[r].remove((r, pos[1]))
            except ValueError:
                pass
    init_qweens.append(pos)

for r in range(7, -1, -1):
    if cand[r] == []:
        cand.pop(r)

qweens = []
for per in itertools.permutations([i for i in range(8 - k)]):
    qweens = copy.deepcopy(init_qweens)
    for r, c in enumerate(per):
        qweens.append(cand[r][c])

    if is_safe(qweens):
        break

print_boad(qweens)



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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  bool dup = false;
  for(int i = 0;i<s.size();i++)
    for(int j = i+1;j<s.size();j++)
      if(s[i]==s[j]) dup = true;

  if(!dup) cout << "yes" << endl;
  else cout << "no" << endl;
  
  return 0;
}


Measured memory_bytes: 3608
n=int(input())
listm=[]
listt=[]
ans=0
for i in range(n):
    m,t=input().split()
    listm.append(m)
    listt.append(t)
lastm=input()
index=listm.index(lastm)
for i in range((index+1),n):
    ans+=int(listt[i])
print(ans)


Measured memory_bytes: 3060
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    VV gragh(n);
    rep(i, n - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        gragh[a].push_back(b);
        gragh[b].push_back(a);
    }
    ll m;
    cin >> m;
    queue<ll> q;
    q.push(0);
    V reg(n, -1);
    reg[0] = 0;
    while (!q.empty())
    {
        ll k = q.front();
        q.pop();
        rep(i, gragh[k].size())
        {
            if (reg[gragh[k][i]] == -1)
            {
                reg[gragh[k][i]] = (1LL << gragh[k][i] | reg[k]);
                q.push(gragh[k][i]);
            }
        }
    }
    V reg2(m);
    rep(i, m)
    {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        reg2[i] = reg[u] ^ reg[v];
      //    cout<<bitset<8>(reg2[i])<<endl;
    }
    ll res = 0;
    rep3(bit, 0, (1LL << m))
    {
        ll temp = 0;
        rep(j, m)
        {
            if ((bit>>j)&1LL)
            {
                temp |= reg2[j];
            }
        }
       // cout<<temp<<endl;
        ll k = n - 1 - __builtin_popcountll(temp);
        ll f = __builtin_popcountll(bit);
     //   cout<<k<<" "<<f<<endl;
        if (f % 2 == 0)
        {
            res += (1LL<<k);
        }
        else
        {
            res -= (1LL<<k);
        }
      //  cout<<(1LL<<k)<<endl;
    }
    cout << res << endl;
}


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

#ifdef ONLINE_JUDGE
#define lld I64
#endif

#define endl '\n'
#define ii pair<int,int>
#define ll long long
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define add push_back

int main(){ios_base::sync_with_stdio(false);
    
    int n;
    map<ll, int> freq;
    ll ans=0, x;

    cin >> n;
    for(int i=0; i<n; ++i){
        cin >> x;
        ans += freq[i-x];
        freq[x+i]++;
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 26364
/******************************************************************************

                         بسم الله الرحمن الرحيم
                     Author: Mst: Mhamuda Khatun
                               RUCSE27

*******************************************************************************/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define MAX 1000000000000
#define N 305

int main()
{
    fastio;
    int r;
    cin>>r;

    cout<<2*pi*r;
    cout<<"\n";
    return 0;   //:D
}




Measured memory_bytes: 3752
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	ll N, M, Q;
	cin >> N >> M >> Q;
	vector< vector<ll> > edges_row(N, vector<ll>(M, 0)), edges_line(N, vector<ll>(M, 0));
	vector< vector<ll> > nodes(N, vector<ll>(M, 0));
	vector<string> s(N);
	rep(N){
		cin >> s[i];
		repp(j, M){
			if(s[i][j] == '1'){
				if(i == 0 && j == 0){
					nodes[0][0] = 1;
				}else if(j == 0){
					nodes[i][0] = nodes[i-1][0] + 1;
				}else{
					nodes[i][j] = nodes[i][j-1] + 1;
					if(i > 0) nodes[i][j] += nodes[i-1][j] - nodes[i-1][j-1];
				}
			}else{
				if(i > 0 && j == 0){
					nodes[i][0] = nodes[i-1][0];
				}else{
					if(i > 0){
						nodes[i][j] = nodes[i-1][j];
					}
					if(j > 0){
						nodes[i][j] += nodes[i][j-1];
						if(i>0){
							nodes[i][j] -= nodes[i-1][j-1];
						}
					}
				}
			}
		}
	}

	rep(N){
		reppp(j, 1, M-1){
			if(s[i][j] == '1' && s[i][j-1] == '1'){
				edges_line[i][j] = edges_line[i][j-1] + 1;
			}else{
				edges_line[i][j] = edges_line[i][j-1];
			}
		}
	}

	reppp(i, 1, N-1){
		repp(j,M){
			edges_line[i][j] += edges_line[i-1][j];

			if(s[i][j] == '1' && s[i-1][j] == '1'){
				edges_row[i][j] = edges_row[i-1][j] + 1;
			}else{
				edges_row[i][j] = edges_row[i-1][j];
			}
		}
	}

	reppp(j, 1, M-1){
		rep(N){
			edges_row[i][j] += edges_row[i][j-1];
		}
	}

	rep(Q){		
		int x, y, xx, yy;
		cin >> x >> y >> xx >> yy;
		x--;y--;xx--;yy--;
		ll n_nodes = nodes[xx][yy];
		ll n_edges = edges_row[xx][yy] + edges_line[xx][yy];
		if(x > 0){
			n_nodes -= nodes[x-1][yy];
			n_edges += edges_line[x-1][y]- edges_line[x-1][yy];
		}
		n_edges -= edges_row[x][yy];
	
		if(y > 0){
			n_nodes -= nodes[xx][y-1];
			n_edges += edges_row[x][y-1] - edges_row[xx][y-1];
		}
		n_edges -= edges_line[xx][y];
		
		if(x > 0 && y > 0){
			n_nodes += nodes[x-1][y-1];
		}
		cout << n_nodes - n_edges << endl;
	}
}


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

int main()
{
    string S;
    int ans = 0;
    cin >> S;
    for (int i = 0; i < S.size(); i++)
    {
        if (i == S.size() - i - 1 || i == S.size() - i - 2)
        {
            if (S.at(i) != S.at(S.size() - i - 1))
            {
                ans++;
                break;
            }
            else
            {
                break;
            }
        }
        if (S.at(i) != S.at(S.size() - i - 1))
        {
            ans++;
        }
    }

    cout << ans << endl;
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    vector<int> a(3);
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }
    SORT(a);
    cout << a[2] - a[0] << endl;
    return 0;
}


Measured memory_bytes: 256
N=gets.to_i
A=gets.split.map(&:to_i)

MOD=10**9+7

ans=0

(0...60).each do |i|
	count=[0,0]
	A.each do |a|
		count[a[i]]+=1 
	end
	ans=(ans+((count[0]*count[1]%MOD)*((1<<i)%MOD))%MOD)%MOD
end
p ans

Measured memory_bytes: 36892
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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 ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()
ans =[]

for x in a:
	ans.append(x-1)
	ans.append(x)
	ans.append(x+1)

#print(ans)
#print(Counter(ans))
#print(Counter(ans).values())
print(max(Counter(ans).values()))

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

using namespace std;

#define REP(s,e) for(int i=(s);i<(e);i++)

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

    REP(0,s.size()){
        if(s[i]==',') s[i]=' ';
    }

    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

using ll = long long;
using Vec = vector<ll>;
using P = pair<ll, ll>;
using VecP = vector<P>;
#define rep(i, n) for(ll i=0;i<(n);i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//static const ll MOD = 1000000007;
//static const ll INF = 1000000000000000000;
//#define PI 3.14159265359


int main() {
    // input
    long double A, B;
    cin >> A >> B;

    //process
    long double ans = A * B;

    cout << (ll) (ans / 1.0);
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define MP make_pair
#define VI vector<int>
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=2e2+5;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

pair<ii,ll> r[MAXn];
set<ll> Sx;

int main(){
	IOS();
	ll n;cin>>n;
	REP(i,n){
		cin>>r[i].F.F>>r[i].F.S;
		r[i].S=0;
	}
	for(int i=n;i<2*n;i++){
		cin>>r[i].F.F>>r[i].F.S;
		r[i].S=1;
	}
	ll ans=0;
	sort(r,r+2*n);
	//debug("ok");
	REP(i,2*n){
		if(!r[i].S) Sx.insert(r[i].F.S);
		else if(!SZ(Sx)) continue;
		else{
			ll t=r[i].F.S;
			auto it=Sx.begin();
			if(*it>=t) continue;
			//debug("st");
			for(;it!=Sx.end() && *it<t;it++);
			//debug("hi",*it);
			it--;
			Sx.erase(it);
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

vector<ll> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(i);
    rak.assign(f+1,1);
}

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

ll union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rak[a]+=rak[b];
        return (rak[a]-rak[b])*(rak[b]);
    }
    return 0;
}

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ld kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,s1,s2;
vvpl v;
vl vis,d;

void dfs(int g){
    vis[g]=1;
    d[g]=p;
    for(auto u:v[g]){
        if(vis[u.ff]==0){
            p=d[g]^(u.ss%2);
            dfs(u.ff);
        }
    }
}

int main() {
    IOS;
    cin>>n;
    v.resize(n);
    vis.assign(n,0);
    d.assign(n,0);
    fo(i,n-1){
        cin>>x>>y>>z;x--;y--;
        v[x].pb({y,z});
        v[y].pb({x,z});
    }
    dfs(0);
    fo(i,n)cout<<d[i]<<el;
    return 0;
}


Measured memory_bytes: 9984
#include<stdio.h>
#include<math.h>

int main(void){

    int N;
    int i,x,y,z,f[10001]={},lhs;

    scanf("%d",&N);

    for(x=1;x<sqrt(N);x++){
        for(y=1;y<sqrt(N);y++){
            for(z=1;z<sqrt(N);z++){
                lhs = x*x + y*y + z*z + x*y + y*z + z*x;
                if(lhs<=N) f[lhs]++;
            }
        }
    }

    for(i=1;i<=N;i++){
        printf("%d\n",f[i]);
    }

    return 0;
}

Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
     
using ll = long long;
using P = pair<ll, ll>;
     
const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;
     
#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
     
ll N;
string S;
     
int main(int argc, char **argv)
{
	cin >> N >> S;
     
	string res(N, ' ');
	bool is{false};
	REP(i, 2)REP(j, 2)
	{
		res.assign(N, ' ');
		
		if (i == 0)
			res[0] = 'S';
		else
			res[0] = 'W';
     
		if (j == 0)
			res[1] = 'S';
		else
			res[1] = 'W';
     
		for (ll i = 1; i < N-1; ++i)
		{
			char c = res[i];
     
			if (c == 'S')
			{
				if (S[i] == 'o')
					res[i+1] = res[i-1];
				else
				{
					if (res[i-1] == 'S')
						res[i+1] = 'W';
					else
						res[i+1] = 'S';
				}
			}
			else // wolf
			{
				if (S[i] == 'x')
					res[i+1] = res[i-1];
				else
				{
					if (res[i-1] == 'S')
						res[i+1] = 'W';
					else
						res[i+1] = 'S';
				}
			}
		}

		ll ok{true};

		REP(i, N)
		{
			char c = res[i];
			char l = res[(i-1+N)%N];
			char r = res[(i+1)%N];
			char is = S[i];

			if (c == 'S')
			{
				if (is == 'o')
				{
					if (l != r)
						ok = false;
				}
				else // 'x'
				{
					if (l == r)
						ok = false;
				}
			}
			else // wolf
			{
				if (is == 'o')
				{
					if (l == r)
						ok = false;
				}
				else
					if (l != r)
						ok = false;
			}
		}
		if (ok)
		{

			std::cout << res << std::endl;
			return 0;
		}
     
	}
     
	std::cout << -1 << std::endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc167_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine(); 
            string t = Console.ReadLine();
            string T = t.Substring(0, t.Length - 1); //文字列tから最後の1文字を抜いた文字列

            if (s == T)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 25816
while true 
	hash = Hash.new
	n = gets.to_i  #???????????°

	break if n == 0
	for r in 0...n do 
		line = gets.chomp!
		line = line.split

		no = line[0].to_i #????????????
		unitPrice = line[1].to_i #????£???????
		quantity = line[2].to_i #?£??????°???
		total = unitPrice * quantity #?°??¨?

		if hash.key?(no)
			total += hash[no]
		end
		
		hash[no] = total
	end

	if hash.select{|key, val| val >= 1000000}.empty?
		puts "NA"
	else
		hash.each{ |key, val|
			if val >= 1000000
				p key
			end
		}
	end
end	

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

using namespace std;

#define N 30000

int n,tot,ans,a[N][2],b[N][2],head[N],pre[N];
bool vis[N];
struct edge{int v,nxt;}e[N];

void add(int x,int y){e[++tot].v=y; e[tot].nxt=head[x]; head[x]=tot;}

bool dfs(int u){
	for (int i=head[u],v;i;i=e[i].nxt)
		if (!vis[v=e[i].v]){
			vis[v]=1;
			if (!pre[v]||dfs(pre[v])){pre[v]=u; return 1;}
		}
	return 0;
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d%d",&a[i][0],&a[i][1]);
	for (int i=1;i<=n;++i) scanf("%d%d",&b[i][0],&b[i][1]);
	for (int i=1;i<=n;++i)
		for (int j=1;j<=n;++j)
			if (a[i][0]<b[j][0]&&a[i][1]<b[j][1]) add(i,j);
	for (int i=1;i<=n;++i){
		memset(vis,0,sizeof vis);
		if (dfs(i)) ++ans;
	}
	printf("%d\n",ans);
	
	return 0;
}
			

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

int main(){
  int a1, a2, a3; cin >> a1 >> a2 >> a3;
  int d1=abs(a1-a2), d2=abs(a2-a3), d3=abs(a3-a1);
  cout << min(d1+d2, min(d2+d3, d3+d1)) << endl;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, k;
string s;

int main() {
    cin >> s;

    V<Vl> dp(s.size(), Vl(3, 1e18));
    ll st = s[0] - '0';
    dp[0][1] = st;
    dp[0][2] = min(st+1, 10-st);
    REP2(i, 1, s.size()) {
        ll x = s[i] - '0';
        dp[i][0] = dp[i-1][2] + (10 - x);
        dp[i][1] = min({dp[i-1][0], dp[i-1][1], dp[i-1][2] + 1}) + x;
        if (i != s.size()-1) {
            dp[i][2] = min({dp[i-1][0], dp[i-1][1]}) + min(x+1, 10-x);
            dp[i][2] = min(dp[i][2], dp[i-1][2] + (10-x-1));
        }
    }

    std::cout << min({dp[s.size()-1][0], dp[s.size()-1][1], dp[s.size()-1][2]+1}) << '\n';

    return 0;
}


Measured memory_bytes: 55940
N, A, B = map(int, input().strip().split())

total = 0
for i in range(1, N+1):
  _i = i
  k=0
  for _ in range(len(str(i))):
    k += _i % 10
    _i //= 10
  if A <= k <= B:
    total += i
    
print(total)

Measured memory_bytes: 3060
#include <stdio.h>
int n;
int main() {
	scanf("%d", &n);
	for (int i = 0; i <= n / 100; i++) {
		if (5 * i >= n - 100 * i) {
			printf("1\n");
			return 0;
		}
	}
	printf("0\n");
}

Measured memory_bytes: 128
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll ans = 0;
    if (n >= b) {
        if (n % b != b - 1) {
            n -= n % b + 1;
        }
    }

    cout << a * n / b - a * (n / b) << "\n";
    return 0;
}

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

#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  int ma = 1e9;
  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    int a;
    cin >> a;
    if ( a < ma ) ans++;
    ma = min(ma, a);
  }

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


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin, (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

ll calcproduct(int n) {
  if (n == 0)
    return 1;
  ll ans = 1;
  for (int i = 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}

ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

ll combination(int n, int k) {
  ll a = calcproduct(n);
  ll b = calcproduct(k);
  ll c = calcproduct(n-k);
  b = mod_pow(b, MOD-2);
  c = mod_pow(c, MOD-2);
  ll ans = ((a*b)%MOD*c)%MOD;
  return ans;
}

ll modsubtraction(ll a, ll b) {
  ll ans = (a - b) % MOD;
  if (ans < 0)
    ans += MOD;
  return ans;
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  vector<ll> C;
  rep(i, N) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  ll temp = calcproduct(K-1);
  ll tmp = temp;
  ll tmp2 = 1;
  rep(i, N-K+1) {
    ll a = tmp;
    ll b = mod_pow(temp, MOD-2);
    ll c = mod_pow(tmp2, MOD-2);
    C.pb(((a*b)%MOD*c)%MOD);
    tmp *= K+i;
    tmp %= MOD;
    tmp2 *= i+1;
    tmp2 %= MOD;
  }
  ll m1 = 0;
  ll m2 = 0;
  rep(i, N-K+1) {
    m1 += C[C.size()-1-i]*A[N-1-i];
    m1 %= MOD;
    m2 += C[C.size()-1-i]*A[i];
    m2 %= MOD;
  }
  cout << modsubtraction(m1, m2) << endl;
}


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

//#define int long long
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,n+1)
#define repst(i,s,n) reps(i,s,n+1)
#define reprt(i,n,t) for(ll (i)=(n);(i)>=t;--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb emplace_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) for(int (i)=0;i<n;++i){cout<<x[i]<<(i==n-1?'\n':' ');}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// 2つの操作はどちらも逆方向でも可能 ということは文字列aをいろいろ操作してbにできるときbをaにすることもできる(空文字は例外)
// ある部分文字列をAのみで表すことにすると全ての文字列はA, AA, AAAの3通りに分類できる
// B==AAだからAを1、Bを2としてカウントした和を3で割った余りが等しければ、その文字列同士は互いに変換可能

string s, t;
int q, a, b, c, d, ss[114514], ts[114514];

signed main() {
	cin >> s >> t;
	repst(i,1,s.length()) {
		if (s[i-1]=='A') ss[i] = 1;
		else ss[i] = 2;
		ss[i] += ss[i-1];
	}
	repst(i,1,t.length()) {
		if (t[i-1]=='A') ts[i] = 1;
		else ts[i] = 2;
		ts[i] += ts[i-1];
	}
	cin >> q;
	rep(i,q) {
		cin >> a >> b >> c >> d;
		if ((ss[b]-ss[a-1])%3 == (ts[d]-ts[c-1])%3) cout << "YES" << ln;
		else cout << "NO" << ln;
	}
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/05/19  Problem: ABC 126 B / Link: http://abc126.contest.atcoder.jp/tasks/abc126_b  ----- */


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

	string s; cin >> s;

	int A = stoi(s.substr(0, 2));
	int B = stoi(s.substr(2));
	DD(de(A, B));
	int st = 0;
	if (0 < B&& B <= 12)st = 1;
	if (0 < A&&A <= 12)st |= 2;
	if (st == 3) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (st == 2) {
		cout << "MMYY" << endl;
	}
	else if (st == 1) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a, b;
  cin >> a >> b;
  
  
  if (a+b>=10) puts("error");
  else {
  cout << a+b << endl;
  }
  
}



Measured memory_bytes: 256
def getval():
    n = int(input())
    s = input()
    return n,s 

def main(n,s):
    pos = [-1 for i in range(10)]
    for i in range(n):
        temp = int(s[i])
        if pos[temp]==-1:
            pos[temp] = i 
    flag1 = [[[False for i in range(10)] for i in range(10)] for i in range(10)]
    flag2 = [[False for i in range(10)] for i in range(10)]
    for i in range(10):
        if pos[i]==-1 or pos[i]>=n-1:
            continue
        for j in range(pos[i]+1,n):
            f = flag2[i]
            temp = int(s[j])
            for k in range(10):
                if f[k]:
                    flag1[i][k][temp] = True 
            if not f[temp]:
                flag2[i][temp] = True
    ans = 0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if flag1[i][j][k]:
                    ans += 1
    print(ans)

if __name__=="__main__":
    n,s = getval()
    main(n,s)

Measured memory_bytes: 9356
import java.util.*;

public class Main {
    static ArrayList<Route>[] graph;
    static long[] distances;
	public static void main (String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		graph = new ArrayList[n + 1];
		distances = new long[n + 1];
		for (int i = 1; i <= n; i++) {
		    graph[i] = new ArrayList<Route>();
		}
		for (int i = 0; i < n - 1; i++) {
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int cost = sc.nextInt();
		    graph[a].add(new Route(b, cost));
		    graph[b].add(new Route(a, cost));
		}
		search(new Route(1, 1), 0);
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= n; i++) {
		    sb.append(distances[i] % 2).append("\n");
		}
		System.out.print(sb);
	}
	
	static void search(Route r, long sum) {
	    if (distances[r.to] != 0) {
	        return;
	    }
	    distances[r.to] = r.cost + sum;
	    for (Route x : graph[r.to]) {
	        search(x, r.cost + sum);
	    }
	}
	
	static class Route {
	    int to;
	    int cost;
	    
	    public Route(int to, int cost) {
	        this.to = to;
	        this.cost = cost;
	    }
	}
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int dx = x2 - x1;
	int dy = y2 - y1;

	int x3 = x2 - dy;
	int y3 = y2 + dx;
	int x4 = x3 - dx;
	int y4 = y3 - dy;

	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

	return 0;
}


Measured memory_bytes: 256
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        s: Chars,
    }

    let ss:String = s.iter().collect();
    if s[s.len()-1] == 's' {
        println!("{}es", ss);

    } else {
        println!("{}s", ss);
    }

}


Measured memory_bytes: 2080
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()

using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll n,a,b; cin >> n >> a >> b;
    ll cnt=n/(a+b);
    ll ans=cnt*a;
    ans+=min(a,(n-cnt*(a+b)));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int x;
  scanf("%d",&x);

  int max=0;

  for(int i=1; i<=34; i++){
    if(i*i<=x){
      if(max<i*i){
        max=i*i;
      }
    }
  }

  for(int i=1; i<=10; i++){
    if(i*i*i<=x){
      if(max<i*i*i){
        max=i*i*i;
      }
    }
  }

  for(int i=1; i<=5; i++){
    if(i*i*i*i<=x){
      if(max<i*i*i*i){
        max=i*i*i*i;
      }
    }
  }

  for(int i=1; i<=3; i++){
    if(i*i*i*i*i<=x){
      if(max<i*i*i*i*i){
        max=i*i*i*i*i;
      }
    }
  }

  for(int i=1; i<=3; i++){
    if(i*i*i*i*i*i<=x){
      if(max<i*i*i*i*i*i){
        max=i*i*i*i*i*i;
      }
    }
  }

  if(128<=x){
    if(max<128){
      max=128;
    }
  }

  if(256<=x){
    if(max<256){
      max=256;
    }
  }  

  if(512<=x){
    if(max<512){
      max=512;
    }
  }  


    printf("%d",max);
    return 0;

}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int i, a, b, s = 0;
	scanf("%d %d", &a, &b);
	for(i=0;i<2;i++) {
		if(a > b) {
			s += a;
			a--;
		} else {
			s += b;
			b--;
		}
	}

	printf("%d", s);
	
	return 0;
}


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

using namespace std;

int main(){
  int a,b,c,k;
  cin >>a >>b>>c>>k;
  if(k<=a){
    cout << k << endl;
  }
  else if(k<=a+b){
    cout << a << endl;
  }
  else{
    cout << a-(k-a-b) << endl;
  }
}




Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define longinf 9223372036854775807LL
#define intinf 2147483647
#define inf 998244353
#define lol long long
#define in(n,s) insert(n,s)//ノート参照
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d,e=0,g,h;
int i[111110];
int dp[100011];
int ka(int x){
  if(dp[x]!=-1) return dp[x];
  if(x==0) return dp[x]=0;
  if(x==1) return dp[x]=abs(i[0],i[1]);
  int nx=abs(i[x],i[x-1]);
  int ny=abs(i[x],i[x-2]);
  return dp[x]=min(ka(x-1)+nx,ka(x-2)+ny);
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>a;
  memset(dp,-1,sizeof(dp));
  for(int n=0;n<a;n++) cin >>i[n];
  cout <<ka(a-1)<<'\n';
  return (0);
}


Measured memory_bytes: 3328