akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int min = Math.Max(A + B - N, 0);
		int max = Math.Min(A, B);
		Console.WriteLine("{0} {1}",max, min);
	}
	int N, A, B;
	public Sol(){
		var d = ria();
		N = d[0]; A = d[1]; B = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=505,p=998244353,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,a[N*N],h[N][N],g[N][N],ans;
void work(int x,int y){
	g[x][y]--;
	if (g[x][y+1]>g[x][y]+h[x][y+1]) work(x,y+1);
	if (g[x][y-1]>g[x][y]+h[x][y-1]) work(x,y-1);
	if (g[x+1][y]>g[x][y]+h[x+1][y]) work(x+1,y);
	if (g[x-1][y]>g[x][y]+h[x-1][y]) work(x-1,y);
}
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	n=read();
	for (int i=1;i<=n*n;i++) a[i]=read();
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++)
	h[i][j]=1,g[i][j]=min(min(i,n-i+1),min(j,n-j+1));
	for (int i=1;i<=n*n;i++){
		int x=(a[i]-1)/n+1,y=(a[i]-1)%n+1;
		h[x][y]=0;
		work(x,y);
		ans+=g[x][y];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 25964
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(){
  while(1){
    int H,W,R,C;
    scanf("%d %d %d %d",&H,&W,&R,&C);
    if(H==0)break;
    int goal[H+2][W+2];
    for(int i=0;i<=H+1;i++)for(int j=0;j<=W+1;j++){
      if(i*j==0||i==H+1||j==W+1)goal[i][j]=1;
      else goal[i][j]=0;
    }
    int hor[H+1][W];
    int ver[H][W+1];


    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++)scanf("%d",&hor[i][j]);
      for(int j=0;j<W+1;j++)scanf("%d",&ver[i][j]);
    }
    for(int i=0;i<W;i++)scanf("%d",&hor[H][i]);
    while(1){
      int flag=0;
    for(int i=1;i<=H;i++)for(int j=1;j<=W;j++){
      if(goal[i][j]==0&&goal[i-1][j]==1&&goal[i+1][j]==1&&hor[i-1][j-1]!=hor[i][j-1]){goal[i][j]=1;flag=1;}
      if(goal[i][j]==0&&goal[i][j-1]==1&&goal[i][j+1]==1&&ver[i-1][j-1]!=ver[i][j-1]){goal[i][j]=1;flag=1;}
    }
    for(int i=H;i>=1;i--)for(int j=W;j>=1;j--){
      if(goal[i][j]==0&&goal[i-1][j]==1&&goal[i+1][j]==1&&hor[i-1][j-1]!=hor[i][j-1]){goal[i][j]=1;flag=1;}
      if(goal[i][j]==0&&goal[i][j-1]==1&&goal[i][j+1]==1&&ver[i-1][j-1]!=ver[i][j-1]){goal[i][j]=1;flag=1;}
    }
    for(int i=1;i<=H;i++)for(int j=1;j<=W;j++){
      if(goal[i][j]==0&&goal[i-1][j]==1&&goal[i][j-1]==1&&hor[i-1][j-1]!=ver[i-1][j-1]){goal[i][j]=1;flag=1;}
    }
    for(int i=H;i>=1;i--)for(int j=1;j<=W;j++){
      if(goal[i][j]==0&&goal[i+1][j]==1&&goal[i][j-1]==1&&hor[i][j-1]!=ver[i-1][j-1]){goal[i][j]=1;flag=1;}
    }
    for(int i=1;i<=H;i++)for(int j=W;j>=1;j--){
      if(goal[i][j]==0&&goal[i-1][j]==1&&goal[i][j+1]==1&&hor[i-1][j-1]!=ver[i-1][j]){goal[i][j]=1;flag=1;}
    }
    for(int i=H;i>=1;i--)for(int j=W;j>=1;j--){
      if(goal[i][j]==0&&goal[i+1][j]==1&&goal[i][j+1]==1&&hor[i][j-1]!=ver[i-1][j]){goal[i][j]=1;flag=1;}
    }
    if(flag==0)break;
}
if(goal[R+1][C]==1&&hor[R][C-1]==0)printf("Yes\n");
else if(goal[R-1][C]==1&&hor[R-1][C-1]==0)printf("Yes\n");
else if(goal[R][C-1]==1&&ver[R-1][C-1]==0)printf("Yes\n");
else if(goal[R][C+1]==1&&ver[R-1][C]==0)printf("Yes\n");
else printf("No\n");
  }
  return 0;
}



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

int main(){
  int N;
  cin >> N;
  long a=1, b=1;
  for(int i=1; i<=N; i++){
    long x, y; cin >> x >> y;
    long n = max((a+x-1)/x,(b+y-1)/y);
    a = n*x;
    b = n*y;
  }
  cout << a+b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  //int A, B, C, X, Y;
//  int m[101]={};
  long long min=0;
  int A, B, C, K;
//  int sosu[20000]={};
  int i,j,k;
  int flag=0;
  int cnt =0;
  int next_cnt = 0;
  int tmp_cnt =0;
  int tmp_next_cnt = 0;

//    int k=0;

  scanf("%d %d", &A, &B);
  //printf("%d\n", A);

  for(i=0;i<999;i++){
    cnt = cnt +i;
    next_cnt = cnt + (i+1);
    //printf("%d",cnt );
      for(j=0;j<cnt;j++){
         tmp_cnt = cnt;
         tmp_next_cnt = next_cnt;
         if ( ( ( tmp_cnt - j ) == A ) && ( ( tmp_next_cnt - j ) == B ) ){
           printf("%d", j);
           return 0;
        }
         
      }
   
}

return 0;
}


Measured memory_bytes: 128
import fractions


def resolve():
    N,X=map(int,input().split())
    x=[abs(int(i)-X) for i in input().split()]
    a=x[0]
    for i in x[1:]:
        a=fractions.gcd(a,i)
    print(a)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 88172
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
    int cnt=0;
    string s;
    vector<string> ans;
    for(int i=0;i<1000;i++){
        cin>>s;
        for(int j=0;j<s.size()-1;j++){
            if(s[j]=='A'){
                if(s[j+1]!='B'&&s[j+1]!='D') break;
            }
            else if(s[j]=='B'){
                if(s[j+1]!='A'&&s[j+1]!='C'&&s[j+1]!='E') break;
            }
            else if(s[j]=='C'){
                if(s[j+1]!='B'&&s[j+1]!='F') break;
            }
            else if(s[j]=='D'){
                if(s[j+1]!='A'&&s[j+1]!='E'&&s[j+1]!='G') break;
            }
            else if(s[j]=='E'){
                if(s[j+1]!='B'&&s[j+1]!='D'&&s[j+1]!='F'&&s[j+1]!='H') break;
            }
            else if(s[j]=='F'){
                if(s[j+1]!='C'&&s[j+1]!='E'&&s[j+1]!='I') break;
            }
            else if(s[j]=='G'){
                if(s[j+1]!='D'&&s[j+1]!='H') break;
            }
            else if(s[j]=='H'){
                if(s[j+1]!='E'&&s[j+1]!='G'&&s[j+1]!='I') break;
            }
            else if(s[j]=='I'){
                if(s[j+1]!='F'&&s[j+1]!='H') break;
            }
            if(j==s.size()-2){
                ans.push_back(s);
                cnt++;
            }
        }
        if(s.size()==1){
            ans.push_back(s);
            cnt++;
        }
    }
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 3252
M, D = map(int, input().split())

res = 0

for m in range(1, M + 1):
    for d in range(1, D+1):
        d1 = d % 10
        d2 = d // 10

        if d1 == 1 or d2 == 1:
            continue

        if d1 * d2 == m:
            res += 1

print(res)


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

int main() {
  string S;
  cin >> S;

  string ans="";

  for(int i=0; i<S.size(); i++){
    if(S.at(i)=='0'){
      ans.push_back('0');
    }
    else if(S.at(i)=='1'){
      ans.push_back('1');
    }
    else if(S.at(i)=='B'){
      if(!ans.empty()){
        ans.pop_back();
      }
    }
  }

  cout << ans << endl;

return 0;  
}

Measured memory_bytes: 256
import math

def plot(x, y):
    print(f'{x:.8f} {y:.8f}')

def Koch(n, x1, y1, x2, y2):
    if n == 0:
        plot(x1, y1)
        return
    sx = (2 * x1 + x2) / 3
    sy = (2 * y1 + y2) / 3
    tx = (x1 + 2 * x2) / 3
    ty = (y1 + 2 * y2) / 3
    ux = (tx - sx) * (1/2) - (ty - sy) * (math.sqrt(3)/2) +sx
    uy = (tx - sx) * (math.sqrt(3)/2) + (ty - sy) * (1/2) +sy
    
    Koch(n-1, x1, y1, sx, sy) # Koch(n-1, x1, y1, sx, sy)
    Koch(n-1, sx, sy, ux, uy)
    Koch(n-1, ux, uy, tx, ty)
    Koch(n-1, tx, ty, x2, y2) #無限フローでERRORのでnを使う
    
    #plot(x1, y1)
    #plot(sx, sy)
    #plot(ux, uy)
    #plot(tx, ty)
    #plot(x2, y2)

n = int(input())
Koch(n, 0, 0, 100, 0)
plot(100, 0)



Measured memory_bytes: 5752
#include<bits/stdc++.h>
using namespace std;
int counter[200005];
vector<int>tree[200005];
bool visited[200005];
void dfs(int curr,int add){
	visited[curr] = true;
	counter[curr]+=add;
	for(int i=0; i<tree[curr].size(); i++){
		int child = tree[curr][i];
		if(!visited[child]) dfs(child,counter[curr]);	
	}
}
int main(){
	int n,q;
	cin>>n>>q;
	for(int i=1; i<n; i++){
		int a,b;
		cin>>a>>b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	while(q--){
		int a,b;
		cin>>a>>b;
		counter[a]+=b;
	}
	dfs(1,0);
	for(int i=1; i<=n; i++) cout<<counter[i]<<" ";
}

Measured memory_bytes: 24820
#include <stdio.h>
int main(void){
    // Your code here!
    int n[4];
    int cnt=0;
    for(int i=0;i<3;i++)
        scanf("%d",&n[i]);
    if(n[0]!=n[1]) cnt++;
    if(n[1]!=n[2]) cnt++;
    if(n[0]!=n[2]) cnt++;
    if(n[0]==n[1] && n[1]==n[2]) cnt=1;
    printf("%d\n",cnt);
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
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; }
const long long INF = 1LL<<60;

const int MAX_N = 110;
const int MAX_V = 100100;

// 入力
int N;
long long W, weight[MAX_N], value[MAX_N]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];
    
    // 初期化
    for (int i = 0; i < MAX_N; ++i) for (int j = 0; j < MAX_V; ++j) dp[i][j] = INF;
    
    // 初期条件
    dp[0][0] = 0;
    
    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
            
            // i 番目の品物を選ぶ場合
            if (sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
            
            // i 番目の品物を選ばない場合
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }
    
    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
        if (dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;
}


Measured memory_bytes: 86272
//07/03/2020
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");

#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
struct OverloadedNode{
    ll val,pos;
    bool operator < (const OverloadedNode &rhs) const {
        if(val==rhs.val) return pos<rhs.pos;
        else return val<rhs.val;
    }
};

template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//typedef tree<OverloadedNode,null_type,less<OverloadedNode>,rb_tree_tag,tree_order_statistics_node_update>OverloadedPbds;

/*Containers*/
//vector<ll>v;
//deque<ll>dq;
//stack<ll>stk;
//map<ll,ll>mp;
//unordered_map<ll,ll>ump;
//set<ll>st;
//multiset<ll>mst;
//unordered_set<ll>ust;
//unordered_multiset<ll>umst;
//priority_queue<ll,deque<ll>,greater<ll>>pq;
//Pbds<ll>ost;
/*OverLoaded Containers*/
//vector<OverloadedNode>v;
//deque<OverloadedNode>dq;
//stack<OverloadedNode>stk;
//map<OverloadedNode,OverloadedNode>mp;
//set<OverloadedNode>st;
//multiset<OverloadedNode>mst;
//priority_queue<OverloadedNode>pq;
//OverloadedPbds oost;
/*Global Variables*/

int main(){
    _fastio
    ll n,a,b;
    cin>>n>>a>>b;

    ll x=n/(a+b);
    ll ans=x*a;
    x=n%(a+b);
    ans+=min(x,a);

    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,k,s[10];

int main(){
	while(cin>>n){
		if(!n)return 0;
		fill(s,s+10,0);
		while(n--){
			cin>>k;
			s[k]++;
		}
		for(int i=0;i<10;i++){
			if(!s[i])cout<<"-"<<endl;
			else{
				for(int j=0;j<s[i];j++)cout<<"*";
				cout<<endl;
			}
		}
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    ll sum=0;
    vector<long> a(n+2,0);
    long i;
    for(i=1; i<=n; i++) {
        scanf("%ld", &(a[i]));
        sum+=abs(a[i]-a[i-1]);
    }
    sum+=abs(a[n+1]-a[n]);

    for(i=1; i<=n; i++) {
        ll ans=sum-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i+1]-a[i-1]);
        printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 2048
# -*- coding: utf-8 -*-
import itertools
N, M = map(int, input().split())
edges = [input().replace(" ", "") for i in range(M)]
res = 0
for l in itertools.permutations(list(range(1,N+1,1))):
    if l[0]!=1:
        continue
    for i in range(len(l)-1):
        e = str(min(l[i], l[i+1])) + str(max(l[i], l[i+1]))
        if not e in edges:
            break
    else:
        res += 1
print(res)


Measured memory_bytes: 9096
X = int(input())
dp = [False for _ in range(X+1)]
dp[0] = True
for x in range(X+1):
    if x > 99:
        item = [100, 101, 102, 103, 104, 105]
        for i in item:
            if dp[x-i]:
                dp[x] = True
if dp[X]:
    print(1)
else:
    print(0)

Measured memory_bytes: 3864
#include <stdio.h>

int main(void) {

  int l1,l2,l3,l4,l5,l6,l7,l8,l9,l10;
  int v1,v2;

  double intersec;
  int l[10];
  int result;

  int i;


  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l1,&l2,&l3,&l4,&l5,&l6,&l7,&l8,&l9,&l10,&v1,&v2)!=EOF) {

    intersec=(double)(l1+l2+l3+l4+l5+l6+l7+l8+l9+l10)*v1/(double)(v1+v2);

    l[0]=l1; l[1]=l2; l[2]=l3; l[3]=l4; l[4]=l5; l[5]=l6; l[6]=l7; l[7]=l8; l[8]=l9; l[9]=l10;

    for(i=0;i<10;i++) {

      intersec-=l[i];
      
      if(intersec<=0) {

	printf("%d\n",i+1);
	break;

      }

    }

  }

}

Measured memory_bytes: 0
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=3000+10;
const int mod=1e9+7;
void add(int& x,int y) { x+=y; if (x>=mod) x-=mod; }

int n,m; char str[N];
struct node { int l,r; } p[N];
bool operator <(node a,node b) { return a.l<b.l||(a.l==b.l&&a.r>b.r); }
int C[N][N],sum[N],dp[N][N];

int main() {
	n=read(),m=read(); scanf("%s",str+1);
	for (int i=1;i<=m;++i) p[i].l=read(),p[i].r=read();
	sort(p+1,p+m+1); int top=0;
	for (int i=1,x=0;i<=m;++i)
		if (p[i].r>x) p[++top]=p[i],x=p[i].r;
	m=top,p[m+1].l=n+1;
	for (int i=1;i<=n;++i) sum[i]=sum[i-1]+str[i]-'0';
	dp[p[1].l-1][sum[p[1].l-1]]=1;
	for (int i=C[0][0]=1;i<=n;++i)
		for (int j=C[i][0]=1;j<=i;++j)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	for (int i=1;i<=m;++i) {
		int l=p[i].l,r=p[i].r,nxt=p[i+1].l;
		for (int j=0;j<l;++j) {
			if (!dp[l-1][j]) continue;
			int s=sum[r]-j;
			if (nxt>r) 
				add(dp[nxt-1][sum[nxt-1]],1ll*dp[l-1][j]*C[r-l+1][s]%mod);
			else {
				int x=max(0,s-(r-nxt+1)),y=min(s,nxt-l);
				for (int k=x;k<=y;++k)
					add(dp[nxt-1][j+k],1ll*dp[l-1][j]*C[nxt-l][k]%mod);
			}
		}
	}
	printf("%d\n",dp[n][sum[n]]);
	return 0;
}

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

int N;
ll d[100];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> d[i];
    
    ll ans = 0;
    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            ans += d[i]*d[j];
        }
    }

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 50
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans,cnt;

ll fac[MAX]; // n!
ll finv[MAX]; // n!の逆元
ll inv[MAX]; // nの逆元


// n!(fac)とその逆元(finv)を先に計算しておく
void comInit(int N) {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// nCrを計算(先にcomInit()が必須)
ll com(ll n, ll r) {
	if (n < r) return 0;
	if (n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}


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

	comInit(40);

	ll N, P;
	cin >> N >> P;
	
	vector<ll> A(N);
	ll odd_cnt = 0, even_cnt = 0;

	rep(i, N) {
		cin >> A[i];
		if (A[i] % 2 == 0) {
			even_cnt++;
		}
		else {
			odd_cnt++;
		}
	}

	ll ep = pow(2, even_cnt);
	ll oq = 0;

	if (P == 0) {
		for (ll i = 0; i <= odd_cnt; i += 2) {
			oq += com(odd_cnt, i);
		}
	}
	else {
		for (ll i = 1; i <= odd_cnt; i += 2) {
			oq += com(odd_cnt, i);
		}
	}
	
	ans = ep * oq;
	cout << ans << endl;


	return 0;
}


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

int main() {
  int N, K, x, A, B;
  int y = 0;
  cin >> N >> K;
  
  vector<int> position(N);  
  for (int i = 0; i < N; i++) {
    cin >> x;
    A = x * 2;
    B = (K - x) * 2;
      
    if (A < B){
      y += A;
    } else {
      y += B;
    }
  }
  cout << y << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N, M, Q, u, w, v[100001], d[100001], c[100001];
	list *adj[100001] = {}, e[200001];
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d %d", &u, &w);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
	}
	scanf("%d", &Q);
	for (i = 1; i <= Q; i++) scanf("%d %d %d", &(v[i]), &(d[i]), &(c[i]));

	int ans[100001] = {}, flag[100001], max[100001], q[100001], head, tail;
	for (i = 1; i <= N; i++) {
		flag[i] = -1;
		max[i] = -1;
	}
	list *p;
	for (i = Q; i >= 1; i--) {
		if (max[v[i]] >= d[i]) continue;
		else max[v[i]] = d[i];
		flag[v[i]] = (Q - i) * 16 + d[i];
		q[0] = v[i];
		for (head = 0, tail = 1; head < tail; head++) {
			u = q[head];
			if (ans[u] == 0) ans[u] = c[i];
			if (flag[u] > (Q - i) * 16) {
				for (p = adj[u]; p != NULL; p = p->next) {
					w = p->v;
					if (flag[w] < (Q - i) * 16) {
						flag[w] = flag[u] - 1;
						if (flag[w] - (Q - i) * 16 > max[w]) {
							max[w] = flag[w] - (Q - i) * 16;
							q[tail++] = w;
						}
					}
				}
			}
		}
	}
	
	for (i = 1; i <= N; i++) printf("%d\n", ans[i]);
	fflush(stdout);
	return 0;
}

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

int main(void){

    int x,y;
    cin >> x >> y;
    if (x>y)
    {
        cout << "a > b" << endl;
    }

    if (y>x)
    {
        cout << "a < b" << endl;
    }

    if (x == y)
    {
        cout << "a == b" << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
// using namespace atcoder;

const ll mod=1000000007;//998244353;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

vector<vector<ll>> bunkai(ll a){
  if(a<=0) return {};
  if(a==1) return {{1,1}};
  vector<ll> f;
  ll b=a;
  for(ll i=2;i*i<=a;i++){
    if(b%i==0){
      f.push_back(i);
      b=b/i;
      i--;
    }
  if(b==1)break;
  }
  if(b!=1)f.push_back(b);

  vector<vector<ll>> u;
  ll p=f[0];
  ll c=1;
  for(ll i=1;i<f.size();i++){
    if(f[i]==p)c++;
    else{
      u.push_back({p,c});
      p=f[i];
      c=1;
    }
  }
  u.push_back({p,c});

  return u;
}

vector<ll> yakusu(ll a){
  if(a<=0)a=-a;
  if(a==1) return {1};
  vector<ll> f={1,a};
  for(ll i=2;i*i<=a;i++){
    if(a%i==0 && i*i!=a){
      f.push_back(i);
      f.push_back(a/i);
    }
    if(i*i==a)f.push_back(i);
  }
  sort(f.begin(),f.end());

  return f;
}

int main(){

  ll n;
  cin >> n;

  vector<vector<ll>> F(1000001);//Fは1~10^6の素因数分解

  for(ll i=1;i<1000001;i++){
    if(i==1)F[i]={1};
    else{
      for(ll j=2;j*j<=i;j++){
        if(i%j==0){
          F[i]=F[i/j];
          F[i].push_back(j);
          break;
        }
      }
      ll b=F[i].size();
      if(b==0)F[i].push_back(i);
      sort(F[i].begin(),F[i].end());
    }
  }

  ll ans=0;

  for(ll i=1;i<n;i++){
    vector<vector<ll>> u;
    ll p=F[n-i][0];
    ll c=1;
    for(ll j=1;j<F[n-i].size();j++){
      if(F[n-i][j]==p)c++;
      else{
        u.push_back({p,c});
        p=F[n-i][j];
        c=1;
      }
    }
    u.push_back({p,c});
    if(i==n-1)ans++;
    else{
      ll a=1;
      for(ll j=0;j<u.size();j++)a*=(u[j][1]+1);
      ans+=a;
    }
  }

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

Measured memory_bytes: 84576
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int n,ans=0;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    rep(i,n){
        if(i==0||a[i]!=a[i-1])ans++;
    }
    
    cout<<ans;
	return 0;
}


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

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

  vector<int> vec(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    
    vec.at(a - 1)++;
    vec.at(b - 1)++;
  }
  
  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
  for(int i=b-a+1;i<=b;i++)
    cout<<i<<' ';
  for(int i=b+1;i<b+a;i++)
    cout<<i<<' ';
}

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

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> A(N, 0);
	for (int i = 0; i < N; i++)cin >> A[i];
	vector<int> cnt(200000, 0);

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

	sort(cnt.rbegin(), cnt.rend());

	int out = 0;
	for (int i = K; i < N; i++)
	{
		out += cnt[i];
	}

	cout << out << endl;

    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  char c = getchar();
  if (c >= 'a') putchar('a');
  else putchar('A');
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3548
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a<=8 &&b<=8)
			System.out.println("Yay!");
		else
			System.out.println(":(");
	}
}


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


int main() {
	char enki;

	cin >> enki;
	if (enki == 'A') {
		cout << 'T' << endl;
	}
	else if (enki == 'C') {
		cout << 'G' << endl;
	}
	else if (enki == 'T') {
		cout << 'A' << endl;
	}
	else {
		cout << 'C' << endl;
	}

	
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
 
 
def main():
    n,a,b = [int(i) for i in input().strip().split()]
    if (b-a) % 2 == 0:
        print(abs(b - a) // 2)
    else:
        ans = min(a - 1, n - b) + 1 + (b - a - 1) // 2
        print(ans)
    return 
 
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 61852
#include<iostream>
#include<float.h>
#include<cfloat>
#include<string>
#include<ctype.h>
#include<algorithm>
#include<errno.h>
#include<cerrno>
#include<assert.h>
#include<cassert> 
#include<map>
#include<memory.h>
#include<cctype>
#include<ctype.h>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<new>
#include<memory>
#include<cmath>
#include<queue>
#include<cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{string s;
 cin>>s;
 fo(i,0,s.size())
 if(s[i]==',')
 s[i]=' ';
 cout<<s; 
 system("pause");
 return 0;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int a,b,c,k;

main() {
    cin >> a >> b >> c >> k;
    if(k%2) ct(b-a)
    else ct(a-b)
}


Measured memory_bytes: 256
n = int(input())
abc = [ list(map(int,input().split())) for _ in range(n) ]

dp = [ [0,0,0] for _ in range(n) ]

dp[0] = abc[0]

for i in range(1,n):
    # print("i={}".format(i))
    dp[i][0] = max(dp[i-1][1]+abc[i][0],dp[i-1][2]+abc[i][0])
    dp[i][1] = max(dp[i-1][0]+abc[i][1],dp[i-1][2]+abc[i][1])
    dp[i][2] = max(dp[i-1][0]+abc[i][2],dp[i-1][1]+abc[i][2])

print(max(dp[n-1]))

Measured memory_bytes: 47344
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main(){
    vector<int> n;
    int input;
    while(cin >> input){
        int ans = 0;
        if(input == 0) break;
        if(input % 1111 == 0){
            cout << "NA" << endl;
            continue;
        }
        while(input != 6174) {
            for(int i=0; i < 4; i++){
                n.push_back(input%10);
                input /= 10;
            }
            vector<int> minNum ,maxNum;

            sort(n.begin(), n.end());
            minNum = n;
            reverse(n.begin(), n.end());
            maxNum = n;

            int L=0, S=0;
            for(int i=0, m = 1000; i < 4; i++, m/=10){
                L += maxNum[i]*m;
                S += minNum[i]*m;
            }
            input = L-S;
            ans++;

            n.clear();
        }
        cout << ans << endl;
    }
}

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

int check(const char*str, const char* ring);

int main(void)
{
    char str[16];
    char ring[16];
    int n;
    int i, j;
    int cnt;
    
    scanf("%s", str);
    scanf("%d", &n);
    for (cnt = 0; n-- > 0; ){
        char tmp[32] = {0};
        
        scanf("%s", ring);
        sprintf(tmp, "%s%s", ring, ring);
        for (j = 0; j < strlen(tmp); j++){
            if (strncmp(tmp + j, str, strlen(str)) == 0){
                cnt++;
                break;
            }
        }
    }
    printf("%d\n", cnt);
    
    return 0;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
		#include <bitset>
		using namespace std;
		#define ll long long 
		#define ld long double
		#define MOD 1000000007
		#define mod9 1000000009
		#define mod 1000003
		#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
		#define mp make_pair
		#define pb push_back
		#define ct ll t;cin>>t;while(t--)
		#define bi begin()
		#define ei end()
		#define fi first 
		#define se second   	
		bool isPrime(ll n) 
		{ 
			// Corner case 
			if (n <= 1) 
				return false; 
			
			// Check from 2 to n-1 
			for (ll i = 2; i*i <= n; i++) 
				if (n % i == 0) 
					return false; 
			
			return true; 
		}
		long long binpow(long long a, long long b) {
			long long res = 1;
			while (b > 0) {
				if (b & 1)
					res = (res%mod) * (a%mod);
				a = (a%mod) * (a%mod);
				b >>= 1;
			}
			return res%mod;
		}

		bool compare(const pair<ll,ll>&a,const pair<ll,ll>&b)
		{
			return (a.se<b.se);
		}
		ll lcm(ll a,ll b)
		{
			return(a*b)/__gcd(a,b);
		}
		// vector<ll>s;
		void SieveOfEratosthenes() 
		{  
			ll n=10005;
			bool prime[1000005]; 
			memset(prime, true, sizeof(prime)); 
			// s[0]=1;
			// s[1]=1;
			for (int p=2; p*p<=n; p++) 
			{ 
				
				if (prime[p] == true) 
				{   
					for (int i=p*p; i<=n; i += p) {
						prime[i] = false; 
						// s[i]=1;
						}
				} 
			} 
			for(ll i=2;i<10005;i++)
			{
				if(prime[i])
				{
					// s.pb(i);
				}
			}
		} 
		void eea(ll a, ll b, ll & x, ll & y) {
		if (a == 0) {
			x = 0;
			y = 1;
			return ;
		}
		ll x1, y1;
		eea(b % a, a, x1, y1);
		x = y1 - (b / a) * x1;
		y = x1;
		return ;
	}
	ll modinverse(ll a,ll m)
	{
		ll x, y;
		eea(a, m, x, y);
		if (__gcd(a,m) != 1) {
		return -1;
		}
	else {
		x = (x % m + m) % m;
		cout << x << endl;
		return x;
	}
	}
		ll fact[1000007]={0};
		ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
		y=y>>1;x=(1ll*x*x)%MOD;} return res;}
		void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
		ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
		ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
			ll C(ll n, ll k) {
    ll res = 1;
    for (ll i = 1; i <= k; ++i)
        res = ((res) * (n - k + i) / i)%MOD;
    return (ll)(res + 0.01)%MOD;
}
				
		int main()
		{
			fast
			ll n;
			cin>>n;
			ll s=0;
			for(ll i=1;i<=n;i++)
			{
				if(i%3!=0&&i%5!=0)
				{
					s+=i;
				}
			}
			cout<<s<<"\n";
			}

 

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000007
typedef long long int lint;

int main(){
	lint N, K;
	cin >> N >> K;
	lint ans = 0;
    ans = -(N+1)*(N+2)*(2*N+3)/6 + (N+1)*(N+1)*(N+2)/2 + (N+1) + (K-1)*K*(2*K-1)/6 - (N+1)*(K-1)*K/2 - (K-1);
	co(ans % mod);
}

Measured memory_bytes: 3640
# include <iostream>

using namespace std;

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

	unsigned long int* row;
	row = (unsigned long int*)malloc(people * sizeof(unsigned long int));
	
	for (int i = 0; i < people; i++)
	{
		cin >> row[i];
	}
	long long stool = 0;
	for (int i = 0; i < people-1; i++)
	{
		if (row[i] > row[i + 1])
		{
			stool += row[i] - row[i + 1];
			row[i + 1] += row[i] - row[i + 1];
		}
	}
	cout << stool;
	
	return 0;
}

Measured memory_bytes: 5116
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		int N = scan.nextInt();

		int[] a = new int[N];

		int all = 0;

		for (int i = 0; i < N; i++) {
			a[i] = scan.nextInt();
			all ^= a[i];
		}

		//演算


		//結果出力
		for (int i = 0; i < N; i++) {
			System.out.print(all ^ a[i]);

			if (i != N - 1) {
				System.out.print(" ");
			}
		}
	}
}


Measured memory_bytes: 60448
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define MOD2 998244353
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;

template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}

int main(){
    FAST;
    string s;
    cin >> s;
    for(auto c: s) {
        if(c == '7') {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

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

int main() {
	int a[4];
	
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	sort(a, a + 4);
	
	if (a[0] == a[1] && a[2] == a[3]) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
N = int(input())
a_list = [int(input())-1 for i in range(N)]
next_i = 0
done_flag = False
for i in range(N):
    next_i = a_list[next_i]
    if  next_i == 1:
        done_flag = True
        break

if done_flag:
    print(i + 1)
else:
    print(-1)

Measured memory_bytes: 12924
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

int GCD(long long x, long long y) { return x ? GCD(y % x, x) : y; }
int main() {
    long long N;
    cin >> N;
    long long sum = 0;
    if(N == 1) {
        cout << 0 << endl;
        return 0;
    }
    for(long long i = 1; i * i <= N; i++) {
        if((N - i) % i == 0) {
            long long k = (N - i) / i;
            if(N / k == N % k) {
                sum += (N - i) / i;
                // cout << i << "," << (N - i) / i << endl;
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

bool is_ok(vector<int> &a, vector<int> &b) {
    int d = 0; rep (i, a.size()) d += (a[i]-b[i]) * (a[i]-b[i]);
    int ok = -1, ng = d + 1;
    while (ng - ok > 1) {
        int med = (ng + ok) / 2;
        if (med * med <= d) ok = med;
        else ng = med;
    }
    return (ok * ok == d);
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d; cin >> n >> d;
    vector<vector<int> > x(n, vector<int>(d, 0));
    rep (i, n) rep (j, d) cin >> x[i][j];
    int ans = 0;
    rep (i, n) repp (j, i + 1, n) ans += is_ok(x[i], x[j]);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

judge = 0
for i in range(N-1):
  count = 1
  for j in range(i+1,N):
    if s[i] == s[j]:
      count += 1
  for k in range(M):
    if s[i] == t[k]:
      count -= 1
  if count > judge:
    judge = count
print(judge)

Measured memory_bytes: 3064
import bisect

def solve():
    N = int(input())
    L = [int(i) for i in input().split()]
    L.sort()
    total = 0
    for s in range(N-2):
        for m in range(s+1, N-1):
            l = bisect.bisect_left(L, L[s] + L[m], 0, N)
            if l > m: total += l - m - 1
    print(total)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3188
#include<stdio.h>

int main(void){
   int N,i,a[1000],v,j;
   scanf("%d",&N);
   for(i=0;i<N;i++)
	scanf("%d",&a[i]);
	
	for(i=1;i<=N;i++){
		 for(j=0;j<N;j++){
printf("%d",a[j]);
while(j!=N-1){
putchar(' ');
break;
}
}
putchar('\n');

		v=a[i];
		j=i-1;
		while(j>=0 && a[j]>v){
			a[j+1]=a[j];
			j--;
			a[j+1]=v;
		}
	}

return 0;
}


Measured memory_bytes: 1904
#include <iostream>
using namespace std;
const int N = 3;
int main (void) {
    string S[N];

    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    int turn = 0;
    int pos[N] = {0};
    int len[N];
    for (int i = 0; i < N; i++) {
        len[i] = S[i].length();
    }
    while (true) {
        if (pos[turn] == len[turn]) {
            break;
        }
        char c = S[turn][pos[turn]];
        pos[turn]++;
        if (c == 'a') {
            turn = 0;
        } else if (c == 'b') {
            turn = 1;
        } else {
            turn = 2;
        }
    }

    if (turn == 0) {
        cout << 'A' << endl;
    } else if (turn == 1) {
        cout << 'B' << endl;
    } else {
        cout << 'C' << endl;
    }

    return 0;
}

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

using namespace  std;

#define ll long long






int main(){
    

string s;
cin>>s;
if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
}
else if (s=="Cloudy")
{
  cout<<"Rainy"<<endl;
}

else if (s=="Rainy")
{
    cout<<"Sunny"<<endl;
}
 //cerr<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    return 0;
} 

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

using namespace std;

#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)
#define lt(a,b) (a-b < -EPS)
#define le(a,b) (lt(a,b) || equal(a,b))

struct Point{
  double x,y;

  Point(){}
  Point(double x,double y) : x(x),y(y) {}

  Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
  Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
  Point operator * (const double &k)const{ return Point(x*k,y*k); }
  Point operator / (const double &k)const{ return Point(x/k,y/k); }
  bool operator < (const Point &p)const{ return x != p.x ? x < p.x : y < p.y; }
};

Point operator * (const Point &a,const Point &b){ return Point(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x); }

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double norm(const Point &p){ return dot(p,p); }
double abs(const Point &p){ return sqrt(norm(p)); }

istream &operator >> (istream &is,Point &p){ 
  return is >> p.x >> p.y;
}

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;

int ccw(Point p0,Point p1,Point p2){
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(cross(a,b) > EPS){ return COUNTER_CLOCKWISE; }
  if(cross(a,b) < -EPS){ return CLOCKWISE; }
  if(dot(a,b) < -EPS){ return ONLINE_BACK; }
  if(norm(a) < norm(b)){ return ONLINE_FRONT; }
  return ON_SEGMENT;
}

struct Line{
  Point s,t;
  Line(){}
  Line(Point s,Point t) : s(s),t(t) {}
};

Point projection(const Line &l,const Point &p){
  Vector b = l.t-l.s;
  double t = dot(p-l.s,b)/norm(b);
  return l.s+b*t;
}

double distanceLP(const Line &l,const Point &p){
  return abs(p-projection(l,p));
}

struct Circle{
  Point p;
  double r;
  Circle(){}
  Circle(Point p,double r) : p(p),r(r) {}
};

vector<Point> crosspointCL(const Circle &c,const Line &l){
  vector<Point> res;
  double d = distanceLP(l,c.p);
  if(le(d,c.r)){
    Point p = projection(l,c.p);
    Vector v = (l.t - l.s) / abs(l.t - l.s);
    d = sqrt(c.r*c.r-d*d);
    res.push_back(p - v*d);
    res.push_back(p + v*d);
  }
  return res;
}

int main(){
  Circle c;
  int Q;
  cin >> c.p >> c.r >> Q;
  while(Q--){
    Line l;
    cin >> l.s >> l.t;
    vector<Point> cp = crosspointCL(c,l);
    sort(cp.begin(),cp.end());
    printf("%.10f %.10f %.10f %.10f\n",cp[0].x,cp[0].y,cp[1].x,cp[1].y);
  }
  return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll Mod=1e9+7;
int n,a[100010];
ll inv[100010],s[100010],fac;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	inv[1]=1;
	for (int i=2;i<=n;i++)
	{
		inv[i]=inv[Mod%i]*(Mod-Mod/i)%Mod;
	}
	s[0]=0;
	fac=1;
	for (int i=1;i<=n;i++)
	{
		s[i]=(s[i-1]+inv[i])%Mod;
		fac=fac*i%Mod;
	}
	ll ans=0;
	for (int i=1;i<=n;i++)
	{
		ans=(ans+(s[i]+s[n-i+1]-1+Mod)%Mod*fac%Mod*a[i]%Mod)%Mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>

using namespace std;
int modul (int a)
{
    if (a<0)
        return -a;
    return a;
}
struct punct
{
    int x, y;
} student[100], control[1000];
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i<=n; ++i)
        cin >> student[i].x >> student[i].y;
    for (int i = 1; i<=m; ++i)
        cin >> control[i].x >> control[i].y;
    for (int i = 1; i<=n; ++i)
    {
        int minim = 1<<30;
        int p = 0;
        for (int j = 1; j<=m; ++j)
        {
            if (minim > modul(student[i].x-control[j].x)+modul(student[i].y-control[j].y))
            {
                p = j;
                minim = modul(student[i].x-control[j].x)+modul(student[i].y-control[j].y);
            }
        }
        cout << p << '\n';
    }
    return 0;
}


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

#define M 800000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
//上は完成されている

int h1(int key){ return key%M; }
int h2(int key){ return 1 + (key%(M-1)); }
long long h0(int key,int i){return (h1(key) + i*(h2(key)))%M;}

int find(char str[]){
  int i;
  long long key = getKey(str);
  long long h;
  /* your task */
  for(i=0;;i++){
    h = h0(key,i);
    if(H[h][0]=='\0')return 0;
    else if(strcmp(str,H[h])==0)return 1;
  }
  return 0;
}

int insert(char str[]){
  int i;
  long long key = getKey(str),g;
  
  for(i=0;;i++){
    g = h0(key,i);
    if(strcmp(H[g],str)==0) return 0;
    if(H[g][0]=='\0'){
      strcpy(H[g],str);
      return 1;
    }
    
  }
}
int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
      
    if ( com[0] == 'i' ){
      insert(str);
    }
    else {
      if (find(str)){
	printf("yes\n");
      }
      else {
	printf("no\n");
	}
    }
  }
  
  return 0;
}




Measured memory_bytes: 12680
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
const int N=2e5+100;
int fac[N],inv[N];
const int mod=1e9+7;
inline int C(int a,int b) { return 1LL*fac[a+b]*inv[a]%mod*inv[b]%mod; }
int main()
{
	int n=gi()-1,m=gi()-1,a=gi()-1,b=gi()-1,i;
	for (i=fac[0]=1;i<=n+m;i++) fac[i]=1LL*fac[i-1]*i%mod;
	for (i=2,inv[0]=inv[1]=1;i<=n+m;i++) inv[i]=-1LL*(mod/i)*inv[mod%i]%mod;
	for (i=3;i<=n+m;i++) inv[i]=1LL*inv[i-1]*inv[i]%mod;

	int ans=C(n,m);
	for (i=0;i<=b;i++)
		ans=(ans-1LL*C(n-a-1,i)*C(a,m-i))%mod;
	
	printf("%d\n",(ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 1792
h, w = map(int, input().split())
a = [input() for i in range(h)]
b = [['0']*w for i in range(h)]
for i in range(w):
    cnt = 0
    for j in range(h):
        if a[j][i] == '.':
            cnt += 1
    if cnt != h:
        for p in range(h):
            b[p][i] = a[p][i]
for i in range(len(b)):
    b[i] = [j for j in b[i] if j != '0']
for i in b:
    if ''.join(i) != '.'*len(i):
        print(''.join(i))

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

int main() {

	int N, R,L;
	cin >> N >> R;
	 
	if (N >= 10) {
		L = R;
	}
	else {
		L = 100 * (10 - N) + R;
	}

	cout << L << endl;

	return 0;
}

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

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

    int smaller = min(a, b);
    int larger = max(a, b);

    string result = to_string(smaller);
    for (int i = 1; i < larger; ++i)
    {
        result += to_string(smaller);
    }

    cout << result << endl;
}

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

int main()
{
  int w, h, n, xs, ys, xe, ye;
  cin >> w >> h >> n;
  vector<int> X(n, 0), Y(n, 0), a(n, 0);

  xs = ys = 0;
  xe = w;
  ye = h;

  for (int i = 0; i < n; i++)
  {
    cin >> X.at(i) >> Y.at(i) >> a.at(i);
  }

  for (int i = 0; i < n; i++)
  {
    switch (a.at(i))
    {
    case 1:
      if (xs < X.at(i))
      {
        xs = X.at(i);
      }
      break;
    case 2:
      if (X.at(i) < xe)
      {
        xe = X.at(i);
      }
      break;
    case 3:
      if (ys < Y.at(i))
      {
        ys = Y.at(i);
      }

      break;
    case 4:
      if (Y.at(i) < ye)
      {
        ye = Y.at(i);
      }

      break;
    default:
      break;
    }
  }
  if (xe < xs || ye < ys)
  {
    cout << 0 << endl;
    return 0;
  }

  cout << (xe - xs) * (ye - ys) << endl;
}


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

int main(){
  int N, M; cin >> N >> M;
  vector<int> flag(M);
  
  for(int i=0; i<N; i++){
    int K; cin >> K;
    for(int j=0; j<K; j++){
      int A; cin >> A;
      flag.at(A-1)++;    
    }
  }
  
  int count=0;
  for(int i=0; i<M; i++){
    if(flag.at(i) == N)
      count++;
  }
  cout << count << endl;
}


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

int main () {
  string s; cin >> s;
  int N = s.size();
  int S =0, F =0;
  for (int i =0; i<N; i++) {
    if (s[i] == 'A') {
      S = i; break;
    }
  }
  for (int i =N-1; i>0; i--) {
    if (s[i] == 'Z') {
      F = i; break;
    }
  }
  
  cout << F - S + 1 << endl;
        
}                                                

Measured memory_bytes: 3748