akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int dp[3001][3001];
int solve(string &str1,string &str2,int n,int m)
{
    if(n==0 || m==0)
        return 0;
    else if(dp[n][m]!=-1)
        return dp[n][m];
    else
    {
        if(str1[n-1]==str2[m-1]){
            return dp[n][m]=1+ solve(str1,str2,n-1,m-1);
        }
        else
            return dp[n][m]=max(solve(str1,str2,n,m-1),
                solve(str1,str2,n-1,m));
    }
}
int32_t main()
{
    fast;
    string str1,str2;
    cin>>str1>>str2;

    int n=str1.length(),m=str2.length();
    memset(dp,-1,sizeof(dp));
    solve(str1,str2,str1.length(),str2.length());

    string ans="";
    while(n> 0 && m>0){

        // cout<<"Im in loop"<<endl;
        if(str1[n-1]==str2[m-1]){
            ans.pb(str1[n-1]);
            n=n-1;m=m-1;
        }
        else{
            if(dp[n][m]==dp[n-1][m])
                n=n-1;
            else
                m=m-1;
        }
    }

    reverse(all(ans));
    cout<<ans<<endl;
    return 0;
}

// 1 1 2 2 2 3 3 4 5 6 

Measured memory_bytes: 74332
#include <cstdio>
#include <string>
#include <queue>
using namespace std;

int main() {
  char com[20];
  priority_queue<int> PQ;

  while (1) {
    scanf("%s", com);
    if (com[0] == 'i') {
      int key;
      scanf("%d", &key);
      PQ.push(key);
    }
    else if (com[1] == 'x') {
      printf("%d\n", PQ.top());
      PQ.pop();
    }
    else if (com[0] == 'e') {
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 6508
import java.util.*;
public class Main{
	public static void main(String args[]){

		Scanner ob = new Scanner(System.in);
		int L = ob.nextInt();
		int R = ob.nextInt(); 
		int d = ob.nextInt();
		int sum = 0;

		for (int i = L; i <= R; i++) {

			if(i % d == 0){
				++sum;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 35448
#include<stdio.h>
long long n,res=1;
int main(){
	scanf("%lld",&n);
	while(n--){
		long long a; 
		scanf("%lld",&a);
		if(a==0)
		{
			printf("0");
			return 0;
		}
		else if(1000000000000000000/a<res) res=-1;
		if(res!=-1) res*=a;
		if(res>1000000000000000000) res=-1;
	}
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 1692
import java.util.*;

class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		Vector<Integer> attend = new Vector<Integer>();
		for(int i=1; i<=30; i++)
			attend.add(new Integer(i));
		for(int i=0; i<28; i++){
			Integer e = new Integer(in.nextInt());
			attend.remove(e);
		}
		System.out.printf("%d\n%d\n", attend.elementAt(0), attend.elementAt(1));
	}
}

Measured memory_bytes: 12000
import sys,math
try:sys.stdin,sys.stdout=open('input.txt','r'),open('out.txt','w')
except:pass
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt,log
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
# print('{:.3f}'.format(1),round(1.123456789,4))
# sys.setrecursionlimit(500000)
def lcm(a,b): return (a*b)//gcd(a,b)
def setbits(n):return bin(n).count('1')
def resetbits(n):return bin(n).count('0')
def modinv(n,p):return pow(n,p-2,p)
def ncr(n,r):
    num,den=1,1;r=min(n,n-r)
    for i in range(r):num*=(n-i);den*=(i+1)
    return num//den
def ncr_p(n, r, p):
    num,den=1,1;r=min(r,n-r)
    for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
    return (num * modinv(den,p)) % p
def isPrime(num) :
    if num<=1:return False
    if num==2 or n==3:return True
    if (num % 2 == 0 or num % 3 == 0) :return False
    m = int(num**0.5)+1
    for i in range(5,m,6):
        if (num % i == 0 or num % (i + 2) == 0) :return False
    return True
def bin_search(arr, low, high, val):
    while low <= high:
        mid = low + (high - low) // 2;
        if arr[mid] == val:return mid
        elif arr[mid] < val:low = mid + 1
        else:high = mid - 1
    return -1
def sumofdigit(num):
    count=0;
    while num : count+=num % 10;num //= 10;
    return count;
def inputmatrix():
    r,c=iia();mat=[0]*r;
    for i in range(r):mat[i]=iia();
    return r,c,mat;
def prefix_sum(n,arr):
    for i in range(1,n):arr[i]+=arr[i-1]
    return arr;
def binomial(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0
def divisors(n):
    res = [];
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if i==n//i:res.append(i)
            else:res.append(i);res.append(n//i)
    return res;
# code start from here-

n= ii1()
arr = iia()
# arr= list(set(arr))
arr.sort()
count=0

n=len(arr)
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if arr[i]!=arr[j] and arr[j]!=arr[k]:
                if arr[i]+arr[j]>arr[k] and arr[j]+arr[k]>arr[i] and arr[k]+arr[i]>arr[j]:
                    count+=1
print(count)


Measured memory_bytes: 73604
#include<bits/stdc++.h>
using namespace std;
set<int>s;
int a[]={400,800,1200,1600,2000,2400,2800,3200};
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int i,j,n,l,m=0,f;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>l;
        f=0;
        for(j=0;j<8;j++)
        {
            if(l<a[j])
            {
                f=1;
                s.insert(j);
                break;
            }
        }
        if(f==0)
        {
            m++;
        }
    }
    l=s.size();
    cout<<max(l,1)<<" "<<(l+m)<<"\n";
    return 0;
}


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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;


int main(){
    int N, M;
    cin >> N >> M;
    int a[M],b[M];
    REP(i,M){
        cin >> a[i] >> b[i];
    }
    vector<int> v(N);
    int perm_num = 1;
    REP(i,N){
        v[i] = i+1;
        perm_num *= i+1;
    }
    bool flag;
    int cnt = 0;
    REP(i,perm_num){
        if(v[0]!=1) continue;
        REP(j,N-1){
            flag = true;
            REP(k,M){
                if(v[j]==a[k] && v[j+1]==b[k] || v[j]==b[k] && v[j+1]==a[k]){
                    flag = true;
                    break;
                }else{
                    flag = false;
                }
            }
            if(!flag) break;
        }
        if(flag) cnt++;
        next_permutation(v.begin(),v.end());
    }
    cout << cnt;
}





Measured memory_bytes: 256
from collections import Counter, defaultdict

N = int(input())
A = list(map(int, input().split()))

ans = sum(A)
c = Counter(A)

Q = int(input())
for _ in range(Q):
  B, C = (int(i) for i in input().split())
  bef_B = c[B]
  c[C] += c[B]
  ans = ans - bef_B * B + bef_B * C
  print(ans)
  c[B] = 0
  
  
  

Measured memory_bytes: 23884
import java.text.ParseException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws ParseException {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		double total = 0;
		int N = sc.nextInt();
		for (int i = 0; i < N; i++) {
			double money = sc.nextDouble();
			String jb = sc.next();
			if (jb.equals("JPY")) {
				total += money;
			} else {
				total += money * 380000;
			}

		}
		System.out.println(total);
	}

}


Measured memory_bytes: 24148
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int n,count=0,sum=0;
	string s;
	cin>>n;
	s=to_string(n);
	for(int i=1;i<s.size();i++){
		if(s[i]=='0'){
			count++;
		}
	}
	REP(i,s.size()){
		sum+=int(s[i]-'0');
	}
	if(s[0]=='1'&&count==s.size()-1){
		cout<<10<<endl;
	}
	else{
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define NIL 500009
 
int n;
 
int getleft(int i){
    i *= 2;
    if(i > n) return NIL;
    else return i;
}
 
int getright(int i){
    i = 2*i+1;
    if(i > n) return NIL;
    else return i;
}
 

void maxHeapify(int A[],int i){
  int l,r,largest,temp;
  
  l = getleft(i);
  r = getright(i);

  if(l <= n && A[l] > A[i])
    largest = l;
  else largest = i;
  

  if(r <= n && A[r] > A[largest])
    largest = r;
  
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(A,largest);
  }
  
}

void buildMaxHeap(int A[]){
  int i;
  for(i=n/2; i>=1; i--){
    maxHeapify(A,i);
  }
  }


int main(){
  int i,parent,left,right,key[500010];
  
  scanf("%d",&n);
  for(i=1; i<=n; i++){
    scanf("%d",&key[i]);
  }
  
  buildMaxHeap(key);
  
  for(i=1; i<=n; i++){
    printf(" %d",key[i]);
  
  }
  
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 2552
//Author : Abhishek Yadav
#include <bits/stdc++.h>
#define endl "\n"
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        string s;
        cin>>s;
        int len = s.length();
        if(len<=n)cout<<s;
        else
        	{rep(i,n)cout<<s[i];
        	        	cout<<"...";}
        
    
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
int a[9<<9],s,n,i;
std::bitset<1<<22> d;     
int main(){
    std::cin>>n;d[0]=1;
    for(;i<n;i++)std::cin>>a[i],s+=a[i],d|=(d<<a[i]);
    while(!d[++s/2]){} std::cout<<s/2;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
     
#define mp make_pair
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define eb emplace_back
 
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef vector< pii > vpii;
typedef vector< vpii > vvpii;
typedef vector< pll > vpll;
typedef long double ld;
typedef vector< ld > vld;
typedef unsigned int uint;
 
const ll MOD2 = 1e9 + 7;
const int MOD = 1e9 + 7;
 
const ull infull = numeric_limits<unsigned long long>::max();
 
void fix(int &x, ll MOD) {
    x = (x % MOD);
    if(x < 0) x += MOD;
    return;
}
 
ll lgput(ll a, ll b, ll MOD) {
    ll ret = 1;
    a %= MOD;
    while(b) {
        if(b&1) ret = ret*a % MOD;
        a = a*a % MOD;
        b >>= 1;
    }
 
    return ret;
}
 
ll inv(ll a, ll MOD) {
    return lgput(a, MOD-2, MOD);
}
 
template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    const bool operator<(const M& o) const {return v < o.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
 
using Mint = ModInt<(int)1e9 + 7>;

int main() { 
    #ifdef BLAT
        freopen("stdin", "r", stdin);
        freopen("stderr", "w", stderr);
    #endif
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    srand(time(NULL));

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << min(a, k) - max(0, k-a-b);
    return 0; 
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

using namespace std;


int32_t main(){IOS;
	int n ; cin >> n ; 
	if(n&1){
		cout << 0 << endl; 
		return 0 ;
	}
	int ans = 0 , ten = 5 ;
	n /= 2;
	while(ten <= n){
		ans += n/ten;
		ten *= 5;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;
string s;
main()
{
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,m,x,y;
cin>>n>>m;
vector<ll> v(n+1),vis(n+1);
for(ll i=1;i<=n;i++)
cin>>v[i];
vector<ll> g[n+1];
for(ll i=0;i<m;i++)
{
	cin>>x>>y;
	g[x].push_back(y);
	g[y].push_back(x);
}
ll ans=0;
for(ll i=1;i<=n;i++)
{
	if(vis[i])
	continue;
	x=v[i];
	ll y=1;
	for(auto j :g[i])
	{
		if(v[j]<=x)
		vis[j]=1;
		if(v[j]>=x)
		y=0;
		
	}
	if(y)
	ans++;
	
}
cout<<ans;

}

Measured memory_bytes: 10600
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
string s,t;
int f;
int main(){
	cin>>s>>t;
	for (int i=0;i<s.size();i++){
		char c=s[0];
		s=s.substr(1)+c;
		if (s==t) f=1;
	}
	if (f==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCollatzProblem solver = new BCollatzProblem();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCollatzProblem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();

            int i = 1;

            HashSet<Integer> visited = new HashSet<>();
            visited.add(a);
            for (; ; i++) {
                if (a % 2 == 0) {
                    a /= 2;
                } else {
                    a = 3 * a + 1;
                }
                if (visited.contains(a)) {
                    break;
                }
                visited.add(a);
            }

            out.println(i + 1);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

using namespace std;

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

    int n, m, ac = 0, wa = 0;

    cin >> n >> m;

    vector<int> v(n+1, 0);

    for(int i=1; i<=m; i++){
        int p;
        string s;

        cin >> p >> s;

        if(v[p] == -1) continue;

        if(s == "AC"){
            wa += v[p];
            ac++;
            v[p] = -1;
        }
        else{
            v[p]++;
        }
    }

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

    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

 int main() {
	 string S;
	 cin >> S;
	 int x = 0;
	 for (int i = 0; i < 3; i++) if (S[i] == 'o') x++;
	 cout << 700 + x * 100 << endl;
}

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

int main(){

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	
	int x;
	cin>>x;

	for(long long int i = -118;i<=119;i++){
		for(long long int j = -119; j<=118; j++){
			if( pow(i,5) - pow(j,5)  == x ){
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 4044
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    ll s = 0;
    int i,j,k;
    for (i = 1; i <= n; i++) {
        for (j = 1; j <= n; j++) {
            for (k = 1; k <= n; k++) {
                s+=gcd(gcd(i, j), k);
            }
        }
    }
    printf("%lld\n", s);


    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 1732
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k,l;
  int x[5][1000],y[5][1000],a[5][1000],b[5],w,h,sx,sy,gx,gy;
  int mn,bm;
  while(cin>>w>>h&&w+h){
    memset(b,0,sizeof(b));
    for(i=0;i<h;i++){
      string s;
      cin>>s;
      for(j=0;j<w;j++){
	if(s[j]=='.'){
	}else if(s[j]=='S'){
	  sx=j;
	  sy=i;
	}else if(s[j]=='G'){
	  gx=j;
	  gy=i;
	}else{
	  x[s[j]-'1'][b[s[j]-'1']]=j;
	  y[s[j]-'1'][b[s[j]-'1']]=i;
	  b[s[j]-'1']++;
	}
      }
    }
    if(!!b[0]+!!b[1]+!!b[2]+!!b[3]+!!b[4]<4)
      cout<<"NA"<<endl;
    else if(!!b[0]+!!b[1]+!!b[2]+!!b[3]+!!b[4]==4){
      for(i=0;b[i];i++);
      mn=0;
      memset(a,0,sizeof(a));
      for(j=0;j<b[(i+1)%5];j++)
	a[(i+1)%5][j]=abs(sx-x[(i+1)%5][j])+abs(sy-y[(i+1)%5][j]);
      for(j=1;j<4;j++){
	for(k=0;k<b[(i+j)%5];k++){
	  for(l=0;l<b[(i+j+1)%5];l++){
	    if(a[(i+j+1)%5][l]==0||a[(i+j+1)%5][l]>abs(x[(i+j+1)%5][l]-x[(i+j)%5][k])+abs(y[(i+j+1)%5][l]-y[(i+j)%5][k])+a[(i+j)%5][k])
	      a[(i+j+1)%5][l]=abs(x[(i+j+1)%5][l]-x[(i+j)%5][k])+abs(y[(i+j+1)%5][l]-y[(i+j)%5][k])+a[(i+j)%5][k];
	  }
	}
      }
      for(k=0;k<b[(i+j)%5];k++){
	if(mn==0||mn>abs(gx-x[(i+j)%5][k])+abs(gy-y[(i+j)%5][k])+a[(i+j)%5][k]){
	  mn=abs(gx-x[(i+j)%5][k])+abs(gy-y[(i+j)%5][k])+a[(i+j)%5][k];
	  bm=i+1;	    
	}
      }
      cout<<bm<<" "<<mn<<endl;
    }else{
      mn=0;
      for(i=0;i<5;i++){
	memset(a,0,sizeof(a));
	for(j=0;j<b[(i+1)%5];j++)
	  a[(i+1)%5][j]=abs(sx-x[(i+1)%5][j])+abs(sy-y[(i+1)%5][j]);
	for(j=1;j<4;j++){
	  for(k=0;k<b[(i+j)%5];k++){
	      for(l=0;l<b[(i+j+1)%5];l++){
		  if(a[(i+j+1)%5][l]==0||a[(i+j+1)%5][l]>abs(x[(i+j+1)%5][l]-x[(i+j)%5][k])+abs(y[(i+j+1)%5][l]-y[(i+j)%5][k])+a[(i+j)%5][k])
		    a[(i+j+1)%5][l]=abs(x[(i+j+1)%5][l]-x[(i+j)%5][k])+abs(y[(i+j+1)%5][l]-y[(i+j)%5][k])+a[(i+j)%5][k];
	      }
	  }
	}
	for(k=0;k<b[(i+j)%5];k++){
	  if(mn==0||mn>abs(gx-x[(i+j)%5][k])+abs(gy-y[(i+j)%5][k])+a[(i+j)%5][k]){
	    mn=abs(gx-x[(i+j)%5][k])+abs(gy-y[(i+j)%5][k])+a[(i+j)%5][k];
	    bm=i+1;	    
	  }
	}
      }
      cout<<bm<<" "<<mn<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 988
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();

			if (Math.abs(a - c) <= d) {
				System.out.println("Yes");
			} else if (Math.abs(a - b) <= d && Math.abs(b - c) <= d) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

//親の場合parには，-(集合のサイズ)を格納
vector<ll> par(1e5+5,-1),dep(1e5+5,0);

//木の根を求める
ll find(ll x){
    if(par[x]<0){
        return x;
    }else{
        //return find(par[x])でも可能だが
        //根をつなぎなおして計算量を落としている
        return par[x]=find(par[x]);
    }
}

//xとyが同じ集合に属するか否か
bool same(ll x, ll y){
    return find(x)==find(y);
}

//xとyの属する集合を併合
void unite(ll x, ll y){
    //同じ集合なら意味なし
    x=find(x);
    y=find(y);
    if(x==y) return;
    //rankの大小でどちらにくっつけるかを判定
    if(dep[x]<dep[y]){
        par[y]+=par[x];
        par[x]=y;
    }else{
        par[x]+=par[y];
        par[y]=x;
        //同じdepのときは，yをxにくっつけ
        //xのdepをプラスする
        if(dep[x]==dep[y]) dep[x]++;
    }
}

//xの属する集合のサイズを求める
ll size(ll x){
    return -par[find(x)];
}

int main(){
    ll n,m;
    cin>>n>>m;
    vector<P> pa(m+2);
    vector<ll> ans(m+2);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        pa[i]={a,b};
    }
    //m番目の辺から順につなげていく
    //UnionFind利用
    for(int i=m-1;i>=0;i--){
        //全ての橋が壊れている場合
        if(i==m-1){
            ans[i]=n*(n-1)/2;
        }else{
            if(ans[i+1]==0 || same(pa[i+1].first,pa[i+1].second)) {
                ans[i]=ans[i+1];
            }else{
                ll tmp=size(pa[i+1].first)*size(pa[i+1].second);
                ans[i]=ans[i+1]-tmp;
                unite(pa[i+1].first,pa[i+1].second);
            }
        }
    }
    //答え出力
    for(int i=0;i<m;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 5248
ary = gets.split(" ").map(&:to_i)
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]

result = []
ary.each do |a|
    result.push("g1") if g1.include?(a)
    result.push("g2") if g2.include?(a)
    result.push("g3") if g3.include?(a)
end

output = "No"
output = "Yes" if result[0] == result[1]
puts output

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

int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  vector<ll> count(n+1);
  for(ll i=0;i<n;i++) {
    if(s[i]=='#') {
      count[i+1]=count[i]+1;
    }
    else {
      count[i+1]=count[i];
    }
  }
  ll ans=n;
  for(ll i=0;i<n+1;i++) {
    ans=min(ans,count[i]+(n-i-(count[n]-count[i])));
  }
  cout << ans << endl;
}

Measured memory_bytes: 2180
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner pw = new Scanner(System.in);
		String S = pw.next();
		String S1 = "Sunny";
		String S2 = "Cloudy";
		String S3 = "Rainy";
		if(S.equals(S1)){System.out.println(S2);}
		else if(S.equals(S2)){System.out.println(S3);}
		else if(S.equals(S3)){System.out.println(S1);}
		
		
	}
	

}

Measured memory_bytes: 21844
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n;
	ll k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0;i < n;i++){
		cin >> a[i];
		a[i]--;
	}

	vector<int> now;
	int index = 0;
	int last = 0;
	map<int,bool> used;
	while(true){
		if(used[index] == true){
			last = index;
			break;
		}
		now.push_back(index);
		used[index] = true;
		index = a[index];
	}
	int cyc;
	for(int i = 0;i < now.size();i++){
		if(now[i] == last)cyc = i;
	}

	if(k <= cyc)cout << now[k] + 1 << endl;
	else{
		k -= cyc;
		k %= (int)(now.size() - cyc);
		cout << now[cyc+k] + 1 << endl;
	}
}


Measured memory_bytes: 13784
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n;
    cin >> n;
    vector<list<ll>> edge(n+1);

    for(int i = 0; i < n-1; i++){
        ll a,b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    vector<ll> num(n);
    for(int i = 0; i < n; i++){
        cin >> num[i];
    }

    sort(num.begin(),num.end(),greater<ll>());

    ll idx = 0;

    for(int i = 1; i < n+1; i++){
        if(edge[i].size() == 1){
            idx = edge[i].back();
            break;
        }
    }

    ll used = 0;

    vector<ll> ans(n+1,0);

    vector<bool> u(n+1,false);

    stack<ll> st;

    st.push(idx);

    while(!st.empty()){
        ll tmp = st.top();
        st.pop();
        if(u[tmp])continue;
        u[tmp] = true;
        ans[tmp] = num[used++];
        for(auto itr = edge[tmp].begin(); itr != edge[tmp].end(); itr++){
            if(!u[(*itr)]){
                st.push(*itr);
            }
        }
    }

    ll snum = 0;
    for(int i = 1; i < n; i++){
        snum += num[i];
    }

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

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    int A, B;
    cin >> A >> B;
    PRINT(A * B);
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(){

  int a,b,c=0;
	
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  
  if(a>=c && c>=b){  
    
    printf("Yes\n");
    
  }else if(b>=c && c>=a){
    
   	 printf("Yes\n");
    
  }else{
    
   	 printf("No\n");
    
  }

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define FAST     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ll MAX = 500005;
//https://www.youtube.com/watch?v=zlJDTxahav0--ps -Still miss you !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1

int main()
{
FAST
ll t;
cin>>t;
cout<<t*t;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

struct edge {
	int from, to, cost;
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, m;
	cin >> n >> m;
	vector<edge> graph;
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		graph.pb({ a,b,-c });
	}
	vector<ll> dis(n, INF);
	vector<bool> loop(n);
	dis[0] = 0;
	rep(i, n) {
		for (edge e : graph) {
			if (chmin(dis[e.to], dis[e.from] + e.cost) && i == n - 1) loop[e.to] = true;
		}
	}
	queue<int> que1, que2;
	vector<bool> vis1(n), vis2(n);
	que1.push(0); que2.push(n - 1);
	vis1[0] = true; vis2[n - 1] = true;
	while (!que1.empty()) {
		int q = que1.front(); que1.pop();
		for (edge e : graph) {
			if (e.from == q && !vis1[e.to]) {
				vis1[e.to] = true;
				que1.push(e.to);
			}
		}
	}
	while (!que2.empty()) {
		int q = que2.front(); que2.pop();
		for (edge e : graph) {
			if (e.to == q && !vis2[e.from]) {
				vis2[e.from] = true;
				que1.push(e.from);
			}
		}
	}
	rep(i, n) {
		if (loop[i] && vis1[i] && vis2[i]) {
			cout << "inf\n";
			return 0;
		}
	}
	cout << -dis[n - 1] << '\n';
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 2000 + 10;
int dp[N][N];
bool visit[N][N];
int idx[2][N];
int n;
int c[N * 2];

void insert(int x, int y, int n) {
  for (; x <= n; x += x & -x) {
    c[x] += y;
  }
}

int query(int x) {
  int ret = 0;
  for (; x; x -= x & -x) {
    ret += c[x];
  }
  return ret;
}

int solve(int x, int y) {
  if (x == n && y == n) return 0;
  int& ret = dp[x][y];
  if (visit[x][y]) return ret;
  visit[x][y] = true;
  ret = INF;
  if (x + 1 <= n) {
    insert(idx[0][x], 1, n * 2);
    ret = min(ret, solve(x + 1, y) + idx[0][x] - 1 - query(idx[0][x] - 1));
    insert(idx[0][x], -1, n * 2);
  }
  if (y + 1 <= n) {
    insert(idx[1][y], 1, n * 2);
    ret = min(ret, solve(x, y + 1) + idx[1][y] - 1 - query(idx[1][y] - 1));
    insert(idx[1][y], -1, n * 2);
  }
  return ret;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < 2 * n; ++i) {
    static char s[10];
    int k, x;
    scanf("%s%d", s, &x);
    --x;
    k = (s[0] == 'B' ? 0 : 1);
    idx[k][x] = i + 1;
  }
  printf("%d\n", solve(0, 0));
  return 0;
}


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

#define ll long long int

int main() {
    string s;
    cin >> s;
    int ans = s.size();
    for(int i = 0; i < s.size(); i++) {
        string s1 = s.substr(i, 1);
        string s2 = s.substr(i + 1, 1);
        if(s1 == s2) {
            ans--;
            i += 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len;
    cin >> len;
    long long ans = 0;
    for(int i = 1; i < len; i++)
        ans += i;
    cout << ans;
}



Measured memory_bytes: 3608
S = input()
T = input()
len_S = len(S)
len_T = len(T)

dp = {i: {j: 0 for j in range(len_T+1)} for i in range(len_S+1)}
for i in range(len_S):
    for j in range(len_T):
        if S[i] == T[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

# backtrack
ans = ''
i, j = len_S, len_T
while i > 0 and j > 0:
    if S[i-1] == T[j-1]:
        ans = S[i-1] + ans
        i, j = i - 1, j - 1
    else:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        else:
            j -= 1
print(ans)

Measured memory_bytes: 742920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    int ans=0;
    rep(i,n){
        if(a[i]%2==0){
            while(a[i]%2==0){
                a[i]=a[i]/2;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
//ABC071A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int x, a, b;
	cin >> x >> a >> b;
	if(abs(x-a) > abs(x-b)){
		cout << "B" << endl;
	}else{
		cout << "A" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N,Y = map(int, input().split())
for i in range(N + 1):
    for l in range(N - i + 1):
            if i * 10000 + l * 5000 + 1000*(N - i - l) == Y:
                print(i ,l ,(N - i - l))
                exit()

print(-1 ,-1 ,-1)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var list = new List<Dictionary<char, int>>();

            var n = int.Parse(Console.ReadLine());

            for (var i = 0; i < n; i++)
            {
                var input = Console.ReadLine();

                list.Add(new Dictionary<char, int>());

                foreach (var character in input)
                {
                    if (!list[i].ContainsKey(character))
                    {
                        list[i][character] = 1;
                    }
                    else
                    {
                        list[i][character]++;
                    }
                }
            }

            IEnumerable<char> intersectedKeys = list.First().Keys;

            foreach (var item in list)
            {
                intersectedKeys = intersectedKeys.Intersect(item.Keys);
            }

            var sb = new StringBuilder();

            for (int j = 0; j < intersectedKeys.Count(); j++)
            {
                var tmp = new List<int>();
                for (int i = 0; i < list.Count; i++)
                {
                    tmp.Add(list[i][intersectedKeys.ElementAt(j)]);
                }

                for (int i = 0; i < tmp.Min(); i++)
                {
                    sb.Append(intersectedKeys.ElementAt(j));
                }
            }

            var outtmp = sb.ToString().OrderBy(c => c);

            for (int i = 0; i < outtmp.Count(); i++)
            {
                Console.Write(outtmp.ElementAt(i));
            }

            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 16268
while True:
    a, op, b = input().split()
    a, b = int(a), int(b)
    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)


Measured memory_bytes: 5600
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	long long n;
	cin >> n;
	vector<long long> a(n+1);
	
	a[0]=2;
	a[1]=1;
	for(int i=2;i<=n;i++){
		a[i] = a[i-1] + a[i-2];
	}
	
	cout << a[n] << endl;
	
	return 0;
	
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long ans = 1;
		long max = (long)Math.pow(10,18);
		
		for(int i=0; i<n; i++){
		    a[i]=sc.nextLong();
		    if(a[i]==0){
		        System.out.println(0);
		        return;
		    }
		}
		
		if(ans != 0){
		    for(int i=0; i<n; i++){
		        if(max/ans <a[i]){
		            System.out.println(-1);
		            return;
		        }else{
		            ans = ans*a[i];
		        }
		    }
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 61920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    long double sum = 0;
    REP(i, n) sum += a[i];
    sum /= 4*m;

    ll ret = 0;
    REP(i, n) if(a[i] >= sum) ret++;
    
    if(ret >= m) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	char c;
	int cnt[26],i,j;
	for(i=0;i<26;i++)	cnt[i]=0;
	while(scanf("%c",&c)!=EOF)	{
		if(c>='A' && c<='Z')	c+='a'-'A';
		if(c>='a' && c<='z')	cnt[c-'a']++;
	}
	for(i=0;i<26;i++)	printf("%c : %d\n",'a'+i,cnt[i]);
	return 0;
}


Measured memory_bytes: 968
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  int A[3][3],N;
  bool CAN[3][3],P=false;
  REP(i,3){
    REP(j,3){
      cin>>A[i][j];
      CAN[i][j]=false;
    }
  }
  cin>>N;
  int B[N];
  REP(i,N){
    cin>>B[i];
    REP(j,3){
      REP(k,3){
        if(B[i]==A[j][k]){
          CAN[j][k]=true;
        }
      }
    }
  }
  
  REP(i,3){
    if(CAN[i][0]==true&&CAN[i][1]==true&&CAN[i][2]==true){
      P=true;
    }
  }
  REP(i,3){
    if(CAN[0][i]==true&&CAN[1][i]==true&&CAN[2][i]==true){
      P=true;
    }
  }
  
  if(CAN[0][0]==true&&CAN[1][1]==true&&CAN[2][2]==true){
    P=true;
  }
  
  if(CAN[0][2]==true&&CAN[1][1]==true&&CAN[2][0]==true){
    P=true;
  }
  
  if(P) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;
int i,j,k,n,m;
string s;

int main() {
  cin>>n;
  vector<long> a(n);
  for(i=0;i<n;++i) {
    cin>>a[i];
    a[i] -= i + 1;
  }
  sort(a.begin(),a.end());
  long b = a[n/2];
  long out =0;
  for(i=0;i<n;++i)out += abs(a[i] - b);
  cout << out << endl;
  return 0;
}

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

int X;

int main() {
    cin >> X;

    int Xdiv100 = X/100;
    int Xmod100 = X%100;

    if (Xdiv100 * 5 >= Xmod100) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static int a[];
	private static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		a = new int [n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			if (solve(0, sc.nextInt())) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}

		sc.close();
	}

	private static boolean solve(int i, int m) {
		if (m == 0) return true;
		if (i >= n) return false;
		return solve(i + 1, m) || solve(i + 1, m - a[i]);
	}
}


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

int main()
{
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for(int i = 0; i <= d; i++){
        int e = i / 10;
        int f = i % 10;
        if(e >= 2 && f >= 2 && e * f <= m) ans++;
    }
    cout << ans << endl;
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b > c+d){
        cout << "Left" << endl;
    }
    else if(a+b < c+d){
        cout << "Right" << endl;
    }
    else{
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 764
from sys import exit
INF = 1<<32
V,E = [int(n) for n in input().split()]
s = [0]*E
t = [0]*E
d = [0]*E
dist = [[INF for _ in range(V)] for __ in range(V)]
for i in range(V):
    dist[i][i]= 0
for i in range(E):
    s[i], t[i], d[i] = [int(n) for n in input().split()]
    dist[s[i]][t[i]] = d[i]

for k in range(V):
    for i in range(V):
        if(dist[i][k]== INF):continue
        for j in range(V):
            if(dist[k][j]== INF):continue
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

for i in range(V):
    if dist[i][i] < 0:
        print("NEGATIVE CYCLE")
        exit()

for i in range(V):
    for j in range(V):
        if j != V-1:
            print(dist[i][j] if dist[i][j] != INF else "INF",end=" ")
        else:
            print(dist[i][j] if dist[i][j] != INF else "INF")

# N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()



Measured memory_bytes: 6696
n = int(input())
a = [[0,0] for _ in range(n)]

for i in range(n):
    a[i][0],a[i][1]=map(int,input().split())
    a[i][0],a[i][1]=(a[i][0]-a[i][1]),(a[i][0]+a[i][1])
a.sort(key=lambda x: x[1])
INF = 10**10
preR = -INF
cnt=0
for L,R in  a:
    if L<preR:
        continue
    cnt+=1
    preR=R
print(cnt)

Measured memory_bytes: 21416