akhauriyash/Code-Regression huggingface dataset:
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
void solve()
{
    char c;
    cin>>c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') cout<<"vowel";
    else cout<<"consonant";
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		boolean bool;
		String str[] = null;
		
		while(sc.hasNext()){
			str=sc.nextLine().split(" ");
			bool=false;
			for(int k=0;k<26;k++){
				for(int i=0;i<str.length;i++){
					char ch[]=str[i].toCharArray();
					for(int j=0;j<ch.length;j++){
						if(Character.isLowerCase(ch[j])){//
							ch[j]=(char)((ch[j]-'a'+1)%26+'a');
						//                    	 ch[j]=(char)((ch[j]+1)%26+'a');  
							//                    	 System.out.println(k+" "+ch[j]+" "+(int)ch[j]);
						}
					}//for j
					str[i]=new String(ch);

					if(str[i].equals("the")||str[i].equals("this")||str[i].equals("that"))
						bool=true;
				}//for i
				if(bool) break;
			}//for k
			boolean f=true;
			for(int i=0;i<str.length;i++){
				if(!f)System.out.print(" ");
				f=false;
				System.out.print(str[i]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 17408
#include <iostream>
#include <vector>
using namespace std;
int main(){
	vector<int> a;
	int in;
	while(cin>>in,in){
		a.push_back(in);
	}
	int no = 1;
	for(auto it : a){
		cout << "Case " << no << ": " << it << endl;
		no++;
	}
return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {

	int N;int ans=0;int candy1[100]={};int candy2[100]={};
	cin >> N;
	
	for(int i=0;i<N;i++){
	        cin >> candy1[i];
	        if(i!=0)candy1[i]+=candy1[i-1];
	}
		for(int i=0;i<N;i++){
	        cin >> candy2[i];
	        if(i!=0)candy2[i]+=candy2[i-1];
	}
    
    for(int i=0;i<N;i++){
        ans=max(ans,candy1[i]+candy2[N-1]-candy2[i-1]);
        if(i==0)ans=max(ans,candy1[i]+candy2[N-1]);
    }
	
	if(N==1)ans=candy1[0]+candy2[0];
	
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, k  = map(int, input().split())
an = list(map(int, input().split()))
bn = [-1]*(n+1)

now=1
bn[1]=0
for i in range(1, k+1):
 #   print(bn)
    now = an[now-1]
    if bn[now] >0:
        rp =i-bn[now]
        p= (k-i)%rp
        for j in range(p):
            now = an[now-1]
        print(now)
        exit(0)
    bn[now]=i
print(now)

Measured memory_bytes: 32136
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

double dp[105][105];
int n;
vi t(102);
vi v(102);

double d(int i,int k,int j) {
  int tt = t.at(i+1)-t.at(i);
  double S;
  double vv=(double)v.at(i+1);
  if(dp[i][k] == 0 and !(i==0 and k==0)) return 0;
  if(vv<j) return 0;
  if(abs(j-k)>tt) return 0;
  if(k>vv) return 0;
  if(2*vv-(k+j)<=tt) {

    S = ((vv-k)*(vv+k)+(vv-j)*(vv+j))/2.0 + vv*(tt-(vv-k)-(vv-j));
  } else {
    double a = (tt+(j-k))/2.0;
    S = a*k+(a*a)/2.0+((a-j+k)*(a-j+k))/2.0+j*(a-j+k);
  }
  return S+dp[i][k];
}

int main() {
  cin >> n;
  int sum = 0;
  orep(i,n) {
    int tmp;
    cin >> tmp;
    sum+=tmp;
    t.at(i) = sum;
  }
  orep(i,n) cin >> v.at(i);

  rep(i,n) rep(j,101) {
    rep(k,101) dp[i+1][j] = max(dp[i+1][j],d(i,k,j));
  }

  fcout << dp[n][0] << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int a[3];
int main(){
	for(int i=0;i<3;i++) scanf("%d", &a[i]);
	sort(a, a+3);
	int sum = a[2]*10 + a[1] + a[0];
	printf("%d\n", sum);
}

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

int gcd(long long int x, long long int y){
    long long r;
    if(x < y) swap(x,y);

    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main(){
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long g = gcd(c,d);
    long long x, y, p;
    p = a-1;
    x = b - (b / c + b / d - b / (c*d / g));
    y = p - (p / c + p / d - p / (c*d / g));
    cout << x - y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, x) for (ll i = 0; i < (x); i++)

using namespace std;
typedef long long int ll;
template<typename T>
using reversed_priority_queue = \
    std::priority_queue<T, std::vector<T>, std::greater<T> >;

const ll INF = 1e16;
ll Y, X, K;
ll sx, sy, gx, gy;
vector<vector<vector<ll>>> dp; // dp[y][x][dir]
vector<string> s;

ll dy[] = {0, -1, 0, 1};
ll dx[] = {-1, 0, 1, 0};

int main(void) {
  // input
  cin >> Y >> X >> K;
  cin >> sy >> sx >> gy >> gx;
  sx--, sy--, gx--, gy--;
  s.resize(Y);
  rep(y, Y)
    cin >> s[y];

  // init dp
  dp.resize(Y, vector<vector<ll>>(X, vector<ll>(4, INF)));

  // dijkstra
  typedef tuple<ll, ll, ll, ll> T;
  reversed_priority_queue<T> q; // {cost, y, x, dir}
  rep(dir, 4)
    q.emplace(0, sy, sx, dir);
  while (!q.empty()) {
    auto [cost, y, x, dir] = q.top();
    q.pop();
    // printf("cost=%lld y=%lld x=%lld dir=%lld\n", cost ,y, x, dir);
    if (y < 0 || y >= Y || x < 0 || x >= X) continue;
    if (dir < 0 || dir >= 4) continue;
    if (dp[y][x][dir] <= cost) continue;
    if (s[y][x] == '@') continue;
    dp[y][x][dir] = cost;
    // 向きを変える
    rep(ndir, 4) {
      q.emplace(((cost + K - 1) / K) * K, y, x, ndir);
    }
    // その方向に進む
    ll nx = x + dx[dir], ny = y + dy[dir];
    q.emplace(cost + 1, ny, nx, dir);
  }
  ll ans = INF;
  rep(dir, 4) {
    if (dp[gy][gx][dir] == INF)
      continue;
    auto cost = (dp[gy][gx][dir] + K - 1) / K;
    ans = min(ans, cost);
  }

  if (ans == INF)
    ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 144952
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
const int INF = 100000000, mod = 1000000007;
using namespace std;

int main() {
    int n, fourcount = 0, twocount=0, oddcount = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        if (tmp % 4 == 0) fourcount++;
        else if (tmp % 2 == 0) twocount++;
        else oddcount++;
    }
    if (twocount == 0) {
        if (fourcount + 1 < oddcount) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    else {
        if (fourcount < oddcount) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm> // sort
#include <map>       // pair
#include <vector>
using namespace std;

#define REP(a,b) for(int i =(a);i < (b);i++)
#define FOR(n) for(int i = 0; i<(n); i++)
#define COUT(c)  cout<<(c)<<endl


const int INF = 100100100;
const int MOD = (int)1e9 +7;
const double EPS = 1e-9; 

typedef long long int ll;

//char in[120];
//ex. pair
//pair<pair<string,int>,int> p[110];

int main(){
    ll n,ret=0,mini;cin>>n;
    vector<ll> c(5,0);
    cin >>c[0]>>c[1]>>c[2]>>c[3]>>c[4];
    mini =c[0];
    for(int i=0;i<c.size();i++){
        mini = min(mini,c[i]);
    }
    int t=((n%mini)==0?0:1);
    cout << 4 + (n/mini +t)<<endl;
    return 0;    
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
	int n,a[200],i,cnt=0,tf=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	while(1)
	{
		for(i=0;i<n;i++)
		{
			if(a[i]%2!=0)
			{
				tf=1;
			}
		}
		if(tf==1)
			break;
		for(i=0;i<n;i++)
		{
			a[i]/=2;
		}
		cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int W = sc.nextInt();
		if (S <= W) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}
		sc.close();
	}
}


Measured memory_bytes: 35500
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

const int NUM = 1000000007;

int main() {
	int n; cin >> n;
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		mp[a]++;
	}
	if (n % 2 == 0) {
		for (int i = 1; i < n; i += 2) {
			if (mp[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
		long long ans = 1;
		for (int i = 0; i < n / 2; i++) {
			ans *= 2;
			ans %= NUM;
		}
		cout << ans << endl;
		return 0;
	}
	else {
		if (mp[0] != 1) {
			cout << 0 << endl;
			return 0;
		}
		for (int i = 2; i < n; i += 2) {
			if (mp[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
		long long ans = 1;
		for (int i = 0; i < (n - 1) / 2; i++) {
			ans *= 2;
			ans %= NUM;
		}
		cout << ans << endl;
		return 0;
	}	
	return 0;
}

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

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

  ll N; cin >> N;
  ll W; cin >> W;
  vector<ll> w(N), v(N);
  for (ll i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  vector<ll> dp(W + 1, 0), dp2(W + 1, 0);
  for (ll i = 0; i < N; i++) {
    for (ll j = w[i]; j <= W; j++) {
      dp[j] = max(dp2[j], dp2[j - w[i]] + v[i]);
    }
    dp2 = dp;
  }
  cout << dp[W] << '\n';
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    string s; cin >> s;
    ll n=0,S=0,w=0,e=0;
    rep(i,s.size()){
        if(s[i] == 'N') n++;
        else if(s[i] == 'S') S++;
        else if(s[i] == 'W') w++;
        else e++;
    }
    bool flag = true;
    if(n>0) if(S==0) flag = false;
    if(S>0) if(n==0) flag = false;
    if(w>0) if(e==0) flag = false;
    if(e>0) if(w==0) flag = false;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

void ask(int x, string& str)
{
	cout << x << endl;
	cin >> str;
	if (str == "Vacant") exit(0);
}

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

    string sl, sr;
    int l = 0, r = N-1;
    ask(0, sl);

    while (r > l) {
		int m = (l + r + 1) / 2;
        string ver;
        ask(m, ver);

        bool onLeft = 0;
        if ((m - l) % 2 == 0 && ver != sl) onLeft = 1;
        if ((m - l) % 2 == 1 && ver == sl) onLeft = 1;

		if (onLeft) r = m-1;
		else l = m, sl = ver;
    }
    ask(l, sl);
}


Measured memory_bytes: 880
#include<stdio.h>
int main(){
  int a, b;
  double s, n=3.305785;
  scanf( "%d %d" ,&a ,&b);  /*土地の縦と横の入力*/
  s=(a*b)/n;     /*土地の坪平均を求める*/
  printf("%lf\n",s);   
  return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T; cin >> S >> T;
  cout << T << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
//#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

int32_t main()
{
    io
 int n;cin>>n;
 vector<int>a(n);int sum=0;int tt=0;
for(int i=0;i<n;i++)cin>>a[i];vector<int>suff(n,0);
  for(int i=n-1;i>=0;i--)
  {
    if(i==n-1)
    {
      suff[i]=a[i];
    }
    else
    {
      suff[i]=(suff[i+1]%mod+a[i]%mod)%mod;
    }
  }
  int ans=0;
  for(int i=0;i<n-1;i++)
  {
      ans+=(a[i]%mod*suff[i+1]%mod)%mod;
      ans%=mod;
  }
  cout<<ans<<endl;


    
}

Measured memory_bytes: 6348
#include<stdio.h>
#include<string.h>
int main(){
char S[100];

  scanf("%s",&S);
  if(!strcmp(S,"A")){
    printf("T");}
   else if(!strcmp(S,"T")){
    printf("A");}
     else if(!strcmp(S,"C")){
    printf("G");}
     else if(!strcmp(S,"G")){
    printf("C");}
 
return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    long long x,y,z;
    int n,count;
    scanf("%d",&n);
    if(n==0){
        printf("2\n");
        return 0;
    }
    if(n==1){
        printf("1\n");
        return 0;
    }
    x=2;
    y=1;
    z=x+y;
    count=2;
    while(1){
        if(n==count){
            break;
        }
        count++;
        x=y;
        y=z;
        z=x+y;
    }
    printf("%lld\n",z);
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << a[K-1] << endl;
}

Measured memory_bytes: 888
n = int(input())
p = list(map(int, input().split()))
l = list(range(1,(n+1)))

if p == l:
    ans = "YES"
cnt = 0
for i in range(n):
    if p[i] != l[i]:
        if p[p[i]-1] == l[i]: cnt += 1
        else:
            ans = "NO"
            break
if cnt > 0:
    print("YES" if cnt//2 == 1 else "NO")
else:
    print(ans)

Measured memory_bytes: 9200
//https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_b
//B - Exactly N points
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;    
    ll sum=0;
    ll cnt=0;
    FOR(i,1,N+1){
        sum+=i;
        if(sum>=N) {
            cnt=i;
            break;
        }
    }
    ll d=sum-N;
    FOR(i,1,cnt+1){
        if (d!=i) cout<<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;


ll n, m;


int main() {
	cin >> n >> m;
	vector< vector<ll> >v(n,vector<ll>(3,0));
	rep(i, 0, n) {
		cin >> v[i][0] >> v[i][1] >> v[i][2];
	}


	ll li[2] = { -1,1 };
	ll ans = -inf;
	rep(i, 0, 2) {
		rep(j, 0, 2) {
			rep(k, 0, 2) {
				vector<ll>P;
				ll temp = 0;
				rep(l, 0, n) {
					P.push_back(li[i]*v[l][0]+li[j]*v[l][1]+li[k]*v[l][2]);
				}
				sort(P.begin(), P.end());
				reverse(P.begin(), P.end());
				rep(s, 0, m) {
					temp += P[s];
				}
				ans = max(ans,temp);
			}
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
import fractions

A,B,C,D=map(int,input().split())
E=C*D//fractions.gcd(C,D)
C1 = (A-1)//C
D1 = (A-1)//D
E1 = (A-1)//E
C2 = B//C
D2 = B//D
E2 = B//E

#1-Aまでの数からC or Dで割り切れる数の個数
W1 = C1 + D1 - E1

#1-Bまでの数からC or Dで割り切れる数の個数
W2 = C2 + D2 - E2

#A-Bまでの数からC or Dで割り切れる数の個数
W = W2 - W1

print(B-(A-1)-W)

Measured memory_bytes: 5076
#include<stdio.h>

int main(){
    int love[4][3][10]={{{}}};
    int b,f,r,v;
    int i,j,k;
    int n;
    scanf("%d",&n);

    for (i=0;i<n;++i){
        scanf("%d%d%d%d",&b,&f,&r,&v);
        love[b-1][f-1][r-1]+=v;
    }

    for(i=0;i<4;++i){
        for(j=0;j<3;++j){
            for(k=0;k<10;++k){
                printf(" %d",love[i][j][k]);
            }
            printf("\n");
        }
        if(i!=3)printf("####################\n");
    }
    return 0;
}


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

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

using namespace std;

int main(){
  char a,b;
  cin>>a>>b;
  
  if(a=='H'){
    cout<<b;
  }else{
    if(b=='H'){
      cout<<'D';
    }else{
      cout<<'H';
    }
    
  }
  return 0;
}


Measured memory_bytes: 256
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int s, w;
        cin >> s >> w;

        if(s <= w)
            cout << "unsafe\n";
        else
            cout << "safe\n";
        
    }
    
    return 0;
}



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

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

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  cout << (n % 1000 == 0 ? 0 : 1000 - (n % 1000)) << endl;
}

Measured memory_bytes: 3632
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def f(S, start):
    H = len(S)
    W = len(S[0])
    stack = [start]
    closed = set()
    r = 0
    while stack:
        next_stack = []
        for s in stack:
            if s in closed:
                continue
            closed.add(s)
            for d in (-1, 1):
                for p in ((s[0] + d, s[1]), (s[0], s[1] + d)):
                    if p in closed:
                        continue
                    if p[0] < 0 or H <= p[0] or p[1] < 0 or W <= p[1]:
                        continue
                    if S[p[0]][p[1]] == "#":
                        continue
                    next_stack.append(p)
        stack = next_stack
        r += 1
    return r - 1


def main():
    H, W = read_values()
    S = [input() for _ in range(H)]

    res = 0
    for h in range(H):
        for w in range(W):
            if S[h][w] == "#":
                continue
            res = max(res, f(S, (h, w)))
    print(res)

        
if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>
#include <string.h>
#include <algorithm>
//#include <bits/stdc++.h>
#include    <vector>
#define INF 999999999
# include <cstdio>
# include <cstdlib>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int n ,k ,num=0, fa =0;
int aaa[1000000];
int cmd (int a , int b){
    return a>b;
}
int main(){
   cin >>n >>k;
   for(int i=0;i<n;i++){
        cin >>aaa[i];
   }
   stable_sort(aaa,aaa+n,cmd);
   for(int  i=0;i<k;i++){
        num+=aaa[i];
   }
   cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
struct SegTree {
    int N;
    vector<int> A;
    SegTree(int n) {
        N = 1; while (N < n) N *= 2; A.resize(2 * N);
    }
    void set(int idx, int val) {
        idx += N; A[idx] = val; idx /= 2;
        while (idx > 0) {
            A[idx] = max(A[2*idx+0], A[2*idx+1]);
            idx /= 2;
        }
    }
    int query(int L, int R) {
        int ans = 0;
        L += N, R += N;
        while (L < R) {
            if (L & 1) ans = max(ans, A[L++]);
            if (R & 1) ans = max(ans, A[--R]);
            L /= 2, R /= 2;
        }
        return ans;
    }
};
int main() {
    int N, K, C; cin >> N >> K >> C;
    string S; cin >> S;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        if (i - 1 >= 0) A[i] = A[i - 1];
        if (S[i] == 'o') A[i] = max(A[i], (i - C - 1 >= 0 ? A[i - C - 1] : 0) + 1);
    }
    for (int i = N - 1; i >= 0; i--) {
        if (i + 1 < N) B[i] = B[i + 1];
        if (S[i] == 'o') B[i] = max(B[i], (i + C + 1 < N ? B[i + C + 1] : 0) + 1);
    }
    SegTree st(N + C);
    for (int i = 0; i < N + C; i++) {
        st.set(i, (i - C - 1 >= 0 ? A[i - C - 1] : 0) + (i < N ? B[i] : 0));
    }
    if (C == 0) {
        int cnt = 0;
        for (char c : S) if (c == 'o') cnt++;
        if (cnt == K) {
            for (int i = 0; i < N; i++) if (S[i] == 'o') cout << i + 1 << '\n';
        }
    } else {
        for (int i = 0; i < N; i++) {
            if (st.query(i + 1, i + C + 1) < K) cout << i + 1 << '\n';
        }
    }
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}



Measured memory_bytes: 3132
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var s = next(1);
  if(s.length % 2)return "No";
  for(var i = 0; i < s.length; i+=2){
    if(s[i] !== "h" || s[i+1] !== "i")return "No";
  }
  return "Yes";
}

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  char *s;
  string S;
  cin >> S;

  s = (char*) malloc(sizeof(char)*S.length());
  reverse(S.begin(),S.end());

  char* p=s+S.length();
  sprintf(s,"%s", S.c_str());

  while(s<p){
    if(strncmp(s,"maerd",5)==0) s+=5;
    else if(strncmp(s, "remaerd",7)==0) s+=7;
    else if(strncmp(s, "esare",5)==0) s+=5;
    else if(strncmp(s, "resare",6)==0) s+=6;
    else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 512
n = int(input())
A = list(map(int, input().split()))

X = A[0:n]
S = sum(X)
import heapq
heapq.heapify(X)
L = [0]*(n+1)
L[0] = S
for k in range(n, 2*n):
    s = heapq.heappop(X)
    t = A[k]
    S += max(s, t) - s
    heapq.heappush(X, max(s, t))
    L[k-n+1] = S

Y = A[2*n:3*n]
T = sum(Y)
import heapq
Y = [(-1)*y for y in Y]
heapq.heapify(Y)
R = [0]*(n+1)
R[-1] = T
for k in reversed(range(n, 2*n)):
    s = heapq.heappop(Y)
    t = -A[k]
    T -= max(s, t) - s
    heapq.heappush(Y, max(s, t))
    R[k-n] = T

ans = -float('inf')
for i in range(n+1):
    ans = max(ans, L[i]-R[i])
print(ans)


Measured memory_bytes: 122768
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    VL a(n);
    REP(i,n)cin>>a[i];

    LL ans = 0;
    map<LL,LL> cnt;
    REP(i,n){
        LL k = a[i] - (i + 1);
        LL t = - a[i] - (i + 1);
        ans += cnt[k];
        cnt[t] = cnt[t] + 1;
    }
    PUTS(ans);
}

//i番目の人の身長がa[i]のとき、
//a[i] + a[j] == i - j | 1 < j < i
//a[i] - i == - a[j] - j


Measured memory_bytes: 27392
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,k;cin >> n >> k;
    int a[n];
    rep(i,n)cin >> a[i];
    int ans = 0;
    rep(i,n)ans += (a[i] >= k);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4400
n,m = map(int, input().split())
H = list(map(int, input().split()))
g = [1]*n

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a]<H[b]:
        g[a] = 0
    elif H[a]>H[b]:
        g[b] = 0
    else:
        g[a] = g[b] = 0
print(sum(g))

Measured memory_bytes: 20052
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
////////////////////////////////////////////////////////////

signed main() {
  int x;
  cin>>x;
  int amari=x%11;
  if(amari>6)cout<<x/11*2+2;
  if(amari==0)cout<<x/11*2;
  else if(amari<=6)cout<<x/11*2+1;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans = "";
    int dx = tx - sx;
    int dy = ty - sy;
    rep(i, dy) ans += 'U';
    rep(i, dx) ans += 'R';
    rep(i, dy) ans += 'D';
    rep(i, dx) ans += 'L';
    ans += 'L';
    rep(i, dy+1) ans += 'U';
    rep(i, dx+1) ans += 'R';
    ans += 'D';
    ans += 'R';
    rep(i, dy+1) ans += 'D';
    rep(i, dx+1) ans += 'L';
    ans += 'U';
    
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

const ll MOD = ((ll)1e9) + 7;

const int MAXN = 1e5 + 1;
ll ans[MAXN], b[MAXN];

int main() {
	ios_base::sync_with_stdio(0);
	
	int n, m;
	cin >> n >> m;
	ans[0] = 1;
	int j = 1;
	for(int i = 0; i < m; i++) {
		int a;
		cin >> a;
		b[a] = 1;
	}
	ans[1] = 1-b[1];
	for(int k = 1; k <= n; k++) {
		if(b[k]) continue;
		ans[k] = (ans[k-1] + ans[k-2]) % MOD;
	}
	
	cout << ans[n] << '\n';
	
	return 0;
}

Measured memory_bytes: 1792
n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
	x=int(input())
	l.append(x)
def tet(x):
	s=""
	for i in range(n):
		if x%4==0:
			s+="0"
		elif x%4==1:
			s+="1"
		elif x%4==2:
			s+="2"
		else:
			s+="3"
		x//=4
	return s[::-1]
ans=10**25
for i in range(4**n):
	q=tet(i)
	A=B=C=0
	AA=BB=CC=0
	for j in range(n):
		if q[j]=="0":
			A+=l[j]
			AA+=1
		elif q[j]=="1":
			B+=l[j]
			BB+=1
		elif q[j]=="2":
			C+=l[j]
			CC+=1
	if AA==0 or BB==0 or CC==0:
		continue
	cnt=0
	cnt+=(AA+BB+CC-3)*10
	cnt+=abs(A-a)+abs(B-b)+abs(C-c)
	ans=min(cnt,ans)
print(ans)




Measured memory_bytes: 59996
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int n = ni();

        long MOD = 1000000007;
        long ans = 1;

        for (int i = 1; i <= n; i++) {
            ans = (ans * i) % MOD;
        }

        out.println(ans);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

void prians(bool answer) {
  if(answer)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}

long long n, d;
long long a[300005] = {0};
long long ans = 0;

int main() {
  cin >> n >> d;
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) ans ^= (a[i] - 1) % (d + 1);
  prians(ans != 0);
  return 0;
}


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

vector<int> cp;
int N, K;

void dfs(Graph& _G, int v, int p){
  int colorOption;
  if(p == -1){
    colorOption = K-1;
  } else {
    colorOption = K-2;
  }
  for(auto nv: _G[v]){
    if(nv == p)continue;
    cp[nv] = colorOption;
    colorOption--;
    dfs(_G, nv,v);
  }
}


int main(){

  cin >> N >> K;

  Graph G(N);
  for(int i= 0; i < N-1; i++){
    int a, b; cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }


  cp.resize(N);
  cp[0] = K;

  dfs(G, 0, -1);

  ll counter=1;
  for(int i = 0; i < N; i++){
    counter *=cp[i];
    counter %= 1000000007;
  }

  cout << counter << endl;

  return 0;
}



Measured memory_bytes: 10752
#include<iostream>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<stack>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
#include<cstdlib>
#include<typeinfo>
#include<sstream>
#include<list>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fori(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
int stringInt(string a)
{
	return atoi(a.c_str());
}
string intString(int a)
{
	stringstream ss;
	ss<<a;
	return ss.str();
}
vector<int> SieveOfEratosthenes(int x)
{
	vector<int> a;
	vector<int> b(x+1,0);
	for(int i=2;i<=x;i++)
	{
		if(b[i]==0)
		{
			a.push_back(i);
			for(int l=i;l<=x;l+=i)
			{
				b[l]=1;
			}
		}
	}
	return a;
}

struct node
{
	int p,l,r;
};
node a[100];

void pr(int f)
{
	if(f==-1)return;
	cout<<" "<<f;
	pr(a[f].l);
	pr(a[f].r);
	return;
}
void in(int f)
{
	if(f==-1)return ;
	in(a[f].l);
	cout<<" "<<f;
	in(a[f].r);
	return ;
}
void po(int f)
{
	if(f==-1)return ;
	po(a[f].l);
	po(a[f].r);
	cout<<" "<<f;
	return ;
}

int main()
{
	int n;cin>>n;
	rep(i,n)a[i].p=a[i].r=a[i].l=-1;
	rep(i,n)
	{
		int id,L,R;
		cin>>id>>L>>R;
		a[id].l=L;
		a[id].r=R;
		if(L!=-1)a[L].p=id;
		if(R!=-1)a[R].p=id;
	}
	int ro;
	rep(i,n)if(a[i].p==-1)ro=i;

	cout<<"Preorder"<<endl;
	pr(ro);
	cout<<endl;
	cout<<"Inorder"<<endl;
	in(ro);
	cout<<endl;
	cout<<"Postorder"<<endl;
	po(ro);
	cout<<endl;


}

Measured memory_bytes: 1176
from collections import defaultdict
n = int(input())
p = [[int(i) for i in input().split()] for i in range(n)]
x,ans = defaultdict(int),0
for i in range(n):
    for j in range(i+1,n):
        a,b = p[i][0]-p[j][0],p[i][1]-p[j][1]
        x[(a,b)]+=1
        x[(-a,-b)]+=1
for i in x.values(): ans = max(ans,i)
print(n-ans)

Measured memory_bytes: 3828
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>//"geometry.cpp"
#include <iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
#include <queue>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <algorithm>//"lower_bound(it,it,v)", "next_permutation(a,a+n)"
#include <functional>//"greater<T>" Ex. sort(a,a+n,greater<int>());
#include <cmath>//"abs", "sqrt"
using namespace std;
#define pb push_back
#define fi first
#define sc second
#define mp make_pair
#define is insert
typedef pair<int,int> pii;//Add other types in the same way.

int main(){
	int n;
	long long s=0,a[200000];
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a[i];
		s+=a[i];
	}
	long long t=a[0],ans=abs(t-(s-t));
	for(int i=1;i<n-1;++i){
		t+=a[i];
		ans=min(ans,abs(t-(s-t)));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
N = int(input())
S = list(input())
jud = True
if N%2 == 1:
  print('No')
else:
  for i in range(N//2):
    if S[i] != S[i+(N//2)]:
      jud = False
  if jud:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 3060
public partial class IntroductionToProgramming{
	public static void Main(){
		string[] line = System.Console.ReadLine().Split(' ');
		int a = int.Parse(line[0]);
		int b = int.Parse(line[2]);
		string op = line[1];

		while (op != "?")
		{
			int s = 0;
			switch (op)
			{
				case "+":
					s = a + b;
					break;
				case "-":
					s = a - b;
					break;
				case "*":
					s = a * b;
					break;
				case "/":
					s = a / b;
					break;
			}
			System.Console.WriteLine(s.ToString());
			
			string[] line2 = System.Console.ReadLine().Split(' ');
			a = int.Parse(line2[0]);
			b = int.Parse(line2[2]);
			op = line2[1];
		}
	}
}

Measured memory_bytes: 5704
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=500+50;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,m,dis[N][N],sq[N][N];
const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
pii pos[N*N];

bool valid(int x,int y) {return ((x>=1) && (x<=n) && (y>=1) && (y<=n));}

void dfs(int x,int y)
{
    rep(i,0,3)
    {
        int nx=x+dx[i],ny=y+dy[i];
        if ((valid(nx,ny)) && (dis[nx][ny]>dis[x][y]+sq[x][y]))
        {
            dis[nx][ny]=dis[x][y]+sq[x][y];
            dfs(nx,ny);
        }
    }
}

int main()
{
    n=read();
    int tot=0,ans=0;
    rep(i,1,n) rep(j,1,n) 
    {
        pos[++tot]=mkp(i,j);sq[i][j]=1;
        dis[i][j]=min(min(i-1,n-i),min(j-1,n-j));
    }
    rep(i,1,n*n)
    {
        int p=read(),x=pos[p].fir,y=pos[p].sec;
        sq[x][y]=0;ans+=dis[x][y];dfs(x,y);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 23000
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

bool is_palindrome(const string& S)
{
	return equal(S.begin(), S.end(), S.rbegin());
}

bool is_strong_palindrome(const string& S)
{
	const int N = S.size();
	string X = S.substr(0, (N - 1) / 2);
	string Y = S.substr((N + 3) / 2 - 1);
	return is_palindrome(S) && is_palindrome(X) && is_palindrome(Y);
}

int main()
{
	string S;
	cin >> S;
	if (is_strong_palindrome(S)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

count = 0
for i in range(N):
    A = list(map(int, input().split()))
    a_b = [b*a for b, a in zip(B, A)]
    if sum(a_b) + C > 0:
        count += 1
print(count)

Measured memory_bytes: 38512
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>
#include<bitset>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

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

  int h,w,k;
  cin>>h>>w>>k;
  vector2d<int> chocolate(h,vector<int>(w,0));
  for(int i=0;i<h;i++){
    string s;
    cin>>s;
    for(int j=0;j<w;j++){
      if(s[j]=='1'){
        chocolate[i][j]=1;
      }else{
        chocolate[i][j]=0;
      }
    }
  }

  int result=INT32_MAX;

  for(uint div=0;div<pow(2,h-1);div++){
    bitset<10> div_bs(div);
    int h_united=div_bs.count()+1;
    vector2d<int> choco_united(h_united,vector<int>(w,0));

    int r_united=0;
    for(int r=0;r<h;r++){
      for(int c=0;c<w;c++){
        choco_united[r_united][c]+=chocolate[r][c];
      }
      if(div_bs[r]){
        r_united++;
      }
    }

    int tmp_result=div_bs.count();
    vector<int> white_count(h_united);
    bool can_divide=true;
    for(int c=0;c<w;c++){
      for(int r=0;r<h_united;r++){
        white_count[r]+=choco_united[r][c];
        if(white_count[r]>k){
          can_divide=false;
          break;
        }
      }
      if(c+1<w){
        bool divide_here=false;
        for(int r=0;r<h_united;r++){
          if(white_count[r]+choco_united[r][c+1]>k){
            divide_here=true;
          }
        }
        if(divide_here){
          for(int r=0;r<h_united;r++){
            white_count[r]=0;
          }
          tmp_result++;
        }
      }
      if(!can_divide){
        break;
      }
    }
    if(can_divide){
      UpdateMin(result,tmp_result);
    }
  }
  cout<<result<<endl;

  return 0;
}




Measured memory_bytes: 512
#include<bits/stdc++.h>
#define f(i,s,v) for(int i=(int)s;i<(int)v;++i)
#define rf(i,s,v) for(int i=(int)s-1;i>(int)v;--i)
#define pb push_back
#define all(v) ((v.begin()),(v.end()))
#define memset(c, value) memset(c, (int)value, sizeof(c))
using namespace std;
typedef long long ll;
const int oo = 1e9;
const ll MOD =1e9+7;
void fast(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n, k;
int h[100005];
bool valid (int r,int c){
    return (r < n && r >= 0 && c >= 0 && c < n);
}
int row[] = {0 , 1 , 0, -1};
int column[] = {1 , 0, -1, 0};
int vis[100002];
int dp(int i){
    if(i == n-1)
        return 0;
    int &ret = vis[i];
    if(ret != -1)
        return ret;

    int path1 = abs(h[i]-h[i+1]) + dp(i+1);
    f(j, 2, k){
        if( i+j < n)
            path1 = min(path1, abs(h[i]-h[i+j]) + dp(i+j));
        else
            break;
    }
    return ret = path1;
}

int main()
{
    fast();
    memset(vis, -1);
    cin>>n>>k;
    ++k;
    f(i,0,n)
        cin>>h[i];
    cout<<dp(0)<<'\n';
    return 0;
}


Measured memory_bytes: 12116
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            :oyhhhhhhyo:    
#define next         .sdNNNmNNNNNNNmds. 
#define y0          -hNNNNy`yNNNNNN`/Nh-
#define y1          mNNNNNd+dNNNNNN+sNNm
#define yn          mNNNNNNNNy--:smNNNms
#define tm          .+oooooosyysooooo+- 
#define read               :yhy/        
#define rank              :mNmo         
#define index              ... 
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int x = 1, ans = 0;
    while(x < b) {
        x += a - 1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256