akhauriyash/Code-Regression huggingface dataset:
//kunal_goyal
#include<bits/stdc++.h>

using namespace std;
 
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
 
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
 
#define pint(x) printf("%d",x)
#define plint(x) printf("%lld",x)
#define endl '\n'
#define nl printf("\n");
#define ps printf(" "); 
 
#define all(x) x.begin(),x.end()
#define pb push_back
#define Set(a, s) memset(a, s, sizeof (a))
#define mod1 (lli)(1e9 + 7)
#define mod2 (lli)(1e9 + 9)
#define EPS 1e-9

#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
 
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
lli power(lli a, lli b, lli mod){lli x=1,y=a; while(b > 0){if(b&1){x=(x*y)%mod;}y = (y*y)%mod; b /= 2;}return x;}
 
const int INF = 0x3f3f3f3f;
const float pi = 3.14159265;
 
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
 
int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	//srand (time(NULL));
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
    
    lli n;
    cin>>n;
    
   lli ans = 0;
    
    fors(i,1,n+1){
		lli td = (n-i)/i;
		
		if(td<=i) break;
		if(td*i == (n-i)) ans+=td;
	}
    
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(void){
    int A,B,AB,AB2,AB3;
    cin >> A >> B;
    AB = A+B;
    AB2 = A*B;
    AB3 = A-B;
    cout << max({AB,AB2,A-B}) <<endl;
}



Measured memory_bytes: 256
a=input()

if(len(a)==3):
    
    if(a[2] in ['2','4','5','7','9']):
        print('hon')
    elif(a[2] in ['0','1','6','8']):
        print('pon')
    elif(a[2]=='3'):
        print('bon')    
        
elif(len(a)==2):
    if(a[1] in ['2','4','5','7','9']):
        print('hon')
    elif(a[1] in ['0','1','6','8']):
        print('pon')
    elif(a[1]=='3'):
        print('bon')   
        
elif (len(a)==1):
    if(a[0] in ['2','4','5','7','9']):
        print('hon')
    elif(a[0] in ['0','1','6','8']):
        print('pon')
    elif(a[0]=='3'):
        print('bon') 

Measured memory_bytes: 9116
fun main(args: Array<String>) {
    val (N, Y) = readLine()!!.split(" ").map { it.toLong() }
    for (x in 0..N) {
        for (y in 0..(N - x)) {
            if (10000 * x + 5000 * y + 1000 * (N - x - y) == Y) {
                println("$x $y ${N - x - y}")
                System.exit(0)
            }
        }
    }
    println("-1 -1 -1")
}


Measured memory_bytes: 37916
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
using namespace std;

vector< vector< vector< int > > > costs;

struct data_t {
	int m_d, m_x, m_y;
	data_t(int d, int y, int x) { m_d = d; m_y = y; m_x = x; }
};

int solve(void);

int main(void) {
		
	while (solve());

	return 0;

}

int solve(void) {

	//	input
	int w, h;

	cin >> w >> h;
	if (!(w | h)) { return 0; }

	vector< vector< int > > s(h, vector< int > (w, (1<<30)));
	costs.clear();
	costs.resize(4, s);
	vector<int> c(4);

	// right, down, left, up
	int d[4][2] = { {0,1}, {1,0}, {0,-1},{-1,0} };

	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> s[i][j];

	for (int i = 0; i < 4; i++)
		cin >> c[i];

	costs[0][0][0] = 0;

	queue< data_t > q;
	q.push(data_t(0, 0, 0));

	while (!q.empty()) {

		data_t doneNode = q.front();

		q.pop();

		for (int i = 0; i < 4; i++) {

			data_t to = doneNode;
			int cost = costs[doneNode.m_d][doneNode.m_y][doneNode.m_x] + c[i];
			if (i == s[to.m_y][to.m_x]) { cost = costs[doneNode.m_d][doneNode.m_y][doneNode.m_x]; }

			to.m_d = (to.m_d + i) % 4;
			to.m_y += d[to.m_d][0];
			to.m_x += d[to.m_d][1];
			
			if (to.m_x >= 0 && to.m_x < w && to.m_y >= 0 && to.m_y < h) {
				if (cost < costs[to.m_d][to.m_y][to.m_x]) {
					costs[to.m_d][to.m_y][to.m_x] = cost;
					q.push(to);
				}
			}

		}
	}
	
	int ans = costs[0][h - 1][w - 1];

	for (int i = 0; i < 4; i++)
		ans = min(ans, costs[i][h - 1][w - 1]);

	cout << ans << endl;

	return 1;

}

Measured memory_bytes: 3128
N=int(input())
AB=[list(map(int,input().split())) for i in range(N)]
AB=sorted(AB,key=lambda x:x[1])
t=0
n=0
while n<N:
  if t+AB[n][0]<=AB[n][1]:
    t+=AB[n][0]
    n+=1
  else:
    print('No')
    exit(0)
print('Yes')

Measured memory_bytes: 56560
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
 int main(void){
	 long long  N,K,sa=1000000001,a;
	 priority_queue<int> que; 
	 cin >> N >> K;
	 long long  h[N+10];
	 for(int i=0; i<N; i++){
		 cin >> h[i];
		 que.push(h[i]);
	 }
	 for(int i=0; i<N; i++){
		 h[i]=que.top();
		 que.pop();
	 }for(int i=0; i<K-1; i++){
		 int j=i;
		 while(j<N){
			if(j+(K-1)<=N-1){
				a=h[j+(K-1)]-h[j];
				sa=min(sa,abs(a));
			}j=j+(K-1);
		 }
	 }cout << sa << endl;
 }


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

int main() {
	ios::sync_with_stdio(0),cin.tie(0);
	int array[5],k;
	bool big=false;
	for(int i=0;i<5;i++)
		cin>>array[i];
	cin>>k;
	for(int i=0;i<5;i++)
		for(int j=i;j<5;j++)
			if(array[j]-array[i]>k)
				big=true;
	cout<<((big)?":(":"Yay!")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    string s;
    cin >> s;
    ll flag=1;
    vector <ll> arr(26,0);
    for(ll i =0;s[i]!='\0';i++)
    {
        arr[(int)s[i]-97]++;
    }
    for(ll i=0;i<26;i++)
    {
        if(arr[i]%2==1)
        {
            flag=-1;
        }
    }
    if(flag==1)
    {
        cout <<"Yes";
    }
    else
    {
        cout <<"No";
    }
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] as = br.readLine().split(" ");
		int[] ar = new int[n];
		int sum = 0;
		int max = 0 , min = Integer.MAX_VALUE;
		for(int i = 0 ; i < n ; i ++){
			ar[i] = Integer.parseInt(as[i]);
			sum+= ar[i];
			max = Math.max(max, ar[i]);
			min = Math.min(min, ar[i]);
			
		}
		int average = sum/n;
		int res =0;
		int res2 = 0;
		int res3 = 0;
		for(int i = 0 ; i< n ; i++) {
			res += (ar[i]-average)*(ar[i]-average);
			res2 +=(ar[i]-average-1)*(ar[i]-average-1);
			res3 +=(ar[i]-average+1)*(ar[i]-average+1);
		}
		int gati_res = Math.min(res, res2);
		gati_res= Math.min(gati_res,res3);
		System.out.println(gati_res);
		
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int a,b;
	cin>>a>>b;
	if(a+b<10) cout<<a+b;
	else cout<<"error";
	re 0;
}

Measured memory_bytes: 3652
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SR(): return sys.stdin.readline().rstrip()

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))


s=input()

change=len(s)//2
ans=0

for i in range(change):
    if s[i] != s[len(s) - (i + 1)]:
        ans+=1
print(ans)



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

int main(void){
	int rr=0,ll=0,a,b,c;
	while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
		if(a*a+b*b==c*c)rr++;
		if(a==b)ll++;
	}
	printf("%d\n%d\n",rr,ll);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
   int  h,n,c=0;
   cin >> h>>n;
   vector<int> a(n);
 REP(i,n){
   cin >>a[i];
 }
   REP(i,n){
       c++;
       h-=a[i];
       if(h<=0){
           cout << "Yes" ;
           return 0;
       }
   }
  cout << "No";
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
n=int(input())
slist=[]
for i in range(n):
  moji=str(input())
  slist.append(moji)
numdic={}
for chr in ["AC","WA","TLE","RE"]:
  numdic[chr]=slist.count(chr)
for chr,val in numdic.items():
  print(chr," x ",val)

Measured memory_bytes: 16292
num = gets.to_i
foods = gets.split.map(&:to_i)
sats = gets.split.map(&:to_i)
bonus = gets.split.map(&:to_i)

points = 0
j_before = 0

foods.each do |food|
  points += sats[food - 1]
  points += bonus[j_before - 1] if food - j_before == 1 && !j_before.zero?
  j_before = food
end

p points

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

#define int long long

#define Vanya Unstoppable

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    int n, k, d;
    cin >> n >> k >> d;
    
    n = abs(n);
    
    int p = n / d;
    
    if (k <= p) {
        cout << n - k * d;
    } else {
        k -= p;
        n -= p * d;
        int new_n = n - d;
        int ans = 0;
        if (k % 2 == 1) ans = abs(new_n);
        else ans = abs(n);
        cout << ans;
    }
}


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

#define MAX_N 10
#define MAX_M 10

int main() {
    int N, M, k[MAX_M], s[MAX_M][MAX_N], p[MAX_M];
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++) {
            cin >> s[i][j];
        }
    }
    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }

    int count = 0;
    for (int bit = 0; bit < (1<<N); bit++) {
        int num_of_switch_on[MAX_M];
        for (int i = 0; i < M; i++) {
            num_of_switch_on[i] = 0;
        }
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < k[i]; j++) {
                if (bit & (1<<(s[i][j]-1))) {
                    num_of_switch_on[i]++;
                }
            }
        }
        int is_light_on[MAX_M];
        for (int i = 0; i < M; i++) {
            is_light_on[i] = 0;
        }
        for (int i = 0; i < M; i++) {
            if (num_of_switch_on[i] % 2 == p[i]) {
                is_light_on[i] = 1;
            }
        }
        bool all_light_on = true;
        for (int i = 0; i < M; i++) {
            if (!is_light_on[i]) {
                all_light_on = false;
            }
        }
        if (all_light_on) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
elif S == 'SAT':
    print(1)

Measured memory_bytes: 9124
#include <iostream>

using namespace std;

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

	for (int cnt = 0; true; ++cnt) {
		for (int i = 0; i < N; ++i) {
			if (A[i] % 2 != 0) {
				cout << cnt << endl;
				return 0;
			}
			A[i] = A[i] >> 1;
		}
	}

	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mx 1

int main()
{	
	ios_base::sync_with_stdio(0);
	ll w,h,x,y;
	while(cin>>w>>h>>x>>y){
		double ans = 0; ll cnt=-1;
		ans = (w*h)/2.0;
		if(x+x==w && y+y==h) cnt = 1;
		else cnt = 0;
		cout<<fixed<<setprecision(12)<<ans<<" ";
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n, a, b, i, tmp, sum = 0, ans = 0;
	scanf("%d%d%d",&n,&a,&b);
	for(i=1; i<=n; i++){
		tmp = i; //初期化
		sum = 0;

		while(1){ //各桁の和を計算
			sum += tmp%10;
			tmp /= 10;
			if(tmp == 0){
				break;
			}
		}

		if(a <= sum && sum <= b){ //a以上b以下か
			ans += i;
		}
	}
  
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < s.length(); i++){
			list.add(Integer.parseInt(s.substring(i,i+1)));
		}
		int i = 0;
		int ans = 0;
		/*for(int i = 0; i < s.length();i++){
			System.out.print(list.get(i));
		}*/
		while(i < list.size()-1 && ans != s.length()){
			if(list.get(i) != list.get(i+1)){
				ans+=2;
				list.remove(i);
				list.remove(i);
				i = 0;
				//System.out.println(i);
			}else{
				i++;
			}
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 30600
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int abc[3][100000], dp[3][100000];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> abc[0][i] >> abc[1][i] >> abc[2][i];
    }
    dp[0][0] = abc[0][0];
    dp[1][0] = abc[1][0];
    dp[2][0] = abc[2][0];
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            int tmp = 0;
            for (int k = 0; k < 3; k++)
            {
                if (k != j)
                {
                    int hoge = dp[k][i - 1] + abc[j][i];
                    if (tmp < hoge)
                        tmp = hoge;
                }
            }
            dp[j][i] = tmp;
        }
    }
    cout << max(dp[0][n - 1], max(dp[1][n - 1], dp[2][n - 1])) << endl;
    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <array>
#include <cstdio>
using namespace std;

int main(int argc, char *argv[]){
  int a,b,d,r;
  double f,da,db;
  cin >> a;
  cin >> b;
  d = a/b;
  r = a % b;
  da = static_cast<double>(a);
  db = static_cast<double>(b);
  f = da / db;
  printf("%d %d %lf\n",d,r,f);
  //cout << d << " " << r << " " << f << endl;
  return 0;
}

Measured memory_bytes: 1176
package main

import "fmt"

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)

	if -a+b <= 0 {
		fmt.Println("delicious")
	} else if -a+b <= x {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500*a + 100*b + 50*c; // 合計金額
        if (total == X) ++res; // 合計金額が X に一致したら答えをインクリメント
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int>v(3);
    cin>>v[0]>>v[1]>>v[2];
    int count=0;
    sort(v.begin(),v.end());
    count+=v[2]-v[1];
    count+=(v[1]-v[0])/2;
    if((v[1]-v[0])%2==1){count+=2;}
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;
bool vis[7][7];
int check(int i, int j, vector<string> s, int n, int m) {
	int ctr = 0;
	for (int x = 0; x < 7; x++) {
		for (int y = 0; y < 7; y++) {
			vis[x][y] = false;
		}
	}
	for (int x = 0; x < n; x++) {
		if (i & (1 << x)) {
			for (int y = 0; y < m; y++) {
				if (s[x][y] == '#' && !vis[x][y]) {
					ctr++;
					vis[x][y] = true;
				}
			}
		}
	}

	for (int x = 0; x < m; x++) {
		if (j & (1 << x)) {
			for (int y = 0; y < n; y++) {
				if (s[y][x] == '#' && !vis[y][x]) {
					ctr++;
					vis[y][x] = true;
				}
			}
		}
	}
	return ctr;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	std::ios::sync_with_stdio(false);
	int t = 1;
	// cin >> t;
	while (t--) {
		int n, m, k;
		cin >> n >> m >> k;
		vector<string> s(n);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		int total_black = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (s[i][j] == '#')total_black++;
			}
		}

		int ans = 0;


		for (int i = 0; i < (1 << n); i++) {
			for (int j = 0; j < (1 << m); j++) {
				int get_count = check(i, j, s, n, m);
				// cout << get_count << " ";
				if (total_black - get_count == k)ans++;
			}
		}
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
using namespace std;
char a[10],s[10];
int n,K,m,x,bok[101010],ans,fs;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%s",&x,s+1);
		if(s[1]=='A'&&bok[x]!=1)
			fs+=-bok[x],bok[x]=1;
		else if(s[1]=='W'&&bok[x]!=1) bok[x]--;
	}
	for(int i=1;i<=n;i++)
	ans+=(bok[i]==1);
	printf("%d %d\n",ans,fs);
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int a = Integer.parseInt(sc.next());
int b = Integer.parseInt(sc.next());
String ans="";
if(a%3==0||(a+b)%3==0||b%3==0){ans="Possible";}else{ans="Impossible";}
    out.println(ans);
}
}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
  int a;
  cin>>a;
  rep(i,a/4+1){
    rep(j,a/4+1){
      if(i*4+j*7==a){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ss second
#define ff first
#define N 100005
#define inf 1000000009
#define ll long long
#define pii pair<int,int>
#define sz(a) int(a.size())
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int n,a[N],t,t1;
int mx,mx1;
int ans,ans1;
int m[3][N];

int main(){
	scanf("%d",&n);
	for(int i = 0;i < n;i++){
		scanf("%d",&a[i]);
		m[i%2][a[i]]++;
	}
	for(int i = 1;i <= 1e5;i++){
		if(m[0][i] > mx) mx1 = mx,mx = m[0][i],t = i;
		else if(m[0][i] > mx1) mx1 = m[0][i];
		
		if(m[1][i] > ans) ans1 = ans,ans = m[1][i],t1 = i;
		else if(m[1][i] > ans1) ans1 = m[1][i];
	}
	if(t == t1) printf("%d",n-max(ans+mx1,mx+ans1));
	else printf("%d",n-(ans+mx));
}


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

int main()
{
	int a,b,d,r;
	double f;

	cin >> a >> b;

	d = a/b;
	r = a%b;
	f = (double)a/b;

	printf("%d %d %.6f\n",d,r,f);

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int w,h;
	int dp[4][101][101];
	int ans = 0;
	memset(dp,0,sizeof(dp));
	cin >> w >> h;
	if(h == 0 && w == 0) break;
	REP(i,h) dp[3][i][0] = 1;
	REP(i,w) dp[2][0][i] = 1;
	REP(i,h)REP(j,w){
	    dp[0][i+1][j+1] += dp[3][i+1][j];
	    dp[1][i+1][j+1] += dp[2][i][j+1];
	    dp[2][i+1][j+1] += dp[0][i+1][j] + dp[2][i+1][j];
	    dp[3][i+1][j+1] += dp[1][i][j+1] + dp[3][i][j+1];
	    REP(k,4) {
		dp[k][i+1][j+1] %= 100000;
	    }
	}
	REP(i,4) ans += dp[i][h-1][w-1];
	ans %= 100000;
	cout << ans << endl;
	
    }
    return 0;
}

Measured memory_bytes: 1328
a, b, c, d = map(int, input().split())

def gcd (a, b):
    while b != 0:
        a, b = b, a % b
    return a
gcd = gcd(c, d)

large_c = b // c
large_d = b // d
large_cd = b // ((c * d) // gcd)
large = large_c + large_d - large_cd

small_c = (a - 1) // c
small_d = (a - 1) // d
small_cd = (a - 1) // ((c * d) // gcd)
small = small_c + small_d - small_cd

print(int((b - (a - 1)) - (large - small)))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <climits>
#include <cfloat>

using namespace std;

//start of 0uts1de's library

int cin_int_arr(vector<int>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_int_arr(vector<int>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_double_arr(vector<double>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_double_arr(vector<double>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cin >> arr.at(i);
    }
    return 0;
}


int cout_int_arr(vector<int>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_int_arr(vector<int>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_double_arr(vector<double>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_double_arr(vector<double>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}


int max_int_arr(std::vector<int>& arr){    //data mode
    int maxVal = INT_MIN;       //min of int
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
        }
    }
    return maxVal;
}

int max_int_arr(std::vector<int>& arr, int mode){    //overload index mode
    int maxVal = INT_MIN;       //min of int
    int maxIndex = 0;
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
            maxIndex = i;
        }
    }
    return maxIndex;
}

double max_double_arr(std::vector<double>& arr){    //data mode
    double maxVal = -DBL_MAX;       //min of double
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
        }
    }
    return maxVal;
}

int max_double_arr(std::vector<double>& arr, int mode){    //overload index mode
    double maxVal = -DBL_MAX;       //min of double
    int maxIndex = 0;
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
            maxIndex = i;
        }
    }
    return maxIndex;
}

//end of 0uts1de's library

int main(){
    int n;
    cin >> n;
    for (int i = 0; i < 26; ++i){
        for (int j = 0; j < 15; ++j){
            if (i * 4 + j * 7 == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 764
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def backtrack(n, ml, mh, tmp=[]):
    if n == 0:
        yield tmp
        return

    for i in range(ml, mh + 1):
        yield from backtrack(n - 1, i, mh, tmp + [i])


def main():
    def count(ca):
        return sum(d for a, b, c, d in abcd if ca[b - 1] - ca[a - 1] == c)
    N, M, Q = inpl()
    abcd = [inpl() for _ in range(Q)]
    print(max(count(c) for c in backtrack(N, 1, M)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9116
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    A = LI()
    hmax = A[0]
    hmae = A[0]
    ans = 0

    for i in range(N):
        if A[i]>hmax:
            hmax = A[i]
        else:
            ans += hmax - A[i]

        #hmax = 


    
    print(ans)

if __name__ == "__main__":
	main()

Measured memory_bytes: 32236
#include <iostream>
#include <algorithm>
#include <cstdio>
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	int a[n];
	REP(i, n) cin >> a[i];
	for(int i = n-1; i >= 0; i--){
		cout << a[i];
		if(i != 0) cout << " ";
	}
	cout << endl;
	return 0;
}


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

int main()
{
    // 整数の入力
    int N,K;
    cin >> N >> K;

    int flag[N] = {0};

    for(int i = 0; i < K; i++){
        int D;
        cin >> D;
        for(int j = 0; j < D; j++){
            int a;
            cin >> a;
            //cout  << a << endl;
            flag[a-1]++;
        }
    }
    
    int count = 0;
    for(int i = 0; i < N; i++){
        if(flag[i] == 0){
            count++;
        }
        //cout << flag[i] << endl;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int a[1000][3],ans[1000];
int main()
{
    int N;
    while(scanf("%d",&N)==1)
    {
        for(int i = 0; i < N-1; i++)
        {
            scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
            ans[i] = a[i][1]+a[i][0];
            for(int j = 0; j < i; j++)
            {
                if(ans[j]<a[i][1])
                    ans[j]=ans[i];
                else
                {
                     int ge2 = ans[j]>a[i][1]?(a[i][2]-(ans[j]-a[i][1])%a[i][2]):0;
                    if(ge2==a[i][2]) ge2=0;
                    ans[j] = ans[j] + ge2 +a[i][0];
                }

            }
        }
        for(int i = 0; i < N-1; i++)
        {
            printf("%d\n",ans[i]);
        }
        printf("%d\n",0);
    }

    return 0;
}


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

using namespace std;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mod 1000000007 
#define N 10000000
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

ll dp[MAXIMUM];

ll longest_path(vector<vl> & graph,ll vertex)
{
	if(graph[vertex].size()==0)return 0;
	else if(dp[vertex]!=-1)return dp[vertex];
	else
	{
		ll ans=-1;
		for(ll i=0;i<graph[vertex].size();i++)
		{
			ans=max(ans,1+longest_path(graph,graph[vertex][i]));
		}
		dp[vertex]=ans;
		return ans;
	}
}

int main()
{
	fio;
	ll n,m;cin>>n>>m;
	vector<vl> graph(n);
	f(m)
	{
		ll x,y;cin>>x>>y;
		graph[x-1].pb(y-1);
	}	
	ll ans =LLONG_MIN;
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++)
	{
		ans=max(ans,longest_path(graph,i));
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 8576
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int oddC =0;
    if(S.length()%2==0){
      oddC=S.length()/2;
    }else{
      oddC=S.length()/2+1;
    }
      
    String odd[] = new String[oddC];
    for(int i=0;i<oddC;i++){
      odd[i]=S.substring(2*i,2*i+1);
    }
    for(int i=0;i<oddC;i++){
      System.out.print(odd[i]);
    }
  }
  

  
}

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

int main(){

  string S;
  cin>>S;
	
  ll N=S.size()+1;
  ll greater[N];
  greater[0]=0;
  ll count=0;
  rep(i,S.size()){

    if(S.at(i)=='<'){
    
      count++;
      
    }
    else count=0;
    
    greater[i+1]=count;
    
  }
  
  ll lesser[N];
  lesser[N-1]=0;
  count=0;
  for(int i=N-2;i>=0;i--){

    if(S.at(i)=='>')count++;
    else count=0;
    
    lesser[i]=count;

  }
  
  ll sum=0;
  rep(i,N){
  	sum+=max(greater[i],lesser[i]);
  }

  cout<<sum<<endl;
  
}

Measured memory_bytes: 8708
s = input()

if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)
else:
    print(1)


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

int main() {
    string s, t;
    cin >> s >> t;
    vector<int> chars[26];
    for (int i = 0; i < s.size(); i++) {
        chars[s[i] - 'a'].push_back(i);
    }
    long long res = 0;
    int last = -1;
    for (int i = 0; i < t.size(); i++) {
        int tt = t[i] - 'a';
        if (chars[tt].empty()) {
            cout << -1 << endl;
            return 0;
        }
        // pos = (index in chars[tt] of) the first appearance of t[i] after the last index
        int pos = upper_bound(chars[tt].begin(), chars[tt].end(), last) - chars[tt].begin();
        if (pos == chars[tt].size()) {  // next s
            res += s.size();
            last = chars[tt].front();
        } else {
            last = chars[tt][pos];
        }
    }
    res += last + 1;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1344
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
struct pair_hash {
    template <class T1, class T2>
    size_t operator () (const pair<T1,T2> &p) const {
        auto h1 = hash<T1>{}(p.first);
        auto h2 = hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};
using Vote = pair<ll,ll>;
using Unordered_map = unordered_map<Vote, int, pair_hash>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define showvec(arr,a,b) for(ll i=a;i<b;i++) cout<<arr[i]<<" ";
#define read_input(arr,a,b) for(ll i=a;i<b;i++) cin>>arr[i];
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define SmooothOperatorrrrr()                 \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                    \
    cout.tie(0);                   
#define deci(n) cout<<fixed<<setprecision(n)
const int mod=998244353;
const int mod2=1000000007;
#define M_PI 3.14159265358979323846
#define LL_MAX 9223372036854775807
#define MAXN 2000001
/**************************************************************************************************/
int main()
{
    SmooothOperatorrrrr();
    ll n;cin>>n;
    ll a[n];
    read_input(a,0,n);
    ll sum_total=0;
    FOR(i,0,n)
        sum_total+=a[i];
    ll ans=0;
    FOR(i,0,n)
    {
        sum_total-=a[i];
        ans+=((sum_total%mod2)*(a[i]))%mod2;
        ans=ans%mod2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5128
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

bool dp[20010];


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N){
    cin >> A[i];
  }
  dp[0] = 1;
  rep(i, N){
    for(int j = 10000; j >= 0; j--){
      if(dp[j] == 1){
        if(j + A[i] <= 10010)
          dp[j+A[i]] = 1;
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < 10010; i++){
    if(i % 10 == 0)continue;
    if(dp[i] == 1) ans = i;
  }
  cout << ans << endl;

}


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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define LOG 19
#define off 2

#define mod 1000000007LL

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less< i64 >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 100005

typedef double T;

struct PT {
    T x , y ;
    PT() {}
    PT(T x_,T y_) {x=x_,y=y_;}
    PT operator + (const PT &p) {
        return {x+p.x,y+p.y} ;
    }
    PT operator - (const PT &p) {
        return {x-p.x,y-p.y} ;
    }
    PT operator * (const T &t) {
        return {x*t,y*t} ;
    }
    T operator * (const PT &p) {
        return x*p.x + y*p.y ;
    }
    T operator ^ (const PT &p) {
        return x*p.y - y*p.x ;
    }
    double disSq( PT &p )
    {
        return (x-p.x)*(x-p.x) + (y-p.y)*(y-p.y) ;
    }
    double dis( PT &p )
    {
        return sqrt( disSq(p) ) ;
    }
};

double angle( PT x, PT y , PT z )
{
    return acos(((y-x)*(z-x))/(x.dis(y)*x.dis(z))) ;
}

double f( PT x , PT y , PT z )
{
    double t1 = angle(x,y,z) , t2 = angle(y,x,z) ;

    t1 /= 2.0 ; t2 /= 2.0 ;

    double d = x.dis(y) ;

    return d/( 2.0 + (1.0/tan(t1)) + (1.0/tan(t2)) ) ;
}

int main()
{
    PT a , b , c ;

    scanf("%lf %lf %lf %lf %lf %lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y) ;

    double r1 = f(a,b,c) , r2 = f(a,c,b) , r3 = f(b,c,a) ;

    double ans = max(r1,r2) ;

    ans = max(ans,r3) ;

    printf("%0.12f\n",ans) ;

    return 0 ;
}


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

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> p(N);
  vector<int> A(N);
  rep(i,N){
    int a;
    cin >> a;
    p.at(i) = make_pair(a, i+1);
  }
  sort(p.begin(), p.end());
  
  rep(i,N) {
    int a, n;
    tie(a, n) = p.at(i);  // b, a の順であることに注意
    cout << n << " ";
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 4236
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;

int main(){
	string s;
	cin >> s;
	bool OK_A = false;
	bool OK_C = false;
	bool OK_lower = true;
	int cnum;

	if(s[0] == 'A') OK_A = true;
	rep(i, s.size()-1){
		if(i != 1){
			if(s[i] == 'C'){
				cnum = i;
				if(OK_C == false) OK_C = true;
				else OK_C = false;
			}
		}
	}

	rep(i, s.size()){
		if(i != 0 && i != cnum){
			if(isupper(s[i])) OK_lower = false;
		}
	}

	if(OK_A && OK_C && OK_lower) cout << "AC" << endl;
	else cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define x first
#define y second
#define int long long
using namespace std;
typedef long long ll;
const int N = 1e2 + 10;

pair < int, int > a[N];
set < pair < int, int > > c, m;
map < pair < int, int >, bool > e;
int n;

void dfs(pair < int, int > u, pair < int, int > ans)
{
    e[u] = 1;
    if (c.find({u.x + ans.x, u.y + ans.y}) != c.end() && !e[{u.x + ans.x, u.y + ans.y}]) dfs({u.x + ans.x, u.y + ans.y}, ans);
    if (c.find({u.x - ans.x, u.y - ans.y}) != c.end() && !e[{u.x - ans.x, u.y - ans.y}]) dfs({u.x - ans.x, u.y - ans.y}, ans);
}

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


    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i].x >> a[i].y;
        c.insert(a[i]);
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = i + 1; j <= n; ++j)
        {
            int p = a[j].x - a[i].x, q = a[j].y - a[i].y;
            if (p < 0)
            {
                p = -p;
                q = -q;
            }
            m.insert({p, q});
        }
    }

    int uou = 2e9;
    if (m.size() == 0)
    {
        cout << 1;
        return 0;
    }
    for (auto t: m)
    {
        for (int i= 1; i <= n; ++i)
        {
            e[a[i]] = 0;
        }
        int cnt = 0;
        for (int i= 1; i <= n;++i)
        {
            if (!e[a[i]])
            {
                ++cnt;
                dfs(a[i], t);
            }
        }
        uou = min(uou, cnt);
    }
    cout <<uou;

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] T = new int[N];
        for (int i = 0; i < N; i++) {
            T[i] = sc.nextInt();
        }

        int M = sc.nextInt();
        int[] P = new int[M];
        int[] X = new int[M];
        for (int i = 0 ; i < M ; i++) {
            P[i] = sc.nextInt();
            X[i] = sc.nextInt();
        }
        int t = 0;
        for (int i = 0 ; i < N ; i++) {
            t += T[i];
        }
        int temp = t;
        for (int i = 0 ; i < M ; i++) {
            t = t - T[P[i] - 1] + X[i];
            System.out.println(t);
            t = temp;
        }
    }

}

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

int main() {
    int n,m; cin>>n>>m;
    
    int a[n][2];
    int tmp1,tmp2;
    string str;
    
    for(int i=0;i<n;++i){
        for(int j=0;j<2;++j){
            a[i][j]=0;
        }
    }
    
    for(int i=0;i<m;++i){
        cin>>tmp1>>str;
        if(str=="AC") tmp2=1;
        else tmp2 = 0;
        
        if(a[tmp1-1][0]==0 && tmp2 == 1 )a[tmp1-1][0] =1;
        if(a[tmp1-1][0]==0 && tmp2 == 0 )a[tmp1-1][1]+=1;
    }
    
    int ac = 0,wa = 0;
    
    for(int i=0;i<n;++i){
        ac+=a[i][0];
        if(a[i][0]==1)wa+=a[i][1];
    }

    cout<<ac<<" "<<wa<<endl;

	return 0;
}

Measured memory_bytes: 1024
from sys import stdin
def input():
    return stdin.readline().strip()

n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
    i, j = map(int, input().split())
    i -= 1
    j -= 1
    edge[i].append(j)
    edge[j].append(i)

for i in edge[0]:
    if n - 1 in edge[i]:
        print('POSSIBLE')
        exit()
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 105924
#include <iostream>

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

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string N; cin >> N;
    bool flag = false;
    for (auto x: N){
        if (x == '7') flag = true;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3612
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<pair<int, int>> vpi;

#define pb       push_back
#define all(x)   begin(x), end(x)
#define sz(x)    (int)(x).size()
#define ff       first
#define ss       second
#define mp       make_pair
#define lb       lower_bound
#define ub       upper_bound
#define tcase()  int t; cin >> t; while(t--)

const int MOD = 1e9 + 7; // 998244353;
const int MX  = 2e5 + 5;
const ll  INF = 1e18;
const ld  PI  = acos((ld) -1);

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main(){

    setIO();

    int H, W, K;
    cin >> H >> W >> K;

    char grid[H][W];

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> grid[i][j];
        }
    }

    int ans = 0;

    for(int maskR = 0; maskR < (1 << H); maskR++){
        for(int maskC = 0; maskC < (1 << W); maskC++){

            int black = 0;

            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){

                    if(((maskR >> i) & 1) == 1 && ((maskC >> j) & 1) == 1 && grid[i][j] == '#')
                        black++;
                }
            }

            if(black == K) ans++;
        }
    }

    cout << ans;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t l,r;cin>>l>>r;
  int64_t ans=2020;
  if(r-l>2023){
    cout <<0<<endl;
    return 0;
  }
  else{
    for(int64_t i=l;i<=r-1;i++){
      for(int64_t j=i+1;j<=r;j++){
        ans=min(ans,(i*j)%2019);
      }
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  char str[64];
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P,ll>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9)+7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr int di8[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj8[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-9;

int solve(){
    int t;
    string s;
    cin >> t >> s;
    if(t == 0) return 1;
    int n = s.size(), ans = -1, maxi = -1;
    bool rejected = false;
    for(int S=0;S<1<<(n-1);S++){
        int sum = 0, d = 0;
        for(int i=0;i<n;i++){
            d = d*10+s[i]-'0';
            if((S>>i)&1){
                sum += d;
                d = 0;
            }
        }
        sum += d;
        if(sum <= t && sum > maxi){
            maxi = sum;
            ans = S;
            rejected = false;
        }else if(sum == maxi){
            rejected = true;
        }
    }
    if(rejected){
        cout << "rejected" << endl;
    }
    else if(ans >= 0){
        cout << maxi << " ";
        for(int i=0;i<n;i++){
            cout << s[i];
            if((ans>>i)&1) cout << " ";
        }
        cout << endl;
    }else{
        cout << "error" << endl;
    }
    return 0;
}

int main(){
    while(solve()==0);
    return 0;
}



Measured memory_bytes: 3176
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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

int main() {
	int n, k;
	cin >> n >> k;
	int A[100];
	rep(i, n) cin >> A[i];

	sort(A, A+n, greater<int>());
	int res = accumulate(A, A+k, 0);
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
    
using namespace std;
using ll = long long;
using pii = pair<int, int>;
    
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 200200;
const double PI = acos(-1);
vector<int> sz(maxn, 1), p(maxn), ans(maxn, 0);

void init(){
    for (int i=1; i<maxn; i++){
        p[i] = i;
    }
}

int find(int v){
    if (p[v] == v) return v;
    return p[v] = find(p[v]);
}

void union_set(int a, int b){
    a = find(a);
    b = find(b);
    if (a != b){
        if (sz[a] < sz[b]) swap(a, b);
        p[b] = a;
        sz[a] += sz[b];
    }
}
int main(){
    int n, m, k;
    init();
    cin >> n >> m >> k;
    vector<int> adj[maxn];
    for (int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
        union_set(a, b);
    }

    for (int i=1; i<=n; i++){
        ans[i] = sz[find(i)] - adj[i].size();
    }

    for (int i=0; i<k; i++){
        int a, b;
        cin >> a >> b;
        if (find(a) == find(b)) {
            ans[a]--;
            ans[b]--;
        }
    }

    for (int i=1;i<=n; i++){
        if (i-1) cout << " ";
        cout << ans[i] - 1;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 11384