akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    Integer[][] time = new Integer[5][2];

    for (int i = 0; i < 5; i++) {
      int a = sc.nextInt();
      int b = 10 - a % 10;
      if (b == 10) {
        b = 0;
      }
      time[i][0] = b;
      time[i][1] = a;
    }
 
    sc.close();

    Arrays.sort(time, (a1,b1) -> Integer.compare(a1[0],b1[0]));

    int answer = 0;
  
    for (int i = 0; i < 5; i++) {
      if (i != 4) {
        answer += time[i][1];
        answer += time[i][0];
      } else {
        answer += time[i][1];
      } 
    }

    System.out.println(answer);

  }

}

Measured memory_bytes: 26580
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

// int n; 

int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
		int x;
		cin >> x;
		cout << (x == 0 ? 1 : 0) << endl;
	return 0;
}

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

using namespace std;

#define ll long long

int a, b;

void solve() {
  cin >> a >> b;
  if ((a>9)||(b>9)) {
    cout << "-1\n";
  } else {
    cout << a*b << '\n';
  }
}   

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 256
from collections import deque
def main():
    q=deque()
    for i in range(1,10):
        q.append((str(i)))
    Ans=[]
    while q:
        s=q.popleft()
        if int(s)>3234566667:
            continue
        Ans.append(int(s))
        d=int(s[-1])
        if d==0:
            q.append(s+'0')
            q.append(s+'1')
        elif d==9:
            q.append(s+'8')
            q.append(s+'9')
        else:
            V=[d-1,d,d+1]
            for v in V:
                q.append(s+str(v))
    Ans.sort()
    #print(len(Ans))
    k=int(input())
    print(Ans[k-1])
    
if __name__=='__main__':
    main()

Measured memory_bytes: 78044
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n%1000==0)
	{
		cout<<0;
	}
	else
	{
		int t=(n+500)/1000;
		t=t*1000;
		if(t>n)
		{
			cout<<t-n;
		}
		else
		{
			t=t+1000;
			cout<<t-n;
		}
	}
}

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

ans = 1

#state0は未定、1は広義単調増加、2は広義単調減少
state = 0
m = A[0]

i = 1
while i <= N-1:
    if m < A[i]:
        if state == 0:
            state = 1
        elif state == 2:
            ans += 1
            state = 0
    elif m > A[i]:
        if state == 0:
            state = 2
        elif state == 1:
            ans += 1
            state = 0
    m = A[i]
    i += 1

print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int keta_sum(long long n){
    int res=0;
    while(n>0){
        res+=(n%10);
        n/=10;
    }
    return res;
}

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

    int k;
    cin>>k;
    vector<long long> v;
    set<long long> st;
    for(int j=0;j<=12;j++){
        for(int i=1;i<=999;i++){
            long long tmp=i;
            for(int k=0;k<j;k++)tmp=tmp*10+9;
            if(st.count(tmp))continue;
            v.push_back(tmp);
            st.insert(tmp);
        }
    }
    for(int i=0;i<v.size();i++){
        bool f=true;
        for(int j=i+1;j<v.size();j++){
            if(v[i]*keta_sum(v[j])>v[j]*keta_sum(v[i])){
                f=false;
                break;
            }
        }
        if(f){
            cout<<v[i]<<endl;
            k--;
            if(k==0)break;
        }
    }

}

Measured memory_bytes: 896
// https://atcoder.jp/contests/abc099/tasks/abc099_a
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << (n >= 1000 ? "ABD\n" : "ABC\n");
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll N = 2e5 + 10;

ll n, m;
ll a, b;
//ll p[N][2];
ll p[N], d[N], ssize[N];

ll find(ll x) {
	if (p[x] != x) {
        int root = find(p[x]);
        d[x] += d[p[x]];
        p[x] = root;
    }
    return p[x];
    /*
	if (x == p[x][1]){
		return x;
	}
	return p[x][1] = find(p[x][1]);
	*/
}

int main() {
	cin >> n >> m;
	
	for (ll i = 1; i <= n; i++) {
//		p[i][1] = i;
//		p[i][0] = 1;
		p[i] = i;
		ssize[i] = 1;
	}
	
	while (m--) {
		cin >> a >> b;
		if (find(a) == find(b)) {
			continue;
		}
		
		ll pa = find(a), pb = find(b);
		
		d[pa] = ssize[pb];
        ssize[pb] += ssize[pa];
        p[pa] = pb;
        /*
		p[aa][0] += p[bb][0];
        p[aa][1] = bb;
        */
	}
	
	ll res = -1;
	
	for (ll i = 1; i <= n; i++) {
		res = max(res, ssize[i]);
	}
	
	cout << res << endl;
	
	return 0;
}

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

int main() {
    string s;
    int q;
    cin >> s >> q;
    
    bool r = false;
    rep(i, q) {
        int query;
        cin >> query;
        if (query == 1) r = !r;
        if (query == 2) {
            int f;
            string c;
            cin >> f >> c;
            if ((!r && f == 1) || (r && f == 2)) s.insert(0, c);
            if ((r && f == 1) || (!r && f == 2)) s += c;
        }
    }

    if (r) reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
typedef long long LL;
typedef unsigned uint;
typedef unsigned long long ULL;
using namespace std;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 2005;
int f[MAXN][MAXN * 3][3], a[MAXN][3], arr[MAXN * 3], g[MAXN], n;
int b0[MAXN * 3], b1[MAXN * 3][MAXN], b2[MAXN][3], b3[MAXN][MAXN][3];

void upd(int i) {
	for (int k = 0; k < i * 3 + 2; k++)
	for (int x = 0; x < 3; x++) if (i * 3 - 1 + x != k) {
		int t = f[i][k][x] - g[i];
		chkmax(b0[k], t);
		chkmax(b1[k][a[i][x]], t);
		chkmax(b2[i][x], t);
		chkmax(b3[i][arr[k]][x], t);
	}
}

int main() {
	scanf("%d", &n);
	int c = 0;
	scanf("%d%d", &a[0][1], &a[0][2]);
	arr[c++] = a[0][1], arr[c++] = a[0][2];
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++)
			scanf("%d", &a[i][j]), arr[c++] = a[i][j];
		g[i] = g[i - 1] + (a[i][0] == a[i][1] && a[i][0] == a[i][2]);
	}
	scanf("%d", &a[n][0]);
	arr[c++] = a[n][0];
	memset(b0, 0xc0, sizeof(b0));
	memset(b1, 0xc0, sizeof(b1));
	memset(b2, 0xc0, sizeof(b2));
	memset(b3, 0xc0, sizeof(b3));
	
	for (int i = 1; i <= n; i++) {
		upd(i - 1);
		for (int k = 0; k < i * 3 - 1; k++) {
			int e = (k < 2 ? -3 : (k - 2) / 3 * 3) + 2, d = (e + 1) / 3;
			for (int x = 0; x < 3; x++) {
				int a1 = x == 0 ? a[i][1] : a[i][0];
				int a2 = x == 2 ? a[i][1] : a[i][2];
				chkmax(f[i][k][x], b0[k] + g[i - 1]);
				if (a1 == a2) chkmax(f[i][k][x], b1[k][a1] + g[i - 1] + 1);
			}
			for (int x = 0; x < 3; x++) {
				int a1 = x == 0 ? a[i][1] : a[i][0];
				int a2 = x == 2 ? a[i][1] : a[i][2];
				chkmax(f[i][k][x], b2[d][k - e] + g[i - 1]);
				if (a1 == a2) chkmax(f[i][k][x], b3[d][a1][k - e] + g[i - 1] + 1);
			}
		}
		int e = i * 3 - 1;
		for (int x = 0; x < 3; x++) {
			int a1 = x == 0 ? 1 : 0;
			int a2 = x == 2 ? 1 : 2;
			for (int j = 0; j < i; j++)
			for (int y = 0; y < 3; y++) {
				chkmax(f[i][a1 + e][a2], b2[j][y] + g[i - 1]);
				if (a[j][y] == a[i][x]) chkmax(f[i][a1 + e][a2], b3[j][a[i][x]][y] + g[i - 1] + 1);
			}
			f[i][a2 + e][a1] = f[i][a1 + e][a2];
		}
	}
	printf("%d\n", f[n][n * 3][2]);
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m; cin >> n >> m;
  vector<vector<int>> graph(n);
  for (int i = 0; i < m; i++) {
    int k; cin >> k;
    for (int j = 0; j < k; j++) {
      int s; cin >> s;
      s--;
      graph[s].push_back(i);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  int cnt = 0;
  for (int i = 0; i < (1 << n); i++) {
    bitset<10> light(0);
    for (int j = 0; j < n; j++) {
      if (i >> j & 1) {
        for (int s : graph[j]) {
          light.flip(s);
        }
      }
    }
    bool flag = true;
    for (int j = 0; j < m; j++) {
      if (light[j] ^ p[j]) {
        flag = false;
        break;
      }
    }
    if (flag) cnt++;
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();

		double sum=0;
		for(int i=0;i<n;i++) {
			sum+=1.0/(double)sc.nextInt();
		}


			System.out.println(1.0/sum);

	}

}


Measured memory_bytes: 23252
from collections import deque

def main():

    queue = deque()

    for _ in range(int(input())):
        commands = input().split(" ")
        if commands[0] == "insert":
            queue.appendleft(commands[1])
        elif commands[0] == "delete":
            try:
                queue.remove(commands[1])
            except ValueError:
                pass
        elif commands[0] == "deleteFirst":
            queue.popleft()
        elif commands[0] == "deleteLast":
            queue.pop()

    print(" ".join(queue))

main()

Measured memory_bytes: 72052
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 10000000000000000;
const int mod = 1000000007;
int iti[12345678], cnt[12345678], cost[4321][4321];
signed main() {
	int n, t1, t2, a1, a2, b1, b2, saki = 0, ato = 0, ans = 1;
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	int firsta = a1 * t1, firstb = b1 * t1;
	int seconda = a2 * t2, secondb = b2 * t2;
	saki = firsta - firstb; ato = seconda - secondb;
	if (saki + ato == 0) { cout << "infinity" << endl; return 0; }
	if ((firsta > firstb) && (firsta + seconda > firstb + secondb)) {
		cout << 0 << endl; return 0;
	}
	if ((firsta < firstb) && (firsta + seconda < firstb + secondb)) {
		cout << 0 << endl; return 0;
	}
	//cout << saki << ' ' << ato << endl;
	//cout << saki + ato << endl;
	if (saki % (saki + ato) == 0) {
		cout << abs(saki / (saki + ato)) * 2 << endl;
	}
	else {
		cout << abs(saki / (saki + ato)) * 2 + 1 << endl;
	}
	cin >> n; return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

int f[100000];
vector <pair<int, int> > v[100000];

int main() {
    int n, m, i, j;
    queue <int> q;
    map <int, long long> mp;
    
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < m; i++) {
        int x, y, z;
        
        scanf("%d %d %d", &x, &y, &z);
        
        x--;
        y--;
        
        v[x].push_back(make_pair(y, z));
        v[y].push_back(make_pair(x, -z));
    }
    
    for (i = 0; i < n; i++) {
        if (f[i] == 1) continue;
        
        f[i] = 1;
        mp[i] = 0;
        q.push(i);
        
        while (!q.empty()) {
            int x = q.front();
            
            q.pop();
            
            for (j = 0; j < v[x].size(); j++) {
                int y = v[x][j].first;
                long long z = mp[x] + v[x][j].second;
                
                if (mp.count(y) && mp[y] != z) {
                    puts("No");
                    
                    return 0;
                }
                
                if (f[y] == 0) {
                    f[y] = 1;
                    mp[y] = z;
                    q.push(y);
                }
            }
        }
    }
    
    puts("Yes");
    
    return 0;
}


Measured memory_bytes: 15348
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

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

int main(){
  int n;
  while(cin >> n, n){
      vector<int> v(n);
      rep(i, n)cin >> v[i];
      sort(v.begin(), v.end());
      int sum = accumulate(v.begin()+1, v.end()-1, 0);
      cout << sum / (n-2) << '\n';
  }
  return 0;
}

Measured memory_bytes: 1212
import java.util.HashSet;
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			
			HashSet<String> h = new HashSet<String>();
			
			for(int i=0;i<n;i++) {
				h.add(sc.next());
			}

			System.out.println(h.size());
	    }
				
	}


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

int main(){
  int a,b,c,i;
  cin>>a>>b>>c;
  if(c*2>b-a+1){
    while(a!=b+1){
      cout<<a<<endl;
      a++;
    }
    }else{
      for(i=0;i<c;i++){
        cout<<a+i<<endl;
      }
      for(i=c-1;i>=0;i--){
        cout<<b-i<<endl;
      }
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int r;
  cin >> r;
  cout << (3 * r * r);
}
#endif


Measured memory_bytes: 3620
#include<stdio.h>
void selectionSort(int*,int);
int main(){
  int n,i,A[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  selectionSort(A,n);
  return 0;
}
void selectionSort(int*A,int n){
  int i,j,minj,b,c=0,flag;
  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(minj==i)c--;
    b=A[i];
    A[i]=A[minj];
    A[minj]=b;
      c++;
  }
  printf("%d",A[0]);
  for(i=1;i<n;i++){
    printf(" %d",A[i]);
  }
  printf("\n%d\n",c);
}



Measured memory_bytes: 2084
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>

using namespace std;

int X; //Aの枚数
int Y; //B
int Z; //AB

int get_max(int *X, int *Y) {
	int max = 0;
	if (*X > *Y) {
		max = *X;
	}
	else {
		max = *Y;
	}
	return max;
}

int main() {
	int a, b, c = 0; //ピッツァの価格
	int ans = 0;

	cin >> a >> b >> c >> X >> Y;
	//ハーフを入れて買うのがお得な時(ABの値段の2倍がA,Bの和を超えないとき)
	if ((a + b) > c * 2) {
		int max;
		max = get_max(&X, &Y);

		int tmp = max * 2 * c;
		while (X>0 && Y>0) {
			X = X - 1;
			Y = Y - 1;
			Z = Z + 2;

			ans = c * Z + a * X + b * Y;
			if (ans > tmp) {
				ans = tmp;
			}
		}
	}
	//ハーフを入れて買わない時
	else {
		ans = a * X + b * Y;
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
long long a,b,i,d,k,l,r,ll,rr,ans;
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
   	a=read();
   	b=read();
   	if(a==b){
   		pus(1,2);
   		return 0;
   	}
   	for(i=60;i>=0;i--){
   		if(((1LL<<i)&a)&&((1LL<<i)&b)){
   			a^=(1LL<<i);
   			b^=(1LL<<i);
   		}
   		if(((1LL<<i)&a)!=((1LL<<i)&b)){
			d=i;
			k=-1;
			for(i--;i>=0;i--)
				if((1LL<<i)&b){
					k=i;
					break;
				}
			k++;
			l=a;r=(1LL<<d)+(1LL<<k)-1;
			ll=(1LL<<d)+a;rr=(1LL<<(d+1))-1;
			if(r>=ll)
				ans=rr-l+1;
			else
				ans=rr-ll+1+r-l+1;
			break;
		}
	}
	pus(ans,2);
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        int[] seats = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0};
        int[] groupMembers = new int[] {2, 5, 2, 2, 2};
        int[] eatTimes = new int[] {19, 39, 25, 36, 22, 42};

        int headGroup = -1;
        int pastMinutes = 0;
        int customerCount = 0;
        List<Integer> waitTime = new ArrayList<Integer>(100);

        while (customerCount < 100) {
            // たべおわる
            for (int i = 0; i < seats.length; i++) {
                seats[i] = seats[i] == 0 ? 0 : seats[i] - 1;
            }

            // 来店
            if (headGroup == -1 && pastMinutes % 5 == 0) {
                headGroup = pastMinutes / 5;
            }

            // ちゃくせき
            while (headGroup != -1) {
                int sequencialSeats = 0;
                int startIndex = -1;
                for (int i = 0; i < seats.length; i++) {
                    sequencialSeats = seats[i] == 0 ? sequencialSeats + 1 : 0;

                    if (sequencialSeats == groupMembers[headGroup % 5]) {
                        startIndex = i - (groupMembers[headGroup % 5] - 1);
                        break;
                    }
                }

                if (startIndex != -1) {
                    // すわれたみたい
                    waitTime.add(headGroup, pastMinutes - (headGroup * 5));
                    for (int i = startIndex; i < (startIndex + groupMembers[headGroup % 5]); i++) {
                        seats[i] = eatTimes[headGroup % 6];
                    }

                    headGroup = (((headGroup + 1) * 5) <= pastMinutes) ? headGroup + 1
                            : -1;
                    customerCount++;
                } else {
                    // すわれなかったみたい
                    break;
                }

            }

            pastMinutes++;

        }

        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            System.out.println(waitTime.get(sc.nextInt()));
        }

    }
}

Measured memory_bytes: 17180
h,w,K = map(int,input().split())
if w == 1:
    print(1)
    exit()
K -= 1
mod = 1000000007
dp = [[0]*(w) for _ in range(h+1)]
for i in range(w): dp[0][0] = 1

for i in range(h):
    for j in range(1<<(w-1)):
        invalid = False
        for k in range(w-1):
            if j>>k & 1 and j>>(k+1) & 1:
                invalid = True
                break
        if invalid: continue
        used = [False]*w
        for k in range(w):
            if used[k]: continue
            if j>>k & 1:
                dp[i+1][k] = (dp[i+1][k]+dp[i][k+1])%mod
                dp[i+1][k+1] = (dp[i+1][k+1]+dp[i][k])%mod
                used[k] = True
                used[k+1] = True
            else:
                dp[i+1][k] = (dp[i+1][k]+dp[i][k])%mod
                used[k] = True
# for i in range(h+1): print(dp[i])
print(dp[h][K])

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

int main() {
  string s;
  cin >> s;
  bool ans = false;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) ans = true;
  if (ans) puts("Yes");
  else puts("No");
  return 0;
}

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

int main()
{
    int a,b;
    char op;
    while(true){
        cin>>a>>op>>b;
        if(op=='?')break;
        switch(op){
            case '+':cout<<a+b<<endl;
            break;
            case '-':cout<<a-b<<endl;
            break;
            case '*':cout<<a*b<<endl;
            break;
            case '/':cout<<a/b<<endl;
            break;
        }
    }
}


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

int main(){
    int N;
    cin>>N;
    int ans[151];
    if(N>20){
        for(int i=0;i<N;i++){
            string inp1,inp2;
            cin>>inp1;
            cin>>inp2;
            int dp[101][101]={};
            for(int j=1;j<=inp1.size();j++){
                for(int k=1;k<=inp2.size();k++){
                    if(inp1[j-1]==inp2[k-1]){
                        dp[j][k]=dp[j-1][k-1]+1;
                    }else{
                        dp[j][k]=max(dp[j-1][k],dp[j][k-1]);
                    }
                }
            }
            ans[i]=dp[inp1.size()][inp2.size()];
        }
    }else{
        for(int i=0;i<N;i++){
            string inp1,inp2;
            cin>>inp1;
            cin>>inp2;
            int dp[1001][1001]={};
            for(int j=1;j<=inp1.size();j++){
                for(int k=1;k<=inp2.size();k++){
                    if(inp1[j-1]==inp2[k-1]){
                        dp[j][k]=dp[j-1][k-1]+1;
                    }else{
                        dp[j][k]=max(dp[j-1][k],dp[j][k-1]);
                    }
                }
            }
            ans[i]=dp[inp1.size()][inp2.size()];
        }
    }
    for(int i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 7032
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;


struct UnionFind {
    vector<int> size;
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N), size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
            par[i] = i;
            size[i] = 1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        par[x] = root(par[x]);
        return par[x];
    }

    int getSize(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        return size[root(x)];
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y); 
        if (rx == ry) return;
        if (size[rx] < size[ry]) swap(x, y);
        size[rx] += size[ry];
        par[ry] = rx; 
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

void Main()
{
    ll n, m;
    cin >> n >> m;

    vector<ll> A(m), B(m);
    rep(i, m) cin >> A[i] >> B[i];
    
    UnionFind uf(n);

    vector<ll> inc(m);
    
    for (ll i = m - 1; i >= 0; i--) {
        ll a = A[i] - 1;
        ll b = B[i] - 1;
        if (uf.root(a) != uf.root(b)) {
            inc[i] = uf.getSize(a) * uf.getSize(b);
        }
        uf.unite(a, b);
    }

    ll res = 0;
    rep(i, m) {
        res += inc[i];
        put(res);
    }

}
signed main(){ Main();return 0;}

Measured memory_bytes: 6372
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int M1, M2, D1, D2;
    cin >> M1 >> D1;
    cin >> M2 >> D2;
    if (D2 == 1) {
        puts("1");
    } else {
        puts("0");
    }
    return 0;
}


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

using namespace std;

int main()
{
    string result;
    long long n;
    cin >> n;
    while (n > 0)
    {
        n--;
        result += char(97 + (n % 26));
        n /= 26;
    }
    reverse(result.begin(), result.end());
    cout << result;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;

int MOD=1000000007;

int main(){
  long double L,ans=0;
  cin >> L;
  ans=L/3;
  L=L-ans;
  ans*=L/2;
  L=L-L/2;
  ans*=L;
  printf("%.12Lf\n",ans);
}

Measured memory_bytes: 256
S = input()
front = int(S[0:2])
back = int(S[2:4])

if 1 <= front <= 12 and 1 <= back <= 12:
    print('AMBIGUOUS')
elif 0 <= front <= 99 and 1 <= back <= 12:
    print('YYMM')
elif 1 <= front <= 12 and 0 <= back <= 99:
    print('MMYY')
else:
    print('NA')

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

int n;
int li[205];
int tot;
int memo[205][40005];

int dp(int id, int x){
	if(id>n) return min(x,tot-x);
	int &ret = memo[id][x];
	if(ret!=-1) return ret;
	return ret = max(dp(id+1,x+li[id]),dp(id+1,x));
}

int main(){
	memset(memo,-1,sizeof(memo));
	scanf("%d",&n);
	tot = 0;
	n*=2;
	for(int i=1;i<=n;i++){
		scanf("%d",&li[i]);
		tot+=li[i];
	}
	sort(li+1,li+n+1);
	tot = 0;
	for(int i=1;i<=n;i+=2) tot+=li[i];
	int ans = dp(1,0);
	printf("%d\n",tot);
	return 0;
}

Measured memory_bytes: 32256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 2e6 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 2e9 + 51;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    int k = a, k1 = b;
    if (abs(k - k1) % 2 == 0) {
        cout << abs(k - k1) / 2;
        return 0;
    }
    if (k > k1) swap(k, k1);
    int ans = 0, ans1 = 0;
    ans = (k1 - (k - 1) - 1) / 2 + (k - 1) + 1;
    ans1 = (n - (k + (n - k1) + 1)) / 2 + 1 + (n - k1);
    cout << min(ans, ans1);


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 100010;
ll a[N][2];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n, m, p;
	string s;

	cin >> n >> m;
	memset(a, 0, sizeof a);

	for(int i = 0; i < m; i++){
		cin >> p >> s;
		if(a[p][1]) continue;
		
		if(s == "AC") a[p][1] = 1;
		else a[p][0]++; 
	}

	int correct = 0, penalties = 0;
	for(int i = 1; i <= n; i++){
		if(a[i][1]){
			correct++;
			penalties += a[i][0];
		}
	}
	cout << correct << " " << penalties;
}

Measured memory_bytes: 1792
#include <iostream>

int main() {
	
   int count = 0;
   std::string s;
   std::cin >> s;
  
  	if(s[0] == '1') ++count;
	if(s[1] == '1') ++count;
	if(s[2] == '1') ++count;
  
  	std::cout <<  count << std::endl;
  
	return (0);

}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#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<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};

vector<string> split(const string& s, char c = ' '){
	vector<string> ret;
	string t; 
	stringstream ss(s);
	while(getline(ss, t, c)){
		ret.pb(t);
	}
	return ret;
}

int main(){
	string s;
	getline(cin,s);
	map<string, int> mp;
	vector<string> v = split(s);
	rep(i, v.size()){
		mp[v[i]]++;
	}
	string m, l;
	int a = 0;
	for(auto p : mp){
		if(a < p.se) m = p.fi, a = p.se;
		if(l.size() < p.fi.size()) l = p.fi;
	}
	cout<<m<<" "<<l<<endl;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using di = double;

int main(){
  di d;
  di t;
  di s;
  cin >> d >> t >> s;
  if(d/s <= t){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3708
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#define _GLIBCXX_DEBUG
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく


//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

bool E[2005][2005];
vector<bool> seen;
typedef pair<int, int> P;
typedef tuple<int, int, int> Tu;
//typedef pair<string, int> P;
int D[2005];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

int main() {
    string S, T; cin >> S >> T;
    sort(S.begin(), S.end());
    sort(T.begin(), T.end());
    reverse(T.begin(), T.end());
    if (S < T) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())
dp = [10**9+7]*(n+1)
dp[0] = 0
for i in range(1,n+1):
    dp[i] = dp[i-1] + 1
    j = 6
    while i-j >= 0:
        dp[i] = min(dp[i], dp[i-j]+1)
        j *= 6
    k = 9
    while i-k >= 0:
        dp[i] = min(dp[i], dp[i-k]+1)
        k *= 9
print(dp[n])

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n-1);
    for(int i = 0; i < n; i++) cin >> a[i], a[i]--;
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n-1; i++) cin >> c[i];
    int ans = b[a[0]];
    int pre = a[0];
    for(int i = 1; i < n; i++){
        ans += b[a[i]];
        if(pre == a[i]-1) ans += c[pre];
        pre = a[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    let m = 10 ^ 9 + 7
    -- 整数の入力
    n <- readLn
    -- スペース区切り整数の入力
    l <- map strToInt . words <$> getLine
    -- 出力
    putStrLn . show . (flip mod m) $ solve l n

solve :: [Int] -> Int -> Integer
solve l n
    | odd n = if ((group $ sort l) == ([0] : (map (replicate 2 . (* 2)) [1..(n `div` 2)]))) then (2 ^ (n `div` 2)) else 0
    | otherwise = if ((group $ sort l) == (map (replicate 2) $ filter odd [1..(n-1)])) then (2 ^ (n `div` 2)) else 0


Measured memory_bytes: 34044
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>
#include <assert.h>

using namespace std;

#define endl '\n'

const int mod = 998244353;
const int maxn = 1000001;

int modpow(int a, int n)
{
    int b = 1;
    while (n)
    {
        if (n & 1)
        {
            b = 1LL * b * a % mod;
        }

        n >>= 1;
        a = 1LL * a * a % mod;
    }

    return b;
}

int inverse(int a)
{
    return modpow(a, mod - 2);
}

void add(int &a, int b)
{
    a += b;
    if (a >= mod)
        a -= mod;
}

int total[maxn];
int sum_p[maxn];
int mobiu[maxn];
bool ispr[maxn];

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

    int n;
    cin >> n;

    for (int i = 0; i < n; ++i)
    {
        int v;
        cin >> v;
        total[v]++;
    }

    int answer = 0;

    for (int i = 1; i < maxn; ++i)
    {
        mobiu[i] = 1;
        ispr[i] = true;
    }

    for (int i = 2; i < maxn; ++i)
    {
        if (!ispr[i])
            continue;

        for (int j = i; j < maxn; j += i)
        {
            ispr[j] = false;

            if (mobiu[j] && (j % (i * i)) == 0)
            {
                mobiu[j] = 0;
            }
            else
            {
                mobiu[j] *= -1;
            }
        }
    }

    int i2 = inverse(2);

    for (int i = 1; i < maxn; ++i)
    {
        int sum = 0;
        int square_sum = 0;
        auto inv = inverse(i);

        for (int j = i; j < maxn; j += i)
        {
            add(sum, 1LL * j * total[j] % mod);
            add(square_sum, 1LL * j * j % mod * total[j] % mod);
        }

        int t = i * mobiu[i];
        if (t < 0)
            t += mod;

        if (t)
        {
            for (int j = i; j < maxn; j += i)
            {
                add(sum_p[j], t);
            }
        }

        sum = 1LL * sum * sum % mod;
        sum -= square_sum;
        if (sum < 0)
            sum += mod;

        int cur = 1LL * sum * i2 % mod;

        add(answer, 1LL * cur * inverse(i) % mod * sum_p[i] % mod);
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 12928
#include<cstdio>
using namespace std;
int n, ans=0;
char a[3][200];
int main()
{
	scanf( "%d", &n );
	for ( int i=0; i<=2; i++ )
	  scanf( "%s", a[i] );
	for ( int i=0; i<n; i++ )
	{
		if ( a[0][i]==a[1][i]&&a[1][i]==a[2][i] ) continue;
		else 
		  if ( a[0][i]==a[1][i]||a[1][i]==a[2][i]||a[0][i]==a[2][i] ) ans++;
		  else ans+=2; 
	}
	printf( "%d", ans );
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin python3
# -*- coding: utf-8 -*-

T = int(input())
from collections import deque
INF = 10**18

def transit(n, i, p):
    if p == 1:
        num = ((n+(i-1))//i)*i
        cos = d * (num - n)
        num //= i
        cos += ci[i]
    else:
        num = (n//i)*i
        cos = d * (n - num)
        num //= i
        cos += ci[i]
    return (num, cos)

for _ in range(T):
    N, a2, a3, a5, d = map(int, input().split())
    ci = {}
    ci[2]=a2
    ci[3]=a3
    ci[5]=a5
    dp = {}
    def cost(n):
        if n == 0:
            return 0
        if n == 1:
            return d
        if n in dp:
            return dp[n]
        ret = n * d
        for i in [2,3,5]:
            num, cos = transit(n, i, 1)
            ret = min(ret, cos + cost(num))
            num, cos = transit(n, i, -1)
            ret = min(ret, cos + cost(num))
        dp[n] = ret
        return ret
    print(cost(N))


Measured memory_bytes: 11324
while True:
    ans=0
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if(i+j+k==x):
                    ans=ans+1
    print(ans)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n);
    vector<int> vec(n),dp(n);
    in(vec);
    dp[0]=0;
    dp[1]=abs(vec[1]-vec[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(vec[i]-vec[i-1]),dp[i-2]+abs(vec[i]-vec[i-2]));
    }
    out(dp[n-1]);
}


Measured memory_bytes: 3976
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int H, W, M; cin >> H >> W >> M;
    int h[M], w[M];
    vector<int> bomH(H, 0);
    vector<int> bomW(W, 0);
    map<Pint, bool> bomExist;
    rep(i, M) {
        cin >> h[i] >> w[i];
        --h[i];--w[i];
        bomExist[mp(h[i], w[i])] = true;
        bomH[h[i]]++;
        bomW[w[i]]++;
    }
    int maxH = 0, maxW = 0;
    int maxH_h = 0, maxW_w = 0;
    rep(i, H) {
        if(bomH[i] >= maxH) {
            maxH = max(bomH[i], maxH);
            maxH_h = i;
        }
    }
    vector<int> hs, ws;
    rep(i, H) {
        if(bomH[i] == maxH) {
            hs.pb(i);
        }
    }
    rep(i, W) {
        if(bomW[i] >= maxW) {
            maxW = max(bomW[i], maxW);
            maxW_w = i;
        }
    }
    rep(i, W) {
        if(bomW[i] == maxW) {
            ws.pb(i);
        }
    }

    for(int h : hs) {
        for(int w : ws) {
            if(!bomExist[{h, w}]) {
                cout << maxW + maxH << endl;
                return 0;
            }
        }
    }
    cout << maxH + maxW - 1 << endl;
}


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

int N,K,R,S,P;
string T;

int dp[100000][3];

enum DP_INDEX{ RI=0, SI, PI};

int get_score(char me, int index) {
  char machine=T[index];
  if(me == 'r' && machine=='s') return R;
  if(me == 's' && machine=='p') return S;
  if(me == 'p' && machine=='r') return P;
  return 0;
}

int sub(int k) {
  dp[0][RI] = get_score('r' , k);
  dp[0][SI] = get_score('s' , k);
  dp[0][PI] = get_score('p' , k);

  int mx = max(max(dp[0][RI], dp[0][SI]) , dp[0][PI]);
  for(int i=1, ii=k+K; ii<N; i++,ii+=K) {
    dp[i][RI] = get_score('r' , ii) + max(dp[i-1][SI], dp[i-1][PI]);
    dp[i][SI] = get_score('s' , ii) + max(dp[i-1][PI], dp[i-1][RI]);
    dp[i][PI] = get_score('p' , ii) + max(dp[i-1][RI], dp[i-1][SI]);
    mx = max(mx, max(max(dp[i][RI], dp[i][SI]), dp[i][PI]));
  }
  cerr << k << " " << mx << endl;
  return mx;
}

signed main() {
  cin >> N >> K >> R >> S >> P >> T;

  int ans = 0;
  for(int k=0; k<K; k++) {
    ans += sub(k);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
int main(){
	int N,M;cin>>N>>M;
	vector<pair<int,int>> vp(M);
	rep(i,0,M){
        cin>>vp[i].first>>vp[i].second;
        vp[i].first--;
        vp[i].second--;
    }
	sort(vp.begin(), vp.end());
	int e = N-1; int cnt = 0;
	for(int i = M-1; i >= 0; i--){
		if(vp[i].second <= e){
			e = vp[i].first;
			cnt++;
		}
	}cout<<cnt<<endl;
}

Measured memory_bytes: 1024
let () = Scanf.scanf "%d %d" @@ fun n t ->
  let cts = Array.to_list @@ Array.init n @@ fun _ ->
    Scanf.scanf "\n%d %d" @@ fun c t -> c, t in
  match
    List.concat @@ List.map (fun (ci, ti) ->
      if t < ti then [] else [ci]) cts
  with
  | [] -> print_endline "TLE"
  | c :: cs -> Printf.printf "%d\n" @@ List.fold_left min c cs


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;


int main() {
    ll N,num[4] = {0};
    cin >> N;
    int a;
    rep(i,N){
       cin >> a;
       a %= 4;
       num[a]++; 
    }
    
    if(num[0] >= num[1]+ (num[2]>0?1:0) + num[3] - 1) cout << "Yes";
    else cout << "No";    
    //cout << ans;
    //printf("%.15lf", ans);
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
def merge(num, left, mid, right):
    global cnt
    inf = 10**9 + 1
    L = num[left:mid] + [inf]
    R = num[mid:right] + [inf]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            num[k] = L[i]
            i += 1
        else:
            num[k] = R[j]
            j += 1
            cnt += mid - left - i


def merge_count(num, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        merge_count(num, left, mid)
        merge_count(num, mid, right)
        merge(num, left, mid, right)

cnt = 0
input()
num = list(map(int, input().split()))
merge_count(num, 0, len(num))
print(cnt)

Measured memory_bytes: 30624
#include<stdio.h>
int main()
{
  int N,count=0;
  char S[60];
  scanf("%d",&N);
  for(int i=0;i<60;i++)
    scanf("%c",&S[i]);
  
  for(int i=0;i<N;i++){
    if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){count++;}
  }
  
  printf("%d",count);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	vector<int> a(3);
	for (int i = 0; i < 3; i++) cin >> a[i];
	sort(a.begin(), a.end());
	cout << a[2] - a[0] << endl;
}

Measured memory_bytes: 3640
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let S,T=RS string|>fun c -> c.[0],c.[1]
    stdout.Write T
    stdout.WriteLine S
    0


Measured memory_bytes: 11220
<?php 
$sc = new Scanner();
$H = $sc->nextInt();
$W = $sc->nextInt();
for($i =0; $i<$H; $i++){
    $l[$i] = preg_split("//u", str_replace(".", 0, str_replace("#" , 1 ,$sc->next())) , -1, PREG_SPLIT_NO_EMPTY);
}
$result="Yes";
for($i = 0 ; $i < $H; $i++){
    for($j = 0 ; $j < $W; $j++){
        if($l[$i][$j]=="1"){
            if(isset($l[$i][$j+1]) && $l[$i][$j+1]==1){
            }elseif(isset($l[$i][$j-1]) && $l[$i][$j-1]==1){
            }elseif(isset($l[$i+1][$j]) && $l[$i+1][$j]==1){
            }elseif(isset($l[$i-1][$j]) && $l[$i-1][$j]==1){
            } else {
                $result="No";
            }
        }
    }
}
echo $result.PHP_EOL;
 
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}


    

Measured memory_bytes: 4084
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long max = 0;
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		max = a[n-1] - a[0];
		System.out.println(max);
	}
}


Measured memory_bytes: 21972