akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

struct Point
{
    // 座標上の点
    double x,y;
};

// ベクトル
typedef Point Vector;


struct Seg
{
    // 点a,bを通る直線
    Point a,b;
};

typedef Seg Line;

// 二つのベクトルの内積
double dot(Vector a, Vector b){
    return a.x*b.x + a.y*b.y;
}

// 二つのベクトルの外積
double cross(Vector a, Vector b){
    return a.x*b.y-a.y*b.x;

}

Point vecminus (Point p1, Point p2){
    Point p;
    p.x = p1.x-p2.x;
    p.y = p1.y-p2.y;
    return p;
}

bool isOrthogonal(Line l1, Line l2);
bool isParallel(Line l1, Line l2);

int main(){
    int q; cin >> q;
    for(int i = 0; i < q; i++){
        Line l1,l2;
        Point p1,p2,p3,p4;
        int x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        p1.x = x1; p1.y = y1; p2.x = x2; p2.y = y2;
        cin >> x1 >> y1 >> x2 >> y2;
        p3.x = x1; p3.y = y1; p4.x = x2; p4.y = y2;

        l1.a = p1; l1.b = p2;
        l2.a = p3; l2.b = p4;
        if(isOrthogonal(l1,l2)) cout << 1 << endl;
        else if(isParallel(l1,l2)) cout << 2 << endl;
        else cout << 0 << endl;

    }
    return 0;
}

bool isOrthogonal(Line l1, Line l2){
    return dot(vecminus(l1.a, l1.b) , vecminus(l2.a, l2.b)) == 0;
}
bool isParallel(Line l1, Line l2){
    return cross(vecminus(l1.a, l1.b) , vecminus(l2.a, l2.b)) == 0;
}


Measured memory_bytes: 3120
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int n;
int a[101];

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];
    int cnt = 0;

    for (int i = 0; i < n; i++) {
        int minj = i;
        for (int j = i; j < n; j++) {
            if (a[j] < a[minj]) {
                minj = j;
            }
        }
        if (a[i] != a[minj]) {
            swap(a[i], a[minj]);
            cnt++;
        }
    }
    rep(i, n - 1) cout << a[i] << " ";
    cout << a[n - 1] << endl << cnt << endl;
    return 0;
}



Measured memory_bytes: 3092
while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    a=[int(input()) for _ in range(n)]
    s=sum(a[0:k])
    ss=[s]
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))



Measured memory_bytes: 11700
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int>v,p,q;
int n,a;
int main(void){
    cin>>n;
    for(int i=0;i<(1<<n);i++){
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    p.push_back(v.back());
    v.back()=-1;
    for(int i=0;i<n;i++){
        int Q=(1<<i),N=(1<<n);
        sort(p.begin(),p.end());
        q=p;
        while(N){
            if(!Q)break;
            if(v[N-1]==-1){
                N--;
                continue;
            }
            if(v[N-1]<q[Q-1]){
                p.push_back(v[N-1]);
                v[N-1]=-1;
                N--;
                Q--;
                continue;
            }
            N--;
        }
        if(Q>0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x));
#define SORT(x) sort(ALL(x));
#define SUM(x) accumulate(ALL(x), 0);
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
typedef vector<ll> VI;
typedef vector<VI> VVI;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}


void Main()
{
	ll N;
	ll val=1e12;
	double value=1000000000;
	int result=0;
	string S;
	cin>>N;
	VI vec(N);
	REP(i, N) cin >> vec[i];
	FOR(i,-100,100){
		ll cost=0;
		double c=0;
		REP(j,SIZE(vec)){
			cost+=pow(vec[j]-i,2);
			c+=pow((double)(vec[j]-i),2);
		}
		bool change=chmin(val,cost);
		if(change){
			result=cost;
		}
	}
	cout << result << "\n";
	return;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <queue>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n%2 == 0) cout << n << endl;
    else if(n%2 != 0) cout << 2*n << endl;
}

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

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

  Int n;
  cin>>n;
  cin.ignore();

  vector<string> vs;
  for(Int i=0;i<n;i++){
    string s;
    getline(cin,s);
    vs.emplace_back(s);
  }

  map<string, Int> idx;
  for(Int i=0;i<n;i++){
    if(count(vs[i].begin(),vs[i].end(),' ')) continue;
    vs[i].pop_back();
    idx[vs[i]]=i;
  }

  using P = pair<Int, Int>;
  vector< vector<P> > G(n+1);
  for(Int i=0;i<n;i++){    
    if(count(vs[i].begin(),vs[i].end(),' ')){
      auto pos=vs[i].find(' ');
      string s=vs[i].substr(pos+1);
      s.pop_back();
      G[i].emplace_back(idx[s],0);
      G[i].emplace_back(i+1,1);
    }else{
      G[i].emplace_back(i+1,0);
    }
  }
  
  const Int INF = 1e5;
  vector<Int> dp(n+1,INF);
  queue<Int> que;
  dp[0]=0;
  que.emplace(0);

  while(!que.empty()){
    Int v=que.front();que.pop();
    //cout<<v<<":"<<dp[v]<<endl;
    for(auto e:G[v]){
      Int u=e.first,c=e.second;
      if(dp[u]<=dp[v]+c) continue;
      dp[u]=dp[v]+c;
      que.emplace(u);
    }
  }  
  
  cout<<dp[n]<<endl;
  return 0;
}



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

int main() {
    int a,b;
    cin >> a >> b;

    if(a < b){
        swap(a,b);
    }

    if(a - b >0){
        cout << a * 2 -1 <<endl;
    } else {
        cout << a * 2 << endl;
    }
    return 0;
}


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

int main(){
	int n,ans,count=0;
	string s;

	cin>>n>>s;
	
	//ある点を境に右は黒色、左は白色にする;
	//一端全部#にした時を考える;
	for(int i=0;i<n;i++)
		if(s[i]=='.')count++;
	ans=count;
	for(int i=0;i<n;i++){
		if(s[i]=='.')count--;
		else count++;
		ans=min(ans,count);
	}
	cout<<ans;
}

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

int mn;
string a;
int main()
{
	int i;
	cin >> a;
	mn = a.size();
	for (i = 1; i < a.size(); i++) {
		if (a[i] != a[i - 1]) mn = min(mn, max(i, (int)a.size() - i));
	}
    cout << mn << endl;
    return 0;
}

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

template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=1000+5,dx[]={-1,1,0,0},dy[]={0,0,-1,1};
char s[N][N];
int g[N][N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);
#endif
	int n,m;
	cin>>n>>m;
	rep(i,1,n)scanf("%s",s[i]+1);
	
	deque<pair<int,int>>q;
	rep(i,1,n)
	rep(j,1,m)
	if(s[i][j]=='#')q.push_back({i,j});
	else g[i][j]=-1;
	
	int ans=0;
	while(!q.empty())
	{
		int x,y;
		tie(x,y)=q.front();q.pop_front();
		chmax(ans,g[x][y]);
		rep(i,0,3)
		if(g[x+dx[i]][y+dy[i]]==-1)
		{
			g[x+dx[i]][y+dy[i]]=g[x][y]+1;
			q.push_back({x+dx[i],y+dy[i]});
		}
	}
	
	cout<<ans;
}

Measured memory_bytes: 11280
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
while 1:
    w,h = LI()
    if w==h==0:
        break
    hwall,wwall = [],[]
    for i in range(2*h-1):
        hwall.append(LI()) if i%2==0 else wwall.append(LI())
    dhdw = [[-1,0],[1,0],[0,-1],[0,1]]
    min_dist = [[-1]*w for _ in range(h)]
    seen = [[0]*w for _ in range(h)]
    queue = collections.deque() #位置[行,列]を入れておく
    def bfs():
        seen[0][0] = 1
        queue.append([0,0])
        min_dist[0][0] = 1
        while queue:
            qh,qw = queue.popleft()
            for dh,dw in dhdw:
                nh,nw = qh+dh,qw+dw
                if not(0<=nh<=h-1) or not(0<=nw<=w-1) or seen[nh][nw]:
                    continue
                if (dh==-1 and wwall[nh][nw]==1) or (dh==1 and wwall[nh-1][nw]==1):
                    continue
                if (dw==-1 and hwall[nh][nw]==1) or (dw==1 and hwall[nh][nw-1]==1):
                    continue
                if [nh,nw]==[h-1,w-1]:
                    return min_dist[qh][qw]+1
                seen[nh][nw] = 1
                queue.append([nh,nw])
                min_dist[nh][nw] = min_dist[qh][qw]+1
    print(bfs() or 0)


Measured memory_bytes: 6040
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e18;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

typedef pair<Pa, ll> edge;
vector<edge> edges;
ll range[200][200];
vector<ll> pos;
int main() {
	cin >> N >> M >> R;
	rep(i, R) {
		cin >> A;
		A--;
		pos.push_back(A);
	}
	rep(i, N) {
		rep(j, N) {
			if (i == j) continue;
			range[i][j] = MAX;
		}
	}

	rep(i, M) {
		cin >> A >> B >> C;
		A--; B--;
		range[A][B] = min(range[A][B], C);
		range[B][A] = min(range[B][A], C);
	}
	rep(k, N) {
		rep(i, N) {
			rep(j, N) {
				if (i == j || j == k || k == i) continue;
				range[i][j] = min(range[i][j], range[i][k] + range[k][j]);
			}
		}
	}

	ll ans = MAX;
	sort(pos.begin(), pos.end());
	do {
		ll sum = 0;
		rep(i, R - 1) {
			sum += range[pos[i]][pos[i + 1]];
		}
		ans = min(ans, sum);
	} while (next_permutation(pos.begin(), pos.end()));

	cout << ans;
}

Measured memory_bytes: 512
import java.util.*;
 
public class Main{
	public static void main(String[] args){
      	int N,M;
    	Scanner scan = new Scanner(System.in);
      	N = scan.nextInt();
      	M = scan.nextInt();
      	
      	if(M == N){
        	System.out.println("Yes");
        }
      	else if(M != N){
        	System.out.println("No");
        }
      
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define RI register int
using namespace std;

int const MAXN = 1e5 + 5;
char s[10];
int vis[MAXN], cnt[MAXN];

int main() {

    int n, m; cin >> n >> m;
    int ans1 = 0, ans2 = 0;
    for (int i = 1; i <= m; ++i) {
        int num; cin >> num;
        cin >> s;
        if (s[0] == 'W')
            cnt[num] += !vis[num];
        else {
            ans1 += !vis[num];
            vis[num] = 1;
        }
    }
    for (int i = 1; i <= n; ++i)
        if (vis[i]) ans2 += cnt[i];
    printf("%d %d\n", ans1, ans2);

    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    class Program
    {
        
        static void Main()
        {
            //ここから
            int N = ReadLineToInt();
            string S = ReadLineToString();
            long mod = 1000000007;
            int[] str = new int[26];
            for(int i = 0; i < 26; i++)
            {
                str[i] = 0;
            }
            for(int i = 0; i < N; i++)
            {
                int tes = S[i];
                str[S[i]-97]++;
            }

            long ans = 1;
            for(int i = 0; i < 26; i++)
            {
                ans = ans * (str[i]+1) % mod;
            }
            ans--;
            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }


        static public void Swap<T>(ref T a,ref T b) { T temp = a;a = b;b = temp; }
        static public long GCD(int a, int b){ return b != 0 ? GCD(b, a % b) : a;}
        static public long LCM(int a, int b){ return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n,int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }


        
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
    
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double inf = 1e20;
inline double sqr (double k) {return k * k;}
inline int sgn (double p) {
    if (fabs (p) < eps) return 0;
    if (p < 0) return -1;
    return 1;
}
struct point {
    double x, y;
    point (){}
    point (double _x, double _y) {
        x = _x, y = _y;
    }
    void input () {
        scanf ("%lf %lf", &x, &y);
    }
    bool operator == (point b) const {
        return sgn (x - b.x) == 0 && sgn (y - b.y) == 0;
    }
    point operator - (const point &b) const {
        return point (x - b.x, y - b.y);
    }
    double operator * (const point &b) const {
        return x * b.x + y * b.y;
    }
    double operator ^ (const point &b) const {
        return x * b.y - y * b.x;
    }
    double len () {
        return hypot (x, y);
    }
    double len2 () {
        return x * x + y * y;
    }
    double distance (point p) {
        return hypot (x - p.x, y - p.y);
    }
    point operator + (const point &b) const{
        return point (x + b.x, y + b.y);
    }
    point operator * (const double &b) const {
        return point (x * b, y * b);
    }
    point operator / (const double &b) const {
        return point (x / b, y / b);
    }
};
int main () {
//    freopen ("in.txt", "r", stdin);
    int Q;
    cin >> Q;
    while (Q --) {
        int t = 0, ans;
        double u, k;
        point s1, e1, s2, e2, a, b, c;
        s1.input (), e1.input ();
        s2.input (), e2.input ();
        a = e1 - s1;
        b = e2 - s2;
        u = a ^ b;
        k = a * b;
        if (sgn (k) == 0) cout << 1 << endl;
        else if (sgn (u) == 0) cout << 2 << endl;
        else cout << 0 << endl;
//        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3308
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	int n;
	cin >> n;
	int a[n];
	rep (i, n) cin >> a[i];

	map<int, int> mp;
	rep (i, n) {
		if (a[i] <= 399) mp[0]++;
		else if (a[i] < 800) mp[1]++;
		else if (a[i] < 1200) mp[2]++;
		else if (a[i] < 1600) mp[3]++;
		else if (a[i] < 2000) mp[4]++;
		else if (a[i] < 2400) mp[5]++;
		else if (a[i] < 2800) mp[6]++;
		else if (a[i] < 3200) mp[7]++;
		else mp[8]++;
	}

	if (!mp[8]) {
		cout << mp.size() - 1 << " " << mp.size() - 1 << endl;
	}
	else {
		if (n == mp[8]) {
			cout << 1 << " " << mp[8] << endl;
		}
		else {
			cout << mp.size() - 1 << " " << mp.size() - 1 + mp[8] << endl;
		}
	}

	return 0;
}

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

vector<long long int> G[100002];
vector<long long int> c(1e5+2,-1);
int nib=0;
vector<long long int> co(2,0);

int nibu(long long int p,long long int x){
	for(long long int i=0;i<G[p].size();i++){
		if(c[G[p][i]]==-1){
			c[G[p][i]]=abs(x-1);
			co[abs(x-1)]++;
			nibu(G[p][i],abs(x-1));
		}else if(c[G[p][i]]==x){
			nib=1;
		}
	}
	return 0;
}

int main(){
	long long int n,m;
	cin>>n>>m;
	for(long long int i=0;i<m;i++){
		long long int a,b;
		cin>>a>>b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	c[0]=0;
	co[0]++;
	nibu(0,0);
	
	if(nib==0){
		cout<<co[0]*co[1]-m<<endl;
	}else{
		cout<<n*(n-3)/2-m+n<<endl;
	}
	return 0;
}

Measured memory_bytes: 8448
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    ll k;
    cin >> k;

    ll tmp = 7;
    REP(i,k){
        if(tmp%k==0){
            cout << i+1 << endl;
            return 0;
        }
        else{
            tmp = tmp%k;
            tmp = 10*tmp + 7;
            //cout << tmp << endl;
        }
    }
    cout << "-1" << endl;
    return 0;
}

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


int main() {

    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    int N = 7;
    if (S.equals("SUN")) {
      System.out.println(N);
    }
    else if (S.equals("MON")) {
      System.out.println(N-1);
    }
    else if (S.equals("TUE")) {
      System.out.println(N-2);
    }
    else if (S.equals("WED")) {
      System.out.println(N-3);
    }
    else if (S.equals("THU")) {
      System.out.println(N-4);
    }
    else if (S.equals("FRI")) {
      System.out.println(N-5);
    }
    else{
      System.out.println(N-6);
    }
  }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

string s = "";
int n;


const int MAX_N = 2 * (int)1e5+10;
int ans = MAX_N;

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

    int cnt[MAX_N+1];

    cnt[0] = 0;
    FOR(i,0,n)
    {
        if (s[i] == '#')
            cnt[i+1] = cnt[i] + 1;
        else
            cnt[i+1] = cnt[i];

    }


    ///##### -> .#### -> .....
    REP(i,n+1)
    {
        int WtoB;
        int BtoW;

        WtoB = (n - i) - (cnt[n] - cnt[i]);
        BtoW = cnt[i];

        //DEBUG(i);
        //DEBUG(WtoB);
        //DEBUG(BtoW);
        ans = min(ans, WtoB + BtoW );
    }


    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1412
from heapq import heapify, heappush, heappop

def main():
    X, Y, A, B, C = map(int, input().split())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    R = list(map(int, input().split()))

    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)
    PQ = P[:X] + Q[:Y]
    heapify(PQ)
    
    while C:
        mpq = heappop(PQ)
        mr = R.pop(0)
        if mpq >= mr:
            heappush(PQ, mpq)
            break
        heappush(PQ, mr)
        C -= 1
    
    print(sum(PQ))
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 23360
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();

            var o = new string[3];
            for(var i = 0; i < 3; i++){                
                if(s[i] == '1'){
                    o[i] = "9";
                }else{
                    o[i] = "1";
                }
            }

            Console.WriteLine(string.Join("",o));
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
  int n;
  cin >> n;
  vector<int> A;
  int ct=0;
  int a, j;
  rep(i, n){
    cin >> a;
    if(a>n) ct++;
    else A.push_back(a);
  }
  sort(A.begin(), A.end());
  int sz = A.size();
  rep(i, sz){
    int g = A[i];
    int c = 1;
    int m= min(i+g, sz);
    for(j=i+1; j<m; j++){
      if(A[j]!=g){
        i = j-1;
        ct += c; 
        break;
      }
      else c++;
    }
    //cout << j << endl;
    if(j==sz){
      if(c!=g){
        //cout << c << endl;
        ct += c;
        break;
      } 
    }
    
    if(c==g){
      while(A[i]==A[i+c]){
        ct++;
        c++;
        if(i+c==sz) break;
      }
      i += c-1;
    }
    
  }
  cout << ct << endl;
}

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

using namespace std;

const int MAX_N = 6080;

int N, match[MAX_N];
string S, F[MAX_N];

void init() {
    cin >> N;
    cin >> S;
    queue<int> que;
    for (int i = 0; i < 2 * N; i++) {
        if (que.empty() || S[que.front()] == S[i]) que.push(i);
        else {
            int j = que.front(); que.pop();
            match[j] = i; match[i] = j;
        }
    }
}

void solve() {
    static bool sel[MAX_N];
    for (int i = 2 * N - 1; i >= 0; i--) {
        if (match[i] > i) {
            if (S[i] == 'a') F[i] = "ab" + F[match[i] + 1];
            else {
                fill_n(sel, 2 * N, false);
                int lvl = 0, j = i;
                for (j = i; j < 2 * N && (j == i || lvl); j++) {
                    if (S[j] == 'b') {
                        lvl++;
                        sel[match[j]] = true;
                        F[i].push_back('b');
                    } else if(sel[j]) {
                        F[i].push_back('a');
                        lvl--;
                    }
                }
                F[i] += F[j];
            }
        }
        F[i] = max(F[i], F[i + 1]);
    }
    cout << F[0] << endl;
}

int main() {
    init();
    solve();
}


Measured memory_bytes: 14592
def func1(lst, value): return [i for i, x in enumerate(lst) if x == value]
def func2(coping, lst, coefficient=1):return sum(lst[i] * coefficient for i in coping)

lst = [input().split(' ') for i in range(int(input()))]
X = [float(i[0]) for i in lst]
Y = [i[1] for i in lst]

print(func2(func1(Y,"BTC"),X,380000.0) + func2(func1(Y,"JPY"),X))

Measured memory_bytes: 3064
[n,m] = [int(i) for i in input().split()]
ab = []
dic = {}
for i in range(m):
  ab.append([int(j) for j in input().split()])

for i in range(m):
  if ab[i][0] in dic.keys():
    dic[ab[i][0]] += 1
  else:
    dic[ab[i][0]] = 1
    
  if  ab[i][1] in dic.keys():
    dic[ab[i][1]] += 1
  else:
    dic[ab[i][1]] = 1
    
for i in range(n):
  if i+1 in dic.keys():
    print(dic[i+1])
  else:
    print(0)

Measured memory_bytes: 3064
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))


n,k = inpl()
res = 0
for i in range(1,n+1):
    cnt = 0
    now = i
    if i > k:
        res += 1/n
        continue
    while now < k:
        now *= 2
        cnt += 1
    res += 1/n*(1/2**cnt)
print(res)

Measured memory_bytes: 77612
import sys
import math
'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
a=int(input())
count=0
for i in range(1,1+a):
  if len(str(i))%2==1:
    count+=1
print(count)


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

int main() {
    int n,k,a=1;
    cin >> n >> k;
    for(int i = 0;i < n;i ++){
        if(a*2 < a+k){
            a *= 2;
        }else{
            a += k;
        }
    }
    cout << a << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

const int N = 110, K = 100100;
int a[N], dp[K] = {0};
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int x = a[1]; x <= k; x++) {
        for (int i = 1; i <= n; i++) {
            if (a[i] > x) {
                break;
            }
            if (dp[x - a[i]] == 0) {
                dp[x] = 1;
                break;
            }
        }
    }
    if (dp[k]) {
        cout << "First\n";
    }  else {
        cout << "Second\n";
    }
}

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

int main() {
  long long K,A,B;
  cin >> K >> A >> B;
  if (A+1 >= B || K+1 <= A) {
    cout << K+1 << endl;
  } else {
    // A-1 turn to start doubling
    long long initial = A - 1;
    long long doubling = ((K - initial) / 2);
    long long remain = K - (initial + doubling * 2);
    cout << A + doubling * (B - A) + remain << endl;
  }
}

Measured memory_bytes: 256
function Main(input) {
  "use strict"
  const nm = input.split("\n")[0].split(" ")
  const n = parseInt(nm.shift())
  const m = parseInt(nm.shift())
  const ans = (n * (n - 1) + m * (m - 1)) / 2
  console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
    int c[3][3];
    for (auto i = 0; i < 3; i++) {
        for (auto j = 0; j < 3; j++) cin >> c[i][j];
    }

    bool flg = true;
    int a[3] = { 0 }, b[3] = { 0 };
    for (auto i = 0; i <= 100; i++) {
        a[0] = i;
        b[0] = c[0][0] - a[0];
        a[1] = c[1][0] - b[0];
        b[1] = c[1][1] - a[1];
        a[2] = c[2][1] - b[1];
        b[2] = c[2][2] - a[2];

        for (auto j = 0; j < 3; j++) {
            for (auto k = 0; k < 3; k++) {
                if(c[j][k] != a[j] + b[k]) flg = false;
            }
        }
        if(flg) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  vi a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(all(a));
  ll alice = 0;
  ll bob = 0;
  for (ll i = sz(a) - 1; i >= 0;i-=2){
    alice += a[i];
  }
  for (ll i = sz(a) - 2; i >= 0;i-=2){
    bob += a[i];
  }
  print(alice - bob);
}


Measured memory_bytes: 256
// E - Sequence Sum
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	ll N; int X, M; cin>>N>>X>>M;

	int mn = min(N, (ll)M);
	set<ll> S;
	vector<ll> A;
	ll a = X;
	ll sum_9 = 0; // sum of pre + cycle

	rp(_i, 0, mn){
		if(S.find(a) != S.end()) break;
		S.insert(a);
		A.push_back(a);
		sum_9 += a;
		a = a*a % M;
	}

	if((int)A.size() >= mn){ cout<< sum_9 <<endl; return 0; }

	int pre_len = find(A.begin(), A.end(), a) - A.begin();
	int cyc_len = A.size() - pre_len;
	int btm_len = (N - pre_len) % cyc_len;

	ll cyc_num = (N - pre_len) / cyc_len;

	ll pre = 0; rp(i, 0, pre_len) pre += A[i];
	ll cyc = sum_9 - pre;
	ll btm = 0; rp(i, pre_len, pre_len + btm_len) btm += A[i];

	cout<< pre + cyc * cyc_num + btm <<endl;
}


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

int main(){
    int n;
    cin >> n;
    int a[n],b[n],c[n],dpa[n],dpc[n],dpb[n];
      for(int i=0;i<n;i++){
        cin >> a[i] >> b[i] >> c[i];
        dpa[i] = dpb[i] = dpc[i] = 0;
    }
    dpa[0] = a[0];
    dpb[0] = b[0];
    dpc[0] = c[0];
    for(int i=1;i<n;i++){
        dpa[i] = a[i] + max(dpb[i-1],dpc[i-1]);
        dpb[i] = b[i] + max(dpa[i-1],dpc[i-1]);
        dpc[i] = c[i] + max(dpb[i-1],dpa[i-1]);
    }
    cout << max(max(dpa[n-1],dpb[n-1]),dpc[n-1]);
    return 0;
}

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

typedef struct number
{
    int i;
    int next_i;
} number;

int main(void)
{
    int inputN, *inputB, *answer;
    number *a;
    unsigned int answers = 0;
    scanf("%d", &inputN);
    a = (number *)malloc(sizeof(number) * inputN - 1);
    answer = (int *)malloc(sizeof(int) * inputN);
    inputB = (int *)malloc(sizeof(int) * (inputN - 1));
    for (int count = 0; count < inputN - 1; count++)
    {
        scanf("%d", &inputB[count]);
        number tmp;
        tmp.i = inputB[count];
        tmp.next_i = inputB[count];
        a[count] = tmp;
    }
    for (int count = 0; count < inputN - 1; count++)
    {
        if (count == 0)
        {
            answer[count] = a[count].i;
        }
        else
        {
            if (a[count - 1].next_i > a[count].i)
            {
                answer[count] = a[count].i;
            }
            else
            {
                answer[count] = a[count - 1].next_i;
            }
        }
    }
    answer[inputN - 1] = a[inputN - 2].next_i;
    for (int count = 0; count < inputN; count++)
    {
        answers += answer[count];
    }
    
    printf("%u", answers);

    free(inputB);
    free(answer);
    free(a);

    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first1,
	BidirectionalIterator last1,
	BidirectionalIterator first2,
	BidirectionalIterator last2)
{
	if ((first1 == last1) || (first2 == last2)) {
		return false;
	}
	BidirectionalIterator m1 = last1;
	BidirectionalIterator m2 = last2; --m2;
	while (--m1 != first1 && !(*m1 < *m2)) {
	}
	bool result = (m1 == first1) && !(*first1 < *m2);
	if (!result) {
		// ①
		while (first2 != m2 && !(*m1 < *first2)) {
			++first2;
		}
		first1 = m1;
		std::iter_swap(first1, first2);
		++first1;
		++first2;
	}
	if ((first1 != last1) && (first2 != last2)) {
		// ②
		m1 = last1; m2 = first2;
		while ((m1 != first1) && (m2 != last2)) {
			std::iter_swap(--m1, m2);
			++m2;
		}
		// ③
		std::reverse(first1, m1);
		std::reverse(first1, last1);
		std::reverse(m2, last2);
		std::reverse(first2, last2);
	}
	return !result;
}

template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first,
	BidirectionalIterator middle,
	BidirectionalIterator last)
{
	return next_combination(first, middle, middle, last);
}


struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int main() {
	cout<<setprecision(10)<<fixed;

	int tt=false;
	while (true){
		int N,M;cin>>N>>M;
		if(!N)break;

		if (tt)cout << endl;
		tt = true;
		map<string,int>mp;
		map<int,string>revmp;
		{
			for (int i = 0; i < N; ++i) {
				string st;cin>>st;
				mp[st]=i;
				revmp[i]=st;
			}
		}
		vector<vector<int>>langs(M,vector<int>(N));
		for (int i = 0; i < M; ++i) {
			int k;cin>>k;
			for (int j = 0; j < k; ++j) {
				string st;cin>>st;
				langs[i][mp[st]]=true;
			}
		}
		vector<int>perms(N);
		iota(perms.begin(),perms.end(),0);

		vector<string>anss;

		for (int t = 1; t <= (min(N, 5)); ++t) {
			do {
				UnionFind uf(M + min(N, 5));
				for (int i = 0; i < M; ++i) {
					for (int j = 0; j < t; ++j) {
						int lang_id = perms[j];
						if (langs[i][lang_id])uf.unionSet(i, M + j);

						for (int k = 1; k <t; ++k) {
							int lang_id2 = perms[k];
							if (langs[i][lang_id] && langs[i][lang_id2]) {
								uf.unionSet(M + j, M + k);
							}
						}
					}
				}
				set<int>aset;
				for (int i = 0; i < M + t; ++i) {
					aset.emplace(uf.root(i));
				}
				if (aset.size() == 1) {
					for (int i = 0; i < t; ++i) {
						anss.emplace_back(revmp[perms[i]]);
					}
					break;
				}
			} while (next_combination(perms.begin(), perms.begin() + t, perms.end()));
			if(!anss.empty())break;
		}
		if (anss.empty()) {
			cout << "Impossible" << endl;
		}
		else {
			cout<<anss.size()<<endl;
			for(auto ans:anss)cout<<ans<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3068
using System;

namespace ALDS111A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] ans = new int[n, n];
            string outs;
            for (int i = 0; i < n; ++i) 
            {
                for (int j = 0; j < n; ++j) 
                    ans[i, j] = 0;

                string s = Console.ReadLine();
                string[] nums = s.Split(' ');
                int k = int.Parse(nums[1]);
                for (int v = 0; v < k; ++v) 
                    ans[i, int.Parse(nums[v + 2]) - 1] = 1;
            }
            for (int i = 0; i < n; ++i) 
            {
                outs = ans[i, 0].ToString();
                for (int j = 1; j < n; ++j)
                    outs += " " + ans[i, j].ToString();

                Console.WriteLine(outs);
            }
        }
    }
}

Measured memory_bytes: 6160
import itertools

N = int(input())
cities = [list(map(int, input().split())) for _ in range(N)]
patterns = itertools.permutations(cities, N)
result = 0
count = 0
for ptn in patterns:
  count += 1
  dis = 0
  for i in range(N-1):
    dis += ((ptn[i][0]-ptn[i+1][0])**2 + (ptn[i][1]-ptn[i+1][1])**2)**0.5
  result += dis
print(result/count)



Measured memory_bytes: 74576
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

int main()
{
	int N;
	cin >> N;
	vector<int> H(N);
	rep(i,N) cin >> H[i];
	bool flag = true;
	int ma = H[0];
	rep(i, N)
	{
		if (H[i] >= ma-1) 
		{
			ma = max(ma, H[i]);
		}
		else
		{
			flag = false;
			break;
		}
	}

	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

vector<bool> a(10, false);

bool check(int n) {
  while (n > 0) {
    if (a[n % 10]) return false;
    n /= 10;
  }
  return true;
}

int main() {
  int n, k;
  cin >> n >> k;
  rep(i, k) {
    int d;
    cin >> d;
    a[d] = true;
  }

  int ans = n;
  while (1) {
    if (check(ans)) {
      cout << ans << endl;
      return 0;
    }
    ans++;
  }




  
  return 0;
}

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

int N,M,X,a=0,b=0;
int arr[110];
int main(){
	cin>>N>>M>>X;
	for(int i=1; i<=M; i++) {
		cin>>arr[i];
		if(arr[i] > X) {
			a++;
		} else {
			b++;
		}
	}
	cout<<min(a,b)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#include<set>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
 
using namespace std;

int main(){
    int N, K, S;    cin >> N >> K >> S;
    ll MAX = 1000000000;
    if(S == MAX){
        for(int i=0; i<K; i++)  cout << MAX << " ";
        for(int i=K; i<N; i++)  cout << MAX-1 << " ";
    }else{
        for(int i=0; i<K; i++)  cout << S << " ";
        for(int i=K; i<N; i++)  cout << MAX << " ";
    }
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
#define INF (int)1e8

int G[105][105][21];
int G2[105][105];
int p[21],q[51],r[51];

int n,m,c,s,g;

main(){
	int i,j,k,l,x,y,d,cc;
	while(cin>>n>>m>>c>>s>>g,n){
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++){
				G2[i][j] = i==j?0:INF;
				for(k=1;k<=c;k++) G[i][j][k] = i==j?0:INF;
			}
		for(i=1;i<=m;i++){
			cin >> x >> y >> d >> cc;
			G[y][x][cc] = G[x][y][cc] = min(d,G[x][y][cc]);
		}
		for(l=1;l<=c;l++)
		  for(k=1;k<=n;k++)
		    for(i=1;i<=n;i++)
		      for(j=1;j<=n;j++)
			G[i][j][l] = min(G[i][j][l], G[i][k][l] + G[k][j][l]);
		

		for(i=1;i<=c;i++) cin >> p[i];
		for(i=1;i<=c;i++){
			int t=0,x=1,m[20001];
			for(j=1;j<=p[i]-1;j++) cin >> q[j];
			q[p[i]] = INF;
			for(j=1;j<=p[i];j++) cin >> r[j];
			for(j=0;j<=20000;j++){
				if(j == q[x]){
					x++;
				}
				m[j] = t;
				t += r[x];
			}
			for(j=1;j<=n;j++)
				for(k=1;k<=n;k++){
					if(G[j][k][i] == INF) continue;
					G2[j][k] = min(G2[j][k],m[G[j][k][i]]);
				}
		}
		for(k=1;k<=n;k++)
		  for(i=1;i<=n;i++)
		    for(j=1;j<=n;j++)
			G2[i][j] = min(G2[i][j], G2[i][k] + G2[k][j]);
		cout << (G2[s][g]==INF?-1:G2[s][g]) << endl;
	}
	
	return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

int N;

int main()
{
	cin >> N;

	cout << (1 + N) * N / 2 << endl;

	return 0;
}


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

void dfs(vector<int> &x, vector<bool> &y){
  if (x.size() == 5)
  {
    int temp = 0;
    for (int i = 0; i < 4; i++)
    {
      temp += ((x[i] + 9) / 10) * 10; 
    }
    temp += x.back();
    ans = min(ans, temp);
    return;
  }
  
  for (int i = 0; i < 5; i++)
  {
    if (!y[i])
    {
      continue;
    }
    x.push_back(a[i]);
    y[i] = false;
    dfs(x, y);
    x.pop_back();
    y[i] = true;
  }
  
}

int main() {
  a.resize(5);
  for (int i = 0; i < 5; i++)
  {
    cin >> a[i];
  }
  vector<int> x;
  vector<bool> y(5, true);
  ans = 700;
  dfs(x, y);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3572
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ame_A = [0] * N
ame_B = [0] * N

for i in range(N):
  if i == 0:
    ame_A[i] += A[i]
    continue
  ame_A[i] += ame_A[i-1] + A[i]

for i in range(N-1,-1,-1):
  if i == N - 1:
    ame_B[i] += B[i]
    continue
  ame_B[i] += ame_B[i+1] + B[i]
  
ans = 0
for j in range(N):
  cnt = ame_A[j] + ame_B[j]
  ans = max(ans, cnt)
  
print(ans)

Measured memory_bytes: 9228
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
ll dp[110][310][110];
ll n,W;
ll w[101],v[101];
bool f[110][310][110];
ll rec(ll i,ll j,ll k){
  ll res;
  if(f[i][j][k]) return dp[i][j][k];
  if(i==0||k==0) return 0;
  if(j-w[i-1]<0){
    res=rec(i-1,j,k);
  }
  else{
    res=max(rec(i-1,j,k),rec(i-1,j-w[i-1],k-1)+v[i-1]);
  }
  f[i][j][k]=true;
  return dp[i][j][k]=res;
}

int main(){
  cin>>n>>W;
  rep(i,n){
    cin>>w[i]>>v[i];
  }
  ll w0=w[0];
  rep(i,n){
    w[i]-=w0;
  }
  ll m=3*n;
  ll res=0;
  rep(k,n+1){
    fill(dp,0);
    fill(f,0);
    if(W<k*w0) continue;
    ll ww=W-k*w0;
    if(ww>m) ww=m;
    //  prin(rec(n,ww,k));
    res=max(res,rec(n,ww,k));
  }
  prin(res);
  
  

  
  
  

  
  
  

  return 0;
}


Measured memory_bytes: 33280
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e9)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)

const int mxn = 1*(1e5) + 5;
ll n;

int solve(){
	ll m;
	cin>>n>>m;
	cout<<n*m;
	return 0;		
}
 
int main(){
	fast;
	// tt
		solve();
}


Measured memory_bytes: 3640
a = list(input())
b = list(input())
c = list(input())
key = "a"
for i in range(300):
  if key == "a":
    if len(a) == 0:
      print("A")
      break
    else:
      key = a[0]
      a = a[1:]
      
  elif key == "b":
    if len(b) == 0:
      print("B")
      break
    else:
      key = b[0]
      b = b[1:]
      
  else:
    if len(c) == 0:
      print("C")
      break
    else:
      key = c[0]
      c = c[1:]
    
      

Measured memory_bytes: 3064
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int H = in.nextInt();
		int W = in.nextInt();
		int INF = 100000;
		int[][] s = new int[H][W];
		int alreadyBlack = 0;
		for(int i=0;i<H;i++) {
			String str = in.next();
			for(int j=0;j<W;j++) {
				if(str.charAt(j)=='.') s[i][j] = INF;
				else {
					s[i][j] = -1;
					alreadyBlack++;
				}
			}
		}
		in.close();
		Queue<int[]> que = new ArrayDeque<>();
		s[0][0] = 1;
		int[] start = {0,0};
		que.add(start);
		while(s[H-1][W-1]==INF && !que.isEmpty()) {
			int[] now = que.poll();
			int x = now[0];
			int y = now[1];
			if(x-1>=0 && y>=0 && s[x-1][y]!=-1 && s[x-1][y]>s[x][y]+1) {
				s[x-1][y] = s[x][y]+1;
				int[] tmp = {x-1,y};
				que.add(tmp);
			}
			if(x+1<H && y>=0 && s[x+1][y]!=-1 && s[x+1][y]>s[x][y]+1) {
				s[x+1][y] = s[x][y]+1;
				int[] tmp = {x+1,y};
				que.add(tmp);
			}
			if(x>=0 && y-1>=0 && s[x][y-1]!=-1 && s[x][y-1]>s[x][y]+1) {
				s[x][y-1] = s[x][y]+1;
				int[] tmp = {x,y-1};
				que.add(tmp);
			}
			if(x>=0 && y+1<W && s[x][y+1]!=-1 && s[x][y+1]>s[x][y]+1) {
				s[x][y+1] = s[x][y]+1;
				int[] tmp = {x,y+1};
				que.add(tmp);
			}
		}
		if(s[H-1][W-1]==INF) System.out.println(-1);
		else System.out.println(H*W-alreadyBlack-s[H-1][W-1]);
	}

}


Measured memory_bytes: 25300
cnt=gets.chomp.to_i
str=[]
strCnt={}
cnt.times do |j|
	arr=[]
	str[j]=gets.chomp
	str[j].length.times do |i|
		arr[i]=str[j][i]
	end
	str[j]=arr.sort.join
	strCnt[str[j]]||=0
	strCnt[str[j]]+=1
end
cnt=0
strCnt.each_value do |i|
	cnt += i * (i-1) / 2
end
puts cnt

Measured memory_bytes: 38396
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する
int N;
vector<int> t, v;
int T = 0;

int F(int i, int X) {
    if (i == 0) {
        return X;
    }
    if (i == N + 1) {
        return T - X;
    }
    if (X <= t[i - 1]) {
        return 2 * v[i] + (t[i - 1] - X);
    } else if (t[i] <= X) {
        return 2 * v[i] + (X - t[i]);
    } else {
        return 2 * v[i];
    }

}

int main() {

    cin >> N;
    t = vector<int>(N + 1, 0);
    v = vector<int>(N + 1);

    REP(i, 1, N + 1) {
        cin >> t[i];
        t[i] *= 2;
    }
    REP(i, 1, N + 1) cin >> v[i];

    REP(i, 1, N + 1) {
        t[i] += t[i - 1];
    }

//    REP(i, 1, N + 1) T += t[i];
    T = t[N];

    vector<int> w(T + 1, INF);
    REP(i, 0, T + 1) {
        REP(j, 0, N + 2) {
//            if(i == 128){
//                printf("F(%d,%d) = %d\n",j,i,F(j,i));
//            }
            w[i] = min(w[i], F(j, i));
        }
    }

    ll sum_v = 0LL;

    REP(i,1,T+1){
        sum_v += w[i-1] + w[i];
    }

//    cout << 1.0 * sum_v * 0.125 << endl;
    printf("%.3lf\n",1.0 * sum_v * 0.125);

    return 0;
}


Measured memory_bytes: 384