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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

int main() {
	long double l;
	cin >> l;
	cout << fixed << setprecision(15) << (l*l*l)/27;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String args[]) throws IOException {
        FastReader s = new FastReader();
        int n = s.nextInt();
        int a[][] = new int[2][n];
        for(int i=0;i<2;i++){
            for(int j=0;j<n;j++){
                a[i][j] = s.nextInt();
            }
        }
        int ans = 0;
        int t[] = new int[n];
        int b[] = new int[n];
        t[0] = a[0][0];
        for(int i=1;i<n;i++){
            t[i] = t[i-1] + a[0][i];
        }
        b[n-1] = a[1][n-1];
        for(int j = n-2;j>=0;j--){
            b[j] = b[j+1] + a[1][j];
        }
        for(int i=0;i<n;i++){
            ans = Math.max(ans,t[i]+b[i]);
        }
        System.out.println(ans);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define int long long
using namespace std;

vector<vector<pair<int, int>>> G(100000);
vector<int> ans;

void dfs(pair<int, int> data, int k){
	ans[data.second] = k;
	int cnt = (k == 1 ? 2 : 1);
	for(auto i : G[data.first]){
		dfs(i, cnt);
		cnt++;
		if(cnt == k){
			cnt++;
		}
	}
}

int32_t main(){
	int n;
	cin >> n;
	ans.resize(n - 1);
	for(int i = 0; i < n - 1; i++){
		int v1, v2;
		cin >> v1 >> v2;
		v1--; v2--;
		G[v1].push_back({v2, i});
	}
	dfs({0, 0}, 0);
	cout << *max_element(ans.begin(), ans.end()) << endl;
	for(int i = 0; i < n - 1; i++){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 7680
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  int n;
  cin >> n;
  if((n==23||n==38||n==39||n==11||n==13||n==17||n==19||n==22||n==26||n==29||n==31||n==33||n==34||n==37||n==41||n==43||n==44||n==46||n==47||n==50||n==51||n==52||n==53||n==55||n==57||n==58|n==59||n==60||n==61||n==62||n==65||n==66||n==67||n==68||n==69||n==70||n==71||n==73||n==74||n==75||n==76||n==77||n==78||n==79||n==80||n>81)) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, k;
	cin >> n >> k;
	int* p = new int[n];
	rep(i, n) cin >> p[i];
	sort(p, p + n);

	int sum = 0;
	rep(i, k) {
		sum += p[i];
	}
	cout << sum << "\n";

	return 0;
}

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

int n;
struct node{int x,y;}a[200010];
bool cmp(node x,node y){return x.y<y.y;}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d %d",&a[i].x,&a[i].y);
	sort(a+1,a+n+1,cmp);
	int time=0;
	for(int i=1;i<=n;i++)
	{
		time+=a[i].x;
		if(time>a[i].y)
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[700][2005]; // iで総和jの通り数

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll s; cin>>s;
  
  ll n=s/3;
  dp[0][0]=1;
  ll ans=0;
  rep(i,n){
    rep(j,s+1){
      for(ll k=3; k+j<=s; k++){
        (dp[i+1][j+k]+=dp[i][j])%=MOD;
      }
    }
    (ans+=dp[i+1][s])%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 14020
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int  H, W;
    cin >> H >> W;
    char A[H+2][W+2];

    for (int i = 0; i < H+2; i++){
        for (int j = 0; j < W+2; j++){
            A[i][j] = '#';
        }
    }

    for (int i = 1; i < H+1; i++){
        for (int j = 1; j < W+1; j++){
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < H+2; i++){
        for (int j = 0; j < W+2; j++){
            if (j == W + 1){
                cout << '#' << endl;
            }
            else if (i == 0 || j ==0 || i == H + 1){
                 cout << '#';
            }
            else {
                cout << A[i][j];
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int a[3333];
int b[3333];
int iv[6666];

bool notprefix(string a, string b) //a is not a prefix of b
{
	if(a.length()>b.length()) return true;
	for(int i=0;i<a.length();i++)
	{
		if(a[i]!=b[i]) return true;
	}
	return false;
}

string solve(string s)
{
	int n = s.length(); n>>=1;
	int acnt = 0; int bcnt = 0;
	for(int i=0;i<2*n;i++)
	{
		if(s[i]=='a') {iv[i] = acnt; a[acnt++] = i;}
		else {iv[i] = bcnt; b[bcnt++] = i;}
	}
	vector<ii> groups;
	int l=0; 
	for(int i=0;i<n;i++)
	{
		if(i>0&&min(a[i],b[i])>max(a[i-1],b[i-1]))
		{
			groups.pb(mp(l,i-1));
			l=i;
		}
	}
	groups.pb(mp(l,n-1));
	vector<string> bestg;
	for(int z=0;z<groups.size();z++)
	{
		int l = groups[z].fi; int r = groups[z].se;
		if(a[l]>b[l])
		{
			set<int> S;
			string best = ""; 
			for(int i=r;i>=l;i--)
			{
				string cur="";
				S.insert(a[i]); S.insert(b[i]);
				for(int v:S) cur+=s[v];
				if(cur>best) best=cur;
			}
			bestg.pb(best);
		}
		else
		{
			string cur = "";
			int i=a[l];
			while(i<=b[r])
			{
				if(s[i]=='a')
				{
					cur+="ab";
					i = b[iv[i]]+1;
				}
				else
				{
					i++;
				}
			}
			bestg.pb(cur);
		}
	}
	stack<string> S;
	for(string x:bestg)
	{
		while(!S.empty()&&x>S.top()&&notprefix(S.top(),x)) S.pop();
		S.push(x);
	}
	string ans;
	vector<string> V; while(!S.empty()) {V.pb(S.top()); S.pop();}
	for(int i=int(V.size())-1;i>=0;i--) ans+=V[i];
	return ans;
}

void run()
{
	int n; cin>>n;
	string s; cin>>s;
	cout<<solve(s)<<'\n'; exit(0);
}

string naive(string s)
{
	int n = s.length(); n>>=1;
	string best = "";
	int acnt = 0; int bcnt = 0;
	for(int i=0;i<2*n;i++)
	{
		if(s[i]=='a') {iv[i] = acnt; a[acnt++] = i;}
		else {iv[i] = bcnt; b[bcnt++] = i;}
	}
	for(int i=1;i<(1<<n);i++)
	{
		vi v;
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				v.pb(a[j]); v.pb(b[j]);
			}
		}
		sort(v.begin(),v.end());
		string cur;
		for(int j=0;j<v.size();j++) cur+=s[v[j]];
		if(cur>best) best=cur;
	}
	return best;
}

void test(string s)
{
	string na = naive(s);
	string so = solve(s);
	if(na!=so)
	{
		cerr<<"FAIL ON STRING "<<s<<'\n';
		cerr<<"NAIVE : "<<na<<'\n';
		cerr<<"MY SOL : "<<so<<'\n';
		exit(0);
	}
}

string gen()
{
	int n = rand()%5+1;
	vector<char> v;
	for(int i=0;i<n;i++)
	{
		v.pb('a'); v.pb('b');
	}
	random_shuffle(v.begin(),v.end());
	string s="";
	for(char c:v) s+=c;
	return s;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	srand(1729);
	/*
	for(int cc=1;;cc++)
	{
		string s = gen();
		test(s);
		cerr<<"Case #"<<cc<<" complete\n";
	}
	*/
	run();
}


Measured memory_bytes: 640
#include<stdio.h>

int main() {
	int A, B;
	int N;
	int loop;
	char s[100001];
	int ac = 0, bc = 0;

	scanf("%d %d %d", &N, &A, &B);
	scanf("%s", s);

	for (loop = 0; loop < N; loop++) {
		if (s[loop] == 'a'&&ac < A + B) {
			ac++;
			printf("Yes\n");
		}
		else if (s[loop] == 'b'&&ac < A + B&&bc < B) {
			ac++;
			bc++;
			printf("Yes\n");
		}
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y==NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}
void inorder(Node u){
  if(u !=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];
    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
      scanf("%s", com);
      if ( com[0] == 'i' ){
	scanf("%d", &x);
	insert(x);
      } 
      else if ( com[0] == 'p' ){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");  
      } 
    }
    return 0;
  }

Measured memory_bytes: 24036
import heapq
n = int(raw_input())
heap = [map(int, raw_input().split(' '))[::-1] for _ in range(n)]
heapq.heapify(heap)
#(deadline, duration)
def f(heap):
	t = 0
	while(heap):
		nd,d = heapq.heappop(heap)
		gap = nd - t 
		gap -= d
		t += d
		while(heap and heap[0][0] == nd):
			_,v = heapq.heappop(heap) 
			t += v
			gap -= v
		if gap < 0: return False
	return True
print 'Yes' if f(heap) else 'No'

Measured memory_bytes: 53020
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define fd find
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=2e5+50;
const int mod=1e9+7;
using namespace std;
int h,w,n,x,y,ans,i;
set<int>s[nmax],c[nmax];
set<int>::iterator it;
int main()
{
    //freopen("sol.in","r",stdin);
    //freopen("sol.out","w",stdout);
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
   	cin>>h>>w>>n;
   	for(i=1;i<=n;i++)
   	{
   		cin>>x>>y;
   		c[y].in(x);
   		s[x].in(y);
	}
	x=1,ans=h;
	for(i=1;i<=h;i++)
	{
		if(s[i].fd(x)==s[i].end())
		{
			it=c[x].lower_bound(i);
			if(it!=c[x].end())
			{
				ans=min(ans,(*it)-1);
			}
			x++;
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 37760
#include<stdio.h>
int main(){
	char S[1000];
	int i=0;
	scanf("%s",S);
	
	while(S[i])
		i++;
	
	if(S[i-1]!='s')
	printf("%ss\n",S);
	else
	printf("%ses\n",S);
	
	return 0;
}


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

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-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 GetDigit(ll num) {return log10(num)+1;}

int main(){
    int n;
    cin >> n;
    vector<int> rate(9, 0);
    for(ll i = 0; i < n; i++){
        int a = 0;
        cin >> a;
        rate[min(8,a/400)]++;
    }

    ll ans = 0;
    ll cnt = 0;
    for(ll i = 0; i < 8; i++){
        if(rate[i] > 0){
            ans++;
        }
    }
    if(ans > 0) cout << ans << " " << ans+rate[8] << endl;
    else cout << 1 << " " << n << endl;
    
    return 0;
}

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s, t;
    cin >> s >> t;

    int len = s.size(), count = 0;
    for (int i = 0; i < len; ++i) {
        if (s[i] != t[i]) count++;
    }
    cout << count << "\n";
    return 0;
}



Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  //begin input
  int N;
  cin >>N;
  vector<int> A(N);
  for(int t = 0;t<N;t++){
    cin >>A.at(t);
  }
  //end input
  //begin search max
  int max = 0;
  for(int t = 0;t<N;t++){
    if(A.at(t)>max){
      max = A.at(t);
    }
  }
  //cout <<"max:"<<max <<endl;
  //end search max
  //begin count max
  int count_max=0;
  for(int t = 0;t<N;t++){
    if(A.at(t)==max){
      count_max++;
    }
  }
  //cout <<"count max:"<<count_max <<endl;
  //end count max
  //begin search submax
  int submax=-1;
  if(count_max==1){
    for(int t = 0;t<N;t++){
      if(A.at(t)>submax&&A.at(t)!=max){
        submax = A.at(t);
      }
    }
  }
  //end search submax
  //begin output
  if(count_max>1){
    for(int t=0;t<N;t++){
      cout <<max<<endl;
    }
  }else{
    for(int t=0;t<N;t++){
      if(A.at(t)==max){
        cout <<submax<<endl;
      }else{
        cout <<max<<endl;
      }
    }
  }   
}
    

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define read(n) cin>>n;
#define write(n) cout<<n;
#define loop(x,n) for(int x = 0; x < n; ++x)
#define vector_loop(x,n) for(int i = 0; x < n; i++)
#define vii vector<int> a(n)
typedef pair<int, int> pii;
#define endl "\n"
#define sd(val) scanf("%d", &val)
#define ss(val) scanf("%s", &val)
#define sl(val) scanf("%lld", &val)
#define debug(val) printf("check%d\n", val)
#define all(v) v.begin(), v.end()
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val, 0, sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{
	FIO;
	int d, t, s;
	cin >> d >> t >> s;
	float time = (float)d / s;
	if (time <= t)
		cout << "Yes";
	else
		cout << "No";



	return 0;
}

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



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({1LL * a * c, 1LL * a * d, 1LL * b * c, 1LL * b * d}) << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

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

using namespace std;

int main(){
    int n; cin >> n;
    priority_queue<string> pq;
    REP(i, n){
        string x; cin >> x;
        sort(x.begin(), x.end());
        pq.push(x);
    }
    long long ans = 0;                                                 
    int count = 1;
    string x = pq.top(); pq.pop();
    REP(i, n-1){
        string y = pq.top(); pq.pop();
        if(x == y){
            ans+=count;
            count++;
        }else count = 1;
        x = y;
    }

    cout << ans;
}


Measured memory_bytes: 5748
using System.Linq;
using System;

public class P
{
    public int id { get; set; }
    public int p { get; set; }
}

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            if (n == 0 && m == 0) break;
            var ps = new P[n];
            for (int i = 0; i < n; i++) ps[i] = new P { id = i };
            var minp = new int[n];
            for (int i = 0; i < m; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                var s = int.Parse(line[0]);
                var k = int.Parse(line[1]);
                for (int j = 0; j < k; j++)
                {
                    var w = int.Parse(line[j + 2]) - 1;
                    ps[w].p += s;
                    if (k == 1) minp[w] += s;
                }
            }
            var res = getAns(ps, minp);
            Console.WriteLine(res);
        }
    }
    public static int getAns(P[] ps, int[] minp)
    {
        var w = ps.OrderByDescending(x => x.p).ToArray();
        var no1p = w[0].p;
        var no1pid = w[0].id;
        var no2p = w[1].p;
        var ret = 0;
        for (int i = 0; i < minp.Length; i++)
            if (i != no1pid)
            {
                var t = no1p - minp[i] + 1;
                ret = Math.Max(ret, t);
            }
            else
            {
                var t = no2p - minp[i] + 1;
                ret = Math.Max(ret, t);
            }
        return ret;
    }
}


Measured memory_bytes: 37444
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let s=read::<String>().chars().collect::<Vec<char>>();
    let mut f=0;
    for c in s.iter(){
        let mut r=0;
        for d in s.iter(){
            if c==d{r+=1}
        }
        f+=r%2
    }
    println!("{}",if f>0{"No"}else{"Yes"})
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

double PI = 3.14159265358979;
double A, B, H, M, c1, c2;

int main() {
	cin >> A >> B >> H >> M;
	c1 = (60.0 * H + M) / 720.0;
	c2 = M / 60.0;

	double sx = A * cos(2.0 * c1 * PI), sy = A * sin(2.0 * c1 * PI);
	double tx = B * cos(2.0 * c2 * PI), ty = B * sin(2.0 * c2 * PI);
	double ans = sqrt((sx - tx) * (sx - tx) + (sy - ty) * (sy - ty));
	printf("%.12lf\n", ans);
	return 0;
}

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

string ans(int n, vector<int> &s) {
  vector<char> c(n);
  string str;
  
  for(int i=0; i<n; i++){
    if(s[i]==0) c[i]='a';
    else if(s[i]==1) c[i]='b';
    else if(s[i]==2) c[i]='c';
    else if(s[i]==3) c[i]='d';
    else if(s[i]==4) c[i]='e';
    else if(s[i]==5) c[i]='f';
    else if(s[i]==6) c[i]='g';
    else if(s[i]==7) c[i]='h';
    else if(s[i]==8) c[i]='i';
    else if(s[i]==9) c[i]='j';
  }
  
  for(int i=0; i<n; i++){
    str = str + c[i];
  }
  
  return str;
  
}
  
int judge(int n, vector<int> &s){
  for(int i=0; i<n; i++){
    if(s[i]==s[n]) return 1;
  }
  return 0;
}

int main() {
  int n;
  cin>>n;
  
  if(n==1) cout << "a" << endl;
  
  else{
    vector<int> a(n);
    for(int i=0; i<n; i++) a[i]=0; //配列初期化
    cout << ans(n,a) << endl; //初期答え
    
    for(int i=0; i<n; i++){
      if(judge(n-1-i,a)){
        a[n-1-i]++;
        for(int l=n-1; l>n-1-i; l--) a[l]=0;
        cout << ans(n,a) << endl;
        i=-1;
      }
    }
  }
}

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

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> p(A);
  vector<ll> q(B);
  vector<ll> r(C);
  rep(i, A) cin >> p[i];
  rep(i, B) cin >> q[i];
  rep(i, C) cin >> r[i];
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  sort(q.begin(), q.end());
  reverse(q.begin(), q.end());
  sort(r.begin(), r.end());
  reverse(r.begin(), r.end());
  vector<ll> ans(0);
  rep(i, X) {
    ans.push_back(p[i]);
  }
  rep(i, Y) {
    ans.push_back(q[i]);
  }
  sort(ans.begin(), ans.end());
  rep(i, X+Y) {
    if (ans[i] > r[i]) break;
    ans[i] = r[i];
  }
  ll sum = 0;
  rep(i, X+Y) {
    sum += ans[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 4724
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

const int kN = 102;
int N, M[kN], P[kN][kN], K, L[kN];

int solve() {
  vector<int> ans;
  rep(i,N) {
    bool ok = true;
    rep(j,K) {
      bool check = false;
      rep(k,M[i]) {
        if (L[j] == P[i][k]) check = true;
      }
      if (!check) ok = false;
    }
    if (ok) ans.push_back(i+1);
  }
  return ans.size() == 1 ? ans.front() : -1 ;
}

int main() {
  while (scanf("%d", &N), N) {
    rep(i,N) {
      scanf("%d", M+i);
      rep(j,M[i]) scanf("%d", P[i]+j);
    }
    scanf("%d", &K);
    rep(i,K) scanf("%d", L+i);
    printf("%d\n", solve());
  }
  return 0;
}

Measured memory_bytes: 960
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int a[100010];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int mx=0;
	int cnt=0;
	for(int i=0;i<n-1;i++){
		if(a[i]>=a[i+1]){
			cnt++;
		}
		else cnt=0;
		mx=max(mx,cnt);
	}
	cout<<mx<<endl;
	return 0;
}


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

using namespace std;

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

	int minDiff = INT_MAX;
	for (int i = 0; (size_t) i < s.size() - 2; i++) {
		int ss = atoi(s.substr(i, 3).c_str());
		int diff = abs(ss - 753);
		if (diff < minDiff) {
			minDiff = diff;
		}
	}

	cout << minDiff << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}

int32_t main()
{
	c_p_c();
	int ans = 0;
	int x; cin >> x;

	ans += 1000 * (x / 500);

	x %= 500;

	ans += 5 * (x / 5);

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

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 (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int main()
{
	int a; cin >> a;
	if (a < 1200)
		cout << "ABC";
	else
		cout << "ARC";
	cout << endl;

}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n;
  cin >> n;
  vi p(n);
  re(i, n) cin >> p[i];

  sort(all(p), greater<int>());
  p[0] /= 2;
  int s = 0;
  re(i, n) s += p[i];

  cout << s << endl;

  return 0;
}


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

using namespace std;
#define  ll long long 
#define db long double
#define f(i,l,u) for(ll i=l;i<u;i++)
#define all(a) a.begin(),a.end()
#define pb push_back

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll> G[200010];

int main() {
	ll N, u, v, a = 0, d = 0;
	cin >> N;
	for (int i = 1;i < N;i++) {
		cin >> u >> v;
		G[max(u, v)].push_back(min(u, v));
	}
	for (v = 1;v <= N;v++) {
		u = v;
		for (auto j : G[v])
			u -= j;
		d += u;
		a += d;
	}
	cout << a << endl;
}

Measured memory_bytes: 14492
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int n, a[100010];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	sort(a, a + n);
	vector<int> ve;
	int before = a[0], how = 0;
	for(int i = 0;i < n;i++){
		if(before == a[i]) how++;
		else{
			ve.push_back(how);
			before = a[i];
			how = 1;
		}
	}
	ve.push_back(how);

	int amari = 0;
	for(int i = 0;i < ve.size();i++){
		if(ve[i] >= 2){
			amari += ve[i] - 1;
		}
	}
	if(amari % 2 == 0){
		cout << ve.size() << endl;
	}else{
		cout << ve.size() - 1 << endl;
	}
	return 0;
}

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

#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif

#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 998244353;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 3e3 + 10;

int a[maxn];

ll dp[maxn][maxn];

int n,s;


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

  dp[0][0] = exp(2, n);
  for(int i = 1; i <= n; i++)
  {
    for(int j = 0; j <= s; j++)
    {
      dp[i][j] = dp[i-1][j];
      if( j >= a[i] )
        dp[i][j] += dp[i - 1][j - a[i]] * exp(2, mod-2);
      dp[i][j] %= mod;
    }
  }

  cout << dp[n][s] << endl; 

  return 0;
}

Measured memory_bytes: 74200
#include<bits/stdc++.h>
 
using namespace std;
 
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
 
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
 
#define pint(x) printf("%d",x)
#define plint(x) printf("%lld",x)
#define endl '\n'
#define nl printf("\n");
#define ps printf(" "); 
 
#define all(x) x.begin(),x.end()
#define pb push_back
#define Set(a, s) memset(a, s, sizeof (a))
#define mod1 (lli)(1e9 + 7)
#define mod2 (lli)(1e9 + 9)
#define EPS 1e-9
 
#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
 
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
lli power(lli a, lli b, lli mod){lli x=1,y=a; while(b > 0){if(b&1){x=(x*y)%mod;}y = (y*y)%mod; b /= 2;}return x;}
 
const int INF = 0x3f3f3f3f;
const float pi = 3.14159265;
 
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
 
int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	//srand (time(NULL));
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
    
    string s,f;
    cin>>s>>f;
    
    int ans =0;
    
    fors(i,0,3) if(s[i] == f[i]) ans++;
    
    cout<<ans;
    
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
const ll inf = (ll)(1e18),mod = (ll)(1e9+7), MX= 100001; 
#define n_l '\n'
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

 

void solve(){
    int n,m;
  cin>>n;

  vector<char> a(n);
    for(int i = 0; i<n; i++){
        cin>>a[i];
    }
    a.resize(unique(a.begin(), a.end())-a.begin());
    cout<<a.size()<<endl;

    return;
}

int main()
{
    int T = 1;
    // cin>>T;
    while(T--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  sort(a.begin(), a.end(), greater<int>());

#if 0
  for (int i = 0; i < n; i++) {
    cout << a[i] << ", ";
  }
  cout << endl;
#endif

  uint64_t x = 0, y = 0;
  int l;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] == a[i + 1]) {
      x = a[i];
      l = i + 2;
      break;
    }
  }

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

  for (int i = l; i < n - 1; i++) {
    if (a[i] == a[i + 1]) {
      y = a[i];
      break;
    }
  }

  if (y == 0) {
    cout << 0 << endl;
    return 0;
  }
  
  cout << x * y << endl;

  return 0;
}


Measured memory_bytes: 640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
 
sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7
 
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
 
 
def main():
    n = I()
    a = LI()
    r = 1
    c = 0
    for b in a:
        if b <= c * 2:
            r *= c+1
            r %= mod
        else:
            c += 1
    for b in range(2,c+1):
        r *= b
        r %= mod
 
    return r
 
 
print(main())

Measured memory_bytes: 16472
function Main(input) {
  input = input.split("\n");
  var h = parseInt(input[0].split(" ")[0]);
  var w = parseInt(input[0].split(" ")[1]);
  var n = parseInt(input[1]);
  tmp = input[2].split(" ");
  a= new Array();
  for(i=0;i<n;i++){
    var x = parseInt(tmp[i]);
    for(j=0;j<x;j++){
      a.push(i+1);
    }
  }
  var ans="";
  anssub=new Array(h).fill("");
  for(i=0;i<h;i++){
    anssub[i]=a[i*w];
    for(j=1;j<w;j++){
      if(i%2==0){
        anssub[i]=anssub[i]+" "+a[i*w+j];
      }else{
        anssub[i]=a[i*w+j]+" "+anssub[i];
      }
    }
    anssub[i]=anssub[i]+"\n";
    ans+=anssub[i];
  }
  if(ans.slice(-1)=="\n"){
  ans=ans.slice(0,-1);
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

int timeLimit = 1978;
/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();

    int D; cin >> D;
    int N = 26;
    D++; N++;
    
    //しばらく特定のタイプのコンテストが開催されないと、満足度が下がってしまいます
    int c[N]; rep(i,1,N) cin >> c[i]; 
    
    //d日目にiタイプのコンテスト開催　＝＞　満足度 += s[d][i]
    int s[D][N];
    rep(d,1,D) rep(i,1,N) cin >> s[d][i];

    // タイプ i のコンテストを開催した最後の日
    int last[N] = {};

    int ans[D];

    //満足度の合計
    ll satisfaction = 0;
    rep(d,1,D){
        ll tmpSatisfaction = -1e15;
        int tmpAns = 1;

        rep(i,1,N){ // 日ごとに選ぶタイプの候補
            ll minus = 0;
            rep(j,1,N){
                if(i != j) minus += c[j]*(d-last[j]);
            }
            if(satisfaction + s[d][i] - 3*minus > tmpSatisfaction){
                tmpAns = i;
                tmpSatisfaction = satisfaction + s[d][i] - 3*minus;
            }
        }
        satisfaction = tmpSatisfaction;
        last[tmpAns] = d;
        ans[d] = tmpAns;
    }
    // cout << satisfaction << "\n";
    

    //満足度が　sum 1.to 26 ci * (d-last[i]) 低下する
    // つまり、個々のタイプに対しての和、満足度の下がりやすさ×空いた日数


    while(1){
        end = chrono::system_clock::now();
        int time = static_cast<int>(chrono::duration_cast<chrono::microseconds>(end - start).count()/1000);
        if(time > timeLimit){
            break;
        }
        
        //変化量が小さいのに変えてみる、評価関数の重みを変える,高速化

        //変えたい解
        int tryD = rand()%(D-1)+1;
        int tryI = rand()%(N-1)+1;

        //仮の場合の状態を作る
        int tryLast[N] = {};
        int tryAns[D]; rep(d,1,D) tryAns[d] = ans[d];
        tryAns[tryD] = tryI;

        ll trySatisfaction = 0;
        rep(d,1,D){
            trySatisfaction += s[d][tryAns[d]];
            tryLast[tryAns[d]] = d;
            rep(i,1,N){
                trySatisfaction -= c[i]*(d-tryLast[i]);
            }
        }

        
        if(trySatisfaction > satisfaction){
            satisfaction = trySatisfaction;
            ans[tryD] = tryI;
        }
        
    }

    // cout << satisfaction << "\n";

    rep(d,1,D){
        cout << ans[d] << "\n";
    }
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
//#include <string>
using namespace std;

#define loop(i,N) for(int i=0; i<(N); i++)
#define sort_all(v) sort(v.begin(),v.end())
template<typename T>
auto input(int N) {
    vector<T> v(N);
    loop(i,N)
        cin >> v[i];
    return move(v);
}

int main(void)
{
    int N;
    cin >> N;
    auto d = input<int>(N);
    
    if(N % 2) {
        cout << 0 << endl;
    } else {
        sort_all(d);
        cout << (d[N/2] - d[N/2-1]) << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
int n,a[200000];
bool use=false;
int gcd(int x,int y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int lcm(int x,int y){
    int n=gcd(x,y);
    return (x/n)*y;
}
signed main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    if(n==2)cout<<a[1]<<endl;
    else{
        int b=gcd(a[0],gcd(a[1],a[2]));
        int c[3];
        c[0]=gcd(a[0],a[1]);c[1]=gcd(a[1],a[2]);c[2]=gcd(a[2],a[0]);
        sort(c,c+3);
        for(int i=3;i<n;i++){
            if(gcd(b,a[i])==1&&use==false){
                use=true;
            }
            else b=gcd(b,a[i]);
            c[0]=gcd(c[0],a[i]);
            c[1]=gcd(c[1],a[i]);
            c[2]=gcd(c[2],a[i]);
        }
        sort(c,c+3);
        int ans=max(b,c[2]);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
class Tree
	def initialize(key)
		@key = key
		@left = nil
		@right = nil
	end

	def insert(k)
		if @key > k
			if !@left
				@left = Tree.new(k)
			else
				@left.insert(k)
			end

		else
			if !@right
				@right = Tree.new(k)
			else
				@right.insert(k)
			end
		end
	end

	def inorder(list)
		if @left
			list = @left.inorder(list)
		end
		list << @key
		if @right
			list = @right.inorder(list)
		end
		list
	end

	def preorder(list)
		list << @key
		if @left
			list = @left.preorder(list)
		end
		if @right
			list = @right.preorder(list)
		end
		list
	end

	def find(key)
		if @key == key
			return key
		else
			bool = nil
			if @left && @key > key
				bool = @left.find(key)
			end

			if @right && @key < key
				bool = @right.find(key)
			end
			return bool
		end
	end

	def delete(k)

	end
end
n = gets.to_i
head = nil

n.times do
	num = gets.to_s.chomp!
	if num == "print"
		puts " #{head.inorder([]).join(" ")}"
		puts " #{head.preorder([]).join(" ")}"
	else
		num = num.split
		if num[0].to_s == "insert"
			if head
				head.insert(num[1].to_i)
			else
				head = Tree.new(num[1].to_i)
			end
		else
			puts head.find(num[1].to_i) ?  "yes" : "no"
		end

	end

end

Measured memory_bytes: 53068
// new day,new strength,new thougts
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) int((c).size())
#define REP(i,n)  for(int i=0;i<int(n);i++)
#define REPD(i,n) for(int i=int(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FORD(i,a,b) for(int i=int(a);i>=int(b);i--)
#define all(s) (s).begin(),(s).end()
#define bit(num,i) ((num>>i)&1)

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

const ll inf=4e18;
const ll maxn=1e5+10;
const ll mod=1e9+7;

vector<pll>v[maxn];
pll val[maxn];
ll ANS=inf;

void dfs(ll u){
    for(pll p:v[u]){
	ll y=p.F,w=p.S;
	if(val[y].F==0){
	    val[y].F=-val[u].F;
	    val[y].S=w-val[u].S;
	    dfs(y);
	}
	else if(val[y].F==val[u].F){
	    ll num=(w-(val[y].S+val[u].S))*val[u].F;
	    if((num%2)!=0){
		cout<<0;
		exit(0);
	    }
	    ANS=num/2;
	}
	else if(val[y].S+val[u].S != w){
	    cout<<0;
	    exit(0);
	}
    }
}

pair<pll,ll> ed[maxn];

int main(){
    ll n,m;cin>>n>>m;
    REP(i,m){
	ll a,b,w;cin>>a>>b>>w;
	v[a].PB(MP(b,w));
	v[b].PB(MP(a,w));
	ed[i]=MP(MP(a,b),w);
    }
    val[1].F=1;
    dfs(1);
    if(ANS!=inf){
	FOR(i,1,n){
	    if((val[i].F*ANS+val[i].S)<=0){
		cout<<0;
		return 0;
	    }
	}
	REP(i,m){
	    ll a=ed[i].F.F,b=ed[i].F.S,w=ed[i].S;
	    ll A=val[a].F*ANS+val[a].S,B=val[b].F*ANS+val[b].S;
	    if(A+B != w){
		cout<<0;
		return 0;
	    }
	}
	cout<<1;
    }
    else{
	ll mn=inf,mx=0;// mx<ans<mn
	FOR(i,1,n){
	    if(val[i].F==-1){
		mn=min(mn,val[i].S);
	    }
	    else if(val[i].S<0){
		mx=max(mx,-val[i].S);
	    }
	}
	cout<<max(mn-mx-1,ll(0));
    }
}


Measured memory_bytes: 14848
#include <stdio.h>          // printf(), getchar(), scanf()
#include <ctype.h>          // isdigit()

#define MAX_N 100000

int
main(int argc, char** argv)
{
	int n, q;
	int a[MAX_N];
	long d;
	int c;
	int i;

	scanf("%d %d", &n, &q);
	c = getchar();
	for (i = 0; i < n; ++i)
	{
		while (c == ' ' || c == '\n')
			c = getchar();

		d = 0;
		while (isdigit(c))
		{
			d = d * 10 + c - '0';
			c = getchar();
		}

		a[i] = d;
	}

	for (i = 0; i < q; ++i)
	{
		long x;

		while (c == ' ' || c == '\n')
			c = getchar();

		d = 0;
		while (isdigit(c))
		{
			d = d * 10 + c - '0';
			c = getchar();
		}

		x = d;
		long count = 0;
		long sum = 0;
		int s, t;
		for (s = 0, t = 0; s < n; ++s)
		{
			sum += a[s];
			while (sum > x)
				sum -= a[t++];

			count += s - t + 1;
		}

		printf("%ld\n", count);
	}

	return 0;
}

Measured memory_bytes: 984