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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

#include <atcoder/mincostflow>
using namespace atcoder;

typedef pair<int,int> P;

int main(){
   int n,m; cin>>n>>m;
   vector<string> g(n);
   rep(i,0,n)cin>>g[i];
   for(int i=n-1;i>=0;i--)for(int j=m-1;j>=0;j--)if(g[i][j]=='o'){
      bool f=1;
      if(i+1<n and g[i+1][j]!='#')f=0;
      if(j+1<m and g[i][j+1]!='#')f=0;
      if(f)g[i][j]='#';
   }
   mcf_graph<int,ll> mf(n*m*2+2);
   int s=n*m*2,t=n*m*2+1;
   ll res=0;
   rep(i,0,n)rep(j,0,m){
      if(g[i][j]=='o'){
         res+=(n-i)+(m-j);
         mf.add_edge(s,i*m+j,1,0);
         queue<P> que; que.push({i,j});
         bool used[52][52]={}; used[i][j]=1;
         mf.add_edge(i*m+j,n*m+i*m+j,1,(n-i)+(m-j));
         while(!que.empty()){
            auto [x,y]=que.front(); que.pop();
            if(x+1<n and g[x+1][y]!='#' and !used[x+1][y]){
               que.push({x+1,y}); used[x+1][y]=1;
               mf.add_edge(i*m+j,(x+1)*m+y+n*m,1,(n-x-1)+(m-y));
            }
            if(y+1<m and g[x][y+1]!='#' and !used[x][y+1]){
               que.push({x,y+1}); used[x][y+1]=1;
               mf.add_edge(i*m+j,x*m+(y+1)+n*m,1,(n-x)+(m-y-1));
            }
         }
      }
      if(g[i][j]!='#'){
         mf.add_edge(i*m+j+n*m,t,1,0);
      }
   }
   cerr<<res<<endl;
   auto [tmp,x]=mf.flow(s,t);
   res-=x;
   cout<<res<<endl;
   return 0;
}

Measured memory_bytes: 8684
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <vector>
using namespace std;

const double interest = 0.05;

int weeklyAdd(int debt) {
  debt = debt * (1 + interest);
  if (debt % 1000 != 0)
    debt = (debt / 1000 + 1) * 1000;
  // std::cout << debt << '\n';
  return debt;
}

int main(int argc, char const *argv[]) {
  // int week = 5;
  int week;
  std::cin >> week;
  int debt = 100000;

  for (size_t i = 0; i < week; i++) {
    debt = weeklyAdd(debt);
  }
  std::cout << debt << '\n';

  return 0;
}



Measured memory_bytes: 2984
//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 = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;

LL h,n,w;

void solve(){
    for(h=1;h<=3500;h++){
        for(n=h;n<=3500;n++){
            LL a = 4*h*n - N*(n+h);
            if(a<=0) continue;
            LL b = N*h*n;
            if(b%a==0){
                w = b/a;
                //printf("%lld %lld %lld\n",h,n,w);
                return;
            }
        }
    }
}
 
int main(){
    cin >> N;
 
    solve();

    cout << h << " " << n << " " << w << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a, b;
    cin >> a >> b;
    long long ans = 0;
    for(long long i = 1; i <= b; i++){
        if((a*i)%b == 0){
            ans = a*i;
            break;
        }
    }
    cout << ans << endl;
}


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

int main()
{
	int i = 0;
	int a;

	while (i < 10000) {

		cin >> a;

		if (a == 0) {
			break;
		}
		else {
			cout << "Case " << i+1 << ":" <<" "<< a << "\n";
		}
		i++;
	}
    return 0;
}




Measured memory_bytes: 3004
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
	int d[4] = { 0 };
	for (int i = 0; i < 3; ++i) {
		int a, b;
		cin >> a >> b;
		d[a - 1] += 1;
		d[b - 1] += 1;
	}

	int c1 = 0;
	int c2 = 0;
	for (int i = 0; i < 4; ++i) {
		if (d[i] == 1) { ++c1; }
		if (d[i] == 2) { ++c2; }
	}

	if ((c1 == 2) && (c2 == 2)) {
		cout << "YES" << endl; 
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        Program pg = new Program();
        pg.Exe();
    }
    public void Exe()
    {
        int num = int.Parse(Console.ReadLine());
        List<Restaurant> list = new List<Restaurant>(num);
        
        string[] input;
        Restaurant obj = null;
        for(int i = 0; i < num; i++)
        {
            input = Console.ReadLine().Split(' ');
            obj = new Restaurant(input[0], int.Parse(input[1]), i+1);
            list.Add(obj);
        }
        /*
        foreach (Restaurant item in list)
        {
            Console.WriteLine(item.ToString());
        }

        Console.WriteLine("\nSorted\n");
        */
        IOrderedEnumerable<Restaurant> sortedlist = list.OrderBy((value) => value.City)
            .ThenByDescending((value) =>value.Point);
        foreach (Restaurant item in sortedlist)
        {
            Console.WriteLine(item.Num);
        }
    }
}

class Restaurant
{
    public int Point {get;set;}
    public string City {get;set;}
    public int Num{get; private set;}
    public Restaurant(string c, int p, int n)
    {
        this.Point = p;
        this.City = c;
        this.Num = n;
    }
    public Restaurant(int n, int p, string c)
    {
        this.Num = n;
        this.Point = p;
        this.City = c;
    }

    public Restaurant()
    {
        this.Num = 0;
        this.Point = 0;
        this.City = "";
    }

    public override string ToString()
    {
        return $"{this.Num} {this.City} {this.Point}";
    }

}


Measured memory_bytes: 28656
while True:
    h, w = map(int,input().split())
    if h == 0 and w == 0:
        break
    else:
        print('#'*w)
        for i in range(h-h+1,h-1):
            print('#'+'.'* (w-2)+'#')
        print('#'*w)
        print()

            


Measured memory_bytes: 5616
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x7fffffff
#define linf 0x7fffffffffffffffll
#define MN 100005
using namespace std;
inline ll in(){
    ll x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
struct st{
	int to,nxt;
	ll val;
}e[MN<<1];
int head[MN],fa[MN],siz[MN],son[MN],msiz[MN];
int cnt,n,u,v,mn=inf,pos;
ll mv=linf,w,res;
bool vis[MN];
inline void ins(int x,int y,int v){
	e[++cnt].to=y;e[cnt].nxt=head[x];head[x]=cnt;e[cnt].val=v;
}
inline void dfs(int u){
	siz[u]=1;
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if (v==fa[u]) continue;
		vis[u]=1;fa[v]=u;dfs(v);
		siz[u]+=siz[v];son[u]=max(son[u],siz[v]);
	}
	son[u]=max(son[u],n-siz[u]);
	if (son[u]<mn) mn=son[u],pos=u;
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if (v!=fa[u])
		res+=(1ll*min(siz[v],n-siz[v])*e[i].val)<<1ll;
	}
}
int main()
{
	n=in();
	for (int i=1;i<n;++i){
		u=in();v=in();w=in();
		ins(u,v,w);ins(v,u,w);
	}vis[1]=1;dfs(1);
	for (int i=head[pos];i;i=e[i].nxt){
		int v=e[i].to;
		mv=min(mv,e[i].val);
		if (son[pos]==son[v]){
			printf("%lld",res-e[i].val);return 0;
		}
	}printf("%lld",res-mv);return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;
signed main() {
    FAST_IO;
    int n;
    cin>>n;
    double p[n+1];
    for(int i=1;i<=n;i++)
        cin>>p[i];
    double dp[n+1][n+1] = {0};
    double prob = 0;
    dp[1][0] = 1-p[1];
    for(int i=2;i<=n;i++){
        dp[i][0] = dp[i-1][0]*(1-p[i]);
    }
    dp[1][1] = p[1];
    for(int i=2;i<=n;i++){
        dp[i][i] = dp[i-1][i-1]*p[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++){
            dp[i][j] = dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*p[i];
        }
    }
    for(int i = n/2 + 1; i <=n; ++i)
        prob += dp[n][i];
    cout<<fixed<<setprecision(10)<<prob;
    return 0;
}

Measured memory_bytes: 74120
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int INF = 1e9;
int a,b,c,d;
int main(){
  cin>>a>>b>>c>>d;
  if(abs(c-a)<=d || (abs(b-a)<=d && abs(c-b)<=d))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#define X first
#define Y second
using namespace std;
const int maxn = 200000;
int n,k,a[maxn+1];
map<int,int> cnt;
vector<int> V;
int sum;
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	cin >> n >> k;
	//memset(cnt,0,sizeof(cnt));
	cnt.clear();
	for (int i=1; i<=n; i++)
	{
		cin >> a[i];
		if (!cnt.count(a[i])) cnt[a[i]]=1;
		else cnt[a[i]]++;
	}
	V.clear();
	for (auto it=cnt.begin(); it!=cnt.end(); it++)
	V.push_back((*it).Y);
	sort(V.begin(),V.end());
	sum=0;
	for (int i=0; i<(int) V.size()-k; i++)
	sum+=V[i];
	cout << sum;
	return 0;
}

Measured memory_bytes: 11640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int n;
	cin >> n;
	std::priority_queue<pii, vector<pii>, greater<pii>> pque;
	rep(i,n){
		int a,b;
		cin >> a >> b;
		pii p;
		p.first = b;
		p.second = a;
		pque.push(p);
	}

	ll cur_time=0;
	rep(i,n){
		pii p = pque.top();
		pque.pop();
		cur_time += p.second;
		if(cur_time > p.first){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

  return 0;
}


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

const ll m=1000000007;

int main(){
    ll n;
    cin>>n;
    vector<int> prime;
    for(int i=2;i<100;i++){
        bool isprime=true;
        for(int j=2;j<i;j++){
            if(i%j==0) isprime=false;
        }
        if(isprime) prime.push_back(i);
    }
    int k[100]={0};
    for(int i=0;i<prime.size();i++){
        for(int j=1;j<8;j++){
            k[i]+=n/(pow(prime[i],j));
        }
    }
    
    int ans=0;
    
    if(k[0]>=74) ans++;
    
    int b24=0,b14=0,b4=0,b2=0;
    for(int i=0;i<prime.size();i++){
        if(k[i]>=24)b24++;
    }
    for(int i=0;i<prime.size();i++){
        if(k[i]>=14)b14++;
    }
    for(int i=0;i<prime.size();i++){
        if(k[i]>=4)b4++;
    }
    for(int i=0;i<prime.size();i++){
        if(k[i]>=2)b2++;
    }
    
    ans+=b24*(b2-1);
    ans+=b14*(b4-1);
    ans+=b4*(b4-1)*(b2-2)/2;
    
    
    /*for(int i=0;i<prime.size();i++){
        for(int j=0;j<prime.size();j++){
            if(k[i]>=24&&k[j]>=2&&i!=j) ans++;
        }
    }
    
    for(int i=0;i<prime.size();i++){
        for(int j=0;j<prime.size();j++){
            if(k[i]>=14&&k[j]>=4&&i!=j) ans++;
        }
    }*/
    
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S.at(2) == S.at(3)) {
    if(S.at(4) == S.at(5)) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  int n = N;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  if (N % sum == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}

int64 N,M;
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    read(N);read(M);
    int64 ans = 0;
    if(N > M) swap(N,M);
    if(N == 1 && M == 1) {puts("1");enter;}
    else if(N == 1) {
	out(M - 2);enter;
    }
    else {
	out((N - 2) * (M - 2));enter;
    }
    return 0;
}


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

using namespace std;

long N;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin >> N;

    long ans = 1e5;
    long t= 0;
    while(t<=N){
        long six = t;
        long cand = 0;
        while(six>0) {
            cand += six%6;
            six /= 6;
        }
        long nine = N -t;
        while(nine>0){
            cand += nine%9;
            nine /= 9;
        }
        t++;
        ans = min(ans, cand);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
V, E = map(int, input().split())

dists = [[float('inf')]*V for _ in range(V)]

for i in range(V):
    dists[i][i] = 0

for _ in range(E):
    s, t, d = map(int, input().split())
    dists[s][t] = d

for k in range(V):
    for i in range(V):
        for j in range(V):
            dists[i][j] = min(dists[i][j], dists[i][k]+dists[k][j])
            if i == j and dists[i][j] < 0:
                print('NEGATIVE CYCLE')
                exit()

for row in dists:
    print(' '.join(['INF' if d == float('inf') else str(d) for d in row]))




Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

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

    int tgt = 1;
    int a;

    rep(i,n) {
        cin >> a;
        if (a == tgt) tgt++;
    }

    if (tgt == 1) cout << -1 << endl;
	else cout << n - tgt + 1 << endl;

    return 0;
    
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int N,Y,re10000=-1, re5000=-1, re1000=-1;
    cin >> N >> Y;
    
    for(int i=0;i<=N;i++){
        for(int j=0;i+j<=N;j++){
            int k = N-i-j;
            int sum = 10000*i + 5000*j + 1000*k;
            if(sum == Y){
                re10000 = i;
                re5000 = j;
                re1000 = k;
            } 
            
        }
    }
    cout << re10000 << " " << re5000 << " " << re1000 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
int N;
int ans=1000000;
int mod[]={100000,10000,1000,100,10,1};
int solve(int s){
    int res=0;
    for(auto u:mod){
        res+=s/u;
        s%=u;
    }
    return res;
}
int main(){
    std::cin>>N;
    for(int i=1;i<N;i++){
        int sum=solve(i)+solve(N-i);
        ans=std::min(sum,ans);
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int m;
	cin>>m;
	cout<<48-m<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	char a;
	cin >> a;
	if (a!='a' && a!='e' && a!='i' && a!='o' && a!='u') cout << "consonant\n";
	else cout << "vowel\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int
main(void)
{
        int time[5];

        scanf("%d\n", &time[0]);
        scanf("%d\n", &time[1]);
        scanf("%d\n", &time[2]);
        scanf("%d\n", &time[3]);
        scanf("%d", &time[4]);

        int min = 10;
        int total = 0;
        for (int i = 0; i < 5; i++) {
                int remainder = time[i] % 10;
                if (remainder != 0 && remainder < min)
                        min = remainder;
                total += (time[i] + 9) / 10 * 10;
        };

        total += min - 10;

        printf("%d", total);
}


Measured memory_bytes: 128
#include <sstream>
#include <iostream>
#include <vector>
#include <string>

using namespace std;


int selection_sort(vector<int> &list) {
  int count = 0;
  for (int i = 0; i < list.size(); ++i) {
    int mini = i;
    for (int j = i + 1; j < list.size(); ++j) {
      if (list[j] < list[mini]) {
        mini = j;
      }
    }
    if (mini != i) {
      count++;
      int tmp = list[mini];
      list[mini] = list[i];
      list[i] = tmp;
    }
  }
  return count;
}

int main() {
  int N;
  cin >> N;
  cin.ignore();
  string str;
  getline(cin, str);
  string tmp;
  vector<int> v;
  istringstream istr(str);
  while (getline(istr, tmp, ' ')) {
    v.push_back(stoi(tmp));
  }
  int count = selection_sort(v);
  for (auto iter = v.begin(); iter != v.end() - 1; ++iter) {
    cout << *iter << " ";
  }
  cout << v.back() << endl;
  cout << count << endl;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 200005;
const int NN = 1000006;

int a[N], cnt[NN];

int n;

int main() {

	FAST;

	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		cnt[a[i]] ++;
	}
	int ans = 0;
	for (int i = 1; i <= n; i ++) {
		int c = a[i];
		bool flag = true;
		for (int j = 1; j * j <= c; j ++) {
			if (c % j == 0) {
				if ((j != c && cnt[j]) || (j == c) && cnt[j] > 1) {
					flag = false;
					break;
				}
				if ((c / j != c && cnt[c / j]) || (c / j == c) && cnt[c / j] > 1) {
					flag = false;
					break;
				}
			}
		}
		if (flag) {
			ans ++;
			// cout << a[i] << '\n';
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 8340
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int a = N / 100;
//    int b = (N % 100) / 10;
    int c = (N % 100) % 10;

    if (a == c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

struct Dinic {

    const int INF;

    struct edge {
        int to, cap, rev;
        edge(int to, int cap, int rev) :to(to), cap(cap), rev(rev) {}
    };

    int V;
    vector<vector<edge>> g;
    vector<int> level;      // sourceからの距離
    vector<int> itr;       // どこまで調べ終わったか

    Dinic(int V) :INF(1e9+7), V(V), g(V, vector<edge>()) {}

    void add_edge(int from, int to, int cap) {
        g[from].emplace_back(to, cap, g[to].size());
        g[to].emplace_back(from, 0, g[from].size()-1);
    }

    // sourceからの最短路を幅優先で探索
    void bfs(int s) {
        level = vector<int>(V, -1);
        queue<int> que;
        que.push(s);
        level[s] = 0;
        while (que.size()) {
            int v = que.front(); que.pop();
            for (edge &e : g[v]) {
                if (e.cap > 0 and level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    // v->tの増加路を探す
    int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int& i = itr[v]; i < g[v].size(); ++i) {
            edge& e = g[v][i];
            if (e.cap > 0 and level[v] < level[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    g[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int max_flow(int s, int t) {
        int flow = 0, f;
        while (true) {
            bfs(s);
            if (level[t] < 0) return flow;
            itr = vector<int>(V, 0);
            while ((f = dfs(s, t, INF)) > 0) {
                flow += f;
            }
        }
    }
};

int main() {
    int V, E;
    cin >> V >> E;
    Dinic flow(V);
    rep(i, E) {
        int from, to, cap;
        cin >> from >> to >> cap;
        flow.add_edge(from, to, cap);
    }
    cout << flow.max_flow(0, V-1) << endl;
    return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int n,m,a[100],b[100],c[100],d[100];
  cin >> n >> m;
  for(int i = 0; i < n; i++)
    cin >> a[i] >> b[i];
  for(int i = 0; i < m; i++)
    cin >> c[i] >> d[i];
  
  for(int i = 0; i < n; i++) {
    int mi = 2000000000;
    int t;
    for(int j = 0; j < m; j++) {
      if(mi > (abs(a[i]-c[j])+abs(b[i]-d[j]))) {
        mi = (abs(a[i]-c[j])+abs(b[i]-d[j]));
        t = j+1;
      }
    }
    cout << t << endl;
  }
}


Measured memory_bytes: 3544
N = int(input())
MOD = 10 ** 9 + 7
A = []
B = []
for i in range(N):
    A.append((int(input()), 0))

for i in range(N):
    B.append((int(input()), 1))
D = A + B
D = sorted(D)

a = 0
b = 0
ans = 1
for x, i in D:
    if i == 0:
        if b == 0:
            a += 1
        else:
            ans *= b
            b -= 1
    else:
        if a == 0:
            b += 1
        else:
            ans *= a
            a -= 1
    ans %= MOD
print(ans)

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

int main() {
  int N, L, i;
  cin >> N >> L;
  vector<string> S(N);
  for (i = 0; i < N; i++) cin >> S.at(i);
  
  sort(S.begin(), S.end());
  
  string s = "";
  for (i = 0; i < N; i++) s += S.at(i);
  
  cout << s << endl;
}


Measured memory_bytes: 3676
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
typedef pair<int, int> P;

int main() {
  int k; cin >> k;
  queue<ll> q;
  for(int i = 1; i < 10; i++) q.push(i);
  int counter = 0;
  while(true) {
    counter++;
    ll p = q.front(); q.pop();
    if(counter == k) {
      cout << p << endl;
      return 0;
    }
    if(p % 10 == 0) {
      q.push(p*10);
      q.push(p*10+1);
    } else if(p % 10 == 9) {
      q.push(p*10+9-1);
      q.push(p*10+9);
    } else {
      q.push(p*10+(p%10)-1);
      q.push(p*10+(p%10));
      q.push(p*10+(p%10)+1);
    }
  }
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

const int NMAX = 100005;

pair<int, int> dp[NMAX][11];
vector<int> G[NMAX];

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int v, d, c;
        cin >> v >> d >> c;
        dp[v][d] = make_pair(i, c);
    }
    for (int d = 9; d >= 0; --d) {
        for (int i = 1; i <= n; ++i) {
            for (int to: G[i]) {
                dp[i][d] = max(dp[i][d], dp[to][d + 1]);
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        cout << max_element(dp[i], dp[i] + 11)->second << '\n';
    }
}


Measured memory_bytes: 15096
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);++i)
#define rep(i,n) REP(i, 0, n)
typedef long long int i64;
typedef pair<int, int> pint;
bool check(int x) {
    for(int y = 2; y * y <= x; ++y) if(x % y == 0) {
        int sqy = sqrt((double)y) + 1.0e-13;
        for(int a = -sqy; a <= sqy; ++a)
          for(int b = -sqy; b <= sqy; ++b)
            if(a * a + b * b == y) return true;
    }
    return false;
}
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int T; cin >> T;
    int m, n;
    rep(___, T) {
        cin >> m >> n;
        cout << (check(m * m + n * n) ? 'C' : 'P') << '\n';
    }
    return 0;
}

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

int n;
bool ada=false;
int main(){
	cin>>n;
	for (int i=1; i<=9; i++){
		for (int j=1; j<=9; j++){
			if (n==i*j){
				ada=true;
			}
		}
	}
	if(ada){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll  long long int
#define fr(i,n) for(ll i=0; i<n; i++)
#define fre(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define pii pair<ll,ll>
#define ve vector
#define piii pair<pii, ll>
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

ll power(ll x, ll n, ll m)
{
    if(n==0)
        return 1;
    if(n==1)
        return x;
    x%=m;
    if(n%2)
        return (x*(power((x*x)%m, n/2, m)%m))%m;
    return power((x*x)%m, n/2, m)%m;
}

int main(){
  
    FAST;
    ll n,m, mod=1e9+7;
    cin>>n>>m;

    char a[n][m];
    ll ways[n][m];


    for(int i=0; i<n; i++){
      for(int j=0; j<m; j++){
          cin>>a[i][j];
          ways[i][j] = 0;
      }
    }

    ways[0][0] = 1;
    for(int i=0; i<n; i++){
      for(int j=0; j<m; j++){
          if( a[i][j] == '#'){
            ways[i][j] = 0;
            continue;
          }
          if( i-1 >=0 )
            ways[i][j] += ways[i-1][j];
          if( j-1 >=0 )
            ways[i][j] += ways[i][j-1];
          ways[i][j] %= mod;
       }
    }

    cout<<ways[n-1][m-1]<<endl;

}

Measured memory_bytes: 12396
N=int(input())
if N%2==1:
  print("No")
  #偶数なら不適
else:
  s=input()
  b=N//2
  t=0
  for i in range (0,b):
    if s[i]==s[i+b]:
      t=t
    else:
      t=t+1
  if t==0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3316
import fractions
def lcm(a, N):
    ans = a[0]
    for i in range(1, N):
        ans = ans * a[i] // fractions.gcd(ans, a[i])
    return ans

def main():
  N = int(input())
  A = list(map(int,input().split()))
  num = lcm(A, N) - 1
  answer = 0
  for i in A:
    answer += num % i
  print(answer)

if __name__=='__main__':
    main()

Measured memory_bytes: 80704
#include <cmath>
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

void printArr(vector<int> A)
{
    for (int i = 0; i < A.size(); i++)
    {
        if (i != A.size() - 1)
            cout << A[i] << " ";
        else
            cout << A[i];
    }
    cout << endl;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    printArr(a);
    for (int i = 1; i < n; i++)
    {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v)
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        printArr(a);
    }
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    for (int i = vec.size(); i > 1; i--) {
        cout << vec.at(i-1) << " ";
    }
    cout << vec.at(0) << endl;
}


Measured memory_bytes: 3092
#include<iostream>
#include<functional>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef unsigned long long ll;
using namespace std;
const ll mod=1e9+7;

int main()
{
    int n,m;
    cin>>n>>m;
    ll ans=1;
    ll nc=n,mc=m;
    if(abs(n-m)<=1)
    {
        if(n==m)
        {
            rep(i,n-1)
            {
                ans=(ans*((nc*mc)%mod))%mod;
                nc--;mc--;
            }
            ans=(ans*2)%mod;


        }
        else
        {
            rep(i,min(n,m))
            {
        
                ans=(ans*((nc*mc)%mod))%mod;
                nc--;mc--;
            }
        }
    }
    else
    {
        ans=0;
    }
    cout<<ans;
    
    
}

Measured memory_bytes: 256
def insertionSort(a,n,g):
    global cnt
    for i in range(g,n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            cnt += 1
        a[j + g] = v

cnt = 0
n = int(input())
a = [int(input()) for i in range(n)]

i = 0
g = [1]
while 3*g[i]+1 < n:
    g.append(3*g[i]+1)
    i += 1
g.reverse()
m = len(g)

for i in range(m):
    insertionSort(a,n,g[i])

print(m)
print(*g)
print(cnt)
print(*a, sep="\n")

Measured memory_bytes: 63104
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
#include <fstream>
#include <climits>
 
  using namespace std;
   
 
//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ

  typedef long long ll;
  typedef long double lld;
  typedef unsigned long long ull;
  int INF = INT_MAX;
  ll mod = 998244353;
  // lld PI = 3.141592653;



ll power(ll a, ll b){
 ll result = 1;
 while (b>0){
   if (b%2==1) result *= a;
   a*=a;
   b/=2;
 }
 return result;
}





  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
      ll n,x,m;
      cin>>n>>x>>m;
      vector<int> seen(m);
      int ind = 1;
      ll now = x;
      seen[now] = 1;
      ind++;
      ll ans = 0;
      vector<ll> pref;
      pref.push_back(0);
      pref.push_back(x);
      now = power(now, 2) % m;
      if (seen[now]){
        cout<< n * now<<"\n";
        return 0;
      }
      while (seen[now] == 0 && ind<=n){
        seen[now] = ind;
        pref.push_back(pref[pref.size()-1] + now);
        ind++;
       now = power(now, 2) % m;

      }
      if (ind - 1 == n){
        ans = pref[pref.size()-1];
        cout<<ans<<"\n";
        return 0;
      }
      // cout<<ind<<endl;
      ll first = seen[now]-1;
      // cout<<first<<endl;
      ll length = ind - first-1;
      ll k = (n-first)/length;
      // cout<<length<<" "<<k<<endl;

      ans = k* (pref[ind-1] - pref[first]) + pref[first];
      // cout<<ans<<endl;
      ll last = first + 1 + length*k;
      // cout<<last<<endl;

      while (last<=n){
        ans+=now;
        now = power(now, 2) % m;
        last++;
      }
      cout<<ans<<"\n";



}

Measured memory_bytes: 3772
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

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

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

int main() {
    int N, M;
    int A[110];
    cin >> N >> M;
    rep(i, N) cin >> A[i];

    int total = 0;
    for (int i = 0; i < N; i++) {
        total += A[i];
    }

    sort(A, A + N, greater<>());

    bool ok = true;
    double threshold = (double) total / (4 * M);
//    printf("total: %d\n", total);
//    printf("threshold: %f\n", threshold);

    for (int i = 0; i < M; i++) {
//        printf("%d\n", A[i]);
        if (A[i] < threshold) {
            ok = false;
            break;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}


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

int main()
{
    double r;
    double pi=3.14159265359;
    cin>>r;
    cout<<fixed;
    cout<<setprecision(6)<<pi*r*r<<" "<<2*pi*r;
    cout<<"\n";

    return 0;
}



Measured memory_bytes: 3280
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

#define MEM(a,b)    memset(a, b, sizeof(a))
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define MP(a, b)    make_pair(a, b)
#define PAIR(a, b)  pair<int, int>(a, b)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int maxn = 1;
const double EPS = 1e-8;

class BEEEeE {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, k;
		string s;
		in>>n;
		in>>s;
		in>>k;
		int res = 0;
		for(int i = 0; i < n; ++i){
			if(i == k-1)continue;
			if(s[i] != s[k-1])s[i] = '*';
		}
		out << s << '\n';
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	BEEEeE solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
import kotlin.math.max

fun main(args: Array<String>) {
    val n = readInt()
    val L = readIntList().sorted()
    //println(L)

    var ans = 0
    for (b in 0 until n) {
        for (a in 0 until b) {
            val ab = L[a] + L[b]
            var r =
                L.binarySearch(element = ab, comparator = lower).inv()
            //if (r == -1) r = n
            val l = b + 1
            //println("a=$a b=$b ab=$ab l=$l r=$r")
            ans += max(0, r - l)
        }
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

val lower = Comparator { x: Int, y: Int -> if (x >= y) 1 else -1 }

Measured memory_bytes: 55120
#include<stdio.h>
#define M 10
#define N 100
void printB(int n)
{
    int temp;
    while(n)
    {
        temp = n&1;
        n >>= 1;
        printf("%d",temp);
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    unsigned int F[N];
    int P[N][M+1];
    int temp;
    for(int i=0;i<n;i++)
    {
        F[i] = 0;
        for(int j=0;j<M;j++)
        {
            F[i] <<= 1;
            scanf("%d",&temp);
            F[i]+=temp;
        }
    }
    for(int i=0;i<n;i++)
        for(int j=0;j<M+1;j++)
            scanf("%d",&P[i][j]);
    unsigned int times,t;
    int max = 0;
    for(int j=0;j<n;j++)
            max += P[j][F[j]&1];
    for(unsigned int i=1;i<1024;i++)
    {
        temp = 0;
        for(int j=0;j<n;j++)
        {
            t = F[j]&i;
            times = 0;
            while(t)
            {
                times += t&1;
                t >>= 1;
            }
            temp += P[j][times];
        }
        max = (max>temp)?max:temp;
    }
    printf("%d\n",max);
}


Measured memory_bytes: 128
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();
		int cnt = 0;
		if (a == b) {
			cnt++;
		}
		if (b == c) {
			cnt++;
		}
		if (c == a) {
			cnt++;
		}
		if (cnt == 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a, b; cin >> a >> b;
	ll d = b-a;
	if (d%2) cout << "IMPOSSIBLE" << endl;
	else cout << a+d/2 << endl;

}



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int x;
    cin >> x;
    int ans;
    ans = x / 200;
    cout << 10 - ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


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

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

// mod add
const int MOD = 1000000007;
void add(ll &a, ll b){
    a += b;
    if(a >= MOD) a -= MOD;
}

ll solve(int N){
    auto dp = make_vec<ll>(N+1, 5, 5, 5);
    dp[0][0][0][0] = 1;
    for(int n=0; n<N; n++){
        for(int i=0; i<5; i++){
            for(int j=0; j<5; j++){
                for(int k=0; k<5; k++){
                    for(int l=1; l<5; l++){
                        if(j == 1 && k == 2 && l == 3) continue;
                        if(j == 2 && k == 1 && l == 3) continue;
                        if(j == 1 && k == 3 && l == 2) continue;
                        if(i == 1 && k == 2 && l == 3) continue;
                        if(i == 1 && j == 2 && l == 3) continue;
                        add(dp[n+1][j][k][l], dp[n][i][j][k]);
                    }
                }
            }
        }
    }

    ll ret = 0;
    for(int i=0; i<5; i++){
        for(int j=0; j<5; j++){
            for(int k=0; k<5; k++){
                add(ret, dp[N][i][j][k]);
            }
        }
    }
    return ret;
}

int main(){
    int N;
    cin >> N;
    cout << solve(N) << endl;
    return 0;
}

Measured memory_bytes: 384
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int a, b;
    cin >> a >> b;
    cout << ceil((a+b)/2.0) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}




int main(void){
    string N;
    cin>>N;
    if(N.at(0)=='7' || N.at(1)=='7' || N.at(2)=='7') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int dp[8][7001]={};
int main(){
  int m,a[7],b[7],g,n;

  while(1){
    for(int i=0;i<=7;i++)
      for(int j=0;j<=7000;j++)
	dp[i][j]=0;

    cin>>m;

    if(m==0)break;
    for(int i=0;i<m;i++)
      cin>>a[i]>>b[i]; 
   
    cin>>g;

    dp[0][0]=1;      
    for(int i=0;i<m;i++)
      for(int j=0;j<=7000;j++)
	for(int k=0;k<=b[i] && k*a[i]<=j;k++)
	  dp[i+1][j]+=dp[i][j-k*a[i]];
    
    
    for(int i=0;i<g;i++){
      cin>>n;      
      cout<<dp[m][n]<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
const ll MOD=1000000007;

int main(){
    int N,P;
    cin >> N >> P;
    vector<int> A(N);
    rep (i,N){
        cin >> A[i];
        A[i]%=2;
    }
    ll dp[N+1][2];
    dp[0][0]=1;
    dp[0][1]=0;
    rep (i,N){
        if (A[i]==0){
            dp[i+1][0]=dp[i][0]*2;
            dp[i+1][1]=dp[i][1]*2;
        }
        else {
            dp[i+1][0]=dp[i][0]+dp[i][1];
            dp[i+1][1]=dp[i][0]+dp[i][1];
        }
    }
    cout << dp[N][P] << endl;
}

Measured memory_bytes: 256
#include<iostream>

#define int long long

using namespace std;

signed main(void) {
	int X, Y;
	cin >> X >> Y;

	int x = 0, y = 0,z = 0;

	for (x = 0; x <= X; x++) {
		for (y = 0; y <= X - x; y++) {
			if (x * 10000 + y * 5000 + (X - x - y) * 1000 == Y) {
				cout << x << " " << y << " " << (X - x - y) << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 int main() {
	char c;
	cin >> c;

	if(c=='a' ||c== 'i' ||c== 'u' ||c== 'e' ||c== 'o'){
	cout << "vowel" << endl;
	}

	else{
	cout << "consonant" << endl;
	}
}

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

#define max(x, y) ((x)>(y)?(x):(y))
#define sq(x) ((x)*(x))
#define dist(x, y, z, a, b, c) (sq(x-a)+sq(y-b)+sq(z-c))

double res,  L[21], a[21], b[21];
int v[1<<21], n, m;

int popcount(int n)
{
    int res=0;
    while (n>0) { n-=n&-n; ++res; }
    return res;
}

void dfs(int mask)
{
    int i, j;
    v[mask]=1;
    if (popcount(mask)==m) {
        double d=0;
        for(i=0;i<n;++i) if (mask&(1<<i))
            for(j=i+1;j<n;++j) if (mask&(1<<j))
                d+=dist(L[i],a[i],b[i],L[j],a[j],b[j]);
        res=max(res, d);
    }
    else {
        for(i=0;i<n;++i) if ((mask&(1<<i))==0 && !v[mask|(1<<i)]) dfs(mask|(1<<i));
    }
}

int main(void)
{
    while (~scanf("%d%d", &n, &m)) {
        int i;
        memset(v, 0, sizeof(v));
        res=0;
        for(i=0;i<n;++i) scanf("%lf%lf%lf", L+i, a+i, b+i);
        dfs(0);
        printf("%.8f\n", res);
    }
    return 0;
}

Measured memory_bytes: 8860
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef priority_queue<int> Pr; typedef vector<int> Vi; typedef vector<Pi> Vp;
typedef map<int,int> MPi; typedef pair<Int,Int> Pl; typedef vector<Int> VI;
const int mod = 1000000007; const Int INF = 1145141919810893931;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    int n,ans=0; cin>>n; MPi a={};
    for (int i = 0; i < n; i++){
        int k; cin>>k; a[k]++;
    }
    for(auto k:a)ans++;
    END
}

Measured memory_bytes: 256
n = int(input())
s= input()
lc = sum([1 if c==')' else 0 for c in s])
rc = n-lc
ss = s[:]
while True:
    for i in range(len(ss)-1):
        if ss[i:i+2] == '()':
            ss=ss[:i] + ss[i+2:]
            lc,rc = lc-1,rc-1
            break
    else:
        break
news = ''.join(['(' for _ in range(lc)]) + s + ''.join([')' for _ in range(rc)])
print(news)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int n, k;
    cin >> n >> k;
    int R, S, P;
    cin >> R >> S >> P;
    string t;
    cin >> t;
    
    map<char, int> mp;
    mp['r'] = P;
    mp['s'] = R;
    mp['p'] = S;

    int len_t = t.size();
    int flag[len_t];
    for(int i=0; i<len_t; i++) flag[i] = 0;

    int ans = 0;
    for(int i=0; i<k; i++){
        ans += mp[t[i]];
        flag[i] = 1;
    }
    for(int i=k; i<len_t; i++){
        if(flag[i-k] == 1 && t[i] == t[i-k]){
            continue;
        }
        else{
            ans += mp[t[i]];
            flag[i] = 1;
        }
    }

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

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; i64 k; scanf("%d%lld", &n, &k); std::vector<int> a(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);

	const int MOD = 1e9 + 7;
	i64 ans = 0, tmp = k * (k - 1) / 2 % MOD;
	for(int i = 0; i < n; i++) {
		i64 A = 0, B = 0;
		for(int j = 0; j < n; j++) A += (a[j] > a[i]);
		for(int j = 0; j < i; j++) B += (a[j] > a[i]);

		(ans += tmp * A + B * k) %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


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

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

  return 0;
}


Measured memory_bytes: 3084