akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<bits/stdc++.h>
#define MAX 3005
#define ll long long

using namespace std;

ll findit(ll arr[],int i,int j,ll dp[MAX][MAX])
{
    
   // pair<int,int> current=make_pair(i,j);
    
    if(dp[i][j]!=-1)
    {
        return dp[i][j];
    }
    
    
    if(i==j)
    {
        return arr[i];
    }
    
    if(j==i+1)
    {
      return max(arr[i],arr[j]);
    }
    
    ll way1=arr[i]+min( findit(arr,i+2,j,dp) ,findit(arr,i+1,j-1,dp)   );
    ll way2=arr[j]+min(findit(arr,i,j-2,dp) ,findit(arr,i+1,j-1,dp));
    
    
   dp[i][j]=max(way1,way2);
   return dp[i][j];
}


int main() 
{
  int n;
  cin>>n;
  ll arr[n];
 // map< pair<int,int> ,ll> v;
 ll dp[MAX][MAX];
 for(int i=0;i<MAX;i++)
 {
     for(int j=0;j<MAX;j++)
     {
         dp[i][j]=-1;
     }
 }
  ll total=0;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
      total=total+arr[i];
  }
  
  ll maxxget=findit(arr,0,n-1,dp);
  ll yget=total-maxxget;
  
  cout<<maxxget-yget;
  


	return 0;
}


Measured memory_bytes: 70912
import sys
input = sys.stdin.buffer.readline

def main():
    s=int(input())
    ans=0
    if s%10==7:
        ans=1
    if (s//10)%10==7:
        ans=1
    if s//100==7:
        ans=1
    if ans:
        print("Yes")
    else:
        print("No")

main()

Measured memory_bytes: 9168
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong(); // S piece
        long M = scan.nextLong(); // C piece
        
        if(N * 2  > M) {
            System.out.println(M / 2);
        } else {
            System.out.println(N + (M - N * 2) / 4);
        }
    }
}


Measured memory_bytes: 22736
#include <iostream>

using namespace std;

int main() 
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if(c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <math.h>

int main() {
	double x1, x2, y1, y2;
	double lain1, lain2;
	double lainxy;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

	lain1 = x1 - x2;
	lain2 = y1 - y2;
	lainxy = (lain1 * lain1) + (lain2 * lain2);

	lainxy = sqrt(lainxy);

	printf("%f\n" ,lainxy);

	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e5+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
struct edge{int t,ne;}e[N];
ll ans;
int head[N],cnt,cgood,n;
char s[N];
int good[N],mxd[N];
void adde(int a,int b){e[++cnt]=(edge){b,head[a]};head[a]=cnt;}
void dfs(int x,int f){
	good[x]=s[x]=='1';
	run(x)if(v!=f){dfs(v,x);good[x]+=good[v];gmax(mxd[x],mxd[v]+1);}
}
void gao(int x,int f,int upmxd){
	int l,r;
	if(s[x]=='1')l=0;else l=INF;
	int mx1=upmxd,mx2=0;
	if(cgood-good[x])gmin(l,upmxd);
	run(x)if(v!=f){
		gmax(mx2,mxd[v]+1);
		if(mx2>mx1)swap(mx1,mx2);
		if(good[v])gmin(l,mxd[v]+1);
	}
	r=min(mx1-1,mx2+1);
	ans+=max(0,r-l+1);
	run(x)if(v!=f){
		if(mxd[v]+1!=mx1)gao(v,x,mx1+1);else
			gao(v,x,mx2+1);
	}
}
int main(){
	read(n);
	re(i,1,n){
		int x,y;read(x,y);
		adde(x,y);adde(y,x);
	}
	scanf("%s",s+1);
	rep(i,1,n)if(s[i]=='1')cgood++;
	dfs(1,0);
	gao(1,0,0);
	cout<<ans+1<<endl;
}

Measured memory_bytes: 18816
#include <bits/stdc++.h>
#define N 1000000000000000
#define inf 10000000000000000
using namespace std;

typedef pair<int,int>P;
struct edge{
  int req;
  long long cost[2];
};
vector<edge> data[100005];
long long d[2][100005];
long long ans[100005];
long long n,m,t[2];
void dik(int check);

int main(){
  long long i,j,k;
  int a;
  cin >> n >> m >> t[0] >> t[1];
  for(i=0;i<m;++i){
    edge x;
    cin >> a >>x.req >> x.cost[0] >> x.cost[1];
    data[a].push_back(x);
    swap(a,x.req);
    data[a].push_back(x);
  }
  dik(0);
  dik(1);
  //cout << n <<" "<< d[1][1];
  /*for(j=0;j<2;++j){
    for(i=1;i<=n;++i)cout << d[j][i] <<" ";
    cout << endl;
    }*/
  ans[n+1]=inf;
  for(j=n;j>=1;--j)ans[j]=min(ans[j+1],d[0][j]+d[1][j]);
  for(i=1;i<=n;++i)cout << N-ans[i] << endl;
  return 0;
}

void dik(int check){
  priority_queue< P, vector<P> , greater<P> > qu;
  fill(d[check],d[check]+n+1,inf);
  d[check][t[check]]=0;
  qu.push(P(0,t[check]));
  while(!qu.empty()){
    P p = qu.top();
    qu.pop();
    int  v = p.second;
    if(d[check][v]<p.first)continue;
    for(int i=0;i<data[v].size();++i){
      edge e = data[v][i];
      if(d[check][e.req]>d[check][v]+e.cost[check]){
	d[check][e.req]=d[check][v]+e.cost[check];
	qu.push(P(d[check][e.req],e.req));
      }
    }
    
  }
}


Measured memory_bytes: 14820
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> strawberry(H, vector<char>(W));
    vector<vector<int>> ans(H, vector<int>(W, INF));
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> strawberry[i][j];
    vector<int> check(H, 0);
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) if (strawberry[i][j] == '#') check[i]++;
    int count = 1;
    for (int i = 0; i < H; i++) {
        if (check[i] == 0) continue;
        for (int j = 0; j < W; j++) {
            ans[i][j] = count;
            if (strawberry[i][j] == '#' && check[i] > 1) {
                count++;
                check[i]--;
            }
        }
        count++;
    }
    for (int i = 1; i < H; i++) {
        if (ans[i][0] == INF) copy(ans[i - 1].begin(), ans[i - 1].end(), ans[i].begin());
    }
    for (int i = H - 2; i >= 0; i--) {
        if (ans[i][0] == INF) copy(ans[i + 1].begin(), ans[i + 1].end(), ans[i].begin());
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << ans[i][j] << (j == W - 1 ? '\n' : ' ');
        }
    }
}


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

const int N = 100 * 1000 + 5;
int n, a[N], L[N], R[N];
char s[N];

int main()
{
    scanf("%s",s+1); n = strlen(s+1);
    for(int i=n; i>=1; --i) R[i] = (s[i] == 'R') ? R[i+1] : i;
    for(int i=1; i<=n; ++i) L[i] = (s[i] == 'L') ? L[i-1] : i;
    for(int i=1; i<=n; ++i) if (s[i] == 'R') {
        if ((R[i]-i) & 1) a[R[i]-1] += 1; else a[R[i]] += 1;
    } else {
        if ((i-L[i]) & 1) a[L[i]+1] += 1; else a[L[i]] += 1;
    }
    for(int i=1; i<=n; ++i) printf("%d ",a[i]);
}


Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
using namespace std;

int main() {
	char s[200010], t[200010];
	cin >> s >> t;
	int s_length = strlen(s);
	int t_length = strlen(t);
	sort(s, s + s_length);
	sort(t, t + t_length);
	int count = 1;
	vector<int>s_counts, t_counts;
	for (int i = 1; i < s_length; i++) {
		if (s[i - 1] == s[i]) {
			count++;
		}
		else {
			s_counts.push_back(count);
			count = 1;
		}
		if (i == s_length - 1) {
			s_counts.push_back(count);
			count = 1;
		}
	}
	for (int i = 1; i < t_length; i++) {
		if (t[i - 1] == t[i]) {
			count++;
		}
		else {
			t_counts.push_back(count);
			count = 1;
		}
		if (i == t_length - 1) {
			t_counts.push_back(count);
			count = 1;
		}
	}
	string ans = "Yes";
	sort(s_counts.begin(), s_counts.end());
	sort(t_counts.begin(), t_counts.end());
	if (s_counts.size() != t_counts.size()) {
		ans = "No";
	}
	else {
		for (int i = 0; i < s_counts.size(); i++) {
			if (s_counts[i] != t_counts[i]) {
				ans = "No";
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] B = new int[N-1];

    for (int i = 0; i < N-1 ; i++) {
      B[i]=sc.nextInt();
    }
    int ans = 0;
    ans += B[0];
    ans += B[N-2];
    for (int i = 0; i < N-2 ; i++) {
      ans += Math.min(B[i],B[i+1]);
    }

    System.out.println(ans);

  }



}


Measured memory_bytes: 21460
#include<stdio.h>
 
int main(void){
  long long int i,c,tmp;
  long long int N;
  scanf("%ld",&N);
  long long int A[N+1],B[N];
  for(i=0;i<N+1;i++){
    scanf("%ld",&A[i]);
  }
  for(i=0;i<N;i++){
    scanf("%ld",&B[i]);
  }  
  
  for(tmp=0,c=0,i=0;i<N;i++){
    if(A[i]+A[i+1] <= B[i]){
      c = c + A[i]+A[i+1];
      A[i+1] = 0;
    }else{     // A[i]+A[i+1] > B[i]
      if(A[i] < B[i]){
      	A[i+1] = A[i]+A[i+1] - B[i];
        c = c + B[i];
      }else{  // A[i] >= B[i]
        c = c + B[i];      
      }
    }
  }
  
  printf("%ld",c);
  
}

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

using namespace std;

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


int main() {

	ll a,b,n;
	cin>>a>>b>>n;

	cout<<min(n,b-1)*a/b<<endl;

	return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u==s) a--;
    if(u==t) b--;
    cout << a <<" "<< b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string s;
    getline(cin,s);
    for(int i=0;i<s.size();i++){
        char c=s[i];
        if('A'<=c&&c<='Z'){
            c=c+32;
        }
        else if('a'<=c&&c<='z'){
            c=c-32;
        }
        cout <<c;
    }
    cout << endl;
}


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

typedef long long ll;
string n, t ;


void answer(){
    int count = 0 ;
	cin >> n ;
	cin >> t;
	for ( int i = 0 ; i < n.length(); i++){
		if(n[i] != t[i]){
			count += 1;
			}	
		}
	cout << count ;
}

int main (){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	answer(); 
return 0 ;
}


Measured memory_bytes: 3788
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

long long pow_mod(long long x, long long n, long long mod_num) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) { res = (res * x) % mod_num; }
        x = (x * x) % mod_num;
        n = (n >> 1);
    }
    return res;
}

const int MAX_N = 100050;
const int POW_MAX = 18;
int N, L, Q;
int x[MAX_N], a[MAX_N], b[MAX_N];
const int MOD = 1000000007;

int can_go[POW_MAX][MAX_N];

int calc(int na, int nb) {
    if (nb <= can_go[0][na]) {
        return 1;
    } else {
        for (int p = 0; p < POW_MAX; p++) {
            if (can_go[p][na] < nb && nb <= can_go[p+1][na]) {
                return pow_mod(2, p, MOD) + calc(can_go[p][na], nb);
            }
        }
    }
}

int main(int argc, char **argv) {
    std::cin >> N;
    for (int i = 1; i <= N; i++) {
        std::cin >> x[i];
    }
    std::cin >> L;
    std::cin >> Q;
    for (int i = 1; i <= Q; i++) {
        std::cin >> a[i] >> b[i];
    }

    for (int i = 1; i <= N; i++) {
        if (x[N] - x[i] <= L) {
            can_go[0][i] = N;
        } else {
            int lb = i + 1;
            int ub = N;
            while (lb + 1 < ub) {
                int mid = (lb + ub) / 2;
                if (x[mid] - x[i] <= L) {
                    lb = mid;
                } else {
                    ub = mid;
                }
            }
            can_go[0][i] = lb;
        }
        //std::cout << 0 << " " << i << " " << can_go[0][i] << std::endl;
    }

    for (int p = 1; p < POW_MAX; p++) {
        for (int i = 1; i <= N; i++) {
            can_go[p][i] = can_go[p-1][can_go[p-1][i]];
            //std::cout << p << " " << i << " " << can_go[p][i] << std::endl;
        }
    }

    for (int i = 1; i <= Q; i++) {
        std::cout << calc(std::min(a[i], b[i]), std::max(a[i], b[i])) << std::endl;
    }
    
    return 0;
}

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

int main(){
	long long ans=1,even=0,odd=0;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(x%2==0)
			even++;
		else
			odd++;
	}
	for(int i=1;i<=n;i++){
		ans*=3;
	}
	ans-=(1<<even);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main(){
	int n,i;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(i=1;i<n;i++){
		if(a[i]==a[i+1]){
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 1024
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
def inpl(): return list(map(int, input().split()))

#### START
N = int(input())
h_H = int(N/2)
V = list(map(int,input().split()))
v1 = [i for i in V[::2]]
v2 = [i for i in V[1::2]]

c1 = collections.Counter(v1)
c2 = collections.Counter(v2)

# c1のベストを採択
best1 = h_H - c1.most_common()[0][1]

if c1.most_common()[0] != c2.most_common()[0]:
    best1 += h_H - c2.most_common()[0][1]
else:
    if len(c1) == 1:
      best1 += h_H
    else:
      best1 += h_H - c2.most_common()[1][1]

# c2のベストを採択
best2 = h_H - c2.most_common()[0][1]

if c1.most_common()[0] != c2.most_common()[0]:
    best2 += h_H - c1.most_common()[0][1]
else:
    if len(c2) == 1:
      best2 += h_H
    else:
      best2 += h_H - c1.most_common()[1][1]

print(min([best1, best2]))


Measured memory_bytes: 20696
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>


int descending_compare(const void *a, const void *b) {
	if (*(int*)a > *(int*)b) {
		return -1;
	}
	else if (*(int*)a == *(int*)b) {
		return 0;
	}
	else {
		return 1;
	}
}

int ascending_compare(const void *a, const void *b) {
	if (*(int*)a < *(int*)b) {
		return -1;
	}
	else if (*(int*)a == *(int*)b) {
		return 0;
	}
	else {
		return 1;
	}
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y) {
	if (y == 0) {
		return x;
	}
	else if (x > y) {
		return gcd(y, x % y);
	}
	else {
		return gcd(x, y % x);
	}
}



long long factorial(int x) {
	long long rtn = 1;
	int i;
	for (i = x; i > 1; i--) {
		rtn = (rtn*i);
	}
	return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

int main(void) {
	int n;
    int a;
    int cnt;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d", &a);
        if (a % 2 == 1){
            cnt++;
        }
    }

    if (cnt % 2 == 0){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 888
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a[]=new int[3];
		int b[]=new int[2];
		for(int i=0;i<3;i++){
			a[i]=sc.nextInt();
		}
		for(int i=0;i<2;i++){
			b[i]=sc.nextInt();
		}
		Arrays.sort(a);
		Arrays.sort(b);
		System.out.println(a[0]+b[0]-50);
	}
}

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

int main(){
  int N;
  vector<int> p(51);

  cin >> N;
  for (int i=0; i<N; i++) cin >> p[i];

  int cnt = 0;
  for (int i=0; i<N; i++){
    if (p[i] != i+1) cnt++;
  }

  if (cnt == 2 || cnt == 0){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

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

	string name;

	while (n >1) {
		int a = n % 26;
		if (a) {
			name += 'a' + a-1;
		}
		else {
			name += 'z';
			n--;
		}
		
		n /= 26;
		
	}
	if (n == 1) {
		name += 'a';
	}
	reverse(name.begin(), name.end());
	cout << name << endl;

	return 0;
}

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

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

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

    int count = 1;
    for(int i=1; i<n; i++){
        if(d[i] != d[i-1]) count += 1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define endl "\n"
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/any.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"");if(i>INF/2)cout<<"INF";else cout<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
inline lint mex(vector<lint> s){
    lint res=0;
    sort(all(s));
    while(binary_search(all(s),res))res++;
    return res;
}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
int main(){
    lint n;
    cin>>n;
    vec x(n);
    rep(i,n)cin>>x[i];
    lint l;
    cin>>l;
    mat par(n,vec(log2(n)+1));
    rep(i,n)par[i][0]=upper_bound(all(x),x[i]+l)-1-x.begin();
    repi(j,1,log2(n)+1)rep(i,n){
        par[i][j]=par[par[i][j-1]][j-1];
    }
    lint q;
    cin>>q;
    rep(i,q){
        lint l,r;
        cin>>l>>r;
        l--;r--;
        if(l>r)swap(l,r);
        lint cnt=0;
        while(1){
            auto itr=lower_bound(all(par[l]),r);
            if(itr==par[l].begin())break;
            cnt+=pow(2,itr-par[l].begin()-1);
            l=*(itr-1);
        }
        cout<<cnt+1<<endl;
    }
}

Measured memory_bytes: 18048
#include <stdio.h>
#include <string.h>

int main() {
	char s[101];
	scanf("%s", s);
	int list[26];
	for (int i = 0; i < 26; i++) list[i] = 0;
	for (int i = 0; i < strlen(s); i++) {
		list[s[i]-'a'] = 1;
	}
	char alphabet;
	int mincount = 100;
	char soriginal[101];
	strcpy(soriginal, s);
	for (int k = 0; k < 26; k++) {
		if(list[k] == 1) alphabet = (char)k + 'a';
		else continue;
		strcpy(s, soriginal);
		int count = 0;
		while(1) {
			// check
			char c = s[0];
			int endflag = 0;
			for (int i = 0; i < strlen(s); i++) {
				if(c != s[i]) endflag = 1;
			}
			if(endflag == 0) break;

			char ts[101];
			for (int i = 0; i < strlen(s); i++) {
				char first = s[i], second = s[i+1];
				if(second == '\0') {
					ts[i] = '\0';
					break;
				}else{
					if(first == alphabet || second == alphabet) {
						ts[i] = alphabet;
					}else{
						ts[i] = s[i];
					}
				}
			}
			strcpy(s, ts);
			count++;
			if(count > 1000) break;
		}
		if(mincount > count) mincount = count;
	}
	printf("%d\n", mincount);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    vector <long long> v;
    map<string, int> n;
    long long a,b,c,d=1,e=0,i,f=1000000000000000000,g=0,j,k=1,l=0,r=0,z,m,h,p[100001];
    string y,t,s,x;
    double q,u;
    cin>>a;
    for(i=1;i<=a;i++){
        cin>>p[i];
    }
    sort(p+1,p+a+1);
    if(p[1]==0){
        cout<<0;
        stop;
    }
    for(i=1;i<=a;i++){
        if(f/p[i]<d){
            cout<<-1;
            stop;
        }
        d*=p[i];
    }
    cout<<d;
}

Measured memory_bytes: 4408
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    int pcount = 0;
    int gcount = 0;

    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(pcount + 1 <= gcount){
            if(s[i] == 'g'){
                ans++;    
            }
            pcount++;
        } else {
            if(s[i] == 'p'){
                ans--;
            }
            gcount++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int h, w, k; cin >> h >> w >> k;
    vector<string> mat(h);
    rep(i, h) cin >> mat[i];
    
    int ans = 0;
    set<int> H, W;
    int cnt;
    rep(bit, 1<<h) {
        H.clear();
        rep(i, h) {
            if (bit&(1<<i)) H.insert(i);
        }
        rep(bit2, 1<<w) {
            W.clear(); cnt = 0;
            rep(j, w) {
                if (bit2&(1<<j)) W.insert(j);
            }
            rep(ii, h) rep(jj, w) {
                if (H.count(ii)>0||W.count(jj)>0) continue;
                if (mat[ii][jj]=='#') cnt++;
            }
            debug(bit, bit2);
            if (cnt==k) ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int N,K;
long long x[50],y[50];
long long sortX[50],sortY[50];
bool LargeThanK(int i,int j,int k,int l){
    int tmp=0;
    for(int t=0;t<N;t++){
        if(x[t]>=sortX[i] && x[t]<=sortX[j]){
            if(y[t]>=sortY[k] && y[t]<=sortY[l]){
                tmp++;
            }
        }
    }
    if(tmp>=K){
        return true;
    }else{
        return false;
    }
}

int main(){
    cin>>N>>K;
    for(int i=0;i<N;i++){
        cin>>x[i]>>y[i];
        sortX[i]=x[i];
        sortY[i]=y[i];
    }
    sort(sortX,sortX+N); sort(sortY,sortY+N);
    long long ans = 4*1e18+1;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            for(int k=0;k<N;k++){
                for(int l=k;l<N;l++){
                    if(LargeThanK(i,j,k,l)){
                        long long area=(sortX[j]-sortX[i])*(sortY[l]-sortY[k]);
                        ans=min(ans,area);
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, m = MAP()
submits = [[] for i in range(n)]
for i in range(m):
    p, S = input().split()
    p = int(p)
    submits[p-1].append(S)

ac = 0
wa = 0

for i in range(n):
    for j in range(len(submits[i])):
        if submits[i][j] == 'AC':
            ac += 1
            wa += len(submits[i][:j])
            break

print(str(ac) + ' ' + str(wa))

Measured memory_bytes: 80684
#include <cstdio>

const int MAXN = 100;

int ppow[MAXN];

int main() {
    int n;
    scanf("%d", &n);

    for (int i = 1; i <= n; i++) {
        int x = i;
        for (int j = 2; j * j <= i; j++) {
            while (x % j == 0) {
                ++ppow[j];
                x /= j;
            }
        }
        if (x > 1) ++ppow[x];
    }

    int ans = 0;
    for (int i = 2; i < MAXN; i++) if (ppow[i] >= 74) ++ans;

    for (int i = 2; i < MAXN; i++) if (ppow[i] >= 24) for (int j = 2; j < MAXN; j++) if (i != j && ppow[j] >= 2) ++ans;
    for (int i = 2; i < MAXN; i++) if (ppow[i] >= 14) for (int j = 2; j < MAXN; j++) if (i != j && ppow[j] >= 4) ++ans;

    for (int i = 2; i < MAXN; i++) if (ppow[i] >= 4) for (int j = 2; j < MAXN; j++) if (i != j && ppow[j] >= 2)
        for (int k = i + 1; k < MAXN; k++) if (k != j && ppow[k] >= 4) ++ans;

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

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int selectionSort(int matrix[], int N){

  int minj;
  int cnt=0;

  int temp;

  for(int i=0;i<N-1;i++){
    minj = i; 

    for(int j=i+1;j<N;j++){
      if(matrix[j] < matrix[minj]){
        minj = j;
      }
    }
    
    if(i != minj){    
      temp = matrix[i];
      matrix[i] = matrix[minj];
      matrix[minj] = temp;    
      cnt = cnt + 1;
    }
  }

  return cnt;
}

void outputMatrix(int matrix[], int N){
  for(int i=0;i<N;i++){
    if(i>0){
      cout << " ";
    }
    cout << matrix[i];
  }
  cout << endl;
}


int main(void){

  int N_tot;
  cin >> N_tot;

  int* matrix = new int [N_tot];
  for(int i=0;i<N_tot;i++){
    cin >> matrix[i];
  } 
  
  int cnt;
  cnt = selectionSort(matrix, N_tot);

  outputMatrix(matrix, N_tot);
  cout << cnt << endl;

  delete [] matrix;

  return 0;
}


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

typedef unsigned long long ll;

int main()
{
	ll n;
	cin>>n;
	std::vector<ll> a;
	for (ll i = 0; i < (3*n); ++i)
	{
		ll tmp;
		cin>>tmp;
		a.push_back(tmp);
	}
	sort(a.begin(),a.end(),greater<ll>());
	ll ans=0;
	for (ll i = 1; i < 2*n ; i+=2)
	{
		ans+=a[i];
	}
	printf("%lld\n",ans );
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define pi pair<int, int>

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin >> n;
	char s[n];
	for(int i = 0;i<n;i++){
		cin >> s[i];
	}
	if(n % 2 == 1){
		cout << "No";
		return 0;
	}
	for(int i = 0;i<n/2;i++){
		int j = n/2;
		if(s[i] != s[i+j]){
			cout << "No";
			return 0;
		}
		j++;
	}
	cout << "Yes";
	return 0;
}

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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
void Yes(){
  cout << "Yes" << endl;
}
void YES(){
  cout << "YES" << endl;
}
void No(){
  cout << "No" << endl;
}
void NO(){
  cout << "NO" << endl;
}
int main(){
  int N;
  cin >> N;
  
  cout << N*800 - (N/15) * 200 << endl;
}

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int n;
	cin >> n;
	vector<ll> ma(n);
	REP(i,n) cin >> ma[i];
	ma.push_back(1000000200);
	int f = 1;
	string ans = "Yes";
	REP(i,n) {
		if (f) ma[i]-=1;
		if (ma[i]-ma[i+1]>=1) ans = "No";
		else if (ma[i] - ma[i+1] == 0) f = 0;
		else f = 1;

	}

  cout << ans << endl;
}


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll A,B,C;
    cin >> A >> B >> C;

    ll ans = INF_LL;

    if( A%2==0 ) chmin(ans, (ll)0);
    else chmin(ans, B*C);

    if( B%2==0 ) chmin(ans, (ll)0);
    else chmin(ans, A*C);

    if( C%2==0 ) chmin(ans, (ll)0);
    else chmin(ans, A*B);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
struct Edge
{
	int a;
	int b;
	int c;
	int f;
};
template<int S>
struct Flow
{
vector<Edge> es;
vector<int> edges[S];
void add(int a, int b, int cap){
	//cout << "add " << a << ", " << b << ", " << cap << endl;
	es.push_back(Edge());
	Edge& e=es.back();
	e.a=a;
	e.b=b;
	e.c=cap;
	e.f=0;
	edges[a].push_back(es.size()-1);
	edges[b].push_back(es.size()-1);
}
void init(){
	es.clear();
	for(int i=0;i<S;i++){
		edges[i].clear();
	}
}
int fill(int s, int t, int sz=S){
	int ret=0;
	int pre[S];
	int Q[S];
	while(1){
		memset(pre,-1,sizeof(int)*sz);
		int qs=0;
		Q[0]=s;
		pre[s]=-2;
		int qe=1;
		while(qs<qe&&pre[t]==-1){
			int p=Q[qs++];
			for(int i=0;i<edges[p].size();i++){
				int j=edges[p][i];
				int nex;
				if(es[j].a==p){
					if(es[j].f==es[j].c){
						continue;
					}
					nex=es[j].b;
				}
				else{
					if(es[j].f==0){
						continue;
					}
					nex=es[j].a;
				}
				if(pre[nex]==-1){
					Q[qe++]=nex;
					pre[nex]=j;
				}
			}
		}
		if(pre[t]==-1){
			return ret;
		}
		{
			int p=t;
			int f=INT_MAX;
			while(p!=s){
				int j=pre[p];
				if(es[j].b==p){
					f=min(f,es[j].c - es[j].f);
					p=es[j].a;
				}
				else{
					f=min(f,es[j].f);
					p=es[j].b;
				}
			}
			p=t;
			while(p!=s){
				int j=pre[p];
				if(es[j].b==p){
					es[j].f+=f;
					p=es[j].a;
				}
				else{
					es[j].f-=f;
					p=es[j].b;
				}
			}
			ret+=f;
		}
	}
	// ここには来ない
	return -1;
}
};
Flow<2*100*100> f;
const int inf=200*100;
int main() {
	char table[102][102];
	int H,W;
	scanf("%d%d",&H,&W);
	for(int i=0;i<H;i++){
		scanf("%s",table[i]);
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(table[i][j]=='.')continue;
			for(int k=j+1;k<W;k++){
				if(table[i][k]=='.')continue;
				f.add(W*i+j,W*i+k,inf);
				f.add(W*i+k,W*i+j,inf);
			}
		}
	}
	for(int j=0;j<W;j++){
		for(int i=0;i<H;i++){
			if(table[i][j]=='.')continue;
			for(int k=i+1;k<H;k++){
				if(table[k][j]=='.')continue;
				f.add(W*H+W*i+j,W*H+W*k+j,inf);
				f.add(W*H+W*k+j,W*H+W*i+j,inf);
			}
		}
	}
	int s,t;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(table[i][j]=='.')continue;
			if(table[i][j]=='o'){
				f.add(W*i+j,W*H+W*i+j,1);
				f.add(W*H+W*i+j,W*i+j,1);
			}
			else if(table[i][j]=='S'){
				s=W*i+j;
				f.add(W*i+j,W*H+W*i+j,inf);
				f.add(W*H+W*i+j,W*i+j,inf);
			}
			else{
				t=W*i+j;
				f.add(W*i+j,W*H+W*i+j,inf);
				f.add(W*H+W*i+j,W*i+j,inf);
			}
		}
	}
	int v=f.fill(s,t);
	if(v>=inf){
		puts("-1");
	}
	else{
		printf("%d\n",v);
	}

	return 0;

}



Measured memory_bytes: 52704
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long int;
 
 
void dfs_2(int r, int x, const vi &query, vector<bool> &ald, const vvi &tree, vi &res){
    ald[r] = true;
    x += query[r];
    res[r] += x;
    for (auto p : tree[r]) { 
        if(ald[p] == true){continue;}
        dfs_2(p, x, query, ald, tree, res);
    }
    return;
}
 
int main(){
    int N, Q;
    cin >> N >> Q;
    vvi vec(N+1, vi(0));
    for(int i=0; i<N-1; i++){
      int a, b; cin >> a >> b;
      vec[a].emplace_back(b);
      vec[b].emplace_back(a);
    }
    vi query(N+1, 0);
    for(int i=0; i<Q; i++){
        int a, b;
        cin >> a >> b;
        query[a] += b;
    }
 
    vi res(N+1, 0);
    vector<bool> ald_2(N+1, false);
 
    dfs_2(1, 0, query, ald_2, vec, res);
 
    for(int i=1; i<N+1; i++){
        cout << res[i] << " ";
    }
}

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

int main(){
    int h,w;
    int start = 1;
    while(1){
        scanf("%d %d",&h,&w);
        if(start)start = 0;
        else putchar('\n');
        if(h==0 && w == 0)break;
        for(int i = 0 ; i <h ;i++){
            for(int j = 0; j < w;j++)
                if((i+j)%2)putchar('.');
                else putchar('#');
            putchar('\n');
        }
    }
    
    return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
//#define M 998244353
const int inf=4e18;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,m;cin>>n>>m;
	int a[n],s=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	sort(a,a+n,greater<int> ());
	int x=s/(4*m);
	if(s%(4*m)==0)
		x--;
	if(a[m-1]<=x)
		cout<<"No\n";
	else
		cout<<"Yes\n";
}

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


int dp[2][1<<nn][nn+1][4];

void add(int &x,int y){
	x+=y;if(x>1e8) x=1e8;
}
/*
0->last ignore 0
1->last ignore 1
2->nothing
*/

int leng,bst;
int n,now;
void solve(int b){
	now^=1;
	if(b+1<=n) for(int i=0;i<(1<<b+1);i++){
		for(int j=0;j<=b;j++){
			int x=(i&(1<<j));int z=x>0;
			
			int o=i&((1<<j)-1);
			int e=(i-o-x)>>1;e|=o;
		//	cout<<e<<" "<<i<<" "<<j<<"\n";
		//	if(e<0) exit(0);
			for(int k=0;k<4;k++)
				add(dp[now^1][e][j][(1<<z)|k],dp[now][i][j][k]);
		}
	}
	now^=1;
	
	for(int i=0;i<(1<<b);i++){
		for(int j=0;j<b;j++){
			int x=(i&(1<<j));int z=x>0;
			
			for(int k=0;k<4;k++) if((k&(1<<z)));else 
				add(dp[now][i][j+1][0],dp[now][i][j][k]);
		}
	}
}

char str[22][1<<nn+1];int limit;
int main(){
	scanf("%d%d%s",&n,&limit,str[0]);assert(limit<=1e7);
	for(int i=1;i<=n;i++) scanf("%s",str[i]);
	
	for(int i=n;i>=1;i--){
		now^=1;
		for(int j=0;j<(1<<i);j++) memset(dp[now][j],0,sizeof dp[now][j]);
		
		for(int j=0;j<(1<<i);j++) if(str[i][j]=='1')
			add(dp[now][j][0][0],1);
			
		solve(i);bst=1e7;
		for(int j=0;j<(1<<i);j++) 
			if(dp[now][j][i][3]+dp[now][j][i][0]+dp[now][j][i][1]>=limit-dp[now][j][i][2])
				leng=i,bst=min(bst,j);
		
		if(leng){
			string g;
			while(bst){
				if(bst&1) g+='1';
				else g+='0';bst/=2;
				leng--;
			}
			while(leng--) g+='0';
			for(int i=g.size()-1;i>=0;i--)
				putchar(g[i]);
			exit(0);
		}
	}
	
	puts("");
	return 0;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, x; cin >> N >> x;
  if (x == 1 || x == 2*N - 1) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  ll mod = 2 * N - 1;
  for (ll i = 0; i < mod; i++) {
    cout << 1 + (x - N + i + mod) % mod << "\n";
  }
  

  return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, Q;
  cin >> A >> B >> Q;
  vector<int> s(A + 2);
  s[0] = -1e16;
  s[A + 1] = 1e16;
  REP(i, A) cin >> s[i + 1];
  vector<int> t(B + 2);
  t[0] = -1e16;
  t[B + 1] = 1e16;
  REP(i, B) cin >> t[i + 1];

  REP(i, Q) {
    int tmp1;
    int tmp2;
    int x;
    cin >> x;
    //まず s -> t
    auto s1 = lower_bound(all(s), x);
    auto s2 = s1 - 1;
    // s1
    auto st1 = lower_bound(all(t), *s1);
    auto st2 = st1 - 1;
    // s2
    auto st3 = lower_bound(all(t), *s2);
    auto st4 = st3 - 1;
    tmp1 = abs(x - *s1) + min(abs(*s1 - *st1), abs(*s1 - *st2));
    tmp2 = abs(x - *s2) + min(abs(*s2 - *st3), abs(*s2 - *st4));

    int tmp3;
    int tmp4;
    // つぎに t -> s
    auto t1 = lower_bound(all(t), x);
    auto t2 = t1 - 1;
    // t1
    auto ts1 = lower_bound(all(s), *t1);
    auto ts2 = ts1 - 1;
    // t2
    auto ts3 = lower_bound(all(s), *t2);
    auto ts4 = ts3 - 1;
    tmp3 = abs(x - *t1) + min(abs(*t1 - *ts1), abs(*t1 - *ts2));
    tmp4 = abs(x - *t2) + min(abs(*t2 - *ts3), abs(*t2 - *ts4));
    int ans = min(min(tmp1, tmp2), min(tmp3, tmp4));
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
long long f[1<<16],a[1<<16];
int s[17][17],b[1<<16];
int lowbit(int x)
{
    return x&-x;
}
int main()
{
    int p,i,j,n,x,y,z;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
            scanf("%d",&s[i][j]);
        b[1<<(n-i)]=i;
    }
    for(i=1;i<(1<<n);i++)
    {
        x=lowbit(i);
        y=b[x];
        z=x^i;
        a[i]=a[z];
        while(z)
        {
            p=lowbit(z);
            a[i]+=s[y][b[p]];
            z-=p;
        }
    }
    for(i=0;i<(1<<n);i++)
    {
        for(j=i;j;j=(j-1)&i)
            f[i]=max(f[i],a[j]+f[i^j]);
    }

    printf("%lld",f[(1<<n)-1]);
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <complex>
#include <iomanip>
#include <cmath>

using namespace std;

typedef complex<double> P;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
const double eps = 1e-8, inf = 1e8;

template<typename T> T sqr(T x){return x*x;}

double cross(const P &a, const P &b){
    return imag(conj(a) * b);
}

double dot(const P &a, const P &b){
    return real(conj(a) * b);
}

int ccw(P a, P b, P c){
    b -= a; c -= a;
    if(cross(b, c) > eps)return 1;
    if(cross(b, c) < -eps)return -1;
    if(dot(b, c) < 0)return 2;
    if(norm(b) < norm(c))return -2;
    return 0;
}

struct L:vector<P>{
    L(const P &a, const P &b){
        push_back(a); push_back(b);
    }
};

bool interSS(const L &s, const L &t){
    return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
           ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

bool interSP(const L &s, const P &p){
    return abs(s[0]-p) + abs(s[1]-p) - abs(s[1]-s[0]) < eps;
}

P xptSS(const L &s, const L &t){
    double d = cross(s[1] - s[0], t[1] - t[0]);
    if(abs(d) < eps){
        if(interSP(t, s[0]))return s[0];
        if(interSP(t, s[1]))return s[1];
        if(interSP(s, t[0]))return t[0];
        return t[1];
    }
    return t[0] + (t[1] - t[0]) * cross(s[1] - s[0], s[1] - t[0]) * (1. / d);
}

struct C:P{
    double r;
    C(const P &a, double r):P(a), r(r){}
};

int overlap(const C &c1, const C &c2){
    if(sqr(c1.r + c2.r) < norm(c1 - c2))return 0;
    if(abs(c1 - c2) + c1.r < c2.r + eps)return -1;
    if(c2.r < c1.r && abs(c1 - c2) + c2.r < c1.r + eps)return 1;
    if(abs(abs(c1 - c2) - c1.r - c2.r) < eps)return -2;
    return 2;
}

vector<P> xptCC(const C &c1, const C &c2){
    vector<P> res;
    double d = abs(c1 - c2);
    if(d < eps || abs(overlap(c1, c2)) != 2)return res;
    double rc = (sqr(d) + sqr(c1.r) - sqr(c2.r)) / (2. * d);
    double rs = sqrt(sqr(c1.r) - sqr(rc));
    P diff = (c2 - c1) / d;
    res.push_back(c1 + diff * P(rc, rs));
    res.push_back(c1 + diff * P(rc, -rs));
    return res;
}

double solve(vector<C> stake){
    vector<P> fixpt(all(stake));
    vector<L> locus;
    rep(i, (int)stake.size())rep(j, i){
        vector<P> xpt = xptCC(stake[i], stake[j]);
        if(xpt.empty())continue;
        fixpt.push_back((xpt[0] + xpt[1]) / 2.);
        locus.emplace_back(xpt[0], xpt[1]);
    }
    rep(i, (int)locus.size())rep(j, i){
        if(!interSS(locus[i], locus[j]))continue;
        fixpt.push_back(xptSS(locus[i], locus[j]));
    }
    double res = 0.;
    for(auto p: fixpt){
        double h = inf;
        for(auto c: stake)h = min(h, sqr(c.r) - norm(c - p));
        res = max(res, h);
    }
    return res;
}

int main(){
    for(int n; cin >> n, n;){
        vector<C> stake;
        rep(i, n){
            int x, y, l;
            cin >> x >> y >> l;
            stake.emplace_back(P(x, y), l);
        }
        cout << fixed << setprecision(7) << sqrt(solve(stake)) << '\n';
    }
    return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    string s,t;
    i32 a,b,c,d;
    cin >> a >> b>> c>>d;

    while(a > 0 && c > 0) {
        c-=b;
        if(c <= 0) {
            cout << "Yes" << '\n';
            return 0;
        }
        a-=d;
        if(a <= 0) {
            cout << "No" << '\n';
            return 0;
        }
    }


    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3676