akhauriyash/Code-Regression huggingface dataset:
fun main(){
    val s = readLine()!!
    val l = s.length
    val c = Math.floor(l.toDouble()/2).toInt()
    var ans = 0
    for(i in 0 until c){
        if (s.elementAt(i) != s.elementAt(l-i-1)){
            ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 34620
N, M = map(int, input().split())
P = [[] for _ in range(N)]
PY = []

for _ in range(M):
    p, y = map(int, input().split())
    PY.append((p - 1, y))
    P[p - 1].append(y)
# print(P)

PD = [{} for _ in range(N)]

for i in range(N):
    for j, c in enumerate(sorted(P[i]), 1):
        PD[i][c] = j
    # print(PD)

for p, y in PY:
    print('%06d%06d' % (p + 1, PD[p][y]))


Measured memory_bytes: 67816
#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int A[n][m];
    int b[m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >>A[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        int c=0;
        for(int j=0;j<m;j++){
            c+=A[i][j]*b[j];
        }
        cout<<c<<endl;
    }
}



Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
        if(c <= a+b) {
            System.out.println(b+c);
        } else {
            System.out.println(a+b+b+1);
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first

#if MYDEBUG
#define DBG(...) {string dst__=#__VA_ARGS__;dbgsplit(dst__);stringstream dss__; dss__<<dst__; debug(dss__,__VA_ARGS__);}
#else
#define DBG(...)
#endif
void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<'='<<f<<' '; debug(ds,r...);}
void dbgsplit(string &s){int l=s.length(),n=0;for(int i=0; i<l; ++i){if(s[i]=='(')++n;if(s[i]==')')--n;if(s[i]==','&&!n)s[i]=' ';}}
using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

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

    int n;
    string s;
    cin >> n >> s;
    vector<int> ans(n),res;
    for(int i=0; i<4; ++i){
        ans[0]=i/2;
        ans[1]=i%2;
        for(int i=2; i<n; ++i){
            if(ans[i-1]==0 && s[i-1] =='o')ans[i]=ans[i-2];
            if(ans[i-1]==0 && s[i-1] =='x')ans[i]=ans[i-2]^1;
            if(ans[i-1]==1 && s[i-1] =='o')ans[i]=ans[i-2]^1;
            if(ans[i-1]==1 && s[i-1] =='x')ans[i]=ans[i-2];
        }
        if("xo"[(ans[n-2]==ans[0])^ans[n-1]]!=s[n-1])continue;
        if("xo"[(ans[n-1]==ans[1])^ans[0]]!=s[0])continue;
        res=ans;
        break;
    }

    if(res.size()==0)cout << -1 <<"\n";
    else{
        for(int i=0; i<res.size(); ++i){
            cout << "SW"[res[i]];
        }
        cout <<"\n";
    }

    return 0;
}



Measured memory_bytes: 1360
#include<stdio.h>
   int main(void){
      int N,a,b,c,ir,ks;
      scanf("%d",&N);
         for(ks=0;ks<N;ks++){
         scanf("%d%d%d",&a,&b,&c);
         if(a<b)
            ir=a,a=b,b=ir;
         if(a<c)
            ir=a,a=c,c=ir;
         if(a*a==b*b+c*c)
            printf("YES\n");
         else
            printf("NO\n");
         }
   return 0;
}

Measured memory_bytes: 580
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def conb(n,r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = inp()
a = inpl()
b = inpl()
c = inpl()
res = 0
for i in range(n):
    res += b[a[i]-1]
    if i > 0 and a[i] == a[i-1] + 1:
        res += c[a[i-1]-1]
print(res)

Measured memory_bytes: 4328
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<string, string> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;

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 int MAX_N = 100;
const int MAX_V = 100000;

ll n, W;
ll w[MAX_N+1], v[MAX_N+1];
ll dp[MAX_N + 1][MAX_V + 1];

int main() {
    cin >> n >> W;
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
        //V += v[i];
    }

    rep(i, n+1) rep(j, MAX_V+1) dp[i][j] = INF;
    dp[0][0] = 0;
    //minなんだからINF!!!!!

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= MAX_V; j++) {
            chmin(dp[i + 1][j], dp[i][j]);
            if (j >= v[i]) {
                chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
            }
            //cout << dp[i][j] <<" ";
        }
        //cout << endl;
    }

    ll res = 0;
    for (ll i = 0; i <= MAX_V; i++) {
        if (dp[n][i] <= W) {
            res = i;
        }
    }
    cout << res << endl;
    //cout << dp[n][res] << endl;
    return 0;
}

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

int main(void){
    int a,b,c,t=0;
    cin>>a>>b>>c;

    rep(i,61){
        if(t%60<=c && c<=t%60+a){
            cout<<t-t%60+c<<endl;
            return 0;
        }
        t+=(a+b);
    }

    cout<<-1<<endl;

    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<cctype>
#include<climits>
#include<bitset>
#include<stack>

using namespace std;

typedef long long ll;

const int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
const int MAX = 19;
int W, H, fld[10][10];
int P, sx, sy;
map<pair<pair<int, int>, int>, int> memo;

inline int CountBit(int s)
{
	int res = 0;
	for (int i = 0; i < P; i++) res += (s >> i) & 1;
	return res;
}

inline bool IsInside(int x, int y)
{
	return 0 <= x && x < W && 0 <= y && y < H;
}

inline bool CanDown(int x, int y, int s, int noBits)
{
	if (x == sx && y == sy && noBits == P) return true;
	if (fld[y][x] == -1) return false;
	return ((s >> fld[y][x]) & 1) == 0;
}

int DFS(int x, int y, int s)
{
	int cnt = CountBit(s);
	if (x == sx && y == sy && cnt == P) return 1;
	pair<pair<int, int>, int> state = make_pair(make_pair(x, y), s);
	if (cnt < MAX)
	{
		map<pair<pair<int, int>, int>, int>::iterator itr = memo.find(state);
		if (itr != memo.end()) return itr->second;
	}
	int sum = 0;
	for (int i = 0; i < 4; i++)
	{
		int nx = x + dx[i], ny = y + dy[i];
		while (IsInside(nx, ny) && !CanDown(nx, ny, s, cnt))
			nx += dx[i], ny += dy[i];
		if (!IsInside(nx, ny)) continue;
		sum += DFS(nx, ny, s | (1 << fld[ny][nx]));
	}
	if (cnt < MAX && !(cnt >= 18 && sum == 0)) memo[state] = sum;
	return sum;
}

signed main()
{
	while (cin >> W >> H, W || H)
	{
		memo.clear();
		P = 0;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cin >> fld[i][j];
				if (fld[i][j] == 0) fld[i][j] = -1;
				else if (fld[i][j] == 1) fld[i][j] = P++;
				else sx = j, sy = i, fld[i][j] = -1;
			}
		}
		printf("%d\n", DFS(sx, sy, 0));
	}
	return 0;
}

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

int main(void)
{
    int ans=0,min=30000000;
    int N,P;

    scanf("%d",&N);

    for(int i=1;i<=N;i++){
        scanf("%d",&P);
        if(P<=min){
            ans++;
            min = P;
        }
    }

    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int 
#define RD(v,n) for(ll i =0;i<n;i++ ) cin>>v[i]
#define bolt ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{
	bolt;
    ll a,b;
    cin>>a>>b;
    if( ( a == 1 && b == 2 ) || ( a == 2 && b == 1 ) )
        cout<<3<<"\n";
    else if( ( a == 2 && b == 3 ) || ( a == 3 && b == 2 ) )
        cout<<1<<"\n";
    else if( ( a == 1 && b ==3 ) || ( a == 3 && b == 1 ) )
        cout<<2<<"\n";

	return 0;
}

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

int main(){
  int n,x[302][302]={},y[302][302]={};
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)cin>>y[i][j],x[i][j]=y[i][j];
  
  int ans=max(y[0][n-1],y[n-1][0]);
  for(int i=0;i<n;i++)
    for(int j=n-2;j>=0;j--) {
      x[i][j]+=x[i][j+1];
      y[j][i]+=y[j+1][i];
      ans=max(ans,max(y[j][i],x[i][j]));
    }

  
  int sum[302][302],K[2][302][302]={},t=0,f=1;
  while(f){
    t++,f=0;
    for(int i=0;i<n;i++) //yoko
      for(int j=i+1;j<n;j++) {//yoko
	int a=K[t%2][i][j],&b=K[(t+1)%2][i][j];

	b=a;
	sum[i][j]=-10000000;

	for(int k=a+1;k<n;k++) { //tate
	  int X=(x[a][i]-x[a][j+1])+(x[k][i]-x[k][j+1]);
	  int Y=(y[a+1][i]-y[k][i])+(y[a+1][j]-y[k][j]);
	  if(sum[i][j]<=X+Y)sum[i][j]=X+Y,b=k;
	}
	
	if(b!=n-1)f=1;
	ans=max(ans,sum[i][j]);
	for(int k=a+1;k<b;k++){//tate
	  sum[i][j]+=(x[k][i+1]-x[k][j])-(x[k-1][i]-x[k-1][j+1]);
	  ans=max(ans,sum[i][j]);
	}
      }
  }
  cout <<ans<<endl;
	  
  return 0; 
}

Measured memory_bytes: 2948
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool isSubSequence(string &str1, string &str2, int m, int n) 
{ 
    // Base Cases 
    if (m == 0) return true; 
    if (n == 0) return false; 
  
    // If last characters of two strings are matching 
    if (str1[m-1] == str2[n-1]) 
        return isSubSequence(str1, str2, m-1, n-1); 
  
    // If last characters are not matching 
    return isSubSequence(str1, str2, m, n-1); 
} 

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	int ans=0;
	string s; cin>>s;
	for(char a='0';a<='9';a++)
	{
		for(char b='0';b<='9';b++)
		{
			for(char c='0';c<='9';c++)
			{
				string t=""; t+=a; t+=b; t+=c;
				if(isSubSequence(t,s,3,n)) ans++;
			}
		}
	}
	cout<<ans<<'\n';
}


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

int main(){
    string s;
    lint k;
    cin >> s >> k;
    lint cntr = 0;
    lint sonuc = 0;
    for(int i=0; i<s.size()-1; i++){
        
            if(s[i] == s[i+1]){
                cntr++;
            }else{
            	cntr++;
                sonuc+= (cntr/2)*k;
                cntr = 0;
            }
        
    }
    //cout << sonuc << endl;
    if(s.size() == 1){
    	cout << k/2;
    	return 0;
	}
    if(s[0] == s[s.size()-1] && cntr != s.size()-1){
        int i=0;
        int c0 = 0, c1 = 0;
        int j= s.size()-1;
        while(s[i] == s[0]){
            c0++;
            i++;
        }
        while(s[j] == s[0]){
            j--;
            c1++;
        }
        //cout << c0 << " " << c1 << endl;
        if(c0%2 && c1%2){
            sonuc+=k-1;
        }
    }
    //cout << sonuc << endl;
    //aabbaa 3 
    //aabbaaaabbaa 6
    //aabbaaaabbaaaabbaa 9

    /*aabba 2
    aabbaaabba 4
    aabbaaabbaaabba 6
    */

    /*
    abba 1
    abbaabba 3
    abbaabbaabba 5
    abbaabbaabbaabba 7
    */
    //cout << cntr << endl;
    if(cntr && cntr !=s.size()-1){
    	cntr++;
    	sonuc+=(cntr/2)*(k);
        
	}else if(cntr){
		cntr++;
		sonuc+=(cntr * k)/2;
		
	}
        
    
    cout << sonuc;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import breadth_first_order

def resolve():
    N, M = map(int, input().split())
    AB = np.array([list(map(int, input().split())) for _ in range(M)])

    row = AB.T[0]-1
    col = AB.T[1]-1
    data = [1]*M
    csr = csr_matrix((data, (row, col)), shape=(N, N))
    _, proc = breadth_first_order(csr, 0, directed=False)

    impos = any(proc[1:] >= 0)
    if impos:
        print("Yes")
        print(*proc[1:]+1, sep="\n")
    else:
        print("No")

if __name__ == "__main__":
    resolve()

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

int main() {
    int n, x;
    int m[105];
    cin >> n >> x;
    int c = 0;
    for (int i = 0; i < n; i++) {
        cin >> m[i];
        c += m[i];
    }
    sort(m, m + n);
    cout << n + (x - c) / m[0] << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

struct Dice
{
	vi d;
	static const int top = 0, frt = 1, rit = 2, lft = 3, bck = 4, btm = 5;
	Dice(){
		rep(i, 6) d.pb(i + 1);
	}
	Dice(vi d):d(d){}
	Dice(int _d[]){
		rep(i, 6) d.pb(_d[i]);
	}
	void spin(int f1, int f2, int f3, int f4){
		int tmp = d[f1];
		d[f1] = d[f2];
		d[f2] = d[f3];
		d[f3] = d[f4];
		d[f4] = tmp;
	}
	void spinN(){
		spin(top, frt, btm, bck);
	}
	void spinS(){
		spin(top, bck, btm, frt);
	}
	void spinE(){
		spin(top, lft, btm, rit);
	}
	void spinW(){
		spin(top, rit, btm, lft);
	}

	int run(string s){
		rep(i, s.size()){
			if(s[i] == 'N') spinN();
			else if(s[i] == 'S') spinS();
			else if(s[i] == 'E') spinE();
			else if(s[i] == 'W') spinW();
		}
		return d[top];
	}
};


int main(){
	vi v(6);
	rep(i, 6) cin>>v[i];
	string s;
	cin>>s;
	Dice dice(v);
	cout<<dice.run(s)<<endl;
}

Measured memory_bytes: 3188
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))

L.sort()
ans = 0

for i in range(N-2):
  for j in range(i+1, N-1):
    a = bisect_left(L, L[i]+L[j])
    l = a
    ans += a - j - 1 
 
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h> 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> l(n);
  rep(i,n){cin>>l[i];}
  sort(all(l));
  int count=0;
  rep(i,n){for(int j=i+1;j<n;j++){
    for(int k=n-1;k>j;k--){
      if(l[i]+l[j]>l[k]){count++;}
      }}}
  cout<<count<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
    String[] s = new String[n];
    for(int i=0;i<n;i++){
      s[i] = sc.next();
    }
    Map<String,Integer> map = new HashMap<>();
    Integer count;
    for(int i=0;i<n;i++){
      count=map.get(s[i]);
      if(count==null){
        map.put(s[i],1);
      }else{
        map.replace(s[i],count+1);
      }
    }
    int max = 0;
    for(Integer ii : map.values()){
      if( ii> max){
        max = ii;
      }
    }
    List<String> list = new ArrayList<>();
    for(Map.Entry<String,Integer> e : map.entrySet()){
      if(e.getValue() == max){
        list.add(e.getKey());
      }
    }
    Collections.sort(list);
    for(String str : list){
      System.out.println(str);
    }
    System.out.flush();
    
  }
}

Measured memory_bytes: 78632
n = int(input())
d1d2 = [map(int, input().split()) for _ in range(n)]
d1, d2 = [list(i) for i in zip(*d1d2)]
count = 0
for i in range(n-2):
    if d1[i] == d2[i] and d1[i+1] == d2[i+1] and d1[i+2] == d2[i+2]:
        count += 1
if count > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9188
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y= sc.nextInt();
		int z= sc.nextInt();
		String xy= Integer.toString(x) + Integer.toString(y) + Integer.toString(z);
		int yz= Integer.valueOf(xy);
		if(yz%4==0) {
		System.out.print("YES");
		}else {
		System.out.print("NO");
		}
		sc.close();

	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef long long ll;
#define mems(p) memset(p,-1,sizeof(p));
#define mp make_pair;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);}

int main() {
	fast();
	vector<pair<int,int> > arr[100010];
	int colors[100010];
	int n,temp,temp2,leng;
	queue<int> next;
	cin>>n;
	mems(colors);
	for (int i = 0; i < n-1; ++i)
	{
		cin>>temp>>temp2>>leng;
		arr[temp].push_back(make_pair(temp2,leng));
		arr[temp2].push_back(make_pair(temp,leng));
	}
	colors[1]=0;
	next.push(1);
	int curr;
	while (!next.empty()) {
		curr=next.front();
		next.pop();
		for (auto t = arr[curr].begin(); t!=arr[curr].end(); ++t)
		{
			if (colors[(*t).first]!=-1) continue;
			if (((*t).second)%2 == 0) colors[(*t).first]=colors[curr];
			else if (colors[curr]) colors[(*t).first]=0;
			else colors[(*t).first]=1;
			next.push((*t).first);
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		cout<<colors[i]<<endl;
	}
}

Measured memory_bytes: 6784
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

A,B,C,D = I()
print(max(A*B,C*D))

Measured memory_bytes: 10076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

   int n = Integer.parseInt( br.readLine() );
   String[] string=  br.readLine().split(" ");
   int [] Progression = new int[n];


   for(int i = 0; i < n ; i++){
       Progression[i] = Integer.parseInt(string[i] );
   }

   int tmp;
   int flag = 1;
   int count = 0;

    while(flag == 1){

    	flag = 0;
	  for(int j = n - 1; 0 < j; j--){

		  if( Progression[j] < Progression[j - 1] ){
			  tmp = Progression[j];
			  Progression[j] = Progression[j-1];
			  Progression[j-1] = tmp;
			  count++;
			  flag = 1;
		  }
	  }

    }

   for(int k = 0;k < n; k++){

	   System.out.print( Progression[k] );
	   if(k < n-1){
		   System.out.print(" ");
	   }else{
		   System.out.println();
	   }

   }

   System.out.println(count);


 }
}

Measured memory_bytes: 24328
a=input()
if a[0] is not a[2] or a[0] is not a[3]:
    if a[0] == a[1] and a[2] == a[3]:
        print('Yes')
    elif a[0] == a[3] and a[2] == a[1]:
        print('Yes')    
    elif a[0] == a[2] and a[3] == a[1]:
        print('Yes')
    else:
        print('No')

else:
    print('No')

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

vector<long long> pf (long long n)
{
    vector<int> cnt((long long)pow(n, 0.5) + 1);
    for (long long i = 0; i < cnt.size(); i++)
    {
        cnt[i] = 0;
    }
    vector<long long> res;
    res.push_back(1);
    for (long long i = 2; i <= (long long)pow(n, 0.5); i++)
    {
        while(1)
        {
            if (n % i == 0)
            {
                if (cnt[i] == 0)
                {
                    res.push_back(i);
                    cnt[i] =1;
                }
                n = n / i;
            }
            else
            {
                break;
            }
        }
    }
    if (n != 1)
    {
        res.push_back(n);
    }
    return res;
}

int main(void)
{
    long long A, B;
    cin >> A >> B;
    long long minnum = min(A, B);
    long long ans = 0;
    vector<long long> a = pf(A);
    vector<long long> b = pf(B);
    for (long long i = 0; i < a.size(); i++)
    {
        for (long long j = 0; j < b.size(); j++)
        {
            if (a[i] == b[j])
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4156
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)



using namespace std;

int A[110][110] ={};
int dp[110][110] = {};
int H,W;



int main() {
  cin>>H>>W;
  REP(h,H){
    REP(w,W){
      char ch; cin>>ch;
      if(ch == '#') A[h+1][w+1] = -1;
      else A[h+1][w+1] = 1;
    }
  }

  for(int h=1;h<=H;h++){
    for(int w=1;w<=W;w++){
      int fl = 0, fu = 0;
      fl = dp[h][w-1]; fu = dp[h-1][w];
      if(A[h][w-1] != -1 and A[h][w] == -1) fl++;
      if(A[h-1][w] != -1 and A[h][w] == -1) fu++;

      dp[h][w] = min(fl,fu);

      if(h==1) dp[h][w] = fl;
      if(w==1) dp[h][w] = fu;
      if(h==1 and w==1) dp[h][w] =( (A[1][1] == -1) ? 1 : 0 );

     // cout<<dp[h][w];
    }
    //cout<<endl;
  }

  cout<<dp[H][W]<<endl;



  return 0;
}

Measured memory_bytes: 384
S = input()

while True:
    if len(S) == 0:
        print('YES')
        break
    else:
        if S[-5:]=='dream':
            S = S[:-5]
        elif S[-7:] == 'dreamer':
            S = S[:-7]
        elif S[-5:]== 'erase':
            S = S[:-5]
        elif S[-6:] == 'eraser':
            S = S[:-6]
        else:
            print('NO')
            break

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s;
    cin >> s;
    ll x1, y1, x2, y2, x3, y3;
    x1 = 0; y1 = 0;
    x2 = 1000000000;
    x3 = 1;
    y3 = s / x2;
    if(s % x2 != 0) y3++;
    y2 = x2 * y3 - s;
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>
#include <set>
using namespace std;

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

#define max_n 100

long long X,Y;


int extgcd(int a,int b,int& x,int& y){
	int d = a;
	if(b!=0){
		d = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	else {
		x = 1; y = 0;

	}
	return d;
}

int mod_inverse(int a, int m) {
	int x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

int makefact(int a){

	long long r = 1;
	rep(i, a)
	{
		r = r * (i + 1) % 1000000007;
	}
	return r;
}

int mod_fact(int n,int p,int& e){
	e = 0;
	if (n == 0)return 1;
	int res = mod_fact(n / p, p, e);
	e += n / p;
	if (n / p % 2 != 0)return res * (p - makefact(n%p)) % p;
	return res * makefact(n%p) % p;
}

int mod_comb(int n,int k,int p){
	if (n < 0 || k < 0 || n < k)return 0;
	int e1, e2, e3;
	long long a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
	if (e1 > e2 + e3)return 0;
	return a1 * mod_inverse(a2*a3%p, p) % p;
}



int main() {

	cin >> X >> Y;

	int N = 0;
	for(int i=1;;i++)
	{
		int x = X - i;
		int y = Y - i;

		if(x<0||y<0)
		{
			cout << "0" << endl; return 0;
		}

		if (x + y == i) { 
			N = i; break;
		}

		if (x + y < i) {
			cout << "0" << endl; return 0;
		}
	}
	X -= N;
	Y -= N;

	long long ans = mod_comb(X + Y, X, 1000000007);

	cout << ans << endl;

	return 0;	
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

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

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

    vector<ll> dp(100000 + 1);
    rep(i, dp.size()) { dp[i] = -1; }
    dp[0] = 0;

    rep(i, n) {
        int weight, value;
        cin >> weight >> value;
        for (int j = dp.size() - 1 - value; j >= 0; j--) {
            if (dp[j] >= 0 && dp[j] + weight <= w) {
                if (dp[j + value] == -1)
                    dp[j + value] = dp[j] + weight;
                else
                    dp[j + value] = min(dp[j + value], dp[j] + weight);
                // printf("i:%d, dp[%d]=%lld\n", i, j + value, dp[j + value]);
            }
        }
    }

    ll ans = 0;
    rep(i, dp.size()) {
        if (dp[i] >= 0 && dp[i] <= w) {
            // printf("dp[%d]=%lld\n", i, dp[i]);
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int f=0;
	for(int i=0;i<=25;i++)
	{
		for(int j=0;j<=15;j++)
		{
			if((i*4+j*7)==n){
				f=1;
				break;
			}
		}
		if(f) break;
	}
	if(f) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
divs = []
for i in range(1, int(n ** 0.5) + 1):
  if n % i == 0:
    divs.append(i)
    if i != n // i:
      divs.append(n // i)
sdivs = sorted(divs)
lsdivs = len(sdivs)
if lsdivs % 2 == 0:
  a = sdivs[lsdivs // 2 - 1]
  b = sdivs[lsdivs // 2]
  print(a + b - 2)
else:
  a = sdivs[lsdivs // 2]
  print(a * 2 - 2)

Measured memory_bytes: 3296
A = int(input())
B = int(input())
if (A == 1and B == 2) or  (A == 2 and B == 1):
    print(3)
elif (A == 1 and B == 3) or (A == 3 and B == 1):
     print(2)
elif (A == 2 and B == 3) or (A == 3 and B == 2):
    print(1)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))

N, M = inpl()
uv = [ set() for _ in range(3*N) ]
vu = [ set() for _ in range(3*N) ]
for _ in range(M):
    u, v = inpl()
    for k in range(3):
        uv[u-1 + k*N].add(v-1 + ((k+1)%3)*N)
        vu[v-1 + ((k+1)%3)*N].add(u-1 + k*N)
S, T = inpl()
S -= 1
T -= 1

cur = set({S})
for i in range(3*N):
    if i % 3 == 0 and T in cur:
        print(i//3)
        break
    elif len(cur) == 0:
        print(-1)
        break
    prev = cur
    cur = set()
    for u in prev:
        for fr in vu[u]:
            uv[fr].remove(u)
        cur |= uv[u]
else:
    print(-1)

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

int main() {
    int N=0;
    int M=0;

    cin >> N;
    vector<string> s(N);

    for(int i=0; i < N; i++){
        cin >> s.at(i);
    }

    cin >> M;
    vector<string> t(M);

    for(int i=0; i < M; i++){
        cin >> t.at(i);
    }

    int cnt=0;
    int max=0;

    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);

    for(int i=0; i < N; i++){
        int a=0;
        for(int j=0; j < N; j++){
            if(s.at(i)==s.at(j)){
                 a += 1;
            }
        }
        A.at(i)=a;
    }

    for(int i=0; i < N; i++){
        int b=0;
        for(int j=0; j < M; j++){
            if(s.at(i)==t.at(j)){
                 b += 1;
            }
        }
        B.at(i)=b;
    }

  for (int i=0; i<N; ++i) {
    C.at(i) = A.at(i)-B.at(i);
  }

    int d=0;
   for (int i=0; i<N; ++i) {
    if(d < C.at(i))
        d = C.at(i);
  }   

    cout << d << endl;

}

Measured memory_bytes: 256
fun main(args: Array<String>?): Unit {
    val n = readLine()!!.trim().toInt()
    val queries = Array(n){time ->
        val query = readLine()!!.trim().split(' ').map(String::toInt)
        when(query.first()) {
            1 -> Query.Update(time, query[1], query[2])
            else -> Query.Evaluation(time)
        }
    }
    var updateCount = 0
    var allA = 0L
    var allB = 0L
    val sortedUpdate = queries.mapNotNull{it as? Query.Update}.sortedBy { it.a }
    val updateToRank = sortedUpdate.withIndex().associate { Pair(it.value.time, it.index) }
    val indices = IntBit(updateToRank.size)
    val sumValues = LongBit(updateToRank.size)
    for (query in queries) {
        when(query){
            is Query.Update -> {
                indices.add(updateToRank[query.time]!!, 1)
                sumValues.add(updateToRank[query.time]!!, query.a.toLong())
                ++updateCount
                allA += query.a
                allB += query.b
            }
            is Query.Evaluation -> {
                val mid = lowerBound(indices, (updateCount + 1) / 2)
                println(when(updateCount % 2){
                    0 -> "${sortedUpdate[mid].a} ${allA - sumValues[mid] * 2 + allB}"
                    1 -> "${sortedUpdate[mid].a} ${allA - sumValues[mid] * 2 + sortedUpdate[mid].a + allB}"
                    else -> TODO()
                })
            }
        }
    }
}
fun lowerBound(bit: IntBit, value: Int): Int {
    var left = 0
    var right = bit.size
    while(left < right) {
        val mid = (left + right) / 2
        if (bit[mid] < value) left = mid + 1
        else right = mid
    }
    return right
}
class IntBit(val size: Int) {
    private val array = IntArray(size){0}
    fun add(position: Int, value: Int): Unit {
        var pos = position
        while (pos < array.size) {
            array[pos] += value
            pos += pos.inv() and (pos + 1)
        }
    }
    operator fun get(position: Int): Int {
        var pos = position
        var result = 0
        while (pos >= 0) {
            result += array[pos]
            pos -= pos.inv() and (pos + 1)
        }
        return result
    }
}
class LongBit(val size: Int) {
    private val array = LongArray(size){0}
    fun add(position: Int, value: Long): Unit {
        var pos = position
        while (pos < array.size) {
            array[pos] += value
            pos += pos.inv() and (pos + 1)
        }
    }
    operator fun get(position: Int): Long {
        var pos = position
        var result = 0L
        while (pos >= 0) {
            result += array[pos]
            pos -= pos.inv() and (pos + 1)
        }
        return result
    }
}
sealed class Query {
    abstract val time: Int
    class Update(override val time: Int, val a: Int, val b: Int): Query()
    class Evaluation(override val time: Int): Query()
}

Measured memory_bytes: 133460
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
string s4[4]=
{
"aabc",
"ffbc",
"ghdd",
"ghee"};
string s5[5]=
{
"aabbc",
"fdd.c",
"f.gee",
"..ghi",
"jj.hi"};
string s6[6]=
{
"aabbcc",
"ddeek.",
"gh..k.",
"gh...l",
"..ij.l",
"..ijff"};
string s7[7]=
{
"aabbcc.",
"ddee..f",
"g...hhf",
"gi....n",
".ij...n",
"..jk..m",
"...kllm"};
int n,m,i,j,k;
char ans[1005][1005];
void solve(int a,int b,int c)
{
	int i,j,s=0,k;
	fz0k(i,n)fz0k(j,n){
		ans[i][j]='.';
	}
	while(a--){
		fz0k(i,4)fz0k(j,4){
			ans[s+i][s+j]=s4[i][j];
		}
		s+=4;
	}
	while(b--){
		fz0k(i,5)fz0k(j,5){
			ans[s+i][s+j]=s5[i][j];
		}
		s+=5;
	}
	while(c--){
		fz0k(i,6)fz0k(j,6){
			ans[s+i][s+j]=s6[i][j];
		}
		s+=6;
	}
	fz0k(i,n){
		fz0k(j,n){
			putchar(ans[i][j]);
		}
		puts("");
	}
}
int main()
{
	cin>>n;
	if(n==2){
		puts("-1");
		return 0;
	}
	if(n==3){
		puts("aab");
		puts("d.b");
		puts("dcc");
		return 0;
	}
	if(n==7){
		fz0k(i,n){
			puts(s7[i].c_str()); 
		}
		return 0;
	}
	fz0g(i,n)fz0g(j,n){
		k=n-i*4-j*5;
		if(k>=0&&k%6==0){
			solve(i,j,k/6);
			return 0;
		}
	}
	exit(-1);
	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
char A[100002],B[100002];
int V[100002][26];
long long w;
int main() {
	int a,b,p=1;
	cin>>A+1>>B+1,a=strlen(A+1),b=strlen(B+1);
	for(int i=a;i;i--){
		for(int j=0;j<26;j++)V[i][j]=V[i+1][j];
		V[i][A[i]-'a']=i;
	}
	for(int i=1;i<=b;i++){
		if(V[p][B[i]-'a'])w+=V[p][B[i]-'a']-p+1,p=V[p][B[i]-'a']+1;
		else {
			w+=a-p+1,p=1;
			if(V[p][B[i]-'a'])w+=V[p][B[i]-'a']-p+1,p=V[p][B[i]-'a']+1;
			else {
				cout<<-1;
				return 0;
			}
		}
	}
	cout<<w;
}

Measured memory_bytes: 10624
// Last Change: 09/12/2019 11:31:21.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

ll N;
vector<vector<vector<int>>> F;
vector<vector<ll>> P;

void init() {
  cin >> N;
  F.resize(N, vector<vector<int>>(5, vector<int>(2)));
  P.resize(N, vector<ll>(11));

  for (auto &&e : F) {
    for (int i = 0; i < 5; ++i) {
      for (int j = 0; j < 2; ++j) {
        cin >> e[i][j];
      }
    }
  }

  for (auto &&e : P) {
    for (int i = 0; i < 11; ++i) {
      cin >> e[i];
    }
  }
}

ll calc(const int open[5][2]) {
  vector<int> cnt(N, 0);
  int check = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 5; ++j) {
      for (int k = 0; k < 2; ++k) {
        if (open[j][k] == 1 and F[i][j][k] == open[j][k]) {
          ++cnt[i];
          ++check;
        }
      }
    }
  }

  if (check == 0) {
    return numeric_limits<ll>::min();
  }

  ll res = 0;
  for (int i = 0; i < N; ++i) {
    res += P[i][cnt[i]];
  }
  return res;
}

ll dfs(int depth, int open[5][2]) {
  if (depth >= 10) {
    return calc(open);
  }
  ll tmpAns = numeric_limits<ll>::min();
  open[depth / 2][depth % 2] = 0;
  tmpAns = max(tmpAns, dfs(depth + 1, open));
  open[depth / 2][depth % 2] = 1;
  tmpAns = max(tmpAns, dfs(depth + 1, open));
  return tmpAns;
}

ll solve() {
  int open[5][2];
  return dfs(0, open);
}

int main() {
  init();
  cout << solve() << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

 public static void main(String[] args) {

  Scanner sc = new Scanner(System.in);

  int x = sc.nextInt();

  int y = sc.nextInt();

  int[] values = new int[x];

  for (int i = 0; i < values.length; i++) {

   values[i] = i +1;

  }
  for (int i = 0; i < y; i++) {
   String str = sc.next();
   String[] ab = str.split(",");
   int a = Integer.parseInt(ab[0])-1;
   int b = Integer.parseInt(ab[1])-1;
   int t = values[a];
   values[a] = values[b];
   values[b] = t;
  }
  for (int j=0; j < x; j++) {
   System.out.println(values[j]);
  }
 }
}

Measured memory_bytes: 26188
#include<iostream>
#include<cstring>
#include<queue>
#include<map>
#include<vector>
using namespace std;
#define fr first
#define sc second
typedef pair<string,int> P;
int h,w,c,ans,d[]={0,1,0,-1},cnt;
bool used[8][8];
vector<vector<int> > kgym_map;
void kgym_cnt(int x,int y){
  used[x][y] = true;
  cnt++;
  for(int i = 0 ; i < 4 ; i++){
    int nx = x + d[i] , ny = y + d[3 - i];
    if(nx < 0 || nx >= h || ny < 0 || ny >= w || used[nx][ny] ) continue;
    if(kgym_map[nx][ny] == kgym_map[0][0]) kgym_cnt(nx,ny);
  }
  return;
}
void KGYM(int color,int to,int x,int y){
  kgym_map[x][y] = to;
  for(int i = 0 ; i < 4 ; i++){
    int nx = x + d[i] , ny = y + d[3 - i];
    if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
    if(kgym_map[nx][ny] == color) KGYM(color,to,nx,ny);
  }
}
void search(vector< vector<int> > tmp , int n){
  if(n == 5){
    memset(used,false,sizeof(used));
    kgym_map = tmp;
    if(kgym_map[0][0] != c) return;
    cnt = 0;
    kgym_cnt(0,0);
    ans = max( cnt , ans );
    return;
  }
  for(int i = 1 ; i <= 6 ; i++ ){
    if( i == tmp[0][0] ) continue;
    kgym_map = tmp;
    KGYM(tmp[0][0],i,0,0);
    search(kgym_map,n + 1);
  }
}
int main(){
  vector< vector<int> > tmp;
  while(cin >> h >> w >> c && h){
    tmp.resize(h);
    for(int i = 0 ; i < h ; i++ ){
      tmp[i].resize(w);
      for(int j = 0 ; j < w ; j++ ){
        cin >> tmp[i][j];
      }
    }
    ans = 0;
    search(tmp,0);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1236
#include <iostream>
#include <stdio.h>
#include <string>
#include <map>
using namespace std;

#define LEN 100005

typedef struct pp
{
    char name[100];
    int t;
} P;

class queue
{
public:
    P Q[LEN];
    int head;
    int tail;
    queue()
    {
        head = 0;
        tail = 0;
    }
    ~queue() {}
    bool isEmpty()
    {
        return head == tail;
    }
    bool isFull()
    {
        return head == (tail + 1) % LEN;
    }
    void enqueue(P x)
    {
        Q[tail] = x;
        tail = (tail + 1) % LEN;
    }
    P dequeue()
    {
        P x = Q[head];
        head = (head + 1) % LEN;
        return x;
    }
};

int main()
{
    queue *que = new queue;
    int n, q;
    int elaps = 0;
    int c;
    P u;
    cin >> n >> q;

    for (int i = 1; i <= n; i++)
    {
        scanf("%s", que->Q[i].name);
        scanf("%d", &que->Q[i].t);
    }

    que->head = 1;
    que->tail = n + 1;
    while (que->head != que->tail)
    {
        u = que->dequeue();
        c = std::min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0)
            que->enqueue(u);
        else
        {
            printf("%s %d\n", u.name, elaps);
        }
    }

    delete que;

    return 0;
}


Measured memory_bytes: 12852
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int N, M; string s[109], t[109];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> t[i];
	}
	int ret = 0;
	for (int i = 0; i < N; i++) {
		int score = 0;
		for (int j = 0; j < N; j++) {
			if (s[i] == s[j]) score++;
		}
		for (int j = 0; j < M; j++) {
			if (s[i] == t[j]) score--;
		}
		ret = max(ret, score);
	}
	cout << ret << "\n";
	return 0;
}

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

#include <vector>
template<class T>struct UnionFind {
  vector<int> parent, sz;
  vector<T> _diff;
  UnionFind(int n) {
    parent.resize(n, -1);
    sz.resize(n, 1);
    _diff.resize(n, 0); // 親との差
  }
  int root(int x) {
    if (parent[x] == -1)
      return x;
    int r = root(parent[x]);
    _diff[x] += _diff[parent[x]];
    return parent[x] = r;
  }
  T weight(int x) {
    root(x);
    return _diff[x];
  }
  void merge(int x, int y, T w) {
    // weight(x) = weight(y) + w;
    // yが親
    if (root(x) == root(y))
      return;
    T d = weight(y) - weight(x) + w;
    x = root(x); y = root(y);
    parent[x] = y;
    sz[y] += sz[x];
    _diff[x] = d;
    return;
  }
  T diff(int x, int y) {
    return weight(y) - weight(x);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sz[root(x)];
  }
};

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int main() {
  int n, q; cin >> n >> q;
  UnionFind<int> T(n);

  rep(i, q) {
    int com, x, y;
    ins(com, x, y);
    if (com == 0) {
      int in(z);
      T.merge(y, x, z);
    } else if (com == 1) {
      if (T.same(x, y))
        cout << T.diff(x, y) << endl;
      else
        cout << "?" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3880
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

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

  ll ans = 0;
  for (ll i = A; i <= B; i++) {
    string str = to_string(i);
    if (str[0] == str[4] && str[1] == str[3]) ans++;
  }

  cout << ans << endl;

  return 0;
}


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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define pmod 1000000007
#define maxn 100005
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
ll a[1005];
bool c[8000000];


void prime(long long m, ll n){
if (n<m) cout<<n+m<<endl;
else{
    ll j=0;
    //FOR (i,0,m-1) c[i]=0;
    //ll u=m;
    while (j<=n){
    if (c[m]==0){
    for(ll i=1; i*m<=7368792;i++){
        c[i*m]=1;
    }
    j++;
    //cout<<m<<" ";
    }
    //cout<<c[m]<<" ";

    m++;
    }
    cout<<m-1<<endl;
//else cout<<m-u<<endl;


}
}

int main()
{ll m=1;ll n;
while (1){
    memset(c,0,sizeof(c));
    cin>>m>>n;
    if (m==0) return 0;

    prime(m,n);


}

         return 0;
}

Measured memory_bytes: 10904
n = int(input())
L = list(map(int,input().split()))
flag = True
for i in range(n):
  cnt = 0
  if L[i]%2 == 0:
    if L[i]%3 == 0:
      cnt += 1
    elif L[i]%5 == 0:
      cnt += 1
    if cnt == 0:
      flag = False
      break
if flag:
  print('APPROVED')
else:
  print('DENIED')

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

int main(void){
  int n;
  char str1[5],str2[5000];
  char *s;
  fgets(str1,sizeof(str1),stdin);
  n=atof(str1);
  double a[n],b;
  fgets(str2,sizeof(str2),stdin);
  int i,j,k;
  i=0;
  s=strtok(str2," ");
  while(s!=NULL){
    a[i]=atof(s);
    i++;
    s=strtok(NULL," ");
  }
  
  for(i=0;i<n;i++){
    b=0;
    for(j=i;j<n;j++){
      if(a[j]>b){
        b=a[j];
        k=j;
      }
    }
    a[k]=a[i];
    a[i]=b;
  }
  double sum;
  sum=0;
  for(i=0;i<n-1;i++){
    sum+=a[i]/(pow(2.0,i+1));
  }
  sum+=a[n-1]/(pow(2.0,n-1));
  printf("%lf\n",sum);
  return 0;
}
    

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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(1){
    c -= b;
    if(c <= 0){
      cout << "Yes";
      break;
    }
    a -= d;
    if(a <= 0){
      cout << "No";
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<P> p(n);
  for(int i=0;i<n;++i) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  multiset<int> ms;
  ms.insert(-1);
  ms.insert(-1);
  ms.insert(n);
  ms.insert(n);
  ll su = 0;
  for(int i=0;i<n;++i) {
    ll val = p[i].first;
    int pos = p[i].second;
    auto it = ms.lower_bound(pos);
    ll l1, l2, r1, r2;
    r1 = *it++;
    r2 = *it--;
    it--;
    l1 = *it--;
    l2 = *it;
    su += val * (l1 - l2) * (r1 - pos);
    su += val * (r2 - r1) * (pos - l1);
    ms.insert(pos);
  }
  cout << su << endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e18,cnt,flag;

int main(){
	string s;
	cin>>s;
	for(ll i=0; i<s.size()-1; i++){
		if(s[i]!=s[i+1]) ans++;
	}
	cout<<ans<<endl;
}	

Measured memory_bytes: 512
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var Z = one[1];
  var W = one[2];
  var list = nextIntArray();
  if(N == 1){
    myout(Math.abs(list[N - 1] - W));
  }else{
    myout(Math.max(Math.abs(list[N - 2] - list[N - 1]), Math.abs(list[N - 1] - W)));
  }
}



Measured memory_bytes: 30764