akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

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

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int N,M;
int ans;
int sum[10000000];
int main()
{
  vector<int> D;
  while(cin>>N>>M,N||M){
    for(int i = 0;i < N;i++){
      cin >>ans;
      D.push_back(ans);
    }
    D.push_back(0);
    int size = 0;
    for(int i = 0;i <= N;i++){
      for(int j = 0;j <=N;j++){
	sum[size++] =D[i]+D[j];
      }
    }
    sort(sum,sum+size);
    for(int i = 0;i <size;i++){
      int rem =M -sum[i];
      if(rem <0)continue;
      int left = 0;
      int right = size;
      while(left <right){
	int center =(left+right)/2;
	if(rem >sum[center]){
	  left =center +1;
	}else if(rem <sum[center]){
	  right = center;
	}
	else{
	  break;
	}
      }
      D.clear();
      ans = max(ans,sum[i]+sum[right-1]);
  }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 5316
// Aizu Vol-3 0329: Bilateral Trade
// 2017.8.26 bal4u@uu

#include <stdio.h>

#define MAX 200000

#define HASHSIZ 370003LL
#define BASE 200000000000001LL        // -200,000 x 10^9
typedef struct { int i; long long s; } HASH;
HASH hash[HASHSIZ + 5], *hashend = hash + HASHSIZ;

int insert(int i, long long s)
{
    HASH *p;
    s += BASE;
    p = hash + s % HASHSIZ;
    while (p->s) {
        if (p->s == s) return p->i;
        if (++p == hashend) p = hash;
    }
    p->s = s, p->i = i;
    return -1;
}

int main()
{
    int N, d;
    int i, k, max;
    long long s0, s;

    // memset(hash, 0, sizeof(hash));
    scanf("%d", &N);
    insert(0, 0);
    for (max = s0 = 0, i = 1; i <= N; i++, s0 = s) {
        scanf("%d", &d), s = s0 + d;
        if ((k = insert(i, s)) >= 0) {
            if (i - k > max) max = i - k;
        }
    }
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 6380
#include<iostream>
#include<string>
using namespace std;
int main(){
	int h=0;
	int w=0;
	string ma;
	string mb;
	int i=0;
	int j=0;
	int a=0;
	int s[10000];
	
	cin>>h;
	cin>>w;
	mb="c.";
	for(i=0;i<h;i++){
		cin>>ma;
		for(j=0;j<w;j++){
			if(ma[j]==mb[0]){
				s[i*100+j]=0;
				a=1;
			}
			if(ma[j]==mb[1]){
				if(a==0){
					s[i*100+j]=-1;
				}else{
					s[i*100+j]=a;
					a++;
				}
			}
		}
		a=0;
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){	
			cout<<s[100*i+j];
			if(j!=w-1)cout<<" ";
			else cout<<endl;
		}
	}
}

Measured memory_bytes: 3168
import itertools
import numpy as np

n, m ,x = map(int,input().split())
a = []
c = []
for i in range(n):
    temp = list(map(int,input().split()))
    c.append(temp.pop(0))
    a.append(temp)


result = -1
anp = np.array(a)
sum = sum(c)


    
for i in itertools.product([0,1],repeat=n):
    each_cost =0
    ans =anp.T*i
#    print(ans)
#    print(ans.sum(axis=1))
    if min(ans.sum(axis=1))>=x:
        sum = min(np.dot(c,i),sum)
        result = 0

#print(result)
#print(sum)
if result ==0:
    print(sum)
else:
    print(-1)

Measured memory_bytes: 27084
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
typedef pair<int, int> P;
int V, E, r;
int d[100000];
vector<P> edges[100000];
priority_queue<P, vector<P>, greater<P> > q;

void solve(){
	P start = P(0, r);
	d[r] = 0;
	q.push(start);

	while(!q.empty()){
		P p = q.top(); q.pop();
		if(d[p.second] < p.first) continue;

		for(int i = 0; i < edges[p.second].size(); i++){
			P edge = edges[p.second][i];
			P next = P(p.first + edge.second, edge.first);
			if(d[next.second] < next.first) continue;

			d[next.second] = next.first;
			q.push(next);
		}
	}

	return;
}

int main(){
	fill_n(d, 100000, inf);
	cin >> V >> E >> r;
	for(int i = 0; i < E; i++){
		int A, B, cost;
		cin >> A >> B >> cost;
		edges[A].push_back(P(B, cost));
	}

	solve();
	for(int i = 0; i < V; i++){
		if(d[i] == inf){
			cout << "INF" << endl;
		}else{
			cout << d[i] << endl;
		}
	}
}

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

int main() {
  
  int n, m;
  cin >> n >> m;
  
  vector<int> vec(m);
  int total = 0;
  
  for(int i = 0; i < m; i++){
    int x;
    cin >> x;
    vec.at(i) = x;
    total += x;
  }
  
  if(total > n){
    cout << -1 << endl;
  }
  else if(total <= n){
    cout << n - total << endl;
  }
  
  
 
 
}



Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n, m, R;
    cin >> n >> m >> R;
    vector<int> r(R);
    for(int i = 0; i < R; i++){
        cin >> r[i];
    }
    sort(r.begin(), r.end());
    int field[210][210];
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            field[i][j] = INF;
        }
    }
    for(int i = 1; i <= n; i++){
        field[i][i] = 0;
    }
    for(int i = 1; i <= m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        field[a][b] = min(field[a][b], c);
        field[b][a] = field[a][b];
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                field[j][k] = min(field[j][k], field[j][i] + field[i][k]);
            }
        }
    }
    int ans = INF;
    do{
        int cost = 0;
        for(int i = 0; i < R - 1; i++){
            cost += field[r[i]][r[i + 1]];
        }
        ans = min(ans, cost);
    } while(next_permutation(r.begin(), r.end()));
    cout << ans << endl;
    return 0;
}

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

using ll = long long;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x;
  if (n < b) {
    x = n;
  } else {
    x = ((n + 1) / b) * b - 1;
  }
  cout << (a * x / b - a * (x / b)) << endl;
}


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

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

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

const int W = 0, B = 1;

vi g[100005];
ll dp[100005][2];

const int mod = 1000000007;

void dfs(int n, int p) {
	for (int h : g[n]) if (h != p) dfs(h, n);
	
	dp[n][W] = dp[n][B] = 1;
	
	if (g[n].size() - (p != -1) == 0) {
		dp[n][W] = dp[n][B] = 1;
	} else {
		// this B, child W
		for (int h : g[n]) if (h != p) (dp[n][B] *= dp[h][W]) %= mod;
		// this W, child W or B
		for (int h : g[n]) if (h != p) (dp[n][W] *= (dp[h][B] + dp[h][W])) %= mod;
	}

	//printf("%d, W:%d, B:%d\n", n, dp[n][W], dp[n][B]);
}

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

	int n; read(n);
	rep(i, 0, n - 1) {
		int a, b; read(a, b);
		g[a].push_back(b); g[b].push_back(a);
	}

	dfs(1, -1);
	write((dp[1][W] + dp[1][B]) % mod);
}


Measured memory_bytes: 14208
#include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
using namespace std;

int main(){
	int n,m;
	while(1){
		cin>>n>>m;
		if(!(n&&m))break;
		bool num[n+1];
		rep(i,n+1)num[i]=true;
		num[0]=false;
		int now=0,cnt=0,ans;
		while(1){
			now++;
			if(now>n)now-=n;
			if(!num[now])continue;
			else cnt++;
			if(cnt==m){
				num[now]=false;
				cnt=0;
			}
			int check=0;
			loop(i,1,n+1)if(num[i])check++;
			if(check==1)break;
		}
		loop(i,1,n+1)if(num[i]){ans=i;break;}
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;*/
    
    int n,m;cin>>n>>m;
    vector<pair<long long,long long>> v(n);
    for(int i=0;i<n;i++){
        long long a,b;cin>>a>>b;
        v[i]={a,b};
    }
    sort(v.begin(),v.end());
    long long ans=0;
    int p=0;
    while(true){
        if(v[p].second>=m){
            ans+=m*v[p].first;
            break;
        }
        ans+=v[p].first*v[p].second;
        m-=v[p].second;
        p++;
    }
    cout<<ans;

    /*#ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
int MOD=1000000007;
void calc(vector<int>& a,int i,int n){
    rep(j,n){
        if(j==i)a[i]+=n;
        else a[j]-=1;
    }
}
signed main(){
    int k;cin>>k;
    int n=50;
    vector<int> a(n,n-1);
    int buf=k/n;
    rep(i,n){
        a[i]+=buf;
    }
    k%=n;
    rep(i,k){
        calc(a,i,n);
    }
    cout<<n<<endl;
    rep(i,n){
        cout<<a[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;

int main() {
	int N, X;
	cin >> N >> X;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec[i];
	}
	int sum = 0;
	int cnt = 1;
	for (int i = 0; i < N; i++) {
		sum += vec[i];
			if (sum <= X) {
				cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
signed main(){
  int N,M; cin>>N>>M;
  vector<pii> A(M);
  rep(i,0,M) cin>>A[i].second>>A[i].first;
  sort(ALL(A));
  int ans=0,memo=-1;
  rep(i,0,M){
    if(memo<A[i].second){
      ans++;
      memo=A[i].first-1;
    }
  }
  cout<<ans<<endl;
  }




Measured memory_bytes: 1792
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int D = sc.nextInt();
	        int N = sc.nextInt();	
	        long[] a = new long[N];
	        long sum =0;
	        for (int i=0 ; i<N; i++) {
	            a[i] = Long.parseLong(sc.next());
	            sum=sum+a[i];
	        }
	        long ans=D-sum;
	        if(ans<0)ans=-1;
	        System.out.println(ans);
	 }

}

Measured memory_bytes: 42036
/**
 *      purpose : ABC 133 D
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n; cin >> n;
  
  vector<int64_t> a(n);
  rep(i, n) cin >> a[i];

  int64 ans[101010] = {};

  int64 x = 0;
  rep(i, n) {
    if (i & 1) {
      x -= 2 * a[i];
    } else {
      x += 2 * a[i];
    }
  }

  // x = 2 * ans[1]
  // ans[1] + ans[2] = 2 * a[0]
  // ans[n] + ans[1] = 2 * a[n - 1]

  x >>= 1;
  ans[1] = x;

  for (int i = 2; i <= n; ++i) {
    if (i == n) {
      ans[i] = 2 * a[n - 1] - ans[1];
    } else {
      ans[i] = 2 * a[i - 2] - ans[i - 1];
    }
  }

  rep(i, n) {
    cout << ans[i + 1] << " ";
  }

  cout << '\n';

  return 0;
}

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

int main(){
	vector<long> x(5);
	int res = 10;
	for(int i = 0; i < 5; i++) {
		cin >> x[i];
      	if(x[i] % 10 != 0 && x[i] % 10 < res) {
          	if(res < 10) //res更新で1桁目消していたのを繰り上がりに変更
              	x[0] += 10;
        	res = x[i] % 10;
			x[i] -= res;
        } else if(x[i] % 10 != 0) { // 繰り上がり処理
         	x[i] += (10 - x[i] % 10);
        }
	}
  if (res == 10) res = 0;
  for(int i = 0; i < 5; i++)
      	res += x[i];
	cout << res << endl;
	
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

int x, y;

bool check(vector<int>& dir, int goal, int start) {
  set<int> last;

  last.insert(start);

  for (auto& e : dir) {
    set<int> cur;

    for (auto& d : last) {
      cur.insert(d + e);
      cur.insert(d - e);
    }

    last = cur;
  }

  // printf("----------------\n");
  // for (auto &e: dir) {
  //   printf("%d ", e);
  // }
  // printf("\n");

  // printf("start: %d, goal: %d\n", start, goal);
  // printf("----------------\n");

  return last.find(goal) != last.end();
}

int main(void) {
  // Here your code !
  cin >> s;

  if (s.back() == 'F') s.push_back('T');

  scanf("%d %d", &x, &y);

  vector<int> dir_x;
  vector<int> dir_y;

  int parity = 0;
  int cur = 0;

  for (auto& e : s) {
    if (e == 'T') {
      if (parity % 2 == 0) {  // direction: x
        dir_x.push_back(cur);
      } else {  // direction: y
        dir_y.push_back(cur);
      }
      cur = 0;
      parity += 1;
    } else {
      cur += 1;
    }
  }

  int beg_x = 0;
  int beg_y = 0;

  if (s[0] == 'F') {
    beg_x += dir_x[0];
    dir_x.erase(dir_x.begin());
  }

  if (check(dir_x, x, beg_x) && check(dir_y, y, beg_y)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  // for (auto &e: dir_x) {
  //   printf("%d ", e);
  // }
  // printf("\n");

  // for (auto &e: dir_y) {
  //   printf("%d ", e);
  // }
  // printf("\n");

  return 0;
}


Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	s := make([]bool, n)
	for i := 0; i < k; i++ {
		var d int
		fmt.Scan(&d)
		for j := 0; j < d; j++ {
			var a int
			fmt.Scan(&a)
			a--
			s[a] = true
		}
	}

	var ans int
	for i := 0; i < n; i++ {
		if !s[i] {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 2468
#include <iostream>
#include <vector>
using namespace std;
#define MAXQ 100000

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

  vector<bool> prime(MAXQ, true);
  for (int i = 2; i < MAXQ; i++) {
    if (prime[i]) for (int j = i*2; j < MAXQ; j += i) {
      prime[j] = false;
    }
  }

  vector<int> cs(MAXQ+1);
  for (int n = 3; n < MAXQ; n += 2) {
    cs[n] = cs[n-1];
    if (prime[n] && prime[(n + 1) / 2]) cs[n]++;
    cs[n+1] = cs[n];
  }

  int Q; cin >> Q;
  for (int i = 0; i < Q; i++) {
    int l, r; cin >> l >> r;
    cout << cs[r] - cs[l-1] << endl;
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int a=s.size(),b=t.size();
    int dp[a+1][b+1],i,j;
    //cout<<a<<b;
    for(i=0;i<=a;i++)
    {
        for(j=0;j<=b;j++)
        {
            if(j==0 || i==0)
            {
                dp[i][j]=0;
            }
            else if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string n;
    //cout<<dp[a][b] ;
    i=a; j=b;
    while(i>0 && j>0)
    {
        if(dp[i][j]-dp[i-1][j-1]==1 && s[i-1]==t[j-1])
        {
            n=n+s[i-1];
            i--; j--;
        }
        else if(dp[i-1][j]==dp[i][j])
        {
            i--;
        }
        else
        j--;
        //cout<<i<<j<<endl;
    }
    reverse(n.begin(),n.end());
    cout<<n;

}

Measured memory_bytes: 35456
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
int main() {
	std::string s;
	std::cin >> s;
	int pos=0;
	int ct = 0;
	for (int i = 0; i <s.size() / 2; ++i) {
		int l = s.size() - 1-i;
		if (s[i] != s[l]) {
			++ct;
			if (s[i] == 'x')s.insert(l+1,"x");
			else if (s[l] == 'x')s.insert(i, "x");
			else {ct = -1; break; }
		}
	}
	std::cout << ct<< std::endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
using namespace std;
signed main(){
    vector<int>dp(51,1LL),dp2(51,1LL);
    int n,x; cin >> n >> x;
    for(int i = 1; i < dp.size();++i){
        dp[i] = dp[i-1] + dp[i-1] + 3;
        dp2[i] = dp2[i-1] + dp2[i-1] + 1;
    }
    function<int(int,int)>cal = [&](int i,int x) -> int{
        if(x == 0){ return 0;    }
        if(i == 0){ return x > 0;}
        return (x >= dp[i-1] + 2 ? dp2[i-1] + 1 + cal(i-1,x-dp[i-1]-2) : cal(i-1,x-1));
    };
    cout << cal(n,x) << endl;
}




Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n;s(n);
	vector<int> vec;
	
	for(int i = 0;i<n;i++)
	{
		int x;s(x);
		vec.push_back(x);
	}
	
	sort(vec.begin() , vec.end());
	
	int count = 0;
	
	for(int i = 0;i<n;i++)
	{
		for(int j = i+1;j<n;j++)
		{
			for(int k = j+1;k<n;k++)
			{
				if(vec[i] == vec[j] || vec[j] == vec[k]) continue;
				
				if(vec[i] + vec[j] > vec[k]) count++;
			}
		}
	}
	
	cout<<count<<endl;
	return 0;
}

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

int main(){
	int n,m,t;
	while(cin >> n >> m, n){
		vector<int> data;
		for(int i=0;i<n;i++){
			cin >> t;
			data.push_back(t);
		}
		data.push_back(0);

		
		vector<int> ret;
		for(int i=0;i<n+1;i++){
			for(int j=0;j<n+1;j++){
				ret.push_back(data[i]+data[j]);
			}
		}
		
		sort(ret.begin(),ret.end());
		
		int r = 0;
		for(int i=0;i<ret.size();i++){
			int t = m - ret[i];
			if( t < 0 )continue;
			r = max(r,ret[i] + *(lower_bound(ret.begin(),ret.end(),t)-1));
		}
		cout << r << endl;
	}
}

Measured memory_bytes: 4964
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	string s;
	cin >> s;
	bool flag[1000]={};

	LOOP(i,3){
		flag[(int)s[i]]=true;
	}

	if(flag['a'] && flag['b'] && flag['c']){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        
        //先頭文字
        if(str1.charAt(0)=='A'){
            //先頭3文字目から後頭から2文字目までの間
            String str2 = str1.substring(2, str1.length()-1);
            int ct = 0;
            for(int i=0;i<str2.length();i++){
                if(str2.charAt(i) =='C'){
                    ct++;
                }
            }
            //AとC以外小文字
            if(ct==1){
                ct=0;
                for(int i=0;i<str1.length();i++){
                    if(Character.isUpperCase(str1.charAt(i))){
                        ct++;    
                    }
                }
                if(ct==2){
                    System.out.print("AC");
                    return;
                }
            }
        }
        System.out.print("WA");
    }
}

Measured memory_bytes: 22740
x = gets.to_i

if x <= 599 && x >= 400
  puts 8
elsif x <= 799 && x >= 600
  puts 7
elsif x <= 999 && x >= 800
  puts 6
elsif x <= 1199 && x >= 1000
  puts 5
elsif x <= 1399 && x >= 1200
  puts 4
elsif x <= 1599 && x >= 1400
  puts 3
elsif x <= 1799 && x >= 1600
  puts 2
else
  puts 1
end

Measured memory_bytes: 14392
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  int x=A+B;
  int y=A+B+C;
  if(K<=A){
    cout << K << endl;
  }
  else if(A< K &&K<= x){
    cout << A << endl;
  }
  else if(x<K&& K<=y){
    cout << (A+A+B)-K << endl;
  }
  else if(K>y){
    cout << A-C << endl;
  }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF = 1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

const ll M = 1000000007;

int n,m,e,s,t,r;
int d[1000][102][102];
int a[10],b[10],c[10];
bool t_[1000];

int ret = INF;
bool used[10];

int dist(int K,int v,int u){
	/*int rd = d[0][v][u];
	rep(i,e){
		if(used[i]){
			rd = min ( rd , d[v][a[i]] + c[i] + d[b[i]][u] );
			rd = min ( rd , d[v][b[i]] + c[i] + d[a[i]][u] );
		}
	}
	return rd;*/
	//printf("%d %d %d = %d\n",K,v,u,d[K][v][u]);
	return d[K][v][u];
}

void updata(int K,int ed,int K_){
	rep(i,102)rep(j,102){
		d[K][i][j] = d[K_][i][j];
	}
	rep(i,102)rep(j,102){
		d[K][i][j] = min ( d[K][i][j] , d[K][i][a[ed]] + 1 + d[K][b[ed]][j] );
		d[K][i][j] = min ( d[K][i][j] , d[K][i][b[ed]] + 1 + d[K][a[ed]][j] );
	}
	t_[K] = true;
}

void dfs(int v,int r_,int k,int K,int cost){
	if(v != s)dfs(s,0,k+1,K,cost);
	if(dist(K,v,t) <= r-r_){
		ret = min ( ret , k + cost + dist(K,v,t) );
		return;
	}
	rep(i,e){
		if(!used[i]){
			if(dist(K,v,c[i]) <= r-r_){
				if(!t_[K + (1 << i)])updata(K+(1<<i),i,K);
				used[i] = true;
				dfs(c[i],r_+dist(K,v,c[i]),k,K+(1<<i),cost + dist(K,v,c[i]));
				used[i] = false;
			}
		}
	}
	/*if(dist(K,s,t) <= r){
		ret = min ( ret , k + cost + dist(K,s,t) );
		return;
	}
	rep(i,e){
		if(!used[i]){
			if(dist(K,s,c[i]) <= r){
				if(!t_[K + (1 << i)])updata(K+(1<<i),i,K);
				used[i] = true;
				dfs(k+1,K+(1<<i),cost + dist(K,s,c[i]));
				used[i] = false;
			}
		}
	}*/
}

int main(){
	rep(k,1000)rep(i,102)rep(j,102){
		if(i == j)d[k][i][j] = 0;
		else d[k][i][j] = INF;
	}
	rep(i,10)used[i] = false;
	rep(i,1000)t_[i] = false;
	
	scanf("%d%d%d%d%d%d",&n,&m,&e,&s,&t,&r);
	rep(i,m){
		int a_,b_,c_;
		scanf("%d%d",&a_,&b_);
		d[0][a_][b_] = 1;
		d[0][b_][a_] = 1;
	}
	rep(i,e){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	
	rep(k,n)rep(i,n)rep(j,n)d[0][i][j] = min ( d[0][i][j] , d[0][i][k] + d[0][k][j] );
	t_[0] = true;
	
	dfs(s,0,0,0,0);
	if(ret == INF)puts("-1");
	else cout << ret << endl;
}

Measured memory_bytes: 41844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
typedef long long ll;
#define mod 1000000007

vector<int> c, ans;
vector<vector<int>> G;

int n = 0;

void dfs(int cur, int pre) {
  ans[cur] = c[n++];
  for(auto p : G[cur]) {
    if(p == pre) continue;
    dfs(p, cur);
  }
}

int main() {
  int N;
  cin >> N;
  c.resize(N);
  ans.resize(N);
  G.resize(N);
  vector<int> cnt(N);
  rep(i, 0, N - 1) {
    int A, B;
    cin >> A >> B;
    A--, B--;
    G[A].push_back(B);
    G[B].push_back(A);
    cnt[A]++,cnt[B]++;
  }
  rep(i, 0, N) cin >> c[i];
  sort(c.begin(), c.end(), greater<int>());
  int s = 0;
  rep(i, 0, N) {
    if(cnt[i] == 1) {
      s = i;
      break;
    }
  }
  dfs(s, s);
  ll sum = accumulate(c.begin(), c.end(), 0LL);
  int mx = *max_element(c.begin(), c.end());
  cout << sum - mx << endl;
  for(auto p : ans) cout << p << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 1408
//In the name of Allah
#include <bits/stdc++.h>
using namespace std; 

const int maxN = 100 * 1000 + 10;
int a[maxN], b[maxN];


int main() { 
    ios::sync_with_stdio(false); 
    int n; cin >> n; 
    for( int i = 0 ;i < n ; i++ ) 
        cin >> a[i] >> b[i]; 

    long long sum = 0; 

    for( int i = n - 1 ; i >= 0 ; i-- ) { 
        int v = (a[i]+sum) % b[i]; 
        if( v != 0 ) 
            v = b[i] - v; 
        sum += v; 
    }
    cout << sum << endl;
}


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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
using pii = pair<int, int>;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

struct UnionFind {
  vector<int> parent; // parent[root] is the negative of the size.
  UnionFind(int n) : parent(n, -1) { };
  bool unite(int u, int v) {
    u = root(u); v = root(v);
    if (u == v) return false;
    // 負の値同士の比較 小さいほうがランクが高い
    if (parent[u] > parent[v]) swap(u, v);
    parent[u] += parent[v]; parent[v] = u;
    return true;
  }
  bool find(int u, int v) { return root(u) == root(v); }
  int root(int u) { return parent[u] < 0 ? u : parent[u] = root(parent[u]); }
  // ランク
  int size(int u) { return -parent[root(u)]; }
};

signed main(){
    int N, K, L;
    cin >> N >> K >> L;
    UnionFind ws(N), rs(N);
    rep(i, K) {
        int p, q;
        cin >> p >> q;
        ws.unite(p-1, q-1);
    }
    rep(i, L) {
        int r, s;
        cin >> r >> s;
        rs.unite(r-1, s-1);
    }

    map<pii, int> ans;
    rep(i, N) {
        ++ans[make_pair(ws.root(i), rs.root(i))];
    }
    rep(i, N) {
        cout << ans[make_pair(ws.root(i), rs.root(i))] << " \n"[1&(i == N-1)];
    }
}


Measured memory_bytes: 13568
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include<vector>
#include <list>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#include <tuple>
#include <string>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
#define FORk(N) for(int k=0;k<N;++k)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
void swap(ll &a,ll &b){
  ll tmp=a;
  a=b;
  b=tmp;
}
int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  FORi(N){
   cin>>A[i]; 
  }
  sort(A.begin(),A.end());
  ll sum=0;
  sum+=-A[0];
  sum+=A[N-1];
  ll n=1;
  FORi(N-2){
    if(A[i+1]<0){
      n=i+2;
    }
    sum+=abs(A[i+1]);
  }
  cout<<sum<<endl;
  bool f=true;
  string s;
  vector<string> S;
  for(ll i=0;i<n-1;++i){//符号反転を吐く
    //if(f){// sum - (a)
    sum += A[i];
    //s=to_string(sum)+" "+to_string(A[i])+"\n"+s;
    S.push_back(to_string(sum)+" "+to_string(A[i]));
    //}
  }
  for(ll i=n+1;i<N;++i){
    //true a - (sum)
    //false sum - (a)
    if(f){
      sum -= A[i];
      //s=to_string(A[i])+" "+to_string(-sum)+"\n"+s;
      S.push_back(to_string(A[i])+" "+to_string(-sum));
      f=!f;
      sum = -sum;
    }else{
      sum += A[i];
      //s=to_string(sum)+" "+to_string(A[i])+"\n"+s;
      S.push_back(to_string(sum)+" "+to_string(A[i]));
      //f=!f;
    }
  }
  if(!f){
    //s=to_string(A[n-1])+" "+to_string(A[n])+"\n"+s;
    S.push_back(to_string(A[n-1])+" "+to_string(A[n]));
  }else{
    //s=to_string(A[n])+" "+to_string(A[n-1])+"\n"+s;
    S.push_back(to_string(A[n])+" "+to_string(A[n-1]));
  }
  //cout<<s<<endl;
  FORi(N-1){
    cout<<S[N-2-i]<<endl;
  }
  return 0;
}


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

int main(){
  string s;
  cin>>s;
  int a=s.size();
  vector<int> ans(a-2);
  for(int i=0;i<a-2;i++){
    string x=s.substr(i,3);
    int y=stoi(x);
    ans[i]=abs(753-y);
  }
  sort(ans.begin(),ans.end());
  cout<<ans[0]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdlib>
#include <cmath>

#define INF 100000000
template<class T> inline bool chmax(T& a, T b)
{ if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b)
{ if (a > b) { a = b; return 1; } return 0; }

using namespace std;

int main(){
  int i,j,k,n,x,d;

  cin >> n;
  cin >> x;
  d=x-n+1;
  for(i=d;i<x+n;i++){
    cout << i<< " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<char> vc;
typedef map<long long,long long> mpi;
#define vbi vector<bool> 
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
#define ms(x,v) memset(x,v,sizeof(x))
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
const int N = 2e5 + 5;
ll i,j,k;
void solve()

{
  ll n ;cin>>n;
 string s,t; cin>>s>>t;
 for(i=0;i<n;i++){
  cout<<s[i]<<t[i];
}

 return ; 
 
}
signed main(){
   
 //CASET
         solve();
  

 
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	inputs := scanNums(N)
	ans := inputs[0]

	for i := 1; i < N; i++ {
		if inputs[i] > inputs[i-1] {
			ans += inputs[i-1]
		} else {
			ans += inputs[i]
		}
		// ans += math.Min(float64(inputs[i]), float64(inputs[i-1]))
	}

	fmt.Println(ans)
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 512
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		sc.close();

		Set<Integer> divs = new TreeSet<Integer>();

		Main main = new Main();
		int num_GCD = main.GCD(line[0], line[1]);
		divs = main.searchDiviser(num_GCD);
		Integer[] setnums = new Integer[divs.size()];
		divs.toArray(setnums);

		System.out.println(setnums[setnums.length - line[2]]);

	}

	public int GCD(int num1, int num2) {
		if (num2 == 0) {
			return num1;
		} else {
			return GCD(num2, num1 % num2);
		}
	}

	public Set<Integer> searchDiviser(int num) {
		Set<Integer> divisers = new TreeSet<Integer>();

		int numsPiv = (int) Math.sqrt(num);
		if (numsPiv != 1) {
			divisers.add(1);
			divisers.add(num);
		}else {
			divisers.add(1);
			return divisers;
		}

		for (int i = 2; i <= numsPiv; i++) {
			if (num % i == 0) {
				divisers.add(i);
				divisers.add(num / i);
			}
		}

		return divisers;
	}
}


Measured memory_bytes: 26836
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n;  cin >> n;
    vector<ll>a(n);
    rep(i, n)   cin >> a[i];
    sort(a.rbegin(), a.rend());
    ll ans = 0;
    for(int i = 1; i < n; i++){
        ans += a[i/2];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4812
S=input()
s=len(S)
a=S.count("a")
b=S.count("b")
c=S.count("c")
if s%3==0:
    if max(a,b,c)<=s//3:
        print("YES")
    else:
        print("NO")
if s%3!=0:
    if max(a,b,c)<=s//3+1:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    int ave = 0;
    Rep(i, N) {
        cin >> X[i];
        ave += X[i];
    }
    ave = round((double)ave / N);
    int ans = 0;
    Rep(i, N) ans += (X[i] - ave) * (X[i] - ave);
    cout << ans << endl;
    return 0;
}

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


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
	
	while(test--)
	{
	    long long A,B,a,b,c=0,k,d=0,i,n,j,temp,p,m,ex1,ex2,ex3,ex4,x,y;
	    cin>>a>>b;
	    for(i=0;i<=a;i++)
	    {
	        for(j=0;j<=a;j++)
	        {
	            k=b-i-j;
	            if(k>=0 && k<=a)
	            c++;
	        }
	    }
	    cout<<c;
    
        }
    
}


Measured memory_bytes: 256
n,m = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(m)]

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n
    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n)

li = li[::-1]
lin = []
uni = UnionFind(n)
now = n*(n-1)//2
lin.append(now)

for i in range(1,m):
    a,b = li[i-1]
    a -= 1
    b -= 1
    if uni.same(a,b):
        lin.append(lin[-1])
    else:
        lin.append(lin[-1]-uni.size[uni.find(a)]*uni.size[uni.find(b)])
    uni.union(a,b)

lin = lin[::-1]

for i in lin:
    print(i)

Measured memory_bytes: 37688
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
std::string S;
int32_t Enum[300100];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>S;
	for (size_t i = 1; i <= N; i++)
	{
		if (S[i - 1] == 'E') { ++Enum[i]; }
		Enum[i] += Enum[i - 1];
	}

	int32_t min = N;
	for (int i = N; i >= 1; i--)
	{
		min = std::min(min, ((i-1) - Enum[i - 1]) + (Enum[N] - Enum[i]));
	}
	out << min << endl;
	return 0;
}
#endif


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

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}


int main() {
  int A;
  int B;
  int N;
  
  cin >> N >> A >> B;
  
  int res = 0;
  
  for (int i = 1; i <= N; ++i) {
    int sum = findSumOfDigits(i); // i の各桁の和
    if (sum >= A && sum <= B) { //  i の各桁の和が A 以上 B 以下かどうか
      res += i;
    }
  }
  

  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-9;

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    const Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    const Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    const Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    double dist(const Point& p) const{
        return sqrt(pow(y-p.y, 2.0) + pow(x-p.x, 2.0));
    }
};

int solve(vector<Point>& vp)
{
    int n = vp.size();
    int ret = 1;

    for(int i=0; i<n; ++i){
        for(int j=i+1; j<n; ++j){
            double dist = vp[i].dist(vp[j]);
            if(dist > 2.0)
                continue;

            for(int k=0; k<2; ++k){
                Point p = vp[j] - vp[i];
                Point p1(p.x, p.y);
                if(k == 0)
                    p1.x *= -1;
                else
                    p1.y *= -1;
                p = vp[i] + p * 0.5 + p1 * (sqrt(pow(dist, -2) - 0.25));
                int num = 0;
                for(int l=0; l<n; ++l){
                    if(p.dist(vp[l]) < 1.0 + EPS)
                        ++ num;
                }
                ret = max(ret, num);
            }
        }
    }

    return ret;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            break;

        vector<Point> p(n);
        for(int i=0; i<n; ++i)
            cin >> p[i].x >> p[i].y;
        cout << solve(p) << endl;
    }
}

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

int N;
int A[210];

int main(){
    cin >> N;
    for (int i =0;i<N; ++i) cin >> A[i];

    int res =0;

    while (true) {
        bool exist_odd = false;

        for (int i =0; i< N; i++){
            if(A[i]%2 !=0) exist_odd =true;

        }
        if(exist_odd) break;

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

    cout << res << endl;
        
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//227
	int n;
	cin>>n;
	vi arr(n);
	for(int &i:arr)cin>>i;
	sort(arr.begin(),arr.end());
	while(arr.size()>1) {
		vi a;
		REP(i,1,(int)arr.size()-1) {
			int p = arr[i]%arr[0];
			if(p!=0)
			a.PUB(p);
		}
		a.PUB(arr[0]);
		sort(a.begin(),a.end());
		arr=a;
	}
	cout<<arr[0];
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 4076
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m; 
char c[2010][2010];
int a[2010][2010][4];
int res;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++) scanf("%s",&c[i]);
	for (int i=0;i<n;i++)
	{
		a[i][0][0]=(c[i][0]=='#' ? 0 : -1);
		for (int j=1;j<m;j++)
		    a[i][j][0]=(c[i][j]=='#' ? j : a[i][j-1][0]); 
		a[i][m-1][1]=(c[i][m-1]=='#' ? m-1 : m);
		for (int j=m-2;j>=0;j--)
		    a[i][j][1]=(c[i][j]=='#' ? j : a[i][j+1][1]); 
	}
	for (int j=0;j<m;j++)
	{
		a[0][j][2]=(c[0][j]=='#' ? 0 : -1);
		for (int i=1;i<n;i++)
		    a[i][j][2]=(c[i][j]=='#' ? i : a[i-1][j][2]); 
		a[n-1][j][3]=(c[n-1][j]=='#' ? n-1 : n);
		for (int i=n-2;i>=0;i--)
		    a[i][j][3]=(c[i][j]=='#' ? i : a[i+1][j][3]); 
	}
	/*for (int tr=0;tr<4;tr++)
	{
		for (int i=0;i<n;i++)
		{
			for (int j=0;j<m;j++)
			{
				cout <<a[i][j][tr]<<" "; 
			}
			cout <<"\n";
		}
		cout <<"\n";
	}*/
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{
			if (c[i][j]=='#') continue;
			int r=0;
			r+=a[i][j][1]-a[i][j][0]-1;
			r+=a[i][j][3]-a[i][j][2]-1;
			r--;
			res=max(res,r);
		}
	}
	cout <<res;
	return 0;
} 


Measured memory_bytes: 67328
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1 << 30;

int main(int argc, char* argv[])
{
  std::string a, b;
  std::cin >> a >> b;

  int x = std::atoi((a+b).c_str());

  std::string judge = "No";
  for (int i = 1; i * i <= x; i++) {
    if (i * i == x) {
      judge = "Yes";
    }
  }

  std::cout << judge << std::endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

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

int main()
{
	int t;
	ll a, b, c, d;
	cin >> t;
	for(int i=0; i<t; i++)
	{
		cin >> a >> b >> c >> d;
		bool ans;
		if(b>a) ans=false;
		else if(b>d) ans=false;
		else if(b<=c) ans=true;
		else if(c<(a%b)) ans=false;
		else
		{
			ll e=gcd(d, b);
			a%=b;
			if(a>c || e<b-c) ans=false;
			else
			{
				e=((c-a)/e)*e+a+e;
				if(e<b) ans=false;
				else ans=true;
			}
		}
		if(ans) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val x = nextInt()
    println(if (x < 1200) "ABC" else "ARC")
}

Measured memory_bytes: 33812
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn =new Scanner(System.in);
		int K=scn.nextInt();
		int X=scn.nextInt();
		for(int i=-100;i<300;i++) {
			if((X-K)<i&&(X+K)>i) {
				System.out.print(i+" ");
			}
		}
	}

}


Measured memory_bytes: 23636