akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#define all(c) c.begin(),c.end()
#define pb push_back
using namespace std;
int h,w,n;
vector<string> st(vector<string> s,vector<vector<bool> > f){
	for(int i=0;i<w;i++){
		string t="";
		for(int j=h-1;j>=0;j--){
			if(isalpha(s[j][i])&&!f[j][i]){
				t+=s[j][i];
			}
		}
		for(int j=0;j<h;j++){
			if(j<t.size())
				s[h-1-j][i]=t[j];
			else
				s[h-1-j][i]='.';
		}
	}
	return s;
}
bool ret(vector<string> s,int cnt){
	vector<vector<bool> > f(h,vector<bool>(w));
	int sum=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w-1;j++){
			if(!isalpha(s[i][j]))
				continue;
			int a=1;
			for(int k=j;k<w-1;k++){
				if(s[i][k]==s[i][k+1]){
					a++;
				}else break;
			}
			if(a>=n){
				for(int k=0;k<a;k++){
					if(!f[i][k+j]){
						sum++;
					}
					f[i][k+j]=true;
				}
			}
		}
	}
	for(int i=0;i<w;i++){
		for(int j=0;j<h-1;j++){
			if(!isalpha(s[j][i]))
				continue;
			int a=1;
			for(int k=j;k<h-1;k++){
				if(s[k][i]==s[k+1][i]){
					a++;
				}else break;
			}
			if(a>=n){
				for(int k=0;k<a;k++){
					if(!f[k+j][i]){
						sum++;
					}
					f[k+j][i]=true;
				}
			}
		}
	}
	if(cnt-sum==0)
		return true;
	if(!sum)
		return false;
	return ret(st(s,f),cnt-sum);
	
}
int main(){
	while(cin>>h>>w>>n){
		int cnt=0;
		vector<string> s(h);
		for(int i=0;i<h;i++){
			cin>>s[i];
		for(int j=0;j<w;j++){
			if(s[i][j]!='.')
				cnt++;
		}
	}
	bool flag=false;
	for(int i=h-1;i>=0;i--){
		for(int j=0;j<w-1;j++){
			swap(s[i][j],s[i][j+1]);
			flag=ret(st(s,vector<vector<bool> >(h,vector<bool>(w))),cnt);
			if(flag){
				cout<<"YES"<<endl;
				break;
			}
			swap(s[i][j],s[i][j+1]);
		}
		if(flag)
			break;
	}
	if(!flag)
			cout<<"NO"<<endl;
	}
	return 0;
}

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

using ll = long long;

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

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

    ll n,m;cin>>n>>m;
    vector<ll> a(n);

    cin>>a[0];
    int r=1;
    for(ll ia=a[0];ia%2==0;ia/=2)r*=2;
    ll g=a[0];
    bool c=r!=1;
    for(int i=1;i<n;i++)
    {
        cin>>a[i];
        if(!(a[i]%r==0&&(a[i]/r)%2==1))c=false;
        g=lcm(g,a[i]);
    }

    ll ans=0;

    if(c)
    {
        ans=(m+(g/2))/g;
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3984
#include <iostream>

int main() {

	int a, b;

	std::cin >> a >> b;

	if (a < b) {
		std::cout << "a < b"
			<< std::endl;
	}
	else if (a > b) {
		std::cout << "a > b"
			<< std::endl;
	}
	else{
		std::cout << "a == b"
			<< std::endl;
	}
		return 0;
}



Measured memory_bytes: 3016
import itertools
n, m, q = map(int, input().split())
a,b,c,d = [],[],[],[]
for i in range(q):
	A,B,C,D = map(int, input().split())
	a.append(A)
	b.append(B)
	c.append(C)
	d.append(D)
e = [i+1 for i in range(m)]
ans = 0
for i in itertools.combinations_with_replacement(e,n-1):
	f = list(i)
	f.append(1)
	f.sort()
	w = 0
	for j in range(q):
		if f[b[j]-1]-f[a[j]-1] == c[j]:
			w += d[j]
	ans = max(ans,w)
print (ans)


Measured memory_bytes: 9136
//package com.company;
// Always comment out package when submitting.

import java.io.*;
import java.util.*;

public class Main {
    public static class Task {
        private static int mod = 1_000_000_007;

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            char[] seq = sc.next().toCharArray();
            int[] count = new int[26];
            for (int i = 0; i < n; i++) {
                count[seq[i] - 'a']++;
            }
            long ret = 1;
            for (int i = 0; i < 26; i++) {
                ret = ret * (count[i] + 1) % mod;
            }
            pw.println((ret + mod - 1) % mod);
        }
    }

    // template, actual code is in class Task.
    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));
        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
//        System.err.println("Memory increased: " + (usedMemoryAfter - usedMemoryBefore) / 1000000);
//        System.err.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    // Faster IO with BufferedReader wrapped with Scanner
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

Measured memory_bytes: 24660
#include<stdio.h>

int main(){
	int x,y,tmp;
	scanf("%d %d",&x,&y);
	
	while(x%y!=0){
		tmp=x%y;
		x=y;
		y=tmp;
	}
	
	printf("%d\n",y);
	
	
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,d;
  cin >> n >> d;
  d = 2*d+1;
  cout << ((n+d-1)/d) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n;
vl res;

void f(vl a){
	vl dp(n);
	dp[0]++;
	for(auto i:a){
		vl dp1(n),DP(n);
		for(int j=0;j<i;j++) dp1[j%n]++;
		for(int j=0;j<n;j++) for(int k=0;k<n;k++) DP[(j+k)%n]+=dp[j]*dp1[k];
		dp=DP;
	}
	int t=a.size();
	for(int i=0;i<n;i++){
		if(t%2==1) res[i]+=dp[i];
		else res[i]-=dp[i];
	}
}

vl a(3),b(3);

int main(){
	for(auto &i:a) cin>>i;
	for(auto &i:b) cin>>i;
	cin>>n;
	res=vl(n);
	for(int i=0;i<1<<3;i++){
		int t=0;
		for(int j=0;j<3;j++) if(i&1<<j) t++;
		for(int k=0;k<1<<t;k++){
			vl c(t);
			int I=0;
			for(int l=0;l<3;l++) if(i&1<<l){
				if(k&1<<I) c[I]=b[l]+1;
				else c[I]=a[l]-b[l];
				I++;
			}
			f(c);
		}
	}
	for(int i=0;i<n;i++) cout<<res[i]<<" \n"[i==n-1];
}


Measured memory_bytes: 3196
N = gets.to_i
a = [0] + N.times.map { gets.to_i }
i = 1
ans = 0
while i != 2
  ans += 1
  t = a[i]
  if t.nil?
    p -1
    exit
  end
  a[i] = nil
  i = t
end
p ans


Measured memory_bytes: 3892
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cmath>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const int MAX = 4;

ll M[200][200];
vector<ll> v;
void wf(int n) {
	rep(k, 0, n) {
		rep(i, 0, n) {
			if (M[i][k] == INF) continue;
			rep(j, 0, n) {
				if (M[k][j] == INF) continue;
				M[i][j] = min(M[i][j], M[i][k] + M[k][j]);
			}
		}
	}
}
int main() {
	ll n, m, r; cin >> n >> m >> r;

	rep(i, 0, r) {
		ll R; cin >> R;
		v.push_back(--R);
	}

	rep(i, 0, n) {
		rep(j, 0, n) {
			M[i][j] = INF;
		}
	}

	//wf;
	rep(i, 0, m) {
		ll a, b, c; cin >> a >> b >> c;
		a--, b--;
		M[a][b] = c;
		M[b][a] = c;
	}
	wf(n);

	ll minV = INF;

	sort(v.begin(), v.end());
	do {
		ll distance = 0;
		rep(i, 0, r - 1) {
			distance += M[v[i]][v[i + 1]];
		}
		minV = min(minV, distance);
	} while (next_permutation(v.begin(), v.end()));

	cout << minV << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

ll f(ll x) {
    ll res = 0;
    while (x>0) {
        x /= 10;
        res++;
    }
    return res;
}

int main(){
    ll n;
    cin >> n;
    ll ans = 1000;
    for (ll i=1; i*i<=n; i++) {
        if (n%i!=0) continue;
        ll j = n/i;
        ll res = max(f(i), f(j));
        chmin(ans, res);
    }
    
    
    cout << ans << endl;
    return 0;
}


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

int main(){
  vector<uint64_t> Lucas(3);
  int N;
  cin >> N;
  if(N<1 || N>86){
    return 0;
  }

  
  for(int i=0; i<N+1; ++i){
    if(i==0){
      Lucas.at(i%3) = 2;
    }
    else if (i==1){
      Lucas.at(i%3) = 1;
    }
    else{
      Lucas.at(i%3) = Lucas.at((i-1)%3) + Lucas.at((i-2)%3);
    }
  }
  cout << Lucas.at(N%3) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	int l = 1, r = n, ans = 0;
	while (l <= r) {
		int mid = (l + r) / 2;
		long long tmp = a[mid];
		bool flag = 1;
		for (int i = 1; i <= n; ++ i) {
			if (i == mid) continue;
			if (a[i] <= 2 * tmp) {
				tmp += a[i];
			}
			else {
				flag = 0;
				break;
			}
		}
		if (flag) {
			ans = n - mid + 1;
			r = mid - 1;
		}
		else {
			l = mid + 1;
		}
	}
	printf("%d\n", ans);
}



Measured memory_bytes: 640
import fileinput


def GCD(x, y):
    if y != 0:
        return GCD(y, x % y)
    else:
        return x

for line in fileinput.input():
    x, y = [int(s) for s in line.split()]
    #print("{} {}".format(GCD(x, y), int(x * y/GCD(x, y))))#別にformatでなくてもいい
    print(GCD(x, y),int(x * y/GCD(x, y)))


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D , d , M , m ;
  cin >> D >> M >> d >> m ;
  
  if((d-D) == 1){
    cout << 1 << endl;
  }
    else{
      cout<< 0 << endl;
    } 
  }

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	static int ans=0;
	static int v[]= {0,1,2,3,4,5,6,7,8,9};
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {

		for(;;) {
			int n=sc.nextInt();//n個選んで
			int m=sc.nextInt(); //mになる
			if(n==0&&m==0)break;  //深さn以下でmになる値
	System.out.println(solve(n,m,0));

		}

		}
	public static int solve(int n,int m,int c){
	    if(n==1) {
	    	if(m>=c&&m<10) {
	    		return 1;
	    	}else return 0;
	    }
	    int ans=0;
	    for(int i=c;i<10&&i<m;i++){
	        ans+=solve(n-1,m-i,i+1);
	    }
	    return ans;
	}
	}



Measured memory_bytes: 25816
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef unsigned long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	ll a;string b;
	cin>>a>>b;
	ll c;
	if(b.length()==5){
		c=1000;
	}else{
		c=(b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
	}
	cout<<(a*c/100);
}

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

# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_C

if __name__ == '__main__':
    while 1:
        line = raw_input()
        if line == '0 0':
            break
        a, b = map(int, line.split())
        if a < b:
            print a, b
        else:
            print b, a


Measured memory_bytes: 4636
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void ckmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void ckmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(A) A.begin(),A.end()

const int maxn=100000+16;

int n;
vector<int> g[maxn];

int solve(int p,int father)
{
	int sg=0;
	for (int x:g[p]) if (x!=father) sg^=(solve(x,p)+1);
	return sg;
}
int main()
{
#ifdef _MSC_VER
	freopen("input.txt","r",stdin);
#endif
	std::ios::sync_with_stdio(false);
	while (cin>>n)
	{
		REP(i,n) g[i].clear();
		REP(i,n-1)
		{
			int x,y;
			cin>>x>>y;
			--x;
			--y;
			g[x].push_back(y);
			g[y].push_back(x);
		}
		if (solve(0,-1))
			printf("Alice\n");
		else
			printf("Bob\n");
	}
	return 0;
}



Measured memory_bytes: 10368
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int count = 0;
        for(int i=1; i<=n; i++) {
            int num = 0;
            int m = i;
            while(m > 0) {
                num += m % 10;
                m /= 10;
            }
            if(num >= a && num <= b) count += i;
        }
        System.out.println(count);
    }  
}

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

int main(void){
    double dp[50101];
    fill(dp, dp+5001, 1<<29);
    dp[0]=0;
    for(int i=200; i<=5000; i++){
        dp[i]=dp[i-200]+380;
        if(i>=300)  dp[i]=min(dp[i], dp[i-300]+550);
        if(i>=500)  dp[i]=min(dp[i], dp[i-500]+850);
        if(i>=1000) dp[i]=min(dp[i], dp[i-1000]+380*5*0.8);
        if(i>=1200) dp[i]=min(dp[i], dp[i-1200]+550*4*0.85);
        if(i>=1500) dp[i]=min(dp[i], dp[i-1500]+850*3*0.88);
    }
    
    while(true){
        int num;
        cin >> num;
        if(num==0) break;
        cout << dp[num] << "\n";
    }
}



Measured memory_bytes: 3284
from functools import reduce

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def gcd_mult(numbers):
    return reduce(gcd, numbers)


N = int(input())
A = [int(a) for a in input().split()]

print(gcd_mult(A))

Measured memory_bytes: 14596
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int maxn=1e5+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,a[maxn],b[maxn],c[maxn<<1],cnt,posa[maxn],posb[maxn],d[maxn],k;
signed main(){
	n=read();
	for(int i=1;i<=n;i++){a[i]=read();b[i]=read();c[++cnt]=a[i];c[++cnt]=b[i];}
	sort(c+1,c+1+cnt);
	int flag=0,fa=0,fb=0;
	for(int i=1;i<=n;i++){
		a[i]=lower_bound(c+1,c+1+cnt,a[i])-c;
		b[i]=lower_bound(c+1,c+1+cnt,b[i])-c;
		if(a[i]<=n)posa[i]=1,fa=1;
		if(b[i]<=n)posb[i]=1,fb=1;
		if(posa[i]&&posb[i]){
		//	printf("%d %d\n",a[i],b[i]);
			flag=1;break;
		}
	}
	for(int i=1;i<=n;i++){
		d[i]=c[n+i];
	}
	k=n;
	if(flag||(!fa)||(!fb)){
		int ans=0;
		for(int i=1;i<=n;i++)ans=ans+c[i];
		printf("%lld\n",ans);
		return 0;
	}
	int ans=0;
	for(int i=1;i<=n;i++)ans=ans+c[i];
//	printf("%d\n",ans);
	int tmp=0x3f3f3f3f3f3f3f3fll;
	for(int i=1;i<=n;i++){
		if(posa[i]){
			int qaq=1;
			for(int j=1;j<=k;j++){
				if((!qaq)||(c[b[i]]!=d[j])){
					tmp=min(tmp,ans+d[j]-c[a[i]]);
					break;
				}
				else{
					qaq=0;
				}
			}
		}
		else{
			int qaq=1;
			for(int j=1;j<=k;j++){
				if((!qaq)||(c[a[i]]!=d[j])){
					tmp=min(tmp,ans+d[j]-c[b[i]]);
					break;
				}
				else{
					qaq=0;
				}
			}
		}
	}
	printf("%lld\n",tmp);
	return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    string str,res;
    bool flg = false;
    cin >> str;
    for(auto x : str){
	if(flg){
	    if(x == 'Z'){
		flg = false;
		res += "AZ";
	    }
	}else{
	    if(x == 'A'){
		flg = true;
	    }
	}
    }
    if(res.empty()){
	cout << -1 << endl;
    }else{
	cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3156
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define LL long long
using namespace std;
int pra, prb, prc;
int x, y;
LL ans = 0;
int main()
{
	while (cin >> pra >> prb >> prc >> x >> y) {
		ans = 0;
		if (prc * 2 < pra + prb) {
			ans += min(x, y)*prc * 2;
			if (x > y)
				ans += (x - y)*pra;
			else ans += (y - x)*prb;
		} else {
			ans = x*pra + y*prb;
		}
		if (prc * 2 * max(x, y) < ans)
			ans = prc * 2 * max(x, y);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int n;
int dp[100005];
int a[100005];
int func(int i){
    if(i==n-1)  return 0;
    if(dp[i]!=-1)   return dp[i];
    if(i==n-2){
        dp[i] = abs(a[i+1] - a[i]) + func(i+1);
    }
    else    dp[i] = min(abs(a[i+1] - a[i]) + func(i+1),abs(a[i+2] - a[i]) + func(i+2));
    return dp[i];
}
int main(){
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int cost  = func(0);
    cout<<cost<<endl;
}

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

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

int main() {
  long long a,b,k;	cin >> a >> b >> k;
  long long x=min(a,k);
  a-=x;
  k-=x;
  b-=min(b,k);
  cout << a << " " << b;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<P>> vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n ,m ;
  cin >> n >>m;
  UnionFind tree(n);
  
  vl p(n);
  rep(i,n) cin >> p[i];
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    tree.merge(a,b);
  }
  
  int cnt=0;
  rep(i,n){
    if(tree.issame(i,p[i]-1)){
      cnt++;
    }
  }
  cout << cnt << endl;
 
  return 0;     
}


Measured memory_bytes: 2560
s = list(input())
t = list(input())

s = sorted(s)
t = sorted(t)
t = t[::-1]

s_ = ''
t_ = ''

for i in s:
    s_ += i
for j in t:
    t_ += j

if s_ < t_:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n;
  cin >> n;
  vector<ll> a(n+1), b(n);
  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];

  ll ans = 0;
  rep(i, n) {
    if (b[i] > a[i]) {
      ans += a[i];
      b[i] -= a[i];

      if (b[i] > a[i+1]) {
        ans += a[i+1];
        a[i+1] = 0;
      } else {
        ans += b[i];
        a[i+1] -= b[i];
      }
    } else {
      ans += b[i];
    }
  }

  cout << ans << endl;
}


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

#define ll long long
#define endl "\n"

int main ()
{

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //#define int ll
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);

    string a, b;
    cin >> a >> b;
    
    int ans = 0;
    for (int i=0; i<a.size(); i++){
    	if (a[i] != b[i]) ans++;
	}
	
	cout << ans << endl;
    
    return 0;

}

Measured memory_bytes: 3792
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-100
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
//	file();
	fast();
	ll x; cin >> x;
	ll have = 100;
	int cnt = 0;
	while (have < x) {
		cnt++;
		have += (have / 100);
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
int main()
{
  int n;
  int a,b,c;
  
  scanf("%d",&n);
  a=(int)(n/100);
  b=(int)((n-100*a)/10);
  c=(int)(n-100*a-10*b);
  
  if(a==1)a=9;
  else if(a==9)a=1;
  
  if(b==1)b=9;
  else if(b==9)b=1;
  
  if(c==1)c=9;
  else if(c==9)c=1;
  
  printf("%d",100*a+10*b+c);
}

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

int main(int argc, char** argv) {
	int n,i,j,a;
	cin>>n;
	if(n<1||n>100)
		return 0;
	for(i=n;i>0;i--)
	{
		for(j=0;j<n;j++)
		{
			a=pow(2,j);
			if(a>n)
				break;
		}
			
	}
	cout<<pow(2,j-1);
	
	return 0;
}

Measured memory_bytes: 256
l=gets.to_i
n=l-1
array=[]
an=0
l.times{|m|
    array[m]=gets.chomp
}
n.times{|i|
    a=array[i]
    b=array[i+1]
    if a[-1]!=b.chr
        an+=1
        end
    i.times{|k|
        if array[k]==b
            an+=1
            end
    }
}
if an==0
    puts "Yes"
else
puts "No"
end

Measured memory_bytes: 1788
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=3050;
int n,m;
int v[maxn],w[maxn],f[maxn][maxn];
int p[maxn],num;
int main()
{
	cin>>n>>m;
	int maxx=0,pos=0;
	for(int i=1;i<=n;i++) cin>>v[i]>>w[i];
	for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=m-1;j++)
        {
            f[i][j]=f[i-1][j];
            if(j-v[i]>=0) f[i][j]=max(f[i][j],f[i-1][j-v[i]]+w[i]);
        }
    }
	int temp=m-1;
	for(int i=n;i>=1;i--)
    {
        if(temp-v[i]>=0&&f[i][temp]==f[i-1][temp-v[i]]+w[i])
        {
            temp-=v[i];
        }
        else p[++num]=w[i];
    }
	sort(p+1,p+num+1);
	cout<<f[n][m-1]+p[num]<<endl;
	return 0;
}


Measured memory_bytes: 35968
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

string dm3[3] = {"a..",
				 "a..",
				 ".bb"};

string dm4[4] = {"aaef",
				 "bbef",
				 "cdgg",
				 "cdhh"};

string dm5[5] = {"aabbc",
				 "de..c",
				 "de..j",
				 "f.iij",
				 "fgghh"};

string dm6[6] = {"abbe..",
				 "a.ce..",
				 "ddc.ff",
				 "g..ikk",
				 "g..i.l",
				 ".hhjjl"};

string dm7[7] = {".abbcc.",
				 "da...ee",
				 "d.f...g",
				 "h.f...g",
				 "h..ii.j",
				 "kk...lj",
				 ".mmnnl."};

char dm[1111][1111];
int n, num_of_4, left_over;

void make_board(void)
{
	int sty = 0, stx = 0, i, j;

	while (num_of_4--)
	{
		for (i = 0; i < 4; i++)
			for (j = 0; j < 4; j++)
				dm[sty + i][stx + j] = dm4[i][j];

		sty += 4, stx += 4;
	}

	if (left_over == 4)
		for (i = 0; i < 4; i++)
			for (j = 0; j < 4; j++)
				dm[sty + i][stx + j] = dm4[i][j];
	else if (left_over == 5)
		for (i = 0; i < 5; i++)
			for (j = 0; j < 5; j++)
				dm[sty + i][stx + j] = dm5[i][j];
	else if (left_over == 6)
		for (i = 0; i < 6; i++)
			for (j = 0; j < 6; j++)
				dm[sty + i][stx + j] = dm6[i][j];
	else if (left_over == 7)
		for (i = 0; i < 7; i++)
			for (j = 0; j < 7; j++)
				dm[sty + i][stx + j] = dm7[i][j];
}

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

    int i, j;

    cin >> n;

    if (n == 2)
	{
		cout << -1;
		return 0;
	}
    else if (n == 3)
	{
		for (i = 0; i < 3; i++)
			cout << dm3[i] << "\n";
		return 0;
	}

	memset(dm, '.', sizeof(dm));

	num_of_4 = n / 4 - 1;
	left_over = n - num_of_4 * 4;

	make_board();

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
			cout << dm[i][j];
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 2432
a,b,c = map(int, raw_input().split())
area = min((a*b, b*c, c*a))
# print area

if area == a*b:
    d = c
elif area == b*c:
    d = a
else:
    d = b

d1 = d/2
d2 = d - d1
print area * (d2 - d1)


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL<<60;

ll solve() {
    ll N, a, b;
    cin >> N;
    ll sum = 0, mn = INF;
    for ( int i = 0; i < N; i++ ) {
        cin >> a >> b;
        sum += a;
        if ( a > b ) {
            mn = min(mn, b);
        }
    }
    ll ans = sum - mn;
    if ( mn == INF ) ans = 0;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        m: usize,
        k:usize,
        a: [usize;n],
        b: [usize;m]
    }

    let rest_time = 0;

    let mut a_cum_sum = vec![0; n + 1];
    let mut b_cum_sum = vec![0; m + 1];

    for i in 1..n + 1 {
        a_cum_sum[i] = a_cum_sum[i - 1] + a[i - 1];
    }

    for i in 1..m + 1 {
        b_cum_sum[i] = b_cum_sum[i - 1] + b[i - 1];
    }

    let mut ans = 0;
    for i in 0..n + 1 {
        let mut a_sum = a_cum_sum[i];
        let rest = if a_sum > k { 0 } else { k - a_sum };
        let mut b_index = bin_search(&b_cum_sum, rest);
        if a_sum + b_cum_sum[b_index] <= k {
            ans = cmp::max(i + b_index, ans);
        }
        //println!("{} {}", a_cum_sum[i], b_cum_sum[b_index]);
        //println!("{},{}", i, b_index);
    }

    println!("{:?}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet
// 二分探索 vは単調増加 v[x] >= aとなる最小のxを返す
fn bin_search(v: &[usize], a: usize) -> usize {
    if v.is_empty() || a <= v[0] {
        return 0;
    }
    let mut min = 0;
    let mut max = v.len();
    while max - min > 1 {
        let mid = (min + max) / 2;
        if v[mid] <= a {
            min = mid;
        } else {
            max = mid;
        }
    }
    min
}


Measured memory_bytes: 7180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastReader fr = new FastReader();
		String s = fr.nextLine();
		int n = s.length();
		int[] res = new int[n];
		for (int i=0; i<n-1; i++) {
			if (s.charAt(i) == 'R' && s.charAt(i+1) == 'L') {
				for (int j=i; j>=0 && s.charAt(j) == 'R'; j--) {
					res[i + (i-j)%2]++;
				}
				for (int j=i+1; j<n && s.charAt(j) == 'L'; j++) {
					res[i+1 - (j-i-1)%2]++;
				}
			}
		}
		for (int i=0; i<n; i++) {
			System.out.print(res[i]+" ");
		}
	}
	
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}


}


Measured memory_bytes: 46996
def main():
  _,*s=open(0)
  b,q='.'*101,range(101)
  for i,s in enumerate(s):
    a=[]
    for x,y,z,c in zip(b,'.'+s,s,q):
      c+=x=='.'>z
      i+=y=='.'>z
      if i>c:i=c
      a+=i,
    b,q=s,a
  print(a[-2])
main()

Measured memory_bytes: 3060
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int count=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='1')
		count++;
	}
	cout<<count<<endl;
	
	
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a, b;
  char op;

  while(1) {
    scanf("%d %s %d", &a, &op, &b);
    if (op == '?')
      break;
    if (op == '+')
      printf("%d\n", a + b);
    else if (op == '-')
      printf("%d\n", a - b);
    else if (op == '*')
      printf("%d\n", a * b);
    else
      printf("%d\n", a / b);
  }

  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class DIJ{
	public:
	struct edge{
		int to,cost;
	};
	vector<vector<edge> >G;
	int n;
	vi d;//distance
	DIJ(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
		G[b].pb(ee);
	}
	void dij(int s){
		d=vi(n,inf);
		d[s]=0;
		priority_queue<pii>q;
		q.push(pii(0,s));
		while(!q.empty()){
			pii p=q.top();
			q.pop();
			int pos=p.second,cost=-p.first;
			if(cost>d[pos])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				int to=e.to;
				int nowcost=cost+e.cost;
				if(nowcost<d[to]){
					d[to]=nowcost;
					q.push(pii(-d[to],to));
				}
			}
		}
	}
};
int main(){
	int n,m,s,t;
	cin>>n>>m>>s>>t;
	s--;t--;
	DIJ dij(n);
	rep(i,m){
		int a,b;cin>>a>>b;
		a--;b--;
		dij.add_edge(a,b,1);
		dij.add_edge(b,a,1);
	}
	dij.dij(s);
	vi d=dij.d;
	dij.dij(t);
	vi co(n);
	rep(i,n)if(dij.d[i]<n)co[dij.d[i]]++;
	ll out=0;
	rep(i,n)if(d[t]-2-d[i]<n&&d[t]-2-d[i]>=0)out+=co[d[t]-2-d[i]];
	cout<<out<<endl;
}

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

int main() {
	int n; cin >> n;
	map<int, int>a;
	for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		a[tmp]++;
	}
	
	int ans = 0;
	for (auto&& x : a) {
		if (x.second % 2 == 1)ans++;
	}
	cout << ans << endl;
	
	return 0;
}

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

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

  vector<pair<int, int>> students(N);
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;

    students[i] = make_pair(a, i + 1);
  }

  sort(students.begin(), students.end());
  for(int i = 0; i < N; i++){
    if(i){
      cout << ' ' ;
    }
    cout << students[i].second;
  }
  cout << endl;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<typename T>
void chmax(T &a, T b) {
    a = max(a, b);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    REP (i, 0, s.size()) {
        REP (j, i, s.size()) {
            bool ok = true;
            REP (k, i, j + 1) {
                if (s[k] != 'A' && s[k] != 'C' && s[k] != 'G' && s[k] != 'T') {
                    ok = false;
                }
            }
            if (ok) {
                chmax(ans, j - i + 1);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int n, a[200005], vis[1000005];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) 
    {
        cin >> a[i];
        vis[a[i]]++;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        bool mk = 1;
        vis[a[i]]--;
        for (int j = 1; j <= sqrt(a[i]); j++) 
        {
            if (a[i] % j == 0 && (vis[j] || vis[a[i] / j]))
            {
                mk = 0;
                break;
            }
        }
        vis[a[i]]++;
        ans += mk;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8168
def main():
    a, b, c = (int(i) for i in input().split())
    if a == b and a != c:
        print("Yes")
    elif a == c and a != b:
        print("Yes")
    elif b == c and b != a:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
using namespace std;
#define fors(i,a,b) for(int i=(a);i<=(b);++i)
#define ford(i,a,b) for(int i=(a);i>=(b);--i)
#define min(x,y) ((x) < (y) ? (x) : (y))
#define max(x,y) ((x) < (y) ? (y) : (x))
#define swap(x,y) ((x)^=(y),(y)^=(x),(x)^=(y))
#define abs(x) ((x) < 0 ? -(x) : (x)) 
const int maxn=1e6+7;
typedef long long ll;
const int inf=1<<25;
int read(){
    int s=0,f=1;
    char c=getchar();
    while(c<'0' || c>'9') {if(c=='-') f=-1; c=getchar();}
    while(c>='0' && c<='9') {s=s*10+c-48;c=getchar();}
    return s*f;
}
void write(int x){
    if(x<0) {putchar('-');x=-x;}
    if(x>9) write(x/10);
    putchar(x%10+48);
}
int tree[101010];
long long d[101010];
int siz[101010],fa[101010];
bool cmp(const int &x,const int &y)
{
    return d[x]<d[y];
}
map<long long,int> mp;
int main()
{
    int n;
    scanf("%d",&n);
    mp.clear();
    for(int i=1;i<=n;i++){
        scanf("%lld",&d[i]);
        siz[i]=1;
        mp[d[i]]=i;
        tree[i]=i;
    }
    sort(tree+1,tree+n+1,cmp);
    for(int i=n;i>1;i--)
    {
        fa[tree[i]]=mp[d[tree[i]]+2*siz[tree[i]]-n];
        if(!fa[tree[i]]){
            printf("-1");
            return 0;
        }
        siz[fa[tree[i]]]+=siz[tree[i]];
    }
    for(int i=2;i<=n;i++)
        d[tree[1]]-=siz[tree[i]];
    if(d[tree[1]]){
        printf("-1");
        return 0;
    }
    for(int i=2;i<=n;i++)
        printf("%d %d\n",fa[tree[i]],tree[i]);
    return 0;
}

Measured memory_bytes: 9600
#include <stdio.h>

int main(void)
{
	int a = 0;
	int b = 0;
	int hantei = 0;
	scanf("%d %d",&a,&b);
	if(a%3==0 || b%3==0 ||(a+b)%3==0){
		hantei = 1;	
	}
	if(hantei==0){
		printf("Impossible");
	}else{
		printf("Possible");
	}
	
}

Measured memory_bytes: 128
import java.lang.Math.abs

fun main(args: Array<String>){
    readLine()
    val conditions = readLine()!!.split(" ").map(String::toInt)
    val T = conditions[0]
    val A = conditions[1]

    val inpLIst = readLine()!!.split(" ").map(String::toInt)
    val minPlace = inpLIst.indexOf(inpLIst.minBy { abs(A - (T - it * 0.006)) })

    println(minPlace + 1)
}

Measured memory_bytes: 37920
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
    int n,m,ans=0,sum=0;
    cin>>n>>m;
    vector<int> a(10000000);
    for(int i=0;i<m;i++){
    	cin>>a[i];
    	sum+=a[i];
    }
    if(n<sum){
    	ans=-1;
    }
    else{
    	ans=n-sum;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 42328
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    let ans = a
        .iter()
        .zip(1..=n)
        .filter(|(a, b)| *a % 2 == 1 && *b % 2 == 1)
        .count();
    println!("{}", ans);
}


Measured memory_bytes: 2112
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;
const int MAX_NUM = 1000+7;
int mystack[MAX_NUM];
int elements_num = 0;
void push(int x){
	mystack[elements_num++] = x;
}

int pop(){
	int k = mystack[--elements_num];
	return k;
	
}
int main(){
	int result = 0;
	char s[100];
	int a1, a2;
	while(scanf("%s", s)!=EOF){
		if(s[0]=='+'){
			a2 = pop();
			a1 = pop();
			push(a1+a2);
		}else if(s[0] == '-'){
			a2 = pop();
			a1 = pop();
			push(a1-a2);
		}else if(s[0] == '*'){
			a2 = pop();
			a1 = pop();
			push(a1*a2);
		}else{
			int x = atoi(s);
			push(x);
		}
	}
	result = pop();
	cout << result << endl;
	
	return 0;
	
} 


Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define rrep(i,n) ll(i)=(n);ll now=-1;while((i)--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

const string Yes = "Yes";
const string No = "No";

void solve(ll A, ll B, string S){
    regex re("[0-9]{" + to_string(A) + "}-[0-9]{" + to_string(B) + "}");
    Yes(regex_match(S, re));
}

int main() {
    ll A;
    ignore_ret(scanf("%lld",&A));
    ll B;
    ignore_ret(scanf("%lld",&B));
    string S;
    cin >> S;
    solve(A, B, S);
    return 0;
}

Measured memory_bytes: 384
#ABC070B

a,b,c,d=map(int,raw_input().split())
if a<=c<=b<=d:
 print b-c
elif c<=a<=d<=b:
 print d-a
elif a<=c<=d<=b:
 print d-c
elif c<=a<=b<=d:
 print b-a
else:
 print 0


Measured memory_bytes: 2568
#include<iostream>
#include<cassert>
using namespace std;
#define N 8
#define FREE -1
#define NOT_FREE 1
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
bool X[N][N];

void initialize()
{
    for(int i=0; i<N; i++)
    {
        row[i]=FREE,col[i]=FREE;
    }
    for(int i=0; i<2*N-1; i++)
    {
        dpos[i]=FREE;
        dneg[i]=FREE;
    }
}

void printBoard()
{
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<N; j++)
        {
            if (X[i][j])
            {
                if(row[i]!=j)
                    return;
            }
        }
    }
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<N; j++)
        {
            cout<<((row[i]==j)? "Q":".");
        }
        cout<<endl;
    }
}

void recursive(int i)
{
    if(i==N)
    {
        printBoard();
        return;
    }
    for(int j=0; j<N; j++) 
    {
        if(NOT_FREE==col[j]||NOT_FREE==dpos[i+j]||NOT_FREE==dneg[i-j+N-1])
            continue;
    
        row[i]=j;
        col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
        recursive(i+1);
        row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
    }
}

int main()
{
    initialize();
    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++)
            X[i][j]=false;
    int k;
    cin>>k;
    for(int i=0; i<k; i++)
    {
        int r,c;
        cin>>r>>c;
        X[r][c]=true;
    }
    recursive(0);
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int array[n];
    for (int i = 0; i < n; i++) {
        cin >> array[i];
    }
    int min = array[0];
    int max = array[1] - array[0];

    for (int i = 1; i < n; i++) {

        if ((array[i] - min) > max) {
            max = array[i] - min;
        }
        if (array[i] < min) {
            min = array[i];
        }


    }
    cout << max << "\n";
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>   
using namespace std;
#define N 50   
#define REP(i, n) for(int i=0; i<n; i++)
long n,k;
long ans=1;
int main(void){
    cin>>n>>k;
    for(long i=0;i<n;i++){
        ans=ans*k;
        if(i==0)k--;
    }
    printf("%ld",ans);
}


Measured memory_bytes: 256
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const [a, b, n] = inputs[0].split(' ').map(Number);

  let x = b - 1 < n ? b - 1 : n;

  console.log(Math.floor((a * x) / b));
}


Measured memory_bytes: 29964