akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

int d,n;

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

    if (n==100) n++;

    if (d == 0) {
        cout << n << endl;
        return 0;
    }

    cout << fixed << setprecision(0) << pow(100, d) * n <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String args[] ) throws Exception {

//		long startime = System.currentTimeMillis();
		Scanner sc = new Scanner(System.in);
		int n = Integer.valueOf ( sc.nextLine().trim() ) ;
		long x =0 ;
		for ( long a=1 ; a<n ; a++ ) {
			for ( long b=1 ; b<n ; b++ ) {
				long v = a * b ; 
				if ( v >= n ) break ; 
				long c = n - v ;
				x++;

			}
		}
		System.out.println( x ) ;

	}
}

Measured memory_bytes: 27184
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n,a,b,h[100010],sum,k,clo[100010];
bool kill(LL t){
	memcpy(clo,h,sizeof(h));
	for(LL i=0;i<n;i++){
		clo[i]-=t*b;
	}
	LL cnt=0;
	for(LL i=0;i<n;i++){
		if(clo[i]>0)
			cnt+=(clo[i]+k-1)/k;
	}
	return cnt<=t;
}
int main(){
	cin>>n>>a>>b;
	k=a-b;
	for(int i=0;i<n;i++){
		cin>>h[i];
		sum+=h[i];
	}
	LL l=0,r=(sum+b-1)/b,m,ans;
	while(l<=r){
		m=(l+r)/2;
		if(kill(m)){
			ans=m;
			r=m-1;
		}else{
			l=m+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <cstdlib>
#include <ctime>

using namespace std;

int n, c, a[6];
long long f[1 << 5][1 << 5][305];
int main() {
	scanf("%d %d", &n, &c);
	for (int i = 0; i < n; i++) cin >> a[i], a[i] *= n;
	c *= n;
	sort(a, a + n);
	f[0][0][a[n - 1]] = 1;
 // cout << a[n - 1] << endl;
	for (int x = 1; x < c; x++) if (x % n) {//x表示当前准备放的位置共用cn种可能
		for (int l = x + 1; l <= c; l++) {//l表示最右边覆盖到的位置
			for (int i = 0; i < 1 << n - 1; i++) if (!(i >> (x % n - 1) & 1)) { //找一个位置的小数部分状态为i，且和x对应的小数位置没有放
				for (int j = 0; j < 1 << n - 1; j++) if (f[i][j][l]){//找一个线段使用情况为j
					for (int y = 0; y < n - 1; y++) if (!(j >> y & 1)) {//选用第y条线段
            //cout << (i | 1 << (x % n - 1)) << " --- " << (j | 1 << y) << min(c, max(l, x + a[y])) << endl;
						f[i | 1 << (x % n - 1)][j | 1 << y][min(c, max(l, x + a[y]))] += f[i][j][l]; //更新结果
					}
				}
			}
		}
	}
	long long ans = f[(1 << n - 1) - 1][(1 << n - 1) - 1][c];
	long long all = 1;
	for (int i = 1; i < n; i++) {
		all = all * i * c / n;
	}
//	cout << ans << " " << all << endl;
	printf("%.13Lf\n",(long double) ans / all);


}

Measured memory_bytes: 1408
#include <cstring>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

class Node
{
public:
	int x,y;
	vector<int> to;
	Node() {}
};

class Trl
{
public:
	int p,d,c;
	double ds;
	Trl(int p,int d, int c, double ds)
	:p(p),d(d),c(c),ds(ds)
	{}
	
	bool operator<(const Trl& t) const
	{
		if(ds!=t.ds) return ds>t.ds;
		
		return c>t.c;
	}
};

bool v[1000][4];

int main()
{
	int N,C;
	while(cin >> N >> C, (N||C))
	{
		Node node[1000];
		map<string, int> dic;
		for(int i=0; i<N; i++)
		{
			int x,y;
			string s;
			cin >> s >> x >> y;
			dic.insert(make_pair<string, int>(s,i));
			node[i].x=x;
			node[i].y=y;
		}
		
		while(C--)
		{
			string sn,dn;
			cin >> sn >> dn;
			int s=dic.find(sn)->second;
			int d=dic.find(dn)->second;
			
			node[s].to.push_back(d);
			node[d].to.push_back(s);
		}
		
		string sn,dn;
		cin >> sn >> dn;
		int s=dic.find(sn)->second;
		int d=dic.find(dn)->second;
		
		bool g=false;
		memset(v,0,sizeof(v));
		
		priority_queue<Trl> q;
		for(int i=0; i<4; i++)
		{
			q.push(Trl(s,i,1,0));
			v[s][i]=1;
		}
		
		while(!q.empty())
		{
			Trl t=q.top(); q.pop();
			if(t.p==d)
			{
				g=true;
				printf("%d\n", t.c);
				break;
			}
			for(int i=0; i<node[t.p].to.size(); i++)
			{
				int next=node[t.p].to[i];
				int td;
				double dist;

				if(node[t.p].x==node[next].x)
				{
					if(node[t.p].y < node[next].y) td=0;
					else td=2;
					
					dist=(node[t.p].y-node[next].y)*(node[t.p].y-node[next].y);
				}
				else
				{
					if(node[t.p].x < node[next].x) td=1;
					else td=3;
					
					dist=(node[t.p].x-node[next].x)*(node[t.p].x-node[next].x);
				}
				
				if((t.d+1)%4==td||(t.d+2)%4==td) continue;
				if(v[next][td]) continue;
				v[next][td]=1;
				
				q.push(Trl(next,td,t.c+1,t.ds+sqrt(dist)));
			}
		}
		
		if(!g) puts("impossible");
	}
}

Measured memory_bytes: 1108
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let k: usize = read();
    let mut arr = Vec::new();
    for i in 1..min(a, b) + 1 {
        if a % i == 0 && b % i == 0 {
            arr.push(i);
        }
    }
    arr.reverse();
    println!("{}", arr[k - 1]);
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            String[] array = reader.readLine().split(" ");
            int N = Integer.parseInt(array[0]);
            int K = Integer.parseInt(array[1]);

            array = reader.readLine().split(" ");
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = Integer.parseInt(array[i]);
            }

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += A[i];
            }

            List<Integer> divisors = divisor(sum);
            Collections.sort(divisors);
            Collections.reverse(divisors);

            for (Integer divisor : divisors) {
                int d = divisor.intValue();

                int modSum = 0;
                int[] mods = new int[N];
                for (int i = 0; i < N; i++) {
                    mods[i] = A[i] % d;
                    modSum += mods[i];
                }

                Arrays.sort(mods);

                int modSum2 = 0;
                for (int i = 0; i < (modSum / d); i++) {
                    modSum2 += mods[N - 1 - i];
                }

                if ((modSum - modSum2) <= K) {
                    System.out.println(d);
                    System.exit(0);
                }
            }
        }
    }

    public static List<Integer> divisor(int N) {
        List<Integer> list = new ArrayList<Integer>();

        for (int n = 1; n <= Math.sqrt(N); n++) {
            if (N % n == 0) {
                list.add(n);
                int n2 = N / n;
                if (n != n2) {
                    list.add(N / n);
                }
            }
        }

        return list;
    }

}


Measured memory_bytes: 24660
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int S; cin >> S;
    int s1 = S / 100, s2 = S % 100;
    if(s1 >= 1 && s1 <= 12 && s2 >= 1 && s2 <= 12) Out("AMBIGUOUS");
    else if(s1 >= 1 && s1 <= 12) Out("MMYY");
    else if(s2 >= 1 && s2 <= 12) Out("YYMM");
    else Out("NA");

    return 0;
}


Measured memory_bytes: 256
// 14:00
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

char s[10];
ll p10[20];

bool check(ll x) {
    cout << "? " << x << endl;
    scanf("%s", s);
    return (*s == 'Y');
}

inline ll get1(int x) {
    return p10[x - 1];
}

inline ll get9(int x) {
    return p10[x] - 1;
}

int main() {

    for (int i = p10[0] = 1; i <= 11; ++i)
        p10[i] = p10[i - 1] * 10;

    int num;
    if (check(1) == check(1e12)) {
        int l = 1, r = 11;
        while (l <= r) {
            int mid = (l + r) >> 1;
            if (check(get9(mid))) r = (num = mid) - 1;
            else l = mid + 1;
        }
    } else {
        int l = 1, r = 11;
        while (l <= r) {
            int mid = (l + r) >> 1;
            if (check(get1(mid))) l = (num = mid) + 1;
            else r = mid - 1;
        }
    }

    ll l = get1(num), r = get9(num), res;

    while (l <= r) {
        ll mid = (l + r) >> 1;
        if (check(10ll * mid)) r = (res = mid) - 1;
        else l = mid + 1;
    }

    cout << "! " << res << endl;

    return 0;
}


Measured memory_bytes: 660
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define pli pair<long long , int>
#define pil pair<int ,long long>
#define pi acos(-1)
#define pb push_back
#define mkp make_pair
#define all(a) a.begin(), a.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
using namespace std;


int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int a,b;
    cin>>a>>b;
    if(b%a==0){
        cout<<a+b;
    }
    else{
        cout<<b-a;
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[]arg) throws IOException {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		int c500=0;
		int c100=0;
		int c050=0;
		int ndn=0;
		int tori=0;
		String str="";

		str=bfr.readLine();
		c500=Integer.parseInt(str);
		str=bfr.readLine();
		c100=Integer.parseInt(str);
		str=bfr.readLine();
		c050=Integer.parseInt(str);
		str=bfr.readLine();
		ndn=Integer.parseInt(str);
		for(int i=0; i<=c500; i++) {
			for(int j=0; j<=c100; j++) {
				for(int k=0; k<=c050; k++) {
					if(ndn==i*500+j*100+k*50) {
						tori++;
					}
				}
			}
		}

		System.out.println(tori);
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  vector<vector<vector<pair<int, int> > > > E(N, vector<vector<pair<int, int> > >(3, vector<pair<int, int> >()));
  REP(i, M){
    int u, v; cin >> u >> v; u--; v--;
    E[u][0].push_back({v, 1});
    E[u][1].push_back({v, 2});
    E[u][2].push_back({v, 0});
  }
  int S, T; cin >> S >> T; S--; T--;
  vector<vector<int> > dist(N, vector<int>(3, -1));
  queue<pair<int, int> > q;
  q.push({S, 0});
  dist[S][0] = 0;
  while(!q.empty()){
    auto cur = q.front(); q.pop();
    for(auto nxt : E[cur.first][cur.second]){
      if(dist[nxt.first][nxt.second] != -1) continue;
      dist[nxt.first][nxt.second] = dist[cur.first][cur.second] + 1;
      q.push(nxt);
    }
  }
  cout << (dist[T][0] == -1 ? -1 : dist[T][0]/3) << endl;
}

Measured memory_bytes: 25216
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#define r(i,n) for(int i=0; i<n; i++)

using namespace std;
int main(void){
  int n;
  int a;
  deque<int> b;
  cin >> n;
  r(i,n){
    cin >> a;
    if(i%2==0 && n%2==0){
      b.push_back(a);
    }else if(i%2==1 && n%2==0){
      b.push_front(a);
    }else if(i%2==0 && n%2==1){
      b.push_front(a);
    }else{
      b.push_back(a);
    }


  }
  r(i,n-1){
    cout << b[i] << ' ';
  }
  cout << b[n-1] << endl;
  return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
#include<string.h>
int i,l,p,ans,b[100010];
char s[100010],a[100010];
int abs(int a){
    if(a<0) return -a; else return a;
}
int main(){
    scanf("%s",s);
    for(i=0;s[i];i++) if(s[i]!='x') a[l++]=s[i]; else b[l]++;
    a[l]='\0';
    p=1;
    for(i=0;i<l/2;i++) if(a[i]!=a[l-1-i]) p=0;
    if(p){
        for(i=0;i<(l+1)/2;i++) ans+=abs(b[i]-b[l-i]);
        printf("%d\n",ans);
    }else printf("-1\n");
}


Measured memory_bytes: 640
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  x <- unsafeTextToInt <$> T.getLine :: IO Int
  let
    (a, b) = x `divMod` 500
    c = b `div` 5
  print $ 1000 * a + 5 * c

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
/*input
y
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char c; cin >> c;
    cout << (char) (c + 1);

    return 0;
}

Measured memory_bytes: 256
///////////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

///////////////////////////////////////////////////////////////////////////////

#define pb push_back

void intin(int &a)
{
        cin >> a;
}

void intinl1(auto &v, int count)
{
        for (int i = 0; i < count ; ++i) {
                int a;
                cin >> a;
                v.push_back(a);
        }
}

void intinl2(auto &v, int count)
{
        for (int i = 0; i < count ; ++i) {
                int a, b;
                cin >> a >> b;
                v.push_back({a, b});
        }
}

void intinl3(auto &v, int count)
{
        for (int i = 0; i < count ; ++i) {
                int a, b, c;
                cin >> a >> b >> c;
                v.push_back({a, b, c});
        }
}

void intina(auto &v, int count)
{
        intinl1(v, count);
}


///////////////////////////////////////////////////////////////////////////////

int main()
{
        int n, k;
        intin(n); intin(k);

        string s;
        cin >> s;
        size_t slen = s.size();

        vector<int> count0;
        vector<int> count1;
        for (int i = 0, now = '1', count = 0; i < slen; ++i) {
                if (s[i] != now) {
                        if (now == '0') count0.pb(count);
                        if (now == '1') count1.pb(count);
                        now = s[i];
                        count = 0;
                }
                count++;
                if (i == slen - 1) {
                        if (now == '0') count0.pb(count);
                        if (now == '1') count1.pb(count);
                }
        }

        if (count0.size() == count1.size()) count1.pb(0);

        k = min(k, int(count0.size()));

        int ans = 0;
        for (int i = 0; i < k; ++i) {
                ans += count0[i];
                ans += count1[i];
        }
        ans += count1[k];

        for (int i = 0, val = ans; i < count0.size() - k; ++i) {
                val -= count0[i];
                val -= count1[i];
                val += count0[i+k];
                val += count1[i+k+1];
                ans = max(ans, val);
        }

        cout << ans;

        return 0;
}

///////////////////////////////////////////////////////////////////////////////


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

string s;

int main() {

    cin >> s;

    int n = s.length();
    int cntP = 0;
    for(int i = 0; i < n; ++i)
        cntP += (s[i] == 'p');

    cout << n / 2 - cntP << "\n";

    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));

int bubbleSort(vector<int>&A, int N){
    bool flag = true;
    int count = 0;
    while(flag){
        flag = false;
        for(int i = N - 1; i >= 1; i--){
            if(A[i] < A[i - 1]){
                swap(A[i], A[i - 1]);
                flag = true;
                count++;
            }
        }
    }
    return count;
}

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

    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    int n = bubbleSort(A, N);
    for(int i = 0; i < N; i++){
        cout << A[i];
        if(i != N - 1) cout << ' ';
    }
    cout << endl;
    cout << n << endl;
}



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

using namespace std;

typedef long long ll;
ll fact[2100];
ll mod = 1e9 + 7;
void buildFact() {
    fact[0] = 1;
    for(int i = 1; i < 2100; i++) fact[i] = (fact[i-1]*i)%mod;
}

ll power(ll y, ll x) {
    if(x == 0) return 1;
    ll res = 1;
    while(x) {
        if(x&1) res = (res*y)%mod;

        x = x>>1;
        y = (y*y)%mod;
    }
    return res%mod;
}

ll modInverse(ll n) {
    return power(n, mod-2);
}

ll ncr(ll n, ll r) {
    if(n < r) return 0;
    if(n == 0) return 1;
    if(n == r) return 1;
    return ((((fact[n])*(modInverse(fact[n-r])))%mod) * (modInverse(fact[r])))%mod;
}

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

    // cout<< "HI" << ncr(5,2) << endl;

    ll s;
    cin >> s;
    if(s < 3) {
        cout << 0 << endl;
        return 0;
    }
    ll res = 0;
    for(int i = 1; i < (s/3)+1; i++) {
        res = (res+ncr(s-(2*i)-1, i-1))%mod;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <algorithm>

typedef long long ll;
#define rep(i,be,en) for (ll i=be;i<=en;i++)

using namespace std;

const int N=5e5+7;
ll n,ans=0;

int main(){
    scanf("%lld",&n);
    rep(i,1,n){
        rep(j,1,n){
            rep(k,1,n){
                ll temp=__gcd(i,j);
                ans+=__gcd(temp,k);
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const long long mod2=998244353;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}
int n;
int p[N];
int main(){
	//freopen("in.txt","r",stdin);
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		int u;cin>>u;
		if(u!=i)ans++;
	}
	if(ans<=2)o("YES");else o("NO");
}


Measured memory_bytes: 256
N, K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = -10**18
for start in range(N):
    now = start
    cycle = [0]

    while True:
        now = P[now] - 1
        cycle.append(cycle[-1] + C[now])

        if now == start: break

    L = len(cycle)-1
    if cycle[-1] < 0 or K <= L:
        score = max(cycle[1:min(L+1,K)+1])
    else:
        score1 = cycle[-1]*(K//L) + max(cycle[:K%L+1])
        score2 = cycle[-1]*(K//L-1) + max(cycle)
        score = max(score1, score2)

    ans = max(ans, score)

print(ans)

Measured memory_bytes: 81776
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    string S;
    cin >> S;
    int min = 1000;
    int a = 753;
    for(int i = 0; i + 2 < (int)S.size(); i++){
        string y = S.substr(i, 3);
        int x = stoi(y);
        if(min > abs(a - x)) min = abs(a - x);
    }

    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PL;
typedef pair<P, LL> PP;
typedef pair<P, LL> PP;
typedef long long LL;

#define xx first
#define yy second

vector<int> G1[110000], G2[110000];
vector<tuple<int, int, int>> vt;
int n,m,p;
int eg[110000], d[110000];
int vis[110000];

void dfs1(int p){
  if((vis[p]&2))return;
  vis[p] |=2;
  for(auto adj:G1[p]){
    dfs1(adj);
  }
}

void dfs2(int p){
  if((vis[p]&1))return;
  vis[p] |=1;
  for(auto adj:G2[p]){
    dfs2(adj);
  }
}
void bf(){
  for(int i=0;i<n+10;i++)
    d[i]=INT_MAX;
  // cout<<-d[0]<<" "<<d[0]<<endl;
  d[1] = 0;
  int test;
  int fl = 0;
  for(int i=0;i<n;i++){
    // cout<<"round"<<endl;
    test = 0;
    for(auto e:vt){
      int a,b,c;
      tie(a,b,c) = e;
      if(d[a]<INT_MAX && (d[b] > d[a] + c)){
        d[b] = d[a]+c, eg[b] = eg[a]+1, test = (vis[b]==3?1:test);
      }
      if(i>=n-1&&test==1)fl=1;
    }
  }
  // cout<<d[n]<<endl;
  if(fl){
    cout<<-1<<endl;
  }
  else cout<<max(0,-d[n])<<endl;
}
int main()
{
  // #ifndef ONLINE_JUDGE
  //freopen("input", "r", stdin);
  // freopen("output", "w", stdout);
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin>>n>>m>>p;
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    vt.push_back(make_tuple(a,b,p-c));
    G1[a].push_back(b);
    G2[b].push_back(a);
  }
  dfs1(1);
  dfs2(n);
  bf();

}


Measured memory_bytes: 5760
#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
    long long N,K;
    cin >> N >> K;
    long long sum=0;
    long long min,max;
    min=0;
    max=0;
    for(long long i=1;i<K;i++){
        min=min+i-1;
        max=max+N-(i-1);
    }
    for(long long i=K;i<=N+1;i++){
        min=min+i-1;
        max=max+N-(i-1);
        sum=(sum+1+max-min)%(int(1e9+7));
    }

    cout << sum << endl;
}

Measured memory_bytes: 3640
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInts() (int,int) {
  var a,b int
  var s []string = strings.Split(NextLine()," ")
  a,_ = strconv.Atoi(s[0])
  b,_ = strconv.Atoi(s[1])
  return a,b
}

func main() {
  var n,q,l,r int
  var s string
  var c []int
  n,q = NextInts()
  s = NextLine()
  c = make([]int,n)
  for i:=1;i<n;i++ {
    c[i] = c[i-1]
    if s[i-1:i+1] == "AC" {
      c[i]++
    }
  }
  for i:=0;i<q;i++ {
    l,r = NextInts()
    fmt.Println(c[r-1]-c[l-1])
  }
}

Measured memory_bytes: 6016
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solveB();
	}

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		int NA = N * A;

		if (NA > B) {
			System.out.println(B);
		} else {
			System.out.println(NA);
		}
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);

		String N = sc.nextLine();

		int iN = Integer.parseInt(N);

		String[] str = N.split("");

		int I = 0;
		for (int i = 0; i < str.length; i++) {
			int I2 = Integer.parseInt(str[i]);
			I += I2;
		}
		if (iN % I == 0) {
			System.out.println("Yes");
		} else if (iN % I != 0) {
			System.out.println("No");
		}

	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveE() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveF() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

}

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

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

    string S;
    cin >> S;
    ull res = 0;

    rep(i, 1 << S.size()-1) {
        ull sum = 0;
        string s = "";
        rep (j, S.size()) {
            s += S[j];
            if (i & 1 << j)
                s += "+";
        }
        
        int pos = 0;
        while (s.find("+", pos) != string::npos) {
            int nextPos = s.find("+", pos);
            sum += stoull(s.substr(pos, nextPos-pos));
            pos = nextPos + 1;
        }
        sum += stoull(s.substr(pos));
        res += sum;
    }

    cout << res << "\n";
}

Measured memory_bytes: 256
A, B, C, X, Y = [int(x) for x in input().split()]
mon1 = X * A + Y * B
mon2 = 2 * C * max(X, Y)
mon3 = 2 * C * min(X, Y)
mon3 += A * (max(X, Y) - min(X, Y)) if X >= Y else B * (max(X, Y)  - min(X, Y))
print(min(mon1, mon2, mon3))


Measured memory_bytes: 3060
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    int bunpu[101] = {};//0点から100点まで101個
    for(int i = 0; i < n; i++) {
        int p_i;
        scanf("%d", &p_i);
        bunpu[p_i]++;
    }
    for(int i = 99; i >= 0; i--) {
        bunpu[i] += bunpu[i+1];
    }
    for(int i = 100; i >= 0; i--) {
        if(bunpu[i] >= i) {
            printf("%d\n", i);
            return 0;
        }
    }
}


Measured memory_bytes: 2112
#include<stdio.h>
#include<algorithm>


using namespace std ;


int check( int *p ,int sum )
{
	if( sum == 0 )
	{
		return -1 ;
	}

	int i = 1 ;
	for( ; i < 4 ; ++i )
	{
		if( p[ i ] != p[ i - 1 ] )
		{
			return 1 ;
		}
	}


	return 0 ;
}


int main()
{
	int n[ 4 ] = { 0 } ;

	int desc[] = { 1 ,10 ,100 ,1000 } ;
	int asc[] = { 1000 ,100 ,10 ,1 } ;


	int i ;
	while( 1 )
	{
		int sum = 0 ,ans = 0 ;

		for( i = 0 ; i < 4 ; ++i )
		{
			scanf( "%1d" ,&n[ i ] ) ;

			sum += n[ i ] ;
		}


		int ok = check( n ,sum ) ;

		if( ok == -1 )
		{
			return 0 ;
		}

		else if( ok == 0 )
		{
			puts( "NA" ) ;
		}

		else
		{
			sum = n[ 0 ] * asc[ 0 ] + n[ 1 ] * asc[ 1 ] + n[ 2 ] * asc[ 2 ] + n[ 3 ] * asc[ 3 ] ;

			while( sum != 6174 )
			{
				sort( n ,n + 4 ) ;


				sum = ( n[ 0 ] * desc[ 0 ] + n[ 1 ] * desc[ 1 ] + n[ 2 ] * desc[ 2 ] + n[ 3 ] * desc[ 3 ] ) - ( n[ 0 ] * asc[ 0 ] + n[ 1 ] * asc[ 1 ] + n[ 2 ] * asc[ 2 ] + n[ 3 ] * asc[ 3 ] )	;


				++ans ;


				n[ 0 ] = sum / asc[ 0 ] ;
				sum = sum - ( sum / asc[ 0 ] ) * asc[ 0 ] ;

				n[ 1 ] = sum / asc[ 1 ] ;
				sum = sum - ( sum / asc[ 1 ] ) * asc[ 1 ] ;

				n[ 2 ] = sum / asc[ 2 ] ;
				sum = sum - ( sum / asc[ 2 ] ) * asc[ 2 ] ;

				n[ 3 ] = sum / asc[ 3 ] ;


				sum = n[ 0 ] * asc[ 0 ] + n[ 1 ] * asc[ 1 ] + n[ 2 ] * asc[ 2 ] + n[ 3 ] * asc[ 3 ] ;
			}


			printf( "%d\n" ,ans ) ;
		}
	}
}

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*alias*/
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -fsanitize=signed-integer-overflow -fno-sanitize-recover=all -o template template.cpp

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

signed main()
{
	int a{};cin >> a;
	int b{};cin >> b;
	int ans{};

for(int i = 0, i_len = 2; i < i_len; ++i){

	if(a <= b){
		ans += b;
		--b;
	}
	else if(a > b){
		ans += a;
		--a;
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <climits>
#include <stack>
#include <vector>
#include <random>
#include <string.h>
#include <stdio.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef pair<int, int> ii;
typedef pair<long double, int> id;
typedef pair<long long, long long> llp;
const int N = 1e5+1;
int n, t;
int h[N], dp[N];
int main() {
    //freopen("ee.inp", "r", stdin);
    //freopen("ee.OUT", "w", stdout);
    fastIO;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>h[i];
    dp[1] = dp[0] = 0;
    for(int i=2;i<=n;i++) {
        dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
        if (i>2) dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n];
}


Measured memory_bytes: 4444
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#define ll long long
using namespace std;

int main(void){
    int a, b, h;
    cin >> a;
    cin >> b;
    cin >> h;
    cout << (a+b)*h/2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;

  int ab = abs(a - b);
  int ac = abs(a - c);
  int bc = abs(b - c);
  if ( ac <= d ) {
    std::cout << "Yes" << std::endl;
  } else if ( ab <= d && bc <= d) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  int ans = 0;
  int temp = 0;
  for(int i = 0; i < 3; i++) {
    if(S[i] == 'R') {
      temp++;
    }
    else {
      if(ans < temp) {
        ans = temp;
      }
      temp = 0;
    }
  }
  if(ans < temp) 
    ans = temp;
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<stdlib.h>
#include<stdio.h>
#pragma warning(disable:4996)

int main() {
	int n = 0;
	scanf("%d", &n);
	int matrix[100] = { 0 };
	int line = 0;
	for (int a = 0; a < n; a++) {
		scanf("%d", &line);
		int time = 0;
		scanf("%d", &time);
		while(time--) {
			int m = 0;
			scanf("%d", &m);
			matrix[m-1]++;
		}
		for (int j = 0; j < n; j++) {
			printf("%d", matrix[j]);
			if (j!=n-1) {
				printf(" ");
			}
			matrix[j] = 0;
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2148
import itertools

N,M,X = map(int, raw_input().split())
Data = [map(int, raw_input().split()) for _ in range(N)]
C = [itertools.combinations(Data, i) for i in range(N+1)]
ans = -1
for c in itertools.chain.from_iterable(C):
    # print list(c)
    T = [0]*(M+1)
    for a in c:
        for i,b in enumerate(a):
            T[i] += b
    # print T
    ok = True
    for t in T[1:]:
        if t < X:
            ok = False
            break

    if ok:
        price = T[0]
        # print price
        if ans == -1:
            ans = 100000000
        ans = min(ans, price)

print ans


Measured memory_bytes: 73108
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int i_index;
int tmp;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];
int main(){
    cin >> N;
    int D[200010] = {0};
    int T[200010] = {0};
    rep(i, N) cin >> D[i];
    cin >> M;
    rep(i, M) cin >> T[i];
    map<int, int> mpD, mpT;
    rep(i, N) mpD[D[i]]++;
    rep(i, M) mpT[T[i]]++;
    rep(i, M){
        int x = T[i];
        if(mpD[x] < mpT[x]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
inline int read_() {int x_=0,f_=1;char c_=getchar();while(c_<'0'||c_>'9') {if(c_=='-') f_=-1;c_=getchar();}while(c_>='0'&&c_<='9') {x_=(x_<<1)+(x_<<3)+c_-'0';c_=getchar();}return x_*f_;}

#define maxn 100020
int n,head[maxn],tot = 0,sze[maxn],max_sze[maxn],mind,root;
long long ans = 0;
struct edge {
	int v,nxt,w;
}e[maxn<<1];
inline void add_(int u,int v,int w) {
	e[++tot].v = v;
	e[tot].w = w;
	e[tot].nxt = head[u];
	head[u] = tot;
}

void dfs_(int u,int fa)  {
	sze[u] = 1;
	for(int i = head[u];~i;i = e[i].nxt)  {
		int v = e[i].v;
		if( v == fa ) continue;
		dfs_(v,u);
		sze[u] += sze[v];
		max_sze[u] = max( max_sze[u],sze[v] );
		ans += (long long) 2 * e[i].w * min( sze[v],n - sze[v] );
	}
	max_sze[u] = max( max_sze[u],n - sze[u] );
	if( max_sze[u] < mind ) {
		mind = max_sze[u];
		root = u;
	}
}

int main() {
	//freopen("a.txt","r",stdin);
	memset(head,-1,sizeof(head));
	n = read_();int x,y,z;
	for(int i = 1;i < n;++i) {
		x = read_();y = read_();z = read_();
		add_(x,y,z);add_(y,x,z);
	}
	mind = n + 1;
	dfs_(1,0);
	mind = 200000000;
	for(int i = head[root];~i;i = e[i].nxt) {
		int v = e[i].v;
		if( max_sze[root] == max_sze[v] ) {ans -= e[i].w;printf("%lld",ans);return 0;}
		mind = min( mind,e[i].w );
	}	
	printf("%lld",ans-mind);
	return 0;
}

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

#define ll long long int
#define LD long double

const int N = 100010;

int inf = 1e9;
int mod = 1e9 + 7;

signed main()
{
    //freopen("IN", "r", stdin);
    //freopen("OUT", "w", stdout);
    int cnt = 0;
    int n; cin >> n;
    for(int i = 1; i <= n; i++) {
        int x; cin >> x;
        if(i % 2 == 1 && x % 2 == 1)
            cnt++;
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(void){
     int a,b,c;
     
    int count=0;
    
    cin>>a>>b>>c;
    
    for(int i=a; i<=b; i++){if(c % i == 0)count++;}
    
    cout<<count<<endl;
    
    
    
}



Measured memory_bytes: 3108
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>
#include <utility>


#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int n;
	cin >> n;
	static vector<ll> a(n);

	// a_iを固定したときのベストなa_j
	// a_j[a_i := 0] は定義されない
	vector<int> a_j(n);

	REP(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	a_j[1] = 0;
	//REPS(i, 2, n) {
	//	double mid_num = a[i] / 2.0;

	//	double diff = mod;
	//	REPS(j, a_j[i - 1], i) {
	//		if (diff > abs(mid_num - (double)a[j])) {
	//			a_j[i] = j;
	//			diff = abs(mid_num - (double)a[j]);
	//		}
	//		else break;
	//	}
	//	//cout << a[i] << " " << a[a_j[i]]<<endl;
	//}

	double mid_num = a[n - 1] / 2.0;
	int diff = mod;
	REP(i, n) {
		int new_diff = abs((int)(mid_num - a[i]));
		if (diff > new_diff) {
			diff = new_diff;
		}
		else {
			cout << a[n - 1] << " " << a[i - 1];
			break;
		}
	}

	system("pause");
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

vector<vector<ll>> dis(51, vector<ll>(51, INF));

void Warshall_Floyd()
{
    for (int k = 0; k <= 50; k++)
    {
        for (int i = 0; i <= 50; i++)
        {
            for (int j = 0; j <= 50; j++)
            {
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }
}

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

    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    bool f = true;
    for (int i = 1; i <= 50; i++)
    {
        for (int j = 0; j <= 50; j++)
        {
            dis[j][j % i] = 0;
        }
    }
    Warshall_Floyd();
    for (int i = 0; i < n; i++)
    {
        if (a[i] == b[i])
            continue;
        if (dis[a[i]][b[i]] == INF)
            f = false;
    }
    if (!f)
    {
        cout << "-1" << endl;
        return 0;
    }
    vector<ll> use;
    for (int i = 50; i >= 1; i--)
    {
        // i 無しで到達可能か
        for (int j = 0; j <= 50; j++)
            for (int k = 0; k <= 50; k++)
                dis[j][k] = INF;
        for (int j = 1; j < i; j++)
        {
            for (int k = 0; k <= 50; k++)
            {
                dis[k][k % j] = 0;
            }
        }
        for (auto j : use)
        {
            for (int k = 0; k <= 50; k++)
            {
                dis[k][k % j] = 0;
            }
        }
        Warshall_Floyd();
        bool f = true;
        for (int j = 0; j < n; j++)
        {
            if (a[j] == b[j])
                continue;
            if (dis[a[j]][b[j]] == INF)
                f = false;
        }
        if (!f)
            use.push_back(i);
    }
    ll res = 0;
    for (auto v : use)
    {
        res += (1LL << v);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  string ans="NO";
  for(int i=1;i<10000000;i++){
    if(i*A%B==C){
      ans="YES";}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
<?php
	while (1) {
		$n = trim(fgets(STDIN));
		list($a, $op, $b) = explode(" ", $n);

		if ($op == "+")	$val = $a + $b;
		elseif ($op == "-")	$val = $a - $b;
		elseif ($op == "*")	$val = $a * $b;
		elseif ($op == "/")	$val = floor($a / $b);
		elseif ($op == "?") break;
		else break;

		printf("%d\n", $val);
	}

Measured memory_bytes: 6580
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int L = sc.nextInt();
			final int R = sc.nextInt();
			final int d = sc.nextInt();
			
			int answer = 0;
			for(int i = L; i <= R; i++) {
				if(i % d == 0) { answer++; }
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 32696
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n);
  vector<int> y(m);
  rep(i, n) cin >> x[i];
  rep(i, m) cin >> y[i];
  int ma = -100;
  int mi = 100;
  rep(i, n) ma = max(x[i], ma);
  rep(i, m) mi = min(y[i], mi);
  bool ans = false;
  for (int z = -100; z <= 100; z++) {
    if (X < z && z <= Y && ma < z && mi >= z) ans = true;
  }
  if (ans)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}


Measured memory_bytes: 256
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return 0
    return 1


sl = [0, 0]
for j in range(2, 10 ** 5 + 1):
    if j % 2 == 0:
        sl.append(sl[j - 1])
    elif is_prime(j) == 1 and is_prime((j + 1) // 2) == 1:
        sl.append(sl[j - 1] + 1)
    else:
        sl.append(sl[j - 1])

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(sl[r] - sl[l-1])


Measured memory_bytes: 9700
#include <map>
#include <set>
#include <list>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
int a[100005];
int main ( ) {
	int n,i;
	scanf("%d",&n);
	for (i=1;i<=n;i++) {
		int x;
		scanf("%d",&x);
		if (x>0) a[x-1]++;
		a[x]++;a[x+1]++;
	}
	int mymax=0;
	for (i=0;i<=100000;i++) {
		if (a[i]>mymax) mymax=a[i];
	}
	printf("%d\n",mymax);
	return 0;
}
/*
Sample Input 1
7
3 1 4 1 5 9 2
Sample Output 1
4
Sample Input 2
10
0 1 2 3 4 5 6 7 8 9
Sample Output 2
3
Sample Input 3
1
99999
Sample Output 3
1
*/

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(long long A, long long P){
	ll res = 0;
	res = A*3 + P;
	cout << res/2 << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long P;
    scanf("%lld",&P);
    solve(A, P);
    return 0;
}


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

int main()
{
	int n, i, a=0, b=0, c=0, d=0;
	cin >> n;
	string arr[n];
	
	for (i=0; i<n; i++)
		cin >> arr[i];
	
	for (i=0; i<n; i++)
	{
		if (arr[i] == "AC")
			a++;
		else if (arr[i]== "WA")
			b++;
		else if (arr[i]== "TLE")
			c++;
		else if (arr[i]== "RE")
			d++;
	}
		
	cout << "AC x " << a << "\n" << "WA x " << b << "\n" << "TLE x " << c << "\n"<< "RE x " << d << "\n"; 
}


Measured memory_bytes: 6740
#define _USE_MATH_DEFINES
#include<iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main()
{
	int A, B;

	cin >> A >> B;

	if (A + B < 10){
		cout << A + B;
	}
	else{
		cout << "error";
	}

	return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let _n = read::<usize>();
    let ax = read_vec::<usize>();

    let mut ax = ax.iter().enumerate().map(|(i, &a)| (a, i+1)).collect::<Vec<_>>();

    ax.sort();

    let ax = ax.iter().map(|&(_a, i)| i.to_string()).collect::<Vec<_>>();

 
    println!("{}", ax.join(" "));
}

Measured memory_bytes: 13052