akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
	long long a,b,i,x=0,c=0;
	scanf("%lld %lld",&a,&b);
	while(1){
		c++; x=a*c;
		if(x%b==0){
			printf("%lld\n",x);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1736
import cmath
def f():
 global d
 p=[]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a,a+r,a+r+r*cmath.rect(1,cmath.pi/3),b-r]
 d=p+[d[-1]]
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


Measured memory_bytes: 6000
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
int main()
{
	int n, a, b, i, j, k, x;
	scanf("%d%d", &a, &b);
	i = a + b;
	j = a * b;
	k = a - b;
	i = max(i, j);
	i = max(i, k);
	printf("%d\n", i);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<ll> sara(n);
	ll ans = 0;
	for(int i = 0; i < n; i++){
		ll a,b;
		cin >> a >> b;
		sara.push_back(a+b);
		ans -= b;
	}
	sort(all(sara));
	reverse(all(sara));
	for(int i = 0; i < n; i++){
		if(i%2==0) ans += sara[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int n, a[200000], b[200000], pos[200010], mx;
vector<int> arr;

int main() {
    arr.push_back(0);
    scanf("%d", &n);
    for (int i = 0 ; i < n ; i++) scanf("%d", &a[i]);
    for (int i = 0 ; i < n ; i++) {
        scanf("%d", &b[i]);
        if (arr.back() != b[i]) {
            arr.push_back(b[i]);
            pos[b[i]] = i;
        }
    }
    arr.push_back(200001);
    pos[200001] = n;
    for (int i = 0 ; i < n ; i++) {
        int tmp = *lower_bound(arr.begin(), arr.end(), a[i] + 1);
        int gap = pos[tmp] - i;
        if (mx < gap) mx = gap;
    }
    for (int i = 0, j = mx % n ; i < n ; i++, j = (j + 1) % n) {
        if (a[i] == b[j]) {
            printf("No");
            return 0;
        }
    }
    printf("Yes\n");
    for (int i = 0, j = mx % n ; i < n ; i++, j = (j + 1) % n) {
        printf("%d ", b[j]);
    }
}


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

const ll mod = 1e9 + 7;

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

  vector<bool> oks(n + 1, true);
  for (int i = 0; i < m; i++)
  {
    int a;
    cin >> a;
    oks[a] = false;
  }

  vector<int> dp(n + 1, 0);
  dp[0] = 1;
  if (oks[1])
  {
    dp[1] = 1;
  }
  else
  {
    dp[1] = 0;
  }

  for (int i = 2; i <= n; i++)
  {
    if (oks[i])
    {
      dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    }
  }

  cout << dp[n] << endl;
}

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

namespace Atcoder
{
    public class Program
    {
        private static long mod = 1000000007;

        static void Main(string[] args)
        {
            var r = ReadSplit();
            var n = r[0].Int();
            var m = r[1].Long();
            var l = GetCalcDivisor(m).OrderBy(x => x).ToList();
            var ans = 1L;
            foreach (var item in l)
            {
                if (m % item == 0)
                {
                    if (n * item <= m)
                    {
                        ans = Math.Max(item, ans);
                    }
                }
            }
            WriteRead(ans);
        }

        public static List<long> GetCalcDivisor(long n)
        {
            var res = new List<long>();
            for (long i = 1L; i * i <= n; ++i)
            {
                if (n % i == 0)
                {
                    res.Add(i);
                    long j = n / i;
                    if (j != i) res.Add(j);
                }
            }
            res.Sort();
            return res;
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 19124
s = []
t = []
ans = 0

n = int(input())
for i in range(n):
    si = input()
    s.append(si)

m = int(input())
for i in range(m):
    ti = input()
    t.append(ti)

for c in s:
    cnt = s.count(c) - t.count(c)
    ans = max(ans, cnt)

print(ans)


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

int f(char x){
    string str = "abcdefghijklmnopqrstuvwxyz";
    int answer;
    rep(i, 26){
        if(x == str[i]){
            answer = i;
            break;
        }
    }
    return answer;
}

int main(){
    string s, t;
    cin >> s >> t;
    long long N = s.size();
    long long M = t.size();
    long long num[N][26];
    long long S[N], T[M];
    rep(i, N){
        S[i] = f(s[i]);
    }
    rep(i, M){
        T[i] = f(t[i]);
    }
    rep(i, N){
        fill_n(num[i], 26, -2*N);
    }
    num[N-1][S[N-1]] = 1;
    for(int i = N-2; i >= 0; i--){
        rep(j, 26){
            if(j != S[i]){
                num[i][j] = num[i+1][j] + 1;
            }
            else{
                num[i][j] = 1;
            }
        }
    }
    long long sum = 0;
    long long pos = 0;
    rep(i, M){
        if(num[pos][T[i]] > 0){
            sum += num[pos][T[i]];
            pos += num[pos][T[i]];
            pos %= N;
        }
        else{
            if(num[0][T[i]] <= 0){
                sum = -1;
                break;
            }
            else{
                sum += (N-pos);
                pos = 0;
                sum += num[pos][T[i]];
                pos += num[pos][T[i]];
                pos %= N;
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 22528
#include<stdio.h>
int main(void)
{
  int miss1,miss2;
  char str[64];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&miss1);
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&miss2);
  
  switch (miss1)
  {
    case 1:
      if(miss2 == 2) 
      {
        puts("3");
      }else
      {
        puts("2");
      }
      break;
    case 2:
      if(miss2 == 1) 
      {
        puts("3");
      }else
      {
        puts("1");
      }
      break;
    default:
      if(miss2 == 1)
      {
        puts("2");
      }else
      {
        puts("1");
      }
  }
  return 0;
}
      
      
        

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int inf=3005;
string a,b,ans;
int dp[inf][inf];
int sa(char x,char y){
	if(x==y) return 1;
	return 0;
}
void dfs(int x,int y){
	if(!x||!y) return;
	if(a[x]==b[y]){
		ans+=a[x];
		dfs(x-1,y-1);
	}
	else if(dp[x-1][y]>dp[x][y-1]) dfs(x-1,y);
	else dfs(x,y-1);
}
int main(){
	cin>>a>>b;
	a=' '+a;
	b=' '+b;
	for(int i=1;i<a.size();i++){
		for(int j=1;j<b.size();j++){
			dp[i][j]=max(dp[i-1][j-1]+sa(a[i],b[j]),max(dp[i-1][j],dp[i][j-1]));
		}
	}
	dfs(a.size()-1,b.size()-1);
	for(int i=ans.size()-1;i>=0;i--) cout<<ans[i];
	cout<<endl;
	return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, D;
  cin >> N >> M >> D;
  char c[N][M];
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < M; j++) {
      c[i][j] = s[j];
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int cnt = 0;
    for (int j = 0; j < M; j++) {
      if (c[i][j] == '.') cnt++;
      else cnt = 0;
      if (cnt >= D) ans++;
    }
  }
  for (int i = 0; i < M; i++) {
    int cnt = 0;
    for (int j = 0; j < N; j++) {
      if (c[j][i] == '.') cnt++;
      else cnt = 0;
      if (cnt >= D) ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3220
while True:
    a, b = map(int, input().split())
    if a == b == 0:
        break
    
    n = int(input())
    lst = [[1] * (a + 1) for _ in range(b + 1)]
    lst[0] = [0] * (a + 1)
    for y in range(2, b + 1):
        lst[y][0] = 0

    for _ in range(n):
        c = list(map(int, input().split()))
        lst[c[1]][c[0]] = 0

    for x in range(1, a + 1):
        for y in range(1, b + 1):
            if lst[y][x] == 0:
                continue
            lst[y][x] = lst[y - 1][x] + lst[y][x - 1]
    print(lst[b][a])



Measured memory_bytes: 5600
#include<stdio.h>
int main(void){
    int N, K;
    scanf("%d%d", &N, &K);
  	char S[N];
    scanf("%s", &S);
  
  if(S[K-1]=='A'){
    S[K-1]='a';
  }else if(S[K-1]=='B'){
    S[K-1]='b';
  }else if(S[K-1]=='C'){
    S[K-1]='c';
  }
  
    printf("%s",S);
    return 0;
}

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

using namespace std;

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

	for (int ai = 1; ai <= N; ai++) {
		cin >> S;
		if (S == "Y") {
			cout << "Four" << endl;
			break;
		}
		if (ai == N) {
			cout << "Three" << endl;
		}
	}
}

Measured memory_bytes: 256
N,K = gets.split.map{|tmp|tmp.to_i}
A = gets.split.map{|tmp|tmp.to_i}
count = {}
A.each do |a|
    if count[a] == nil
        count[a] = 1
    else
        count[a] += 1
    end
end
if count.keys.length <= K
    puts 0
else
    count = count.sort_by{|_,v|v}
    s = 0
    index = 0
    while count.length - index > K
        if count.length !=0 && index < count.length
            s+=count[index][1]
            index+=1
        end
    end
    puts s
end

Measured memory_bytes: 40940
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  int rank[14];
  scanf("%d %d",&a,&b);

  //the strength of cards
  for(int i=2;i<=13;i++){
    rank[i] = i-1;
  }
  rank[1] = 13;

  
  if(rank[a]>rank[b])
    printf("Alice");
  else if(rank[a]==rank[b])
    printf("Draw");
  else
    printf("Bob");
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
n = int(input())
do = 0
count = [[[ 0 for i in range(10)] for j in range(3)] for k in range(4)]
while do < n:
    b, f, r, v = map(int, input().split(' '))
    
    count[b-1][f-1][r-1] += v
    do += 1
    

for k in range(4):
    for j in range(3):
        for i in range(10):
            print(f' {count[k][j][i]}', end = '')
        print('')
    if k <= 2:
        print('#' * 20)




Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
string s;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
     cin>>s;
     if(s[0]=='S'){
     	 if(s[1]=='U'){
     	 	 cout<<7;
		  }
		 else{
		 	 cout<<1;
		 }
	 }
	 else if(s[0]=='T'){
	 	 if(s[1]=='U'){
	 	 	 cout<<5;
		  }
		  else{
		  	 cout<<3;
		  }
	 }
	 else if(s[0]=='M'){
	 	 cout<<6;
	 }
	 else if(s[0]=='F'){
	 	 cout<<2;
	 }
	 else{
	 	 cout<<4;
	 }
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int need(int n)
{
	n--;
	for(int i=1;i<=16;i*=2)
		n|=n>>i;
	return 1<<__builtin_popcount(n);
}

int main()
{
	for(int n,q;~scanf("%d%d",&n,&q) && n|q;){
		n=need(n);
		vi value(n),index(2*n);
		rep(i,n) index[n+i]=i;
		for(int i=n;--i;) index[i]=index[i*2];
		rep(_,q){
			int a,v; scanf("%d%d",&a,&v); a--;
			value[a]+=v;
			for(int i=(n+a)/2;i;i/=2){
				if(value[index[i*2]]>=value[index[i*2+1]])
					index[i]=index[i*2];
				else
					index[i]=index[i*2+1];
			}
			printf("%d %d\n",index[1]+1,value[index[1]]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 13392
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] s = null;
        int b, f, r, v;

        int[][,] rr = new int[4][,]
        {
            new int[3,10],
            new int[3,10],
            new int[3,10],
            new int[3,10]
        };

        for (int i = 0; i < n; i++)
        {
            s = Console.ReadLine().Split(' ');
            b = int.Parse(s[0]);
            f = int.Parse(s[1]);
            r = int.Parse(s[2]);
            v = int.Parse(s[3]);

            rr[(b-1)][(f-1), (r-1)] += v;
        }

        string ret;

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                ret = "";

                for (int k = 0; k < 10; k++)
                {
                    ret = ret + " " + rr[i][j, k].ToString();
                }

                Console.WriteLine(ret);
            }

            if (i != 3) Console.WriteLine(new String('#', 20));
        }
    }
}


Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m;
  cin>>n>>m;
  if(n==1&&m==1)cout<<1<<endl;
  else if(n==1){
    cout<<m-2<<endl;
  }
  else if(m==1){
    cout<<n-2<<endl;
  }
  else{
    cout<<n*m-(2*m+2*n)+4<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int banyakApel;
	int irisanApel;
	scanf ("%d %d", &banyakApel, &irisanApel);
	
	int hasil = 0;

	hasil = ( (banyakApel*3) + irisanApel )/2;
	printf("%d", hasil);
	
	return 0;
}

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

int main()
{
	string s; cin >> s;
	
	int cnt = 0;
	
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == '1') cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

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

    int m[100];
    rep(i, n){
        cin >> m[i];
    }

    sort(m, m+n);
    int count = 0;
    rep(i, n){
        x -= m[i];
        count++;
    }
    count += x / m[0];

    cout << count << endl;

    return 0;
}

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

int main() {
	// your code goes here
	int n=0, f=0;
	cin>>n; 
	while(n!=0)
	{
		int x = n%10;
		if(x!=0 && x%7==0) f=1;
		n = n / 10;
	}
	if(f==0) cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
struct Point {
    int a, b;
    bool operator < (const Point& op2) const {
        return b < op2.b;
    }
} p[maxn];
int main(void) {
    int n, h;
    while(~scanf("%d%d", &n, &h)) {
        int mx = 0;
        for(int i = 0; i < n; ++i) {
            scanf("%d%d", &p[i].a, &p[i].b);
            mx = max(mx, p[i].a);
        }
        sort(p, p + n);
        int cnt = 0;
        for(int i = n - 1; i >= 0 && p[i].b > mx; --i) {
            ++cnt, h -= p[i].b;
            if(h <= 0) break;
        }
        if(h > 0) {
            cnt += (h / mx);
            if(h % mx) ++cnt;
        }
        printf("%d\n", cnt);
    }
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		int primeNumber=0;
		int circle=input.nextInt();
		int[] list=new int[circle];
		for(int i=0;i<circle;i++){
			boolean isPrime=true;
			list[i]=input.nextInt();
			for(int j=2;j<=Math.sqrt(list[i]);j++){
				if(list[i]%j==0){
					isPrime=false;
					break;
				}
			}
			if(isPrime){
				primeNumber++;
			}
		}
		
		System.out.println(primeNumber);
	}

}

Measured memory_bytes: 41032
#include <algorithm>
#include <cmath>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

int main() {
  int n; std::cin >> n;
  int v[100000];
  for (int i = 0; i < n; i++) std::cin >> v[i];

  std::map<int, int> odds,  evens;
  for (int i = 0; i < n/2; i++) {
    int even = v[2*i];
    int odd = v[2*i+1];

    auto it = evens.find(even);
    if (it == evens.end()) evens.insert(std::make_pair(even, 0));
    evens[even]++;

    it = odds.find(odd);
    if (it == odds.end()) odds.insert(std::make_pair(odd, 0));
    odds[odd]++;
  }

  int ekey1 =  0, ekey2 =  0,  evalue1 =  0,  evalue2 =  0;
  for (auto& v : evens) {
    if (v.second > evalue1) {
      ekey2 = ekey1;
      evalue2 = evalue1;
      ekey1 = v.first;
      evalue1 = v.second;
    } else if (v.second > evalue2) {
      ekey2 = v.first;
      evalue2 = v.second;
    }
  }

  int okey1 =  0, okey2 =  0,  ovalue1 =  0,  ovalue2 =  0;
  for (auto& v : odds) {
    if (v.second > ovalue1) {
      okey2 = okey1;
      ovalue2 = ovalue1;
      okey1 = v.first;
      ovalue1 = v.second;
    } else if (v.second > ovalue2) {
      okey2 = v.first;
      ovalue2 = v.second;
    }
  }

  if (ekey1 != okey1) std::cout << n - ovalue1 - evalue1 << std::endl;
  else                std::cout << std::min(n - ovalue1 - evalue2, n - ovalue2 - evalue1) << std::endl;
}


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

const int NUM = 1000;

int main(){
  int a[NUM],b[NUM],inum=0;
  char op[NUM];

  for(int i=0;i<NUM;++i){
    ++inum;
    
    cin >> a[i] >> op[i] >> b[i];

    if(op[i] == '?'){
      break;
    }
  }

  for(int i=0;i<inum;++i){
    if(op[i] == '+'){
      cout << a[i]+b[i] << endl;
      
    }else if(op[i] == '-'){
      cout << a[i]-b[i] << endl;
    
        
    }else if(op[i] == '/'){
      cout << a[i]/b[i] << endl;
    
        
    }else if(op[i] == '*'){
      cout << a[i]*b[i] << endl;
    
        
    }
  }
  
  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef long long ll;

ll n;
string s[301];

bool check(ll k) {
  REP(i, n) {
    REP(j, n) {
      ll place = j - k;
      place += (place < 0 ? n : 0);
      if (s[i][j] != s[place][(i + k) % n])
        return false;
    }
  }
  return true;
}

int main() {
  cin >> n;
  REP(i, n) { cin >> s[i]; }
  ll ret = 0;
  REP(i, n) { ret += check(i) * n; }
  cout << ret << endl;
}


Measured memory_bytes: 384
import sys
from sys import exit
from math import gcd, factorial, ceil, floor, sqrt
from bisect import bisect_left, bisect_right
from copy import deepcopy
from heapq import heapify, heappop, heappush
from itertools import permutations, combinations, product, accumulate
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(10**7)

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

N = ii()
d = []
for i in range(N):
    a, b = mi()
    d.append([a, b])
cur = 0
for x, y in d:
    if x == y:
        cur += 1
    else:
        cur = 0
    if cur == 3:
        print('Yes')
        sys.exit()
print('No')

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int64 modpow(int64 a, int64 r){
    if(r == 0)return 1;
    if(r % 2 == 0){
        return modpow(a * a % MOD, r / 2) % MOD;
    }else{
        return modpow(a, r - 1) * a % MOD;
    }
}

int64 modComb(int64 n, int64 r){
    r = min(r, n-r);
    int64 retval = 1;
    REP(i,r){
        retval = retval * (n - i) % MOD * modpow(i + 1, MOD-2) % MOD;
    }
    return retval;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,m,k;
    cin >> n >> m >> k;
    int64 pattern = modComb(n * m - 2, k - 2);
    int64 cnt1 = 0;
    FOR(i,1,n){
        cnt1 += i * (n - i);
        cnt1 %= MOD;
    }
    cnt1 = cnt1 * m % MOD * m % MOD * pattern % MOD;
    int64 cnt2 = 0;
    FOR(i,1,m){
        cnt2 += i * (m - i);
        cnt2 %= MOD;
    }
    cnt2 = cnt2 * n % MOD * n % MOD * pattern % MOD;
    ANS((cnt1 + cnt2) % MOD);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a,b,c,d;
    a=s[0]-48;
    b=s[1]-48;
    c=s[2]-48;
    d=s[3]-48;
    int x,y;
    x=a*10 + b;
    y=c*10 + d;
    if(x<=12 && x>0 && y<=12 &&y>0)
    {
        cout<<"AMBIGUOUS"<<endl;
    }
    else if(x<=12 && x>0 &&(y>12||y==0))
    {
        cout<<"MMYY"<<endl;
    }
    else if((x>12||x==0) && y<=12 &&y>0)
    {
        cout<<"YYMM"<<endl;
    }
    else
    {
        cout<<"NA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    N,M=map(int,input().split())
    L=2**N
    dp=[10**8 for i in range(L)]
    dp[0]=0

    for _ in range(M):
        a, _ = map(int, input().split())
        key=sum([2**(int(i)-1) for i in input().split()])
        for j in range(L):
                q=j|key
                x=dp[j]+a
                if dp[q]> x:
                    dp[q]=x


    ans=dp[L-1]
    print(ans if ans<10**8 else -1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
N, X = map(int, input().split())


def dfs(n, x):
    if n == 0:
        return 1
    elif x == 1:
        return 0
    elif 1 < x and x <= 1+na[n-1]:
        return dfs(n-1, x-1)
    elif 2+na[n-1] == x:
        return np[n-1]+1
    elif 2+na[n-1] < x and x <= 2+2*na[n-1]:
        return np[n-1]+1+dfs(n-1, x-2-na[n-1])
    elif x == 3+2*na[n-1]:
        return 2*np[n-1]+1

na = [1]
np = [1]
for i in range(N):
    na.append(na[-1]*2+3)
    np.append(np[-1]*2+1)
print(dfs(N, X))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, ans;
	cin >> num;
	ans = num >> 1;
	if (num % 2 == 0)
		ans--;
	cout << ans << "\n";
	return 0;
}

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

int main(){
string S,T;; cin >> S >> T;
  //sumS[i]は、S[0],,,S[i]までのBの個数(Aはダブルカウント)
  //sumT[i]は、T[0],,,,T[i]までのBの個数(Aはダブルカウント)
  int m = (int)S.size(); int n = (int)T.size();
  vector<int> sumS(m,0); vector<int> sumT(n,0);
  
  for(int i = 0; i < m; i++){
    if(S[i] == 'A'){ sumS[i]+=2;} else{ sumS[i]++;}
    if(i){ sumS[i] += sumS[i-1];}
  }
  
  for(int j = 0; j < n; j++){
    if(T[j] == 'A'){ sumT[j]+=2;} else{ sumT[j]++;}
    if(j){ sumT[j] += sumT[j-1];}
  }
  
  int q; cin >> q;
  for(int i = 0; i < q; i++){
    int a,b,c,d; cin >> a >> b >> c >> d;
    int cnt1 = sumS[b-1];
     if( a > 1){ cnt1 -= sumS[a-2];}
    int cnt2 = sumT[d-1];
     if( c > 1){ cnt2 -= sumT[c-2];}
    
    if( abs(cnt1-cnt2)%3 == 0){ cout << "YES" << endl;}
    else{ cout << "NO" << endl;} 
  }
  
  return 0;}
 

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


int main()
{
    int s[34];s[1]=2;s[0]=1;
    double g[34];g[1]=0.5;
    for(int i=2;i<20;i++)
    {
        s[i] = s[i-1] * 2;
        g[i] = g[i-1] / 2;
       // printf("%d:%d %lf\n",i,s[i],g[i]);
    }
    int n,m;
    while(cin>>n>>m)
    {
        double x,y,ans=0;
        for(int i=1;i<=n;i++)
        {
            if(i>=m)
                ans=ans+1;
            else
            {
                for(int j=1;j<20;j++)
                {
                    if(i*s[j]>=m)
                    {
                        ans=ans+g[j];
                        //printf("%lf  ",g[j]);
                        break;
                    }
                }
            }

        }
        ans = ans/(1.0*n);
        printf("%.12f\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    vector<int> A(3);
    REP(i, 3) cin >> A[i];

    SORT(A);

    int ans = 0;

    if ((A[1] - A[0]) % 2 == 0) {
        ans += (A[1] - A[0]) / 2;
        ans += A[2] - A[1];
    } else {
        ans += 2;
        ans += (A[1] - A[0]) / 2;
        ans += A[2] - A[1];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
    int n;
    cin>>n;
    int d[n];
    int i;
    for(i=0;i<n;i++){
        cin>>d[i];
    }
    int j,r=0;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            r+=d[i]*d[j];
        }
        
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin

a = list(map(int,F.readline().rstrip().split()))
countfive = 0
countseven = 0

for i in range(len(a)):
    if a[i] == 5:
        countfive += 1
        continue
    if a[i] == 7:
        countseven += 1
        continue

if (countfive == 2) and (countseven == 1):
    print('YES')
    sys.exit()

print('NO')


Measured memory_bytes: 5516
#include <algorithm>
#include <iostream>
#include <list>
#include <string>
#include <map>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>

using namespace std;

typedef long long Board;

const int N = 9;
const Board GOAL = 0x087654321;

struct state {
    Board board;
    int count;
};

list<state> q;
map<Board,char> history;

inline void swap(int numpos, int spacepos, Board& board) {
    long long num = (board >> (numpos*4)) & 15;
    board |= num << (spacepos*4);
    board &= ~(15LL << (numpos*4));
}

inline int swap_and_check(int numpos, int spacepos, state s) {
    swap(numpos, spacepos, s.board);
    map<Board,char>::iterator it = history.find(s.board);
    if (it != history.end()) {
        return -1;
    }
    history.insert(make_pair(s.board, ' '));
    ++s.count;
    if (s.board == GOAL) {
        return s.count;
    }
    q.push_back(s);
    return -1;
}

void print(Board b) {
    for (int i = 0; i < N; ++i) {
        printf("%2lld", (b >> (i*4) & 15));
    }
    printf("\n");
}

int main(void) {

    Board board = 0;
    for (int i = 0; i < N; ) {
        char ch;
        scanf("%c", &ch);
        if (isdigit(ch)) {
            board |= static_cast<long long>((ch - '0')) << (i*4);
            ++i;
        }
    }

    if (board == GOAL) {
        printf("0\n");
        return 0;
    }

//    print(GOAL);
//    print(board);

    q.push_back({ board, 0 });
    int count = 0;
    while (!q.empty()) {
        state s = q.front();
        q.pop_front();
        // ?????????????????????
        int pos = -1;
        while (++pos < N) {
            if (((s.board >> (pos*4)) & 15) == 0) {
                break;
            }
        }
//        for (pos = 0; pos < N; ++pos) {
//            if (((s.board >> (pos*4)) & 15) == 0) {
//                break;
//            }
//        }

        if (pos < 6) {
            if ((count = swap_and_check(pos + 3, pos, s)) > 0) {
                break;
            }
        }
        if (pos > 2) {
            if ((count = swap_and_check(pos - 3, pos, s)) > 0) {
                break;
            }
        }
        if (pos % 3 < 2) {
            if ((count = swap_and_check(pos + 1, pos, s)) > 0) {
                break;
            }
        }
        if (pos % 3 > 0) {
            if ((count = swap_and_check(pos - 1, pos, s)) > 0) {
                break;
            }
        }
    }

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 13680
#include <stdio.h>

int D;
long long G;
int p[20];
int c[20];

int S[20];
int pcS[20];

int min = 99999;
bool gc[20];

void Si(int i, long long score, int num)
{
    if (i > D)
    {
        if (score < G)
        {
            for (int j = D; j > 0; j--)
            {
                if (!gc[j] && score + S[j] >= G)
                {
                    num += (G - score - 1) / (j * 100) + 1;
                    if (num < min)
                        min = num;
                }
            }
        }
        else
        {
            if (num < min)
                min = num;
        }
        return;
    }

    gc[i] = false;
    Si(i + 1, score, num);
    gc[i] = true;
    Si(i + 1, score + pcS[i], num + p[i]);
}

int main()
{
    scanf("%d", &D);
    scanf("%lld", &G);
    for (int i = 1; i <= D; i++)
    {
        int P, C;
        scanf("%d%d", &P, &C);
        S[i] = 100 * i * (P - 1);
        pcS[i] = P * 100 * i + C;
        p[i] = P;
        c[i] = C;
    }
    Si(1, 0, 0);

    printf("%d", min);

    return 0;
}

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

int main() {
	vector<char> vc;
	string str;
	cin >> str;
	int len = str.length();
	for (int i = 0; i < len; i++) {
		vc.push_back(str[i]);
	}
	int sum = 0;
	int f = 0, e = len-1;
	while (1) {
		if (f < e) {
			if (vc[f] != 'x' && vc[e] == 'x') {
				sum++;
				e--;
				continue;
			} else if (vc[f] == 'x' && vc[e] != 'x') {
				sum++;
				f++;
				continue;
			} else if (vc[f] != vc[e]) {
				sum = -1;
				break;
			}
			f++;
			e--;
		} else {
			break;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 640
d=input().split()
mawari=[[1,2,4,3,1],[5,2,0,3,5],[5,4,0,1,5],[5,1,0,4,5],[5,3,0,2,5],[4,2,1,3,4]]

for _ in range(int(input())):
    a,b=[d.index(i) for i in input().split()]
    n=mawari[a]
    print(d[n[n.index(b)+1]])


Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iterator>
typedef long long ll;

using namespace std;

vector<int> a;
vector<int> b;
vector<int> c;

int main()
{
	int n;
	ll ans=0;
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		a.push_back(t);
	}
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		b.push_back(t);
	}
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		c.push_back(t);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());

	for(int i=0;i<n;i++)
	{
		//b[i]について調べる
		auto aitr = lower_bound(a.begin(),a.end(),b[i]);
		if(aitr==a.begin())
			continue;
		aitr--;
		auto citr = upper_bound(c.begin(),c.end(),b[i]);
		if((*citr)<b[i])
			continue;
		ll adist=distance(a.begin(),aitr)+1;
		ll cdist=distance(citr,c.end());
		//cerr<<adist<<" "<<cdist<<endl;
		ans+=adist*cdist;
	}

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

Measured memory_bytes: 1784
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const ll mod = 1000000000 + 7;

void add_mod(ll &self, ll b) {
	self += b;
	if (self >= mod) {
		self -= mod;
	}
}

ll suma(ll l, ll ile) {
	// cout << "sum : " << l << ' ' << ile << " = " <<  (l + l + ile - 1) * ile / 2 << endl;
	return (l + l + ile - 1) * ile / 2;
}

int main() {
	ios_base::sync_with_stdio(false);
	ll sum = 0;
	int n, k;
	cin >> n >> k;
	FOR(q, k, n + 1) {
		// cout << "q: " << q << endl;
		ll ile = (suma(n - q + 1, q) - suma(0, q) + 1) % mod;
		add_mod(sum, ile);
	}
	cout << sum << endl;
}

Measured memory_bytes: 3656
import kotlin.math.max
import kotlin.math.min

fun main() {
    val (A, B, K) = readLine()!!.split(" ").map { it.toInt() }
    val C = min(A, B)
    var list = mutableListOf<Int>()

    for (i in 1..(C/2)) {
        if (A % i == 0 && B % i == 0) {
            list.add(i)
        }
    }

    if (max(A, B) % C == 0) {
        list.add(C)
    }

    val ans = list.sortedDescending()[K-1]

    println(ans)
}

Measured memory_bytes: 38988
#ABC081C
#ABC082C
N,K=map(int,input().split())
A=list(map(int,input().split()))
sA=set(A)
ans=0
d={}
for s in sA:
	d[s]=0
for a in A:
	d[a]+=1
d=sorted(d.items(),key=lambda x:x[1])
for i in range(len(sA)-K):
	ans+=d[i][1]
print(ans)

Measured memory_bytes: 50228
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using namespace std;
int n, a, b;

int main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> a >> b;
	if ((a + b) % 2) {
		cout << "Borys";
	} else {
		cout << "Alice";
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg(i,a,b) for(int i=a;i<=b;i++)
#define reh(i,a,b) for(int i=b;i>=a;i--)
#define in(x) scanf("%d",&x)
#define fro freopen("D:\\testdata.in", "r", stdin)
#define il inline
#define lson(q) q<<1
#define rson(q) q<<1|1
using namespace std;
typedef long long ll;
const int mx=1e5+10;
int a[mx];
int main() {
	int n;
	scanf("%d",&n);
	reg(i,1,n){
		scanf("%d",a+i);
		
	}
	if(n==1){
		printf("Yes\n");
		exit(0);
	}
	if(n==2){
		if(abs(a[1]-a[2])>1){
			printf("No\n");
		}else{
			printf("Yes\n");
		}
		exit(0);
	}
	reg(i,2,n){
		if(a[i]>a[i-1]){
			a[i]--;
		}
		if(a[i]<a[i-1]){
			printf("No\n");
			exit(0);
		}
	}
	printf("Yes\n");
	return 0;
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
   long long int t,n,x,y,a[200001]={};
      cin>>n;
      for(long long int i=0;i<n-1;i++)
      {
         cin>>x;
         a[x]++;
      }
      for(int i=1;i<=n;i++)
         cout<<a[i]<<endl;
   //}
   return 0;
}


Measured memory_bytes: 5180
# BIT使ってC問題ちゃんとやろうとしたけど1時間かけて無を生成したので諦める。ぷえwwwww
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split()))for _ in range(d)]
ans=[0]*d
for i in range(0,d,26):
  dd=set()
  uu=set()
  h=[]
  for j in range(i,min(i+26,d)):
    for k in range(26):
      h.append([s[j][k],j,k])
  h.sort(reverse=1)
  for t,j,k in h:
    if j in dd or k in uu:continue
    ans[j]=k
    dd.add(j)
    uu.add(k)
for i in ans:print(i+1)

Measured memory_bytes: 9528
# 標準偏差を求める
# N:人数
# s1 s2 .. sN:スコア
import math
while True:
    N = int(input())
    if N == 0: break
    s = list(map(int, input().split()))
    m = sum(s) / len(s)
    print(math.sqrt(sum([(s-m)**2 for s in s])/N))


Measured memory_bytes: 5708
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  char s[3];
  scanf("%s", s);
  puts(strcmp(s, "ABC") == 0 ? "ARC" : "ABC");
}


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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lep(j, n) for (int j = 0; j < (n); j++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define leps(i, n) for (int j = 1; j < (n); j++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int a, b;
   int h, w;
   cin >> a >> b >> h >> w;

   a = a - h;
   b = b - w;
   cout << a * b << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int x;
int cnt = 100;
int ans;

signed main() {
	cin >> x;
	while (cnt < x) {
		ans++;
		if (ans == 3760)break;
		long double cnt2 = (long double)cnt * 1.01;
		cnt = cnt2;
	}
	cout << ans << endl;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;


// UnionFind uf = UnionFind(10);
// uf.connect(1, 2);
// uf.isSame(1, 2);

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

vector<ll> g[100005];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll n, m;
  cin>>n>>m;
  std::vector<ll> v1(m);
  std::vector<ll> v2(m);
  for(ll i=0;i<m;i++){
    ll a,b;cin>>a>>b;
    a--, b--;
    v1[i] = a;
    v2[i] = b;
  }
  ll res = n*(n-1)/2;
  UnionFind uf = UnionFind(n);
  std::vector<ll> ans;
  for(ll i=m-1;i>=0;i--){
    ans.push_back(res);
    ll a = v1[i];
    ll b = v2[i];
    if(!uf.isSame(a,b)){
      res = res - (uf.size(a) * uf.size(b));
      uf.connect(a,b);
    }
  }
  for(ll i=m-1;i>=0;i--){
    cout<<ans[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 6900
import sys

n=int(input())

a=0
b=0

for i in range(n):
    ti,x,y=map(int,input().split())
    s=abs(x+y-b)
    t=ti-a
    if t>=s and (s-t)%2==0:
        a=ti
        b=x+y
    else:
        print("No")
        sys.exit()
    
print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

#define MAX_M 1000
#define MAX_N 1000

int n, m, dp[MAX_M+1][MAX_N+1];

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int rep;
	if (A <= C) {
		if(B < D) rep = B - C;
		else rep = D - C;
	}
	else {
		if (B < D) rep = B - A;
		else rep = D - A;
	}

	if (rep < 0) cout << 0 << endl;
	else cout << rep << endl;
	return 0;
}


Measured memory_bytes: 256
import numpy

N, M = map(int, input().split())
x = numpy.zeros(N, dtype=int)
y = numpy.zeros(N, dtype=int)
z = numpy.zeros(N, dtype=int)

if M == 0:
    print(0)
else:
    for i in range(N):
        x[i], y[i], z[i] = map(int, input().split())

    best_score = 0
    comb = ((1, 1, 1), (1, 1, -1), (1, -1, 1), (1, -1, -1), (-1, 1, 1), (-1, 1, -1), (-1, -1, 1), (-1, -1, -1))
    for a, b, c in comb:
        score = a * x + b * y + c * z
        score.sort()
        best_score = max(best_score, score[-M:].sum())
    print(best_score)


Measured memory_bytes: 21524
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>	//for "geometry.cpp"
#include<iomanip>	//for "cout<<fixed<<setprecision(a number)<<sth<<endl;"
#include<queue>
#include<string>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<algorithm>
#include<functional>	//for "greater<type>"
#include<cmath>
using namespace std;
#define pb push_back
#define fi first
#define sc second
#define mp make_pair
#define is insert	//tentative

typedef vector<long long> vec;//Be careful of the clash of type names, especially with vec in "geometry.cpp".
typedef vector<vec> mat;//The first index stands for linage.

const int M=1000000009;

mat mul(mat A,mat B){
	mat C(A.size(),vec(B[0].size()));
	for(int i=0;i<A.size();++i){
		fill(C[i].begin(),C[i].end(),0);
		for(int k=0;k<B.size();++k){
			for(int j=0;j<B[0].size();++j){
				C[i][j]+=A[i][k]*B[k][j];//Be careful of MAX_INT, types, etc.
				C[i][j]%=M;
			}
		}
	}
	return C;
}

mat pow(mat A,long long n){
	mat B(A.size(),vec(A.size()));
	for(int i=0;i<A.size();++i){
		fill(B[i].begin(),B[i].end(),0);
		B[i][i]=1;
	}
	while(n>0){
		if(n&1) B=mul(B,A);
		A=mul(A,A);
		n>>=1;
	}
	return B;
}

typedef pair<int,long long> pill;//You can add other pairs of types in the same way.

bool cmp(pill p,pill q){
	return p.sc<q.sc;
}

int c=0;

void solve(int w,long long h,int n){
	pill p[32];
	mat a(w,vec(1)),A(w,vec(w));
	p[0]=(mp(0,0));
	for(int i=1;i<=n;++i){
		cin>>p[i].fi>>p[i].sc;
		--p[i].fi;
		--p[i].sc;
	}
	cout<<"Case "<<++c<<": ";
	if(w>1){
		p[n+1]=(mp(0,h-1));
		sort(p+1,p+n+1,cmp);
		for(int i=0;i<w;++i){
			a[i][0]=0;
			for(int j=0;j<w;++j){
				if(abs(i-j)<=1) A[i][j]=1;
				else A[i][j]=0;
			}
		}
		a[0][0]=1;
		for(int i=1;i<=n+1;++i){
			while(p[i].sc==0) ++i;
			a=mul(pow(A,p[i].sc-p[i-1].sc),a);
			a[p[i].fi][0]=0;
			while(i<=n&&p[i].sc==p[i+1].sc) a[p[++i].fi][0]=0;
		}
		cout<<a[w-1][0]<<endl;
	}else{
		if(n>0){
			cout<<0<<endl;
		}else{
			cout<<1<<endl;
		}
	}
}

int main(){
	while(true){
		int w,n;
		long long h;
		cin>>w>>h>>n;
		if(w==0) break;
		solve(w,h,n);
	}
}

Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;


public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Pattern ptr = Pattern.compile("this|that|the");
		String str;

		while((str=br.readLine())!=null){
			char charArray[] = str.toCharArray();

			for(int i=0; !ptr.matcher(String.valueOf(charArray)).find() & i<26; i++){
				for(int j=0; j<charArray.length; j++){
					if('a'<=charArray[j] && charArray[j] < 'z'){
						charArray[j]++;
					}else if(charArray[j]=='z'){
						charArray[j] = 'a';
					}
				}
			}
			System.out.println(charArray);
		}
	}
}

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

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        final List<Integer> A = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            A.add(sc.nextInt());
        }

        final Solver solver = new Solver();
        solver.solve(A);
    }
}


class Solver {
    public void solve(final List<Integer> A) {
        boolean ans = true;
        for (final Integer a : A) {
            if (a % 2 == 0) {
                if (a % 3 == 0 || a % 5 == 0) {

                }
                else {
                    ans = false;
                    break;
                }
            }
        }

        System.out.println(ans ? "APPROVED" : "DENIED");
    }
}



Measured memory_bytes: 23380
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
#define mp make_pair
#define pb push_back
const int MAX=2e5+9;
const long long mod=1e9+7;
using namespace std;
vector<int>adj[MAX];
ll dp[MAX][10][13];
int main(){
	memset(dp , 0 , sizeof(dp));
	string s;
	cin>>s;
	ll rem[15];
	memset(rem , 0 , sizeof(rem));
	if(s[0]=='?'){
	for(int i=0;i<=9;i++)
		rem[i]=1;
}
else{
	rem[s[0]-'0']=1;
}
	for(int i=1;i<s.size();i++){
		ll temp[13];
		memset(temp , 0 , sizeof(temp));
		if(s[i]=='?'){
			for(int j=0;j<13;j++){
				for(int k=0;k<=9;k++)
					temp[(j*10+k)%13]=(temp[(j*10+k)%13]+rem[j])%mod;
			}
		}
		else{
			int p=s[i]-'0';
			for(int k=0;k<13;k++)
				temp[(k*10+p)%13]=(temp[(k*10+p)%13]+rem[k])%mod;
		}
		for(int k=0;k<13;k++){
			rem[k]=temp[k]%mod;
		//	cout<<rem[k]<<" ";
		}
		//cout<<"\n";
	}
	cout<<rem[5]<<"\n";
	
}

Measured memory_bytes: 208256