akhauriyash/Code-Regression huggingface dataset:
//Keep Working Hard
  // I__Like__Food
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define mod 1000000007
  #define N 100005
  #define INF 1e16
  const double PI = acos(-1);



vector<int> adj[N];

vector<int> dpB(N,1);
vector<int> dpW(N,1);

// dpB(v) denotes the number of ways to paint the subtree rooted at the vertex v black or white such that vertex v is black
// dpW(v) denotes the number of ways to paint the subtree rooted at the vertex v black or white such that vertex v is white


void dfs(int v,int pv)
{
  for(auto i : adj[v])
  {

    if(i == pv)continue;
    dfs(i,v);

    dpB[v] = (dpB[v]%mod)*(dpW[i]%mod)%mod; // since child of black will be white
    dpW[v] = (dpW[v]%mod)*(dpW[i]%mod + dpB[i]%mod)%mod; // since child of white can be either black or white
  }

}



int32_t main()
{
       

    IOS


    int n;
    cin >> n;
    for(int i = 0 ; i <= n; i++)
      {
        dpB[i] = 1;
        dpW[i] = 1;
      }


    for(int i = 1; i <= n - 1; i++)
    {
      int x, y;
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }

    dfs(1,1);


    cout << (dpW[1]%mod + dpB[1]%mod)%mod;



  

  return 0;
} 

Measured memory_bytes: 14208
S = input()
count = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
            count += 1    
        
    else:
        if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
            count += 1
if count == len(S):
    print('Yes')
else:
    print('No')


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0;i < n;i++){
    cin >> x.at(i);
  }
  int ans = 0;
  
  for (int i = 1;i <= 100;i++){
    int p = 0;
    for (int j = 0;j < n;j++){
      p += (x.at(j) - i) * (x.at(j) - i);
    }
    if (p == 0){
      ans = 0;
      break;
    }
    else if (ans == 0){
      ans = p;
    }
    else{
      ans = min(ans,p);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3608
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

const int64_t N_MAX = 100010;
int64_t memo[N_MAX];

int64_t rec(int64_t n)
{
	if (n == 0) return 0;
	if (memo[n] != -1) return memo[n];

	int64_t res = n;

	for (int64_t i = 1; i <= n; i *= 6)
	{
		res = std::min(res, rec(n - i) + 1);
	}

	for (int64_t i = 1; i <= n; i *= 9)
	{
		res = std::min(res, rec(n - i) + 1);
	}

	memo[n] = res;
	return res;
}

void solve()
{
    int64_t N;
	std::cin >> N;
	for (int64_t i = 0; i < N_MAX; i++)
	{
		memo[i] = -1;
	}

	std::cout << rec(N) << std::endl;
}

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


Measured memory_bytes: 7480
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<10

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int dx[] = { 0, 1, 1, 0,-1,-1 };
const int dy[] = { 1, 1, 0,-1,-1, 0 };
const int basex = 100;
const int basey = 100;
const int MAX_N = 200;

int vis[MAX_N][MAX_N];
int main()
{
	ios_base::sync_with_stdio(0);
	int t, n;
	while (cin >> t >> n, t ){
		memset (vis, -1, sizeof (vis ) );
		rep (i, n ){
			int x, y; cin >> x >> y;
			x += basex, y += basey;
			vis[y][x] = 0;
		} // end rep
		int sx, sy; cin >> sx >> sy;
		sx += basex, sy += basey;
		queue<P> que;
		que.push (P (sy, sx ) );
		vis[sy][sx] = 0;
		int res = 1;

		while (!que.empty() ){
			P cur = que.front(); que.pop();
			int cy = cur.first;
			int cx = cur.second;
			int ct = vis[cy][cx];
			if (ct == t ) continue;

			rep (k, 6 ){
				int ny = cy + dy[k];
				int nx = cx + dx[k];
				if (vis[ny][nx] == -1 ){
					vis[ny][nx] = ct + 1;
					que.push (P (ny, nx ) );
					res++;
				} // end if
			} // end rep
		} // end while
		cout << res << endl;

	} // end while

	return 0;
}

Measured memory_bytes: 1384
from numpy import*
(_,k),*t=[int64(t.split())for t in open(0)]
A,F=map(sort,t)
s=sum(A)
l=-1
r=10**12
while r-l>1:
 m=l+r>>1
 if s-sum(minimum(A,m//F[::-1]))>k:l=m
 else:r=m
print(r)

Measured memory_bytes: 37292
x=int(input())
#n=1
#while 1/2*(n**2+n)<x:
#  n+=1
#print(n)

left=0
right=x
while right-left>1:
  mid=(left+right)//2
  if (mid**2+mid)/2==x:
    right=mid
    break
  if (mid**2+mid)/2<x:
    left=mid
  else:
    right=mid
print(right)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
  int n, i, j, k;
  char a[10], b[10];
  while(1) {
    scanf("%s", a);
    scanf("%s", b);
    if(!a[1]) break;
    int h = 0, bl = 0, flag[10];
    for(i = 0; i < 10; ++i) flag[i] = 0;
    for(i = 0; i < 4; ++i) {
    if(a[i] == b[i]) h++;
    else flag[a[i] - '0'] = 1;
    }
    for(i = 0; i < 4; ++i) if(flag[b[i] - '0']) ++bl;
    printf("%d %d\n", h, bl);
  }
  return 0;
} 


Measured memory_bytes: 2572
import random

k = int(input())
qs = [list(map(int, input().split())) for _ in range(k)]


def solve():
    global qs
    if len(qs) == 8:
        return True

    # モンテカルロ的に探索
    ry, rx = random.randint(0, 7), random.randint(0, 7)
    for y in range(8):
        y = (y+ry) % 8
        for x in range(8):
            x = (x+rx) % 8
            f = False
            for qy, qx in qs:
                dy, dx = abs(y-qy), abs(x-qx)
                if qy == y or qx == x or dy == dx:
                    f = True
                    break
            if not f:
                qs.append([y, x])
                if solve():
                    return
                qs.pop(-1)
    return False


solve()

for y in range(8):
    v = ""
    for x in range(8):
        if [y, x] in qs:
            v += "Q"
        else:
            v += "."
    print(v)



Measured memory_bytes: 8188
#include<bits/stdc++.h>
using namespace std;
const int N=200100;
int n,m,a[N],mn[N<<2];
struct st{int l,r;}q[N];
bool cmp(st a,st b){return a.l==b.l?a.r>b.r:a.l<b.l;}
void build(int x,int l,int r)
{
	if(l==r){mn[x]=(l==0)?0:N;return;}
	int mid=l+r>>1;build(x<<1,l,mid);build(x<<1|1,mid+1,r);mn[x]=min(mn[x<<1],mn[x<<1|1]);
}
void chg(int x,int l,int r,int p,int v)
{
	if(l==r){mn[x]=min(mn[x],v);return;}
	int mid=l+r>>1;
	if(p<=mid)chg(x<<1,l,mid,p,v);else chg(x<<1|1,mid+1,r,p,v);
	mn[x]=min(mn[x<<1],mn[x<<1|1]);
}
int qry(int x,int l,int r,int tl,int tr)
{
	if(tl<=l&&r<=tr)return mn[x];
	int mid=l+r>>1;
	if(tr<=mid)return qry(x<<1,l,mid,tl,tr);
	else if(tl>mid)return qry(x<<1|1,mid+1,r,tl,tr);
	else return min(qry(x<<1,l,mid,tl,tr),qry(x<<1|1,mid+1,r,tl,tr));
}
int main()
{
	scanf("%d",&n);int s=0;
	for(int i=1;i<=n;i++){scanf("%d",&a[i]);s+=(1-a[i]);}
	build(1,0,n);scanf("%d",&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&q[i].l,&q[i].r);
	sort(q+1,q+m+1,cmp);
	for(int i=1,j=1;i<=n;i++)
	{
		for(;q[j].l==i;j++)chg(1,0,n,q[j].r,qry(1,0,n,q[j].l-1,q[j].r));
		chg(1,0,n,i,qry(1,0,n,i-1,i-1)+2*a[i]-1);
	}
	printf("%d\n",s+qry(1,0,n,n,n));
	return 0;
}

Measured memory_bytes: 5120
// 2015/03/09 Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		for(int i=0; i<n; i++){
			int x1, y1, z1, w1, x2, y2, z2, w2;
			cin >> x1 >> y1 >> z1 >> w1 >> x2 >> y2 >> z2 >> w2;

			int x3 = x1*x2-y1*y2-z1*z2-w1*w2;
			int y3 = x1*y2+y1*x2+z1*w2-w1*z2;
			int z3 = x1*z2-y1*w2+z1*x2+w1*y2;
			int w3 = x1*w2+y1*z2-z1*y2+w1*x2;

			cout << x3 << ' ' << y3 << ' ' << z3 << ' ' << w3 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
from math import gcd


def main():
    K = int(input())

    ans = 0
    for a in range(1, K + 1):
        for b in range(1, K + 1):
            for c in range(1, K + 1):
                ans += gcd(gcd(a, b), c)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9172
import java.util.Scanner;
public class Main { 
    public static void main(String[] args) { 
        Scanner sc = new Scanner(System.in); 
        int a = sc.nextInt(); 
        int b = sc.nextInt(); 
        int c = sc.nextInt(); 
        if (a < b) { 
            if (b < c) { 
                System.out.printf("%d %d %d\n", a, b, c); 
            } else if (a < c) { 
                System.out.printf("%d %d %d\n", a, c, b); 
            } else {
                System.out.printf("%d %d %d\n", c, a, b);
            }
        } else {
            if (c < b) {
                System.out.printf("%d %d %d\n", c, b, a); 
            } else if (c < a) {
                System.out.printf("%d %d %d\n", b, c, a);                
            } else {
                System.out.printf("%d %d %d\n", b, a, c);
            }
        } 
    } 
}


Measured memory_bytes: 26272
D=int(input())
c=list(map(int,input().split()))
s=[]
for _ in range(D):
  s.append(list(map(int,input().split())))
t=[]
for _ in range(D):
  t.append(int(input()))
g=0
for d in range(D):
  a=s[d][t[d]-1]
  b=0
  for i in range(26):
    for j in range(d+1,0,-1):
      if t[j-1]==i+1:
        b+=c[i]*(d+1-j)
        break
    else:
      b+=c[i]*(d+1)
  g+=a-b
  print(g)

Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;
 
int main() 
{ 
  fastio();
ll int T;//cin>>T;
T=1;while(T--)
{
ll int n;double pi=3.14159265358979323846;
cin>>n;
double ans= (double)2*pi*double(n);
cout<<ans<<endl;




}

       
    return 0; 
} 


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

int N;
vector<string> S(100000);
int main(){
	int ca=0,cb=0,only=0,count=0;
	cin>>N;
	for (int i = 0; i < N; ++i){
		cin>>S.at(i);
		if(S.at(i).at(0)=='B'&&S.at(i).back()=='A'){
			cb++;
			ca++;
		}
		else if(S.at(i).at(0)=='B'){
			cb++;
			only=1;
		}
		else if(S.at(i).back()=='A'){
			ca++;
			only=1;
		}
		
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<S.at(i).size()-1;j++){
			if(S.at(i).at(j)=='A'&&S.at(i).at(j+1)=='B')
				count++;
		}
	}

	if(ca==0&&cb==0)
		cout<<count<<endl;
	else if(only==0)
		cout<<count+ca-1<<endl;
	else
		cout<<count+min(ca,cb)<<endl;

}

Measured memory_bytes: 1536
S = input().split()
A = int(S[0])
B = int(S[1])
C = int(S[2])
K = int(S[3])
a = min(K, A)
if K >= A:
  a = a + min(K-A, B)*0
  if K-A >= B:
    a = a - min(K-A-B, C)
print(a)

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

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

int c2i(char c) { return c-'0'; }

string in;
int prev[100], next[100], prevN, num[100], tmp;

int main() {
  prev[0] = 0;
  prevN = 1;
  while (getline(cin,in)) {
    vector<int> v;
    rep(i,in.size()) if (in[i] == ',') in[i] = ' ';
    stringstream ss(in);
    while (ss >> tmp) v.push_back(tmp);
    const int N = v.size();
    rep(i,N) next[i] = v[i];
    if (prevN < N) {
      rep(i,prevN) {
        next[i] = max(next[i], v[i] + prev[i]);
        next[i+1] = max(next[i+1], v[i+1] + prev[i]);
      }
    } else if (prevN > N) {
      rep(i,prevN) {
        if (i-1 >= 0) next[i-1] = max(next[i-1], v[i-1] + prev[i]);
        if (i < N) next[i] = max(next[i], v[i] + prev[i]);
      }
    }
    //rep(i,N) printf("[%4d]",next[i]); puts("");
    rep(i,N) prev[i] = next[i];
    prevN = N;
  }
  printf("%d\n",prev[0]);
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

const int mod = 1e9+7;
const int inf = (1<<28);
const ll infl = (1LL<<60);

int main() {
  int n, mx = 0; cin >> n;
  map<string, int> mp;
  rep(i,n) {
    string s; cin >> s;
    mp[s]++;
    mx = max(mx, (int)mp[s]);
  }
  for (auto it: mp) {
    if (it.second == mx) {
      cout << it.first << endl;
    }
  }
  return 0;
}


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

int main(){
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  
  cout << (H2-H1)*60+(M2-M1)-K;
  
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
 
int main(){
    int h, i, A[250], j, pk, lk, rk;

    scanf("%d", &h);
    
    for (i = 1; i <= h; i++){
        scanf("%d", &A[i]);  
    }
 
    for (i = 1; i <= h; i++){
        printf("node %d: ",i);
        printf("key = %d, ",A[i]);
        pk = A[i/2];
        lk = A[2*i];
        rk = A[2*i+1];
   
        if(i != 1){
            printf("parent key = %d, ",pk);
        }
        if(2*i <=  h){ 
            printf("left key = %d, ",lk);
        }
        if(2*i+1 <= h){     
            printf("right key = %d, ",rk);
        }
        
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

#define PI 3.141592653589793
#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)

int main() {
    int n;
    int x[1001], y[1001];
    double m,d,dm,dd,dt;
    cin >> n;
    REP(i,n) cin >> x[i];
    REP(i,n) cin >> y[i];
    // p == 1
    d = dm = dd = dt = 0.0;
    REP(i,n) {
        m = (double)abs(x[i]-y[i]);
        d += m;
        dm += pow(m,2);
        dd += pow(m,3);
        dt = m>dt?m:dt;
    }
    printf("%.6lf\n", d);
    printf("%.6lf\n", sqrt(dm));
    printf("%.6lf\n", pow(dd, 1.0/3.0));
    printf("%.6lf\n", dt);
    return 0;
}



Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int T,D,L;cin>>T>>D>>L;
        if(T+D+L==0) break;
        
        vector<int> imo(200005,0);
        
        for(int i=1;i<=T;i++){
            int a;cin>>a;
            if(a>=L){
                imo[i+1]++;
                imo[i+1+D]--;
            }
        }
        
        for(int i=1;i<=200003;i++) imo[i]+=imo[i-1];
        
        int ans=0;
        
        for(int i=2;i<=T;i++){
            if(imo[i]) ans++;
        }
        
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3928
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int>l(n);
    for(auto &x : l){
        cin >> x;
    }
    sort(l.begin(), l.end(), greater<int>());
    auto sum = accumulate(++l.begin(), l.end(), 0);
    if(sum > l[0]){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,work,minj;
    int count=0;
    int S[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
    for(int i=0;i<n-1;i++){
        minj=i;
        for(int j=i+1;j<n;j++){
            if(S[j]<S[minj]){
                minj=j;
            }
        }
        if(i!=minj){
            work=S[i];
            S[i]=S[minj];
            S[minj]=work;
            count++;
        }
    }
    for(int i=0;i<n-1;i++){
        printf("%d ",S[i]);
    }
    printf("%d\n",S[n-1]);
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,a[N],b[N];
bool flag=true;
vector<int>v;

int main()
{
    int res=0;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    for(int i=n; i>=1; i--)
    {
        int ans=0;
        for(int j=i; j<=n; j+=i)
            ans+=b[j];
        if(ans%2!=a[i])
            b[i]=1;
    }
    int resu=0;
    for(int i=1; i<=n; i++)
        if(b[i])
            resu++;
    printf("%d\n",resu);
    int k=0;
    for(int i=1; i<=n; i++)
    {
        if(b[i]&&k==0)
        {
            printf("%d",i);
            k++;
        }
        else if(b[i])
            printf(" %d",i);
    }

}


Measured memory_bytes: 2432
#include<stdio.h>

int main()
{
  char s[100];
  int N;
  scanf("%d",&N);
  scanf("%s",s);

  int alpha[1000];
  int i,j,k,count=0,count_max=0;;

  for(i=1;i<N;i++){
    count=0;
    for(j=0;j<1000;j++){
      alpha[j]=0;
    }

    for(j=i;j<N;j++){ //後半(iから)
      for(k=0;k<i;k++){ //前半(iまで)
        if(s[j]==s[k] && alpha[s[j]]==0){
          count++;
          alpha[s[j]] = 1;
        }
      }
    }
    if(count>=count_max){
      count_max=count;
    }
  }

  printf("%d\n",count_max);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
int main(int argc, const char * argv[])
{
    int n;int k; int x[10000]={};int total=0;
    cin>>n>>k;
   
    for (int i=0; i<n; i++)
    {
        cin>>x[i];
        if (x[i]-0<k-x[i])
        {
            total=total+x[i]-0;
        }
        if (x[i]-0>k-x[i])
        {
            total=total+k-x[i];
        }
        if (x[i]-0==k-x[i])
        {
             total=total+k-x[i];
        }
    }
    cout<<total*2;
    return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(Int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(Int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using Int = long long;
using ll = long long;
using P = pair<Int,Int>;
using vi = vector<Int>;
using vvi = vector<vi>;
using vp = vector<P>;
using vvp = vector<vp>;

const Int INF = (1LL<<50);

void solve(long long x){
  cout << 1-x << endl;

}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long x;
  scanf("%lld",&x);
  solve(x);
  return 0;
}


Measured memory_bytes: 3760
import sys
sys.setrecursionlimit(10**6)
large_p = 10**9 + 7
a = []
kazu_memo = {}
kazu_tmp = 0
def f(target_step):
    global kazu_memo, kazu_tmp
    #print(target_step)
    if target_step < 0:
        return 0
    else:
        if kazu_memo[target_step] >= 0:
            return kazu_memo[target_step]
        else:
            kazu_tmp = (f(target_step - 1) + f(target_step - 2)) % large_p
            kazu_memo[target_step] = kazu_tmp
            return kazu_tmp

def main():
    global a, kazu_memo
    n, m = map(int, input().split())
    kazu_memo = {e: -1 for e in range(0, n + 1)}
    kazu_memo[0] = 1
    for _ in range(m):
        ta = int(input())
        kazu_memo[ta] = 0

    r = f(n)
    print(r % large_p)


if __name__ == '__main__':
    main()

Measured memory_bytes: 116968
import math

A,B,H,M = list(map(int,input().split()))

th_max = 12 * 60
tm_max = 60
th = H * 60 + M
tm = M
degA = 2 * math.pi * tm / tm_max
degB = 2 * math.pi * th / th_max
deg = abs(degA-degB)

cos_deg = math.cos(deg)

res = (A**2 + B**2 - 2*A*B*cos_deg)**(0.5)
print(res)

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long X, t;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> X >> t;
	long long ans = max(X-t, 0LL);
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int count = 0;
    int flag = 0;
    char tmp;
    char tmp2[2] = {'C', 'F'};
    int num, num2;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'C') {
            num = i;
            break;
        }
    }
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'F') {
            num2 = i;
        }
    }
    if(num2 > num) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

LL N,K;
LL A[500];

LL ans = 1;

void solve(){
	LL A_sum = 0;
	for(int i=0;i<N;i++){
		A_sum += A[i];
	}

	//A_sumの約数について一つづつ見ていく
	//約数は高々√(N*max(A)個しかない
	set<LL> divisor;
	for(LL i=1;i*i<=A_sum;i++){
		if(A_sum%i==0){
			divisor.insert(i);
			divisor.insert(A_sum/i);
		}
	}
	for(LL x:divisor){
		LL need;//操作の必要回数
		{
			//calc need
			vector<LL> r(N);
			for(int i=0;i<N;i++) r[i] = A[i]%x;
			sort(r.begin(),r.end());

			//rの要素をいくつかデクリメントして0にし
			//残りをインクリメントしてxの倍数にすることを考えると
			//rのうち小さいものをデクリメントし
			//大きいものをインクリメントすると
			//少ない処理回数で条件を満たせそうというのがわかる
			LL B = 0;
			for(int i=0;i<N;i++) B+=(x-r[i]);

			LL A = 0;
			need = 1e18;//操作の必要回数
			for(int i=0;i<N;i++){
				A += r[i];//デクリメント回数
				B -= (x-r[i]);//インクリメント回数
				if(A==B) need = min(need,A);
			}
		}
		if(need<=K) ans = max(ans,x);
	}
}
 
int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++) cin >> A[i];
 
	solve();
 
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, a, ans=0;
    cin>>n;
    while(n--)
    {
        cin>>a;
        while(a%2==0)
        {
            a/=2;
            ans++;
        }
    }
    cout<<ans;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1e9;

int W, H, my[] = {0, 0, 1, -1}, mx[] = {1, -1, 0, 0};
vector< vector<char> > v;

int solve(){
  priority_queue<PP, vector<PP>, greater<PP> > open;
  open.push(PP(0, P(0, 0)));
  vector< vector<int> > closed(H, vector<int>(W, INF));
  while(!open.empty()){
    PP tmp = open.top(); open.pop();
    int y = tmp.second.first, x = tmp.second.second, cnt = tmp.first;
    if(closed[y][x] <= cnt) continue;
    closed[y][x] = cnt;
    REP(i, 4){
      int ny = y + my[i], nx = x + mx[i];
      if(ny >= 0 && nx >= 0 && ny < H && nx < W) open.push(PP((v[y][x] == '#' && v[ny][nx] != '#' ? cnt + 1 : cnt), P(ny, nx)));
    }
  }
  P tar;
  REP(i, H) REP(j, W) if(v[i][j] == '&') tar = P(i, j);
  return closed[tar.first][tar.second];
}

int main() {
  while(cin >>W >>H && W){
    H += 2; W += 2;
    v = vector< vector<char> >(H, vector<char>(W, '.'));
    FOR(i, 1, H - 1) FOR(j, 1, W - 1) cin >>v[i][j];
    cout <<solve() <<endl;
  }
  return 0;
}

Measured memory_bytes: 1532
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0; i<n; i+=2) {
        cout<<s[i];
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,ar[110];
cin>>a;
for(int i=0;i<a;++i)
{
cin>>ar[i];
}
sort(ar,ar+a,greater<int>());
int sum1=0,sum2=0;
for(int i=0;i<a;i++)
{
if(i%2==0) sum1+=ar[i];
else sum2+=ar[i];
}
cout<<abs(sum1-sum2)<<endl;
return 0;
}



Measured memory_bytes: 384
import math

(N, M, X) = list(map(int, input().split()))

tbs = []
for i in range(N):
    arr = list(map(int, input().split()))
    tbs.append(arr)
tbs.reverse()

m = -1
for i in range(2 ** N):
    _sum = [0] * (M + 1)
    for s in range(N):
        bit = (i >> s) & 1
        if bit == 0:
            continue
        for j in range(len(_sum)):
            _sum[j] += tbs[s][j]
    if min(_sum[1:]) < X:
        continue
    if m == -1 or m > _sum[0]:
        m = _sum[0]        

print(m)


Measured memory_bytes: 9216
N = int(input())
weights = list(map(int,input().split()))
wsum = sum(weights)
wavg = wsum/2
s1 = 0
d = 0
for i in range(N):
  if s1 < wavg: 
    s1 += weights[i]
    d = i
s1d = s1 - weights[d]
ansd = int((wavg - s1d)*2)
ans = int((s1-wavg)*2)
if ansd < ans:	print(ansd)
else:	print(ans)

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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long 
using namespace std;

typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int dp[100010][15];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	string s;
	cin>>s;
	dp[0][0] = 1;
	for(register int i=0;i<s.length();i++)
	{
		if(s[i]!='?')
		{
			for(register int j=0;j<13;j++)
			{
		     	dp[i+1][(j*10 + (int)(s[i] - '0'))%13] = dp[i][j];
			}
		}
		else
		{
			for(register int j=0;j<10;j++)
			{
				for(register int k=0;k<13;k++)
				{
					dp[i+1][(k*10 + j)%13] = (dp[i+1][(k*10 + j)%13] + dp[i][k])%mod;
				}
			}
		}
	}
	
	cout<<dp[s.length()][5];
	return 0;
}

Measured memory_bytes: 12268
n, m = map(int, input().split())

def down_stream_summer(number):
    initial_adder=number-1
    summer=0
    while initial_adder>0:
        summer+=initial_adder
        initial_adder-=1
    return summer

end=down_stream_summer(n)+down_stream_summer(m)
print(end)

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

int H, W;
const int MAX_HW = 2000 + 10;
char S[MAX_HW][MAX_HW];

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }

    int row[H][W];
    for (int i = 0; i < H; i++) {
        queue<int> dot;
        int dot_cnt = 0;
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '.') {
                dot_cnt++;
                if (j == W-1) {
                    dot.push(dot_cnt);
                }
            }
            else {
                if (dot_cnt != 0) {
                    dot.push(dot_cnt);
                    dot_cnt = 0;
                }
            }
        }

        bool f = false;
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '.') {
                row[i][j] = dot.front();
                f = true;
            }
            else {
                row[i][j] = 0;
                if (f) {
                    dot.pop();
                    f = false;
                }
            }
        }
    }

    int col[H][W];
    for (int j = 0; j < W; j++) {
        queue<int> dot;
        int dot_cnt = 0;
        for (int i = 0; i < H; i++) {
            if (S[i][j] == '.') {
                dot_cnt++;
                if (i == H-1) {
                    dot.push(dot_cnt);
                }
            }
            else {
                if (dot_cnt != 0) {
                    dot.push(dot_cnt);
                    dot_cnt = 0;
                }
            }
        }

        bool f = false;
        for (int i = 0; i < H; i++) {
            if (S[i][j] == '.') {
                col[i][j] = dot.front();
                f = true;
            }
            else {
                col[i][j] = 0;
                if (f) {
                    dot.pop();
                    f = false;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans = max(ans, row[i][j] + col[i][j] - 1);
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 35456
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

	long long GCD(long long a, long long b) {
		if (a < b)
			swap(a, b);
		if (b == 0) return a;
		else return GCD(b, a % b);
	}
	bool sosuu_check(int num) {
		int i;
		for (i = 2; i <= sqrt(num); ++i) {
			if (num%i == 0)
				return false;
		}
		return (num < 2) ? false : true;
	}



int main() {
	int N,i,j;
	cin >> N;
	vector<int> L(11);
	REP(i, N) {
		cin >> j;
		L[i]=j;
	}
	sort(L.begin(), L.begin() + N);
	ll sum=0;
	REP(i, N-1) {
		sum += L[i];
	}
	if (sum > L[N - 1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#define fori(x, y) for(int i = x; i<y; i++)
typedef long long ll;
using namespace std;
int main() { 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int N, op=0;
	cin >> N;
	int arr[107];
	fori(0, N)
		cin >> arr[i];
	bool iswatering = 1;
	while(iswatering){
		int m = 1000, numzeros=0;
		fori(0, N){
			while(i < N && arr[i]==0){
				i++;
				numzeros++;
			}
			int l =i ;
			while(i < N && arr[i]!=0){
				if(m>arr[i])
					m=arr[i];
				i++;
			}
			int r = i;
			//fori(0, N) cout << arr[i] << " ";
			//cout << endl << m << " " << op << endl;
			if(m<1000) op+=m;
			fori(l, r) arr[i]-=m;
			i=N;
		}
		if(numzeros==N) iswatering =0;
	}
	cout << op << "\n";
	
	return 0; 
} 

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

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

    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 3636
using System;

namespace E
{
    class Program
    {
        static long[] A;
        static long K;
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var N = NK[0]; K = NK[1];
            A = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            long result = lower_bound(0, 1000000000, cutCount);
            Console.WriteLine(result);
        }

        static bool cutCount(long target)
        {
            long result = 0;
            foreach (int a in A)
            {
                result += ((a + target - 1) / target) - 1;
            }
            return result <= K;
        }

        static long lower_bound(long ng, long ok, Func<long, bool> pred)
        {
            while (Math.Abs(ng - ok) > 1)
            {
                long mid = (ok + ng) / 2;

                if (pred(mid)) ok = mid;
                else ng = mid;
            }
            return ok;
        }
    }
}


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

int main() {
    int n, taro = 0, hanako = 0;
    string str1, str2;
    cin >> n;
    while (n--) {
        cin >> str1 >> str2;
        bool even = true;
        for (int i = 0; i < min(str1.size(), str2.size()); ++i) {
            if (str1[i] > str2[i]) {
                taro += 3;
                even = false;
                break;
            }
            else if (str1[i] < str2[i]) {
                hanako += 3;
                even = false;
                break;
            }
        }
        if (even) {
            if (str1.size() > str2.size()) {
                taro += 3;
            }
            else if (str1.size() < str2.size()) {
                hanako += 3;
            }
            else {
                ++taro;
                ++hanako;
            }
        }
    }
    cout << taro << ' ' << hanako << endl;
    
    return 0;
}


Measured memory_bytes: 3196
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int sum = 0;
        for(int a = 1; a <= k; a++){
            for(int b = 1; b <= k; b++){
                for(int c = 1; c <= k; c++){
                    sum += gcd(a, gcd(b, c));
                }
            }
        }

        System.out.println(sum);
    }

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


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

int main() {
  int K;
  cin >> K;
  string S;
  cin >> S;
  if(S.size()<=K){
    cout << S << endl;
  }
  else{
    for(int i=0;i<K;i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}



Measured memory_bytes: 3644
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
  while(1){
    int a[3];
    scanf("%d%d%d", a, a+1, a+2);
    if(a[0]==0&a[1]==0&a[2]==0) break;

    sort(a, a+3);

    int t = (a[0]*a[0]+a[1]*a[1]);

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

    for(int i=0;i<n;i++){
      int k;
      scanf("%d", &k);
      printf("%s\n", (4*k*k > t)? "OK":"NA");
    }
  }
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstring>
#define ll long long 
#define rep(i,a) for(int i= 0;i < a;i++)
using namespace std;

int main() {
    #ifndef ONLINE_JUDGE
		freopen("input.txt", "r" , stdin);
		freopen("output.txt", "w" , stdout);
	#endif
	ios::sync_with_stdio(0); 
	cin.tie(0); cout.tie(0);
   string s,t;
   cin>>s>>t;
   ll len=t.length();
   t.erase(t.begin()+len-1);
   if(t==s) cout<<"Yes";
   else cout<<"No";



   return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j;
    boost;
    cin>>n;
   string s,t;
   cin>>s>>t;
   string v;
    rep(i,0,sz(s))
    {
        v.pb(s[i]);
        v.pb(t[i]);
    }
    cout<<v;

    return 0;
}



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

UL N;
char S[401];
UL V[401];
vector<UL> R,G,Y;
UL D[251][251][251][3];
UL dp[251][251][251][3];

int main(){
 scanf("%u",&N);
 scanf(" ");
 scanf("%s",S);
 rep(i,N){
  if(S[i]=='R'){ V[i]=R.size(); R.push_back(i); }
  if(S[i]=='G'){ V[i]=G.size(); G.push_back(i); }
  if(S[i]=='Y'){ V[i]=Y.size(); Y.push_back(i); }
 }
 rep(i,N) if(V[i]>200){ printf("-1\n"); return 0; }
 rep(iR,R.size()+1) rep(iG,G.size()+1) rep(iY,Y.size()+1) rep(j,3)
  D[iR][iG][iY][j]=N;
 for(UL i=N-1; i!=~0u; i--){
  if(S[i]=='R'){
   rep(iG,G.size()+1) rep(iY,Y.size()+1){
    rep(j,3) D[V[i]][iG][iY][j] = D[V[i]+1][iG][iY][j];
    D[V[i]][iG][iY][0] = V[i]+iG+iY;
   }
  }
  if(S[i]=='G'){
   rep(iR,R.size()+1) rep(iY,Y.size()+1){
    rep(j,3) D[iR][V[i]][iY][j] = D[iR][V[i]+1][iY][j];
    D[iR][V[i]][iY][1] = iR+V[i]+iY;
   }
  }
  if(S[i]=='Y'){
   rep(iR,R.size()+1) rep(iG,G.size()+1){
    rep(j,3) D[iR][iG][V[i]][j] = D[iR][iG][V[i]+1][j];
    D[iR][iG][V[i]][2] = iR+iG+V[i];
   }
  }
 }

 rep(iR,R.size()+1) rep(iG,G.size()+1) rep(iY,Y.size()+1) rep(j,3)
  dp[iR][iG][iY][j]=(~0u)>>1;
 rep(j,3) dp[0][0][0][j] = 0;
 rep(iR,R.size()+1) rep(iG,G.size()+1) rep(iY,Y.size()+1){
  UL p=iR+iG+iY;
  if(iR) dp[iR][iG][iY][0] = min(dp[iR-1][iG][iY][1],dp[iR-1][iG][iY][2])+D[iR-1][iG][iY][0]-p+1;
  if(iG) dp[iR][iG][iY][1] = min(dp[iR][iG-1][iY][0],dp[iR][iG-1][iY][2])+D[iR][iG-1][iY][1]-p+1;
  if(iY) dp[iR][iG][iY][2] = min(dp[iR][iG][iY-1][0],dp[iR][iG][iY-1][1])+D[iR][iG][iY-1][2]-p+1;
 }
 UL ans = (~0u)>>1;
 rep(j,3) ans = min(ans,dp[R.size()][G.size()][Y.size()][j]);
 if(ans==(~0u)>>1) printf("-1\n");
 else printf("%u\n",ans);
 return 0;
}



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

const int MOD = 1000000007;

template<typename T> T combination(T N, T K) {
	if (N < K) return 0;
	if (N == K || K == 0) return 1;
	vector<T> v(N, 1);
	T prev1 = 1, prev2 = 1; // prev1 = n−1Ck−1, prev2 = n−1Ck

	for (T n = 2; n <= N; n++) {
		prev1 = 1;
		T k = 1;
		while (k < n && k <= K) {
			prev2 = v[k];
			v[k++] = (prev1 + prev2) % MOD; // 余りを答えるように要求された時用
			prev1 = prev2;
		}
	}
	return v[K];
}

// numを素因数分解してprime_factorに結果を格納する
template<typename T> void prime_factorization(T num, vector<pair<T, T>>& prime_factor) {
	T L = static_cast<T>(ceil(sqrt(num))), i = 0;
	prime_factor = vector<pair<T, T>>(L, make_pair(0, 0));
	for (T x = 2; x <= L; x++) {
		while (num % x == 0) {
			if (prime_factor[i].first) prime_factor[i].second++;
			else prime_factor[i] = make_pair(x, 1);
			num /= x;
		}
		if (num == 1) break;
		if (prime_factor[i].first) i++;
	}
	if (num > 1) prime_factor[i] = make_pair(num, 1);
}

signed main()
{
	using ULL = unsigned long long;
	ULL N, M;
	cin >> N >> M;

	// Mを素因数分解
	vector<pair<ULL, ULL>> prime;
	prime_factorization(M, prime);

	// 素因数ごとに重複組合せで振り分け
	ULL comb = 1;
	for (auto& p : prime) {
		if (p.first == 0) break;
		comb = (comb * combination(p.second + N - 1, p.second)) % MOD;
	}

	cout << comb << endl;
	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
int main(void)
{
	int a,b,x,y;
	scanf("%d %d",&x,&y);
	while(x!=0 || y!=0){
		if(y>x){
			printf("%d %d\n",x,y);
		}
		else{
			printf("%d %d\n",y,x);
		}
		scanf("%d %d",&x,&y);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

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

using namespace std;
int N;
ll W;
ll w[101];
int v[101];
ll dp[101][100001];
int main(void){
    cin >> N >> W;
    rep(i,N) scanf("%lld %d",&w[i+1], &v[i+1]);
    fill(dp[0],dp[0]+101*100001,INF);
    rep(i,N+1) dp[i][0] = 0;

    for(int i = 1;i <= N; i++) for(int j = 1;j <= N*1000;j++){
        if(j >= v[i])
            dp[i][j] = min(dp[i-1][j-v[i]] + w[i], dp[i-1][j]);
        else dp[i][j] = dp[i-1][j];
    }

    ll ans = 0;
    for(int i= 1;i<=N*1000;i++) {
        if(dp[N][i] <= W) ans = i;
        /*
        if (dp[N][i] != INF and dp[N][i] <= W)
            ans = i;
        else if(dp[N][i] != INF) break;
        */
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
#define rep(m,x,r) for((m)=(x);(m)<(r);(m)++)
int main(){
    int n,i,m=0;
    cin>>n;
    int a[n+1],ans[n+1];
    a[0]=-1;
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=n;i>0;i--){
            int buf=0;
            for(int j=2*i;j<=n;j+=i)buf^=ans[j];
            if(a[i]!=buf){
                ans[i]=1;
                m++;
            }
            else ans[i]=0;
    }
        cout<<m<<endl;
        rep(i,1,n+1)if(ans[i])cout<<i<<" ";
    cout<<"\n";
}


Measured memory_bytes: 2432
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
  double a,b,c,d,e,f;
  double x,y;
  while(cin>>a>>b>>c>>d>>e>>f){
    y = (double)(a*f-d*c) / (a*e - b*d);
    x = (c-b*y) / a;
    cout << setprecision(3) << setiosflags(ios::fixed) << x << ' ' << setprecision(3) << setiosflags(ios::fixed) << y << endl;
  }
  return 0;
}

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

int x[ 110 ];
int y[ 110 ];

int main()
{
int i;
int N;
int M;
int X;
int Y;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> M;
	cin >> X;
	cin >> Y;

	for( i = 0; i < N;i++ )cin >> x[i];
	for( i = 0; i < M;i++ )cin >> y[i];

	sort( x, x + N );
	sort( y, y + M );

	if( x[ N -1 ] < Y && X < y[ 0 ] &&  x[ N -1 ] < y[ 0 ] )
		cout << "No War"<< endl;
	else
		cout << "War"<< endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            WriteLine(0.5* n * (n + 1));
        }
       

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


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

int main(){
  int n,x,y;
  cin >> n >> x >> y;
  int kazu[n+1]={0};

  for(int i=1; i < n; i++){
    for(int j=i+1; j<=n; j++ ){
      int kyori = 0;
      int a,b,c;
      a = j-i;
      b = abs(x-i) + 1 + abs(y-j);
      kyori = min(a,b);
      kazu[kyori]++;
    }
  }
  for(int i=1; i<n; i++){
    cout << kazu[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256