akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll N,K;
  cin >> N >> K;
  N %= K;
  ll ans = N;
  while(N>0) {
    N -= K;
    chmin(ans,abs(N));
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	size_t c; cin >> c;
	deque<int> l(c);
	for (size_t i = 0; i < c; ++i)
		cin >> l.at(i);
	auto k = l;
	sort(k.begin(), k.end());
	int f = k.at(c - 1);
	int s = k.at(c - 2);
	for (int i = 0; i < c; ++i) {
		cout << ((l.at(i) == f) ? s : f) << endl;
	}
}

Measured memory_bytes: 3200
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 1e6+5;

int cnt[N], cnt2[N], sum[N];
vector<int> nums;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i=0,x;i<n;i++) {
		cin >> x;
		cnt[x]++;
	}
	for(int i=0;i<N;i++) if(cnt[i]) nums.push_back(cnt[i]);
	sort(nums.begin(), nums.end());
	for(auto x : nums) cnt2[x]++, sum[x]+=x;
	for(int i=N-2;i>=0;i--)cnt2[i]+=cnt2[i+1];
	for(int i=1;i<N;i++) sum[i]+=sum[i-1];
	vector<int> ans(n+1,0);
	for(int i=1;i<=n;i++) {
		int x = cnt2[i+1]+sum[i]/i;
		ans[x] = max(ans[x],i);
	}
	for(int i=n-1;i>=1;i--) ans[i]=max(ans[i], ans[i+1]);
	for(int i=1;i<=n;i++) cout << ans[i] << "\n";
	return 0;
}


Measured memory_bytes: 13424
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$K) = explode(" ",trim(fgets(STDIN)));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));
//function chmax(&$a,$b) {if ($a<$b){$a=$b;return true;}return false;}
//function chmix(&$a,$b) {if ($a>$b){$a=$b;return true;}return false;}


printf("%d\n",strlen(base_convert($N,10,$K)));


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define FPEN2 freopen("out.txt", "w", stdout);
#else
#define FPEN
#define FPEN2
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  void solve() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double pi = acos(-1);
    double del = 2 * pi / 12 * (h + m / 60.0) - 2 * pi / 60 * m;
    if (del < 0) del += 2 * pi;
    if (del > pi) del = 2 * pi - del;
    printf("%.10f\n", sqrt(a * a + b * b - 2 * a * b * cos(del)));
  }
} NSPACE;
int main() {
  FPEN;
  FPEN2;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}

Measured memory_bytes: 4276
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
S = input()

query = [input().split() for _ in range(Q)]
res = N

lt = -1
rt = N

while rt - lt > 1:
    mid = (rt + lt) // 2
    pos = mid
    for t, d in query:
        if S[pos] == t:
            if d == 'L':
                pos -= 1
            else:
                pos += 1
            if pos < 0:
                lt = mid
                break
            if pos >= N:
                rt = mid
                break
    else:
        rt = mid

res -= lt + 1

lt = -1
rt = N

while rt - lt > 1:
    mid = (rt + lt) // 2
    pos = mid
    for t, d in query:
        if S[pos] == t:
            if d == 'L':
                pos -= 1
            else:
                pos += 1
            if pos < 0:
                lt = mid
                break
            if pos >= N:
                rt = mid
                break
    else:
        lt = mid

res -= N - rt

print(res)

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

using namespace std;

#define Pas 3
#define Jui 2

int main(void){
	
	int pasta[Pas];
	int juice[Jui];
	
	int Min = 10000;
	
	for(int i = 0;i < Pas;i++){
		
		cin >> pasta[i];
		
	}
	
	for(int i = 0;i < Jui;i++){
		
		cin >> juice[i];
		
	}
	
	for(int i = 0;i < Pas;i++){
		
		for(int j = 0;j < Jui;j++)
		 
		 Min = min(Min,pasta[i] + juice[j]);
		 
	}
	
	cout << Min - 50 << endl;
	
	return 0;
	
}





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

int main(){
	int n,m;
	cin>>n>>m;
	int a[m+5],sum=0;
	for(int i=1;i<=m;i++){
		cin>>a[i];
		sum+=a[i];
	}
	
	if(sum<=n) cout<<n-sum;
	else cout<<-1;
	return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
double pi = acos(-1.0);
const double EPS=1e-9;
#define MOD ll(1e9L+7)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define t() ll tt;cin>>tt;while(tt--) 
#define t2() ll tt2; cin>>tt2; for(ll tti=1;tti<=tt2;tti++)
#define printcj "Case #"<<tti<<": "
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cout << #x << " = " << x << "   " << #y << " = " << y << "\n";

const ll sz=3001;
ll n,a[sz];
ll dp[sz][sz];

int main()
{
    fastio;
    ll i,j;
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];

    // dp[i][j] = optimal difference in [ a[i],a[i+1],........,a[j-1],a[j] ]
    for(i=n-1;i>=0;i--){
        dp[i][i] = (n%2!=0)? a[i] : -a[i]; 
        for(j=i+1;j<n;j++){
            // x turn
            if(n%2==(j-i+1)%2)
                dp[i][j] = max(dp[i+1][j]+a[i],dp[i][j-1]+a[j]);
            else
                dp[i][j] = min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
        }
    }
    cout<<dp[0][n-1];    
    
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n;
ll a[2002];
ll mem[2002][2];

ll dfs(ll i,ll t,ll x,ll y){
  if(mem[i][t]!=-1)return mem[i][t];
  ll res;
  if(t==0)res=abs(a[n-1]-y);
  else res=abs(a[n-1]-x);
  repl(j,i,n-1){
    ll tmp;
    if(t==0)tmp=dfs(j+1,1-t,a[j],y);
    else tmp=dfs(j+1,1-t,x,a[j]);
    if(t==0)maxch(res,tmp);
    else minch(res,tmp);
  }
  return mem[i][t]=res;
}

int main(){
  ll x,y;
	cin>>n>>x>>y;
  rep(i,n)cin>>a[i];
  memset(mem,-1,sizeof(mem));
  cout<<dfs(0,0,x,y)<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>

using namespace std;

void solve(int N) {
  if (N % 2 == 0) {
    printf("%d\n", N);
  } else {
    printf("%d\n", N * 2);
  }
}

int main() {
  int N;
  cin >> N;
  solve(N);
  return 0;
}

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

int main(int argc, char** argv)
{
  int N;

  std::cin >> N;

  int a[3];

  while (N --) {
    std::cin >> a[0] >> a[1] >> a[2];

    std::sort(a + 0, a + 3);

    if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) {
      std::cout << "YES" << std::endl;
    }
    else {
      std::cout << "NO" << std::endl;
    }
  }
}

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

const int maxn = 2005;

int n;

int c[maxn * 2], a[maxn * 2];
int pos[2][maxn];
long long dp[maxn][maxn];

int d[maxn * 2];

void add(int p, int val){
    for(int i = p;i < maxn * 2;i += i & -i){
        d[i] += val;
    }
}

int sum(int p){
    int ret = 0;
    for(int i = p;i > 0;i -= i & -i){
        ret += d[i];
    }
    return ret;
}

int main(){
    cin >> n;
    for(int i = 1;i <= 2 * n;i++){
        char s[5];
        scanf("%s%d", s, &a[i]);
        if(s[0] == 'W'){
            c[i] = 0;
        }else{
            c[i] = 1;
        }
        pos[c[i]][a[i]] = i;
    }
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= n;j++){
            dp[i][j] = 1e18;
        }
    }
    dp[0][0] = 0;
    for(int len = 0;len < 2 * n;len++){
        memset(d, 0, sizeof(d));
        for(int i = 1;i <= max(0, len - n);i++){
            add(pos[0][i], 1);
        }
        for(int i = 1;i <= min(n, len);i++){
            add(pos[1][i], 1);
        }
        for(int i = max(len - n, 0);i <= min(n, len);i++){
            int j = len - i;
            if(i < n){
                int p = pos[0][i + 1];
                int s = sum(p);
                int pp = p + len - s; 
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + pp - (len + 1));
            }
            if(j < n){
                int p = pos[1][j + 1];
                int s = sum(p);
                int pp = p + len - s; 
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + pp - (len + 1));
            }
            if(i + 1 >= 1 and i + 1 <= n){
                add(pos[0][i + 1], 1);
            }
            if(j >= 1 and j <= n){
                add(pos[1][j], -1);    
            }
        }
    }
    cout << dp[n][n] << endl;
    return 0;
}


Measured memory_bytes: 31616
n = int(input())
alist = list(map(int, input().split()))

print(" ".join([str(i) for i in alist]))

def insertion_sort(alist, n):
    for i in range(1, n):
        current = alist[i]
        j = i - 1
        while j >= 0 and alist[j] > current:
            alist[j], alist[j+1] = alist[j+1], alist[j]
            j -= 1
        print(" ".join([str(i) for i in alist]))

insertion_sort(alist, n)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    char c;
    cin>>c;
    if(c>='A' && c<='Z')
        cout<<"A\n";
    else
        cout<<"a\n";
    return 0;
}


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

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

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int n,k; cin >> n >> k;
  vector<int> p(n); REP(i,n) cin >> p[i];

  sort(ALL(p));
  int ans = 0;
  REP(i,k) ans += p[i];

  cout << ans << endl;

  return 0;
}

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

length = len(A)
find_next = 1

for i in range(N):
    if A[i] == find_next:
        find_next += 1

if find_next == 1:
    print(-1)
else:
    print(length - find_next + 1)


Measured memory_bytes: 100760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
    if(a*c<=b) cout<<c<<endl;
    else{
      cout<<b/a<<endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int alice = 0;
  int bob = 0;
  for(int i = 0; i < n; i++) {
    if (i%2 == 0) alice += a.at(i);
    else bob += a.at(i);
  }
  
  cout << alice - bob << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
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; }

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

  ll l, r;
  cin >> l >> r;

  if(r - l >= 2019) cout << 0 << endl;
  else{
    ll ans = INF;
    rep(i, l, r+1){
      rep(j, l, r+1){
        if(i == j) continue;
        //cout << i << ' ' << j << ' ' << i*j % 2019 << endl;
        chmin(ans, (i*j) % 2019);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
 //Now sorting a vector looks like sort(all(vec)) 
//instead of sort(vec.begin(), vec.end()).

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

#define ios                         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fori(n) for(int i=0; i<int(n); i++)
#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }
#define watch(x) cout << (#x) << " is " << (x) << endl
#define see(x) cout << (x) << " ";
#define hh cout << "\n";
typedef long long int ll;
#define vll vector < ll > 
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
int32_t main(){
    ios
    string a,b; cin>>a>>b;
    int n=b.length();
    if(a==b.substr(0,n-1))
    cout<<"Yes\n";
    else
    cout<<"No\n";
} 	

Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 1e5;

int n;
int main() 
{
	while(scanf("%d", &n) != EOF)
	{
		if(n % 10 == 9 || n / 10 == 9) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int, int> P;
typedef long long ll;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> to(n);
	rep(i, n) {
		cin >> to[i];
		to[i]--;
	}
	vector<bool> been(n, false);// n番目の街に行ったことがあるか
	been[0] = true;
	ll now = 0, step = 0;
	vector<ll> ever;
	ever.push_back(0);
	ll re = 0;
	while (true) {
		step++;
		now = to[now];
		if (!been[now]) {//atteru
			been[now] = true;
			ever.push_back(now);
		}
		else {//tabunkoko
			rep(i, ever.size()) {
				if (ever[i] == now) {
					re = i;
					break;
				}
			}
			break;
		}
	}
	if (k < re) {
		cout << ever[k] + 1 << endl;
		return 0;
	}

	ll a = (k - re) % (step - re) + re;
	dunk(ever[a] + 1);
	return 0;
}


Measured memory_bytes: 6896
#include <bits/stdc++.h>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>
#define vi vector<int>
#define vl vector<long long>
#define vpi vector<pair<int,int> >
#define ll long long 
#define vpl vector<pair><long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define un unsigned
# define M_PI           3.14159265358979323846  /* pi */
// #define mod 998244353
#define mod 1000000007
#define MAXN  1000001
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


/*
//------------------------------------------DSU--------------------------------------------------------//
int parent[1000001];
int ssize[1000001];


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

void make_set(int v) {
    parent[v] = v;
    ssize[v] = 1;
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (ssize[a] < ssize[b])
            swap(a, b);
        parent[b] = a;
        ssize[a] += ssize[b];
    }
}
*/

//-----------------------------Sieve Of Eratosthenes--------------------------------------//

/*
v<int> primes;
void SieveOfEratosthenes(int n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.pb(p); 
}

*/




void solve()
{
    ll n;
    cin>>n;
    ll a = n/3;
    ll b = n/5;
    ll c = n/15;
    ll sum = (n*(n+1))/2;
    double a1 = a/2.0;
    double a2 = b/2.0;
    double a3 = c/2.0;
    sum -= (a1)*(2*3 + (a-1)*3);
    sum -= (a2)*(2*5 + (b-1)*5);
    sum += (a3)*(2*15 + (c-1)*15);
    cout<<sum<<endl;
}



int main()
{
    fast;
    int t;
    // cin>>t;
    t = 1;
    solve();
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int a,d,n;
	static boolean read(){
		a = sc.nextInt();
		d = sc.nextInt();
		n = sc.nextInt();
		if(a == 0 && d == 0 && n == 0 ){
			return false;
		}
		return true;
	}
	static boolean isPrime(int n){
		if(n == 1){
			return false;
		}
		boolean ret = true;
		for(int i = 2; i*i <= n; i++){
			if(n % i == 0){
				ret = false;
				break;
			}
		}
		return ret;
	}		
	static int slove(){
		int ret = 0, count = 0;
		for(int i = 0;; i++){
			ret = a+d * i;
			if(isPrime(ret))
				count++;
			if(count == n)
				return ret;
		}
	}
	public static void main(String[] args){
		while(read()){
			System.out.println(slove());
		}
	}
}

Measured memory_bytes: 12000
import java.io.*;
import java.util.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int n, m, k;
	static long mod = 998244353;
	static Boolean[][][] memo;
	static String s;
	static HashMap<Integer, Integer> nums;
	static ArrayList<Integer>[] ad;
	static int inf = 1000000;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n=sc.nextInt();
		HashMap<Integer, Integer> h=new HashMap<>();
		long ans=0;
		for(int i=1;i<=n;i++) {
			int x=sc.nextInt();
			ans+=h.getOrDefault(i-x, 0);
			h.put(x+i, h.getOrDefault(x+i, 0)+1);
		}
		System.out.println(ans);
		out.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 65872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N;
ll P[105000];
ll inv[105000];

int main() {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> P[i];
        inv[P[i]] = i;
    }
    multiset<ll> st;
    st.insert(0);
    st.insert(N+1);
    st.insert(0);
    st.insert(N+1);
    ll ans = 0;
    for(int val = N; val >= 1; val--) {
        int index = inv[val];
        auto itr1 = st.lower_bound(index);
        auto itr2 = itr1;
        itr2++;
        auto itr3 = itr1;
        itr3--;
        auto itr4 = itr3;
        itr4--;
        ans += (*itr2 - *itr1) * (index - *itr3) * val;
        ans += (*itr3 - *itr4) * (*itr1 - index) * val;
        st.insert(index);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6528
#include<cstdio>
#define MAXN 200005
#define LL long long
int n,a[MAXN],pos[MAXN],pr[MAXN],ne[MAXN];
LL ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		pos[a[i]]=i;
	}
	for(int i=0;i<=n+1;i++)
		pr[i]=i-1,ne[i]=i+1;//pr是i的影响区间的左端点(不含) ne是右端点(不含) 注意是不含！！！
	for(int i=n;i>=1;i--)//n的排列 倒着来
	{
		int j=pos[i];
		ans+=1LL*i*(j-pr[j])*(ne[j]-j);//统计区间个数时要注意端点时不含的
		pr[ne[j]]=pr[j];
		ne[pr[j]]=ne[j];
		//核心 用当前这个值依次更新其它数的影响区间 很巧妙
		//由于是倒着来的，那么如果被更新的值要大于当前数，则没有影响，因为被更新的贡献已经算完了
		//所以就假设这些数都小于当前数 而当前数的影响区间内的所有数都要大于它自己，也大于被更新数，所以可以更新区间
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int a,b;
  char op;
int main(){

cin>>a>>op>>b;
while(op!='?'){
switch(op){
case '+':
cout<<a+b<<endl;
break;
case '-':
cout<<a-b<<endl;
break;
case '*':
cout<<a*b<<endl;
break;
case '/':
cout<<a/b<<endl;
break;
}
cin>>a>>op>>b;
}}




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

int main()
{
  string a;
  cin>>a;
  int len=a.size();
  bool f=0;
  for(register int i=0;i<len;i++)
  {
  	if(a[i]=='h'&&a[i+1]=='i')
	  f=1,i++;
  	else
    {
      f=0;
      break;
    }
  }
  if(f)
  	cout<<"Yes\n";
  else
  	cout<<"No\n";
  return 0;
}



Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n,a[4][N];
int p[N],f[N],cnt[2];

int c[N];
void add(int x,int y) { for (;x<=n;x+=x&-x) c[x]+=y; }
int sum(int x) { int s=0; for (;x;x-=x&-x) s+=c[x]; return s; }

int main() {
	n=read();
	for (int i=1;i<=3;++i)
		for (int j=1;j<=n;++j) a[i][j]=read();
	for (int i=1;i<=n;++i) {
		if ((a[1][i]%3!=1&&a[1][i]+1!=a[2][i]||a[2][i]+1!=a[3][i])&&
			(a[1][i]%3!=0&&a[3][i]+1!=a[2][i]||a[2][i]+1!=a[1][i])) {
				puts("No"); return 0;
			}
		p[i]=(a[1][i]-1)/3+1;
		cnt[i&1]^=(a[1][i]>a[3][i]);
	}
	for (int i=1;i<=n;++i)
		if ((i&1)!=(p[i]&1)) { puts("No"); return 0; }
	for (int i=1;i<=n;i+=2) {
		int x=sum(n)-sum(p[i]);
		cnt[0]^=(x&1),add(p[i],1);
	}
	memset(c,0,sizeof(c));
	for (int i=2;i<=n;i+=2) {
		int x=sum(n)-sum(p[i]);
		cnt[1]^=(x&1),add(p[i],1);
	}
	if (cnt[0]||cnt[1]) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 5560
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int solve(int n)
{
    int ans = 0;
    for(int i=1; i<=n; ++i){
        if(n % i == 0)
            ++ ans;
    }
    return ans;
}

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

    int ans = 0;
    for(int i=1; i<=n; i+=2){
        if(solve(i) == 8)
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for(int i = 0; i < n; i++)
#define DUMP(range) do{for(auto& x:range){cout<<x<<' ';}cout<<endl;}while(0)
int main()
{
    int N; cin >> N;
    int primes[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,
                    67, 71, 73, 79, 83, 89, 97 };
    int cnt[100] = {};
    for (int i = 1; i <= N; i++) {
        int x = i;
        for (int p : primes) {
            while (x % p == 0) cnt[p]++, x/=p;
        }
    }
    int ans = 0;
    REP(i, 100) if(cnt[i]>=74) ans++;
    REP(i, 100) if(cnt[i]>=24) REP(j, 100) if(i!=j&&cnt[j]>=2) ans++;
    REP(i, 100) if(cnt[i]>=14) REP(j, 100) if(i!=j&&cnt[j]>=4) ans++;
    for (int i = 0; i < 100; i++) if (cnt[i]>=4)
    for (int j = i+1; j<100; j++) if (cnt[j]>=4)
    for (int k = 0; k < 100; k++) if (i != k && j != k && cnt[k]>=2) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, H, maxH = -1;
  int ans = 0;

  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> H;
    ans += H >= maxH;
    maxH = max(maxH, H);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
using ll=long long;
int main()
{
   ll n,m,i,x;
   ll c=0;
   cin>>n>>m>>x;
   c=m/x-n/x;
     if(n%x==0)
        c++;

 cout<<c<<endl;
    return 0;
}



Measured memory_bytes: 256
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <numeric>
#include <utility>
#include <queue>
#include <memory>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <iterator>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/
// #define ONLINE_JUDGE
#define maxn 1010
#define maxm 40010
#define inf 0x3f3f3f3f3f3f3f3f
struct Edge {
	int u, v;
	ll cost;
	Edge(int u = 0, int v = 0, ll c = 0) : u(u), v(v), cost(c) {}
};
vector<Edge> e;
ll d[maxn];
int n;
bool bellman(int s) {
	memset(d, 0x3f, sizeof d);
	d[s] = 0;
	for (int i = 1; i < n; i++) {
		bool fg = false;
		for (int j = 0; j < e.size(); j++) {
			int u = e[j].u;
			int v = e[j].v;
			ll cost = e[j].cost;
			if (d[v] > d[u] + cost) {
				d[v] = d[u] + cost;
				fg = true;
			}
		}
		if (!fg) {		// 无法再更新 
			return true;
		}
	}
	ll tmp = d[n];
	for (int j = 0; j < e.size(); j++) {
		int u = e[j].u;
		int v = e[j].v;
		ll cost = e[j].cost;
		if (d[v] > d[u] + cost) {
			d[v] = d[u] + cost;
		}
	}
	return d[n] == tmp;
}
int main()
{/*
	#ifdef ONLINE_JUDGE
    	freopen("aplusb.in", "r", stdin);
    	freopen("aplusb.out", "w", stdout);
	#endif*/
	int m, x, y;
	ll z;
	
	scanf("%d%d", &n, &m);
	while (m--) {
		scanf("%d%d%lld", &x, &y, &z);
		e.push_back(Edge(x, y, -z));
	}
	int ans = bellman(1);
	if (ans == 0) {
		puts("inf");
	} else {
		cout << -d[n] << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int f(int n)
{
  int re;
  if((n%2) == 0)
    re = n/2;
  else
    re = 3*n+1;
  return re;
}
 
int main(void)
{
  int error;
  int s,i=0,j,m=0;
  int a[1000];
  error = scanf("%d",&s);
  a[i] = s;i++;
  while(m == 0){
    a[i] = f(a[i-1]);
    for(j=0;j<i;j++){
      if(a[j] == a[i])
        m = i+1;
    }
    i++;
  }
  error = printf("%d",m);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (a > 0 && c > 0) {
		c -= b;
		a -= d;
	}
	if (c <= 0) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
int W,H,x,y,r;
cin>>W>>H>>x>>y>>r;
if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H)
  {
  cout<<"Yes"<<endl;
  }else{
  cout<<"No"<<endl;
  }
return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int gcd(int x, int y){int r;while((r=x%y)!=0)x=y,y=r;return y;}

int main(void){

    int n;
    scanf("%d",&n);
    int t[100000];
    int max=0;
    int scn=0;
    for(int i=0;i<n;i++){
        scanf("%d",&t[i]);
        if(t[i]>max)max=t[i];
    }
    for(int i=0;i<n;i++){
        if(abs(t[i]-max/2)<abs(scn-max/2))scn=t[i];
    }
    printf("%d %d\n",max,scn);
}

Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,q;
    cin>>n>>m>>q;
    int a[q],b[q],c[q],d[q];
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    vector<int>x(1);
    queue<vector<int>>qu;
    for(int i=1;i<=m;i++){
        x[0]=i;
        qu.push(x);
    }
    int M=0;
    while(qu.size()){
        vector<int>f=qu.front();
        qu.pop();
        if(f.size()<n){
            f.resize(f.size()+1);
            for(int i=f[f.size()-2];i<=m;i++){
                f[f.size()-1]=i;
                qu.push(f);
            }
        }
        if(f.size()==n){
            int sc=0;
            for(int i=0;i<q;i++)if(f[b[i]-1]-f[a[i]-1]==c[i])sc+=d[i];
            M=max(M,sc);
        }
    }
    cout<<M<<endl;
    return 0;
}

Measured memory_bytes: 9756
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
#define INF 1e9
using ll = int64_t;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define waru 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

#define MAX_NUM 100
int n;
int a[MAX_NUM];
int b[MAX_NUM];
int c[MAX_NUM];

void Main() {
  //自動整形防止用コメント
  cin >> n;
  rep(i, n){
    cin >> a[i];
  }
  rep(i, n){
    cin >> b[i];
  }
  rep(i, n-1){
    cin >> c[i];
  }

  int sum = 0;
  rep(i, n){
    sum += b[i];
  }

  rep(i, n - 1){
    if (a[i] + 1 == a[i + 1])
    {
      sum += c[a[i] - 1];
    }
  }

  std::cout << sum << std::endl;

  return;
}

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


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

typedef long long llt;

const int MAXN = 5000;
const llt Mod = 1000000007;

int N, len;
char str[MAXN+1];
llt dp[MAXN+1][MAXN+1];

void init()
{
    memset( dp, 0, sizeof dp );
    scanf( "%d\n", &N );
    scanf( "%s", str );
    len = strlen( str );
}

llt fast_pow( llt low, int high )
{
    llt ans = 1;
    while ( high )
    {
        if ( high & 1 ) ans = ans * low % Mod;
        high >>= 1;
        low = low * low % Mod;
    }
    return ans;
}

llt Mod_inverse( llt x ) { return fast_pow( x, Mod - 2 ); }

void solve()
{
    dp[0][0] = 1;
    for ( int i = 1; i <= N; ++i )
    {
        dp[i][0] = ( dp[i - 1][1] + dp[i - 1][0] ) % Mod;
        dp[i][i] = dp[i - 1][i - 1] * 2 % Mod;
        for ( int j = 1; j < i; ++j )
            dp[i][j] = ( dp[i - 1][j - 1] * 2 + dp[i - 1][j + 1] ) % Mod;
    }
    llt ans = dp[N][len] * Mod_inverse( fast_pow( 2, len ) ) % Mod;
    printf( "%lld\n", ans );
}

int main()
{
    init();
    solve();
    return 0;
}

Measured memory_bytes: 195712
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;

//main
int main(){
    int M,D; cin >> M >> D;
    int count = 0;
    rep(i,M){
        rep(j,D){
            if((j+1)/10>=2 && (j+1)%10>=2){
                if(((j+1)/10)*((j+1)%10) == i+1) count += 1;
            }
        }
    }
    cout << count << endl;
}



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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  while (m--) {
    int ai, bi;
    cin >> ai >> bi;
    ai--;
    bi--;
    g[ai].emplace_back(bi);
    g[bi].emplace_back(ai);
  }
  vector<bool> vi(n);
  int mx = 1;
  for (int i = 0; i < n; i++) {
    if (!vi[i]) {
      int c = 1;
      queue<int> qu;
      qu.emplace(i);
      vi[i] = true;
      while (!qu.empty()) {
        int u = qu.front();
        qu.pop();
        for (auto v : g[u]) {
          if (!vi[v]) {
            qu.emplace(v);
            vi[v] = true;
            c++;
          }
        }
      }
      mx = max(mx, c);
    }
  }
  cout << mx << '\n';
  return 0;
}

Measured memory_bytes: 14844
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n,c[21],v[21];
	int total=0;

	cin>>n;
	rep(i,n){
		cin>>v[i];
	}
	rep(i,n){
		cin>>c[i];
		if(v[i]-c[i]>0)total+=v[i]-c[i];
	}
	cout<<total<<endl;
	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}


 

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

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

int n, a, b;

const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int pow_mod(int n, int a)
{
	if (a == 0) return 1;

	int res = pow_mod(n, a/2);
	res *= res;
	res %= MOD;

	if (a & 1) {
		res *= n;
		res %= MOD;
	}

	return res;
}

// O(k)
int C(int n, int k)
{
	int res = 1;

	for (int i = 0; i < k; ++i) {
		res *= (n-i);
		res %= MOD;
		res *= inv[i+1];
		res %= MOD;
	}

	return res;
}

signed main()
{
	int n, a, b; cin >> n >> a >> b;
	int ans = 0;
	ans += pow_mod(2, n) - 1 + MOD;
	ans %= MOD;

	COMinit();
	ans -= C(n, a);
	ans -= C(n, b);

	ans += MOD * 100;
	ans %= MOD;

	cout << ans << endl;
}


Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, l[210];

    cin >> n;
    REP(i, n * 2)
    cin >> l[i];

    sort(l, l + n * 2);

    int res = 0;

    for (int i = 0; i + 1 < n * 2; i += 2)
    {
        res += min(l[i], l[i + 1]);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+1;

vector<int> h;



int main()
{
    int n,m;
    cin>>n>>m;
    h=vector<int>(n);
    rep(i,n)cin>>h[i];
    vector< vector<int> > ab(n);
    vector<int> mv(n,0);
    
    rep(i,m)
    {
        int at,bt;
        cin>>at>>bt;
        at--,bt--;
        mv[at]=max(mv[at],h[bt]);
        mv[bt]=max(mv[bt],h[at]);

        
        
    }
    int ans=0;
    rep(i,n)
    {
        if(h[i]>mv[i])ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 6368
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int cmp(const void *a, const void *b) {
  return *(short*)a > *(short*)b ? 1 : (*(short*)a == *(short*)b ? 0 : -1);
}

int main (void) {
  short h[10];
  char buf[10];
  int i;
  for (i=0; i<10; i++) {
    fgets(buf, 10, stdin);
    buf[strlen(buf)-1] = '\0';
    h[i] = atoi(buf);
  }
  qsort(h, 10, sizeof(short), cmp);
  for (i=9; i>=7; i--) {
    printf ("%d\n", h[i]);
  }
  return 0;
}

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

int n;

void dfs(string str, char mx){
    if(str.size() == n){
        cout << str << "\n";
        return;
    }
    for(char ch = 'a'; ch <= mx; ch++){
        dfs(str + ch, mx);
    }
    dfs(str + (char)(mx + 1), mx+1);
    return;
}

int main(){
    cin >> n;
    dfs("", 'a'-1);
    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t K, A, B;
	if (scanf("%" SCNu64 "%" SCNu64 "%" SCNu64, &K, &A, &B) != 3) return 1;
	if (A + 2 < B && 1 + K >= A) {
		uint64_t cost = A - 1;
		uint64_t yoryoku = K - cost;
		uint64_t kaisu = yoryoku / 2;
		uint64_t tataku = K - kaisu * 2;
		printf("%" PRIu64 "\n", 1 + tataku + (B - A) * kaisu);
	} else {
		printf("%" PRIu64 "\n", 1 + K);
	}
	return 0;
}


Measured memory_bytes: 1732
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


# エントリーポイント
def main():
    N = input(int)
    print(ceil(N / 2))


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3316
n,*a=map(int,open(0).read().split())
l=[a[0]]*n
for i in range(1,n):
  l[i]=l[i-1]+a[i]
r=[l[-1]]*n
for i in range(1,n):
  r[i]=r[i-1]-a[i-1]
ans=10**20
for i in range(n-1):
  ans=min(abs(l[i]-r[i+1]),ans)
print(ans)

Measured memory_bytes: 28324
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
System.out.println(N/3);


	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 21076