akhauriyash/Code-Regression huggingface dataset:
n = int(input())
tn=0
xn=0
yn=0
f=0
for i in range(n):
    t, x, y = map(int, input().split())
    dt=t-tn
    dx=abs(x-xn)
    dy=abs(y-yn)
    dxy= dx + dy
    if dt < dxy:
        f=1
    else:
        if dt%2==0 and dxy%2!=0:
            f=1
        elif dt%2!=0 and dxy%2==0:
            f=1
if f==1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()
const int maxn = 100010;
const int mod = 1e9+7;

int N,X;
int worst;

int B[maxn];
int L[maxn],R[maxn];
vector <pi> sums;

int taken[maxn];

bool test(int k) {
	int fulltake = min(N,k / X);
	int remaining = k - fulltake*X;
	int ans = 0;
	memset(taken,-1,sizeof taken);
	//cout << fulltake << "\n";
	for (int i =0;i<fulltake;i++) {
		ans += sums[i].f;
		taken[sums[i].s] = i;
	}
	
	int cursum = ans;
	//if (k == 389) cout << cursum << "\n";
	//let node i be the rest
	for (int i =0;i<N;i++) {
		int res = cursum;
		if (taken[i] != -1) {
			res -= sums[taken[i]].f;
			res += sums[fulltake].f;
		}
		//if (k == 389) cout << res << "\n";
		if (remaining >= B[i]) {
			res += B[i] * L[i];
			res += (remaining - B[i]) * R[i];
		} else {
			res += remaining * L[i];
		}
		//if (k == 389) {
			//cout << i << " " << taken[i] << " " << res << "\n";
		//}
		ans = max(ans, res);
	}
	
	if (ans - worst >= 0) return 1;
	else return 0;
}

int32_t main() {
	//FAST
	cin >> N >> X;
	for (int i =0; i<N;i++) {
		cin >> B[i] >> L[i] >> R[i];
		sums.push_back(pi(L[i] * B[i] + R[i] * (X - B[i]),i));
	}
	for (int i =0;i<N;i++) {
		worst += B[i] * L[i];
	}
	//cout << worst << "\n";
	
	sort(all(sums),greater<pi>());
	
	int high = 1e10;
	int low = -1;
	while (high - low > 1) {
		int mid = (high + low) /2;
		//cout << low << " " << mid << " " << high << "\n";
		if (test(mid)) high = mid;
		else low = mid;
	}
	cout << high;
}


Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define li long long int
#define ld long double
#define F first
#define S second
const li M = 1000000007;
#define ld long double
li dx[]={-1,1,0,0};
li dy[]={0,0,-1,1};

int main()
{
	li N,K,k,i,j; 
	string ss,tt; cin>>ss>>tt;
	k=0;
	for(i=0;i<ss.size();i++)
	{
		if(ss[i]!=tt[i])
			k++;
	}
	cout<<k;
			
}



Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
main() {
	int n=read(),k=read();
	double ans=0;
	for(int i=1;i<=n;i++){
		if(i>=k) {ans+=1.0/n;continue;}
		int m=ceil(log(ceil(k*1.0/i))/log(2));
		ans+=1.0/((1<<m)*n);
	}
	printf("%0.12lf",ans); 
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static class UnionFind {
		int[] param;
		int[] rank;
		int N;
		int xlen;
		
		public UnionFind(int n) {
			N=n;
			param = new int[N];
			rank = new int[N];
			for(int i=0; i<N; i++)
				param[i] = i;
		}
		
		public void init() {
			for(int i=0; i<N; i++)
				param[i] = i;
			Arrays.fill(rank, 0);
		}
		
		public UnionFind(int x, int y) {
			this(x*y);
			xlen=y;
		}
		
		public boolean same(int a, int b) {
			return getRoot(a)==getRoot(b);
		}
		
		public boolean same(int x1, int y1, int x2, int y2) {
			return same(x1*xlen+y1, x2*xlen+y2);
		}
		
		public int getRoot(int a) {
			if(param[a]==a) return a;
			else return (param[a] = getRoot(param[a]));
		}
		
		public void unite(int a, int b) {
			a = getRoot(a);
			b = getRoot(b);
			if(a==b)
				return;
			
			if(rank[a] < rank[b]) {
				param[a] = b;
			} else {
				param[b] = a;
				if(rank[a]==rank[b])
					rank[a]++;
			}
		}
		
		public void unite(int x1, int y1, int x2, int y2) {
			unite(x1*xlen+y1, x2*xlen+y2);
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		HashMap<Integer, ArrayList<Integer>> xset = new HashMap<>();
		HashMap<Integer, ArrayList<Integer>> yset = new HashMap<>();
		HashSet<Integer> xall = new HashSet<>();
		
		for(int i=0; i<N; i++) {
			int x = sc.nextInt()-1;
			int y = sc.nextInt()-1;
			
			ArrayList<Integer> ys = xset.get(x);
			if(ys == null) {
				ys = new ArrayList<>();
			}
			ys.add(y);
			xset.put(x, ys);
			
			ArrayList<Integer> xs = yset.get(y);
			if(xs == null) {
				xs = new ArrayList<>();
			}
			xs.add(x);
			yset.put(y, xs);
			
			xall.add(x);
		}
		
		UnionFind uf = new UnionFind(100000);
		Iterator<Integer> it = yset.keySet().iterator();
		while(it.hasNext()) {
			int y = it.next();
			ArrayList<Integer> xlist = yset.get(y);
			for(int i : xlist) {
				uf.unite(xlist.get(0), i);
			}
		}
		
		HashMap<Integer, ArrayList<Integer>> xgroup = new HashMap<>();
		
		for(int x=0; x<100000; x++) {
			if(xall.contains(x)) {
				int root = uf.getRoot(x);
				ArrayList<Integer> xs = xgroup.get(root);
				if(xs == null) {
					xs = new ArrayList<>();
				}
				xs.add(x);
				xgroup.put(root, xs);
			}
		}
		
		long finalSize = 0;
		it = xgroup.keySet().iterator();
		while(it.hasNext()) {
			ArrayList<Integer> xlist = xgroup.get(it.next());
			HashSet<Integer> ys = new HashSet<>();
			for(int x : xlist) {
				ys.addAll(xset.get(x));
			}
			finalSize += (long)xlist.size()*ys.size();
		}
		
		System.out.println(finalSize - N);
		sc.close();
	}
}


Measured memory_bytes: 111140
#include<stdio.h>
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){
  int n,i,j,k,s=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      for(k=1;k<=n;k++)s+=gcd(i,gcd(j,k));
    }
  }
  printf("%d\n",s);
  return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
// NOT MY CODE, FROM https://pitsbuffersolution.com/
int N,K;
int b[2002][2002];
int s[4002][4002];
 
int get(int x , int y){
	return s[x+K-1][y+K-1] + s[x-1][y-1] - s[x-1][y+K-1] - s[x+K-1][y-1];
}
 
 // NOT MY CODE, FROM https://pitsbuffersolution.com/
 
int main(){
	cin >> N >> K;
	repp(i,0,N){
		int x,y;
		char c;
		cin >> x >> y >> c;
		if(c=='W') y += K;
		++b[x%(2*K)+1][y%(2*K)+1];
	}
	repp(i,1,4*K+1){
		repp(j,1,4*K+1){
			s[i][j] = s[i][j-1] + b[(i-1)%(2*K)+1][(j-1)%(2*K)+1];
		}
	}
	repp(j,1,4*K+1){
		repp(i,1,4*K+1){
			s[i][j] += s[i-1][j];
		}
	}
	int ans = 0;
	repp(i,1,2*K+1){
		repp(j,1,2*K+1){
			ans = max(ans , get(i,j) + get(i+K,j+K));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 78464
// 2014/07/21 Tazoe

#include <iostream>
#include <cmath>
using namespace std;

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

	for(int i=0; i<n; i++){
		double x1, y1, x2, y2, x3, y3, x4, y4;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

//		int X1 = (int)(x1*100000.0);
//		int Y1 = (int)(y1*100000.0);
//		int X2 = (int)(x2*100000.0);
//		int Y2 = (int)(y2*100000.0);
//		int X3 = (int)(x3*100000.0);
//		int Y3 = (int)(y3*100000.0);
//		int X4 = (int)(x4*100000.0);
//		int Y4 = (int)(y4*100000.0);

//		long long ABX = X2-X1;
//		long long ABY = Y2-Y1;
//		long long CDX = X4-X3;
//		long long CDY = Y4-Y3;

		double abx = x2-x1;
		double aby = y2-y1;
		double cdx = x4-x3;
		double cdy = y4-y3;

		if(fabs(abx*cdy-aby*cdx)<0.0000000001){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}

	return 0;
}

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



int main(){
	string s;
  	cin>>s;
  
  	if (s[0]=='A' and s[1]=='A' and s[2]=='A') cout<<"No"<<endl;
    else if (s[0]=='B' and s[1]=='B' and s[2]=='B') cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  


}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int plusnum = Integer.parseInt(sc.nextLine());
        HashMap<String,Integer> plusMap = new HashMap<String,Integer>();
        HashMap<String,Integer> minusMap = new HashMap<String,Integer>();

        for(int i = 0;i < plusnum;i++){
            String word = sc.nextLine();

            if(plusMap.get(word) == null){
                plusMap.put(word,1);
            }else{
                plusMap.put(word,plusMap.get(word) + 1);
            }
        }

        int minusNum = Integer.parseInt(sc.nextLine());

        for(int i = 0; i < minusNum;i++){
            String word = sc.nextLine();

            if(minusMap.get(word) == null){
                minusMap.put(word,1);
            }else{
                minusMap.put(word,minusMap.get(word) + 1);
            }
        }

        int max = 0;

        for(String key : plusMap.keySet()){

            int plusVal = plusMap.get(key);

            int minusVal = 0;
            if(minusMap.get(key) != null){
                minusVal = minusMap.get(key);
            }

            int result = plusVal - minusVal;
            
            if(result > max){
                max = result;
            }
        }

        System.out.println(max);
    }
}

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

typedef long long ll;
typedef pair<int,int> P;

#define fr first
#define sc second

const int INF = 1000000000;

int main(){
	int n,k,q;
	int a[2002];
	scanf("%d%d%d",&n,&k,&q);
	for(int i = 1 ; i <= n ; i ++){
		scanf("%d",&a[i]);
	}
	
	int ret = INF;
	set<int> S; S.insert(0); S.insert(n+1);
	vector<P> vec;
	for(int i = 1 ; i <= n ; i ++){
		vec.push_back(P(a[i],i));
	}
	sort(vec.begin(),vec.end());
	for(int i = 0 ; i < n ; i ++){
		P p = vec[i];
		int cnt = 0;
		int r;
		map<int,int> T;
		for(int j = i ; j < n && cnt < q ; j ++){
			P q = vec[j];
			auto itr = S.lower_bound(q.sc);
			int x = *itr;
			--itr;
			int y = *itr;
			if(x-y >= k+1+T[x]){
				T[x] ++;
				cnt ++;
				r = q.fr;
			}
		}
		if(cnt == q)ret = min( ret , r-p.fr );
		S.insert(p.sc);
	}
	cout << ret << endl;
}



Measured memory_bytes: 384
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF = 10 ** 9

def dfs(i, a, b, c):
    if i == N:
        if a > 0 and b > 0 and c > 0:
            # 最初の一本目の合体において +10 の必要がないのに足しているので、それぞれについて -10 してあげる
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return INF

    res0 = dfs(i + 1, a, b, c)
    res1 = dfs(i + 1, a + l[i], b, c) + 10
    res2 = dfs(i + 1, a, b + l[i], c) + 10
    res3 = dfs(i + 1, a, b, c + l[i]) + 10
    
    return min(res0, res1, res2, res3)

res = dfs(0, 0, 0, 0)
print(res)

Measured memory_bytes: 42204
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    char op;
    
    while(cin >> a >> op >> b){
        if(op == '?') break;
        switch(op){
            case '+' :
                cout << a + b << endl;
                break;
                
            case '-' :
                cout << a - b << endl;
                break;
                
            case '*' :
                cout << a * b << endl;
                break;
                
            case '/' :
                cout << a / b << endl;
                break;
        }
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int n,k;
	string s;
	cin >> n >> k;
	cin >> s;
	s[k-1] = s[k-1]+32;
	println(s);
	return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append([str(i),str(n//i)])
 
    return divisors


def f(a,b):
    return max(len(a),len(b))

n = int(input())

divisors = make_divisors(n)

ans = 20
for i in divisors:
    ans = min(ans,f(i[0],i[1]))
    
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll inf=1e18;
vec ans(16,inf);
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vec X(n),Y(n),P(n);
    rep(i,n) cin>>X[i]>>Y[i]>>P[i];
    vec x[15],y[15];
    rep(i,pow(2,n)){
        vec A;
        ll p=i;
        rep(j,n) A.push_back(p%2),p/=2;
        rep(j,n){
            ll d=min(abs(X[j])*P[j],abs(Y[j])*P[j]);
            rep(k,n){
                if(A[k]) d=min(d,abs(X[j]-X[k])*P[j]);
            }
            x[j].push_back(d);
        }
    }
    rep(i,pow(2,n)){
        vec A;
        ll p=i;
        rep(j,n) A.push_back(p%2),p/=2;
        rep(j,n){
            ll d=min(abs(X[j])*P[j],abs(Y[j])*P[j]);
            rep(k,n){
                if(A[k]) d=min(d,abs(Y[j]-Y[k])*P[j]);
            }
            y[j].push_back(d);
        }
    }
    ll e2[16];
    e2[0]=1;
    rep(i,15) e2[i+1]=e2[i]*2;
    rep(i,pow(3,n)){
        vec A,B;
        ll p=i,a=0,b=0,c=0,d=0;
        rep(j,n){
            if(p%3==1) a+=e2[j],d++;
            if(p%3==2) b+=e2[j],d++;
            p/=3;
        }
        rep(j,n){
            c+=min(x[j][a],y[j][b]);
        }
        ans[d]=min(ans[d],c);
    }
    rep(i,n+1) cout<<ans[i]<<"\n";
}

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

int main()
{
    int64_t N, T;
    cin >> N >> T;
    int64_t t[N];
    for (int64_t i = 0; i < N; i++)
    {
        cin >> t[i];
    }
    int64_t total = 0;
    int64_t time = 0;
    for (int64_t i = 0; i < N - 1; i++)
    {
        if (t[i + 1] - t[i] >= T)
        {
            total += T;
            //            time += T;
        }
        else
        {
            total += t[i + 1] - t[i];
        }
    }
    total += T;
    cout << total << endl;
}

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

int main(){
  ll N, K;
  cin >> N >> K;
  
  ll B, ans = 0;
  for (B = K + 1; B <= N; B++){
    ll num = (((N - B + 1) / B) + 1), z = 0;
    ans += (B - K) * num;
    ans += max(z, N - K + 1 - B * num);
  }
  
  if (K == 0){
    ans -= N;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3624
//have fun
#include <bits/stdc++.h>
using namespace std;
#define mod 		1000000007
#define ll 		long long
#define mp 		make_pair
#define pb 		push_back
#define forn(i,n) 	for(int i=0;i<n;i++)
#define for1(i,n) 	for(int i=1;i<n;i++)
#define ford(i,n) 	for(int i=n-1;i>=0;i--)
#define vi 		vector<int>
#define vl 		vector<ll>
#define pii 		pair<int,int>
#define pll 		pair<ll,ll>
#define vpi 		vector<pair<int,int> >
#define vpl		vector<pair<ll,ll> >
#define vvi 		vector<vector<int> >
#define vvl 		vector<vector<ll> >
#define ull 		unsigned long long
#define IOS 		ios_base::sync_with_stdio(false);
#define PI 		3.1415926535897932384626
#define ff 		first
#define ss 		second
#define char2Int(c) 	(c-'0')
#define FOREACH(i,t) 	for (auto i=t.begin(); i!=t.end(); i++)
#define clr(a,x) 	memset(a,x,sizeof(a)) //set elements of array to some value
#define all(x)		(x).begin(),(x).end()//cout<<"Case #"<<zzz<<": ";
double dp[3000][3000];
int n;vector<double> p(n);
double getans(int ptr,int req)
{
    if(ptr>=n)
    {
        if(req==0)return 1;else return 0;
    }
    if(req==0)return 1;
    if(req>n-ptr)return 0;
    if(dp[ptr][req]!=-1)return dp[ptr][req];
    double ans=0;
    ans=(1-p[ptr])*getans(ptr+1,req)+p[ptr]*getans(ptr+1,req-1);
    dp[ptr][req]=ans;return ans;
}
int main()
{
    IOS;cin.tie(NULL);
    int zz=1;
    for(int zzz=1;zzz<=zz;zzz++)
    {
        cin>>n;
        p.resize(n);forn(i,n)cin>>p[i];
        forn(i,3000)forn(j,3000)dp[i][j]=-1;
        cout<<fixed<<setprecision(12);
        cout<<getans(0,ceil((double)n/2))<<endl;
    }
    return 0;
}


Measured memory_bytes: 70784
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nk[0];
        var k = nk[1];
        Console.WriteLine(Min(n % k, k - n % k));
    }
}

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

char judge(int mid, int last, int re){
	int total;
	total = mid + last;
	if(mid == -1 || last == -1){
		return 'F';
	}else if(80 <= total){
		return 'A';
	}else if(65 <= total && total < 80){
		return 'B';
	}else if(50 <= total && total < 65){
		return 'C';
	}else if(30 <= total && total < 50){
		if(50 <= re){
			return 'C';
		}
		return 'D';
	}else{
		return 'F';
	}
}

int main()
{
	int middle, last, re_ex;
	char record;
	while(true){
		cin >> middle >> last >> re_ex;
		if(middle == -1 && last == -1 && re_ex == -1){
			break;
		}
		record = judge(middle, last, re_ex);

		cout << record << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    double N, X, Y, D, a = 0;
    cin >> N >> D;
    for (int i = 0; i < N; i++)
    {
        cin >> X >> Y;
        if (D >= hypot(X, Y)) a++;
    }
    cout << a;
}

Measured memory_bytes: 3812
N,M=map(int,input().split())
a=[]
b=[]
for i in range(N):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
c=[]
d=[]
for i in range(M):
    C,D=map(int,input().split())
    c.append(C)
    d.append(D)
ans=[]
for i in range(N):
    ans.append(10**9)
for i in range(N):
    for j in range(M):
        m=abs(a[i]-c[j])+abs(b[i]-d[j])
        ans[i]=min(m,ans[i])

n=[[] for _ in range(N)]
for i in range(N):
    for j in range(M):
        m=abs(a[i]-c[j])+abs(b[i]-d[j])
        if ans[i]==m:
            n[i].append(j+1)
for i in range(N):
    print(n[i][0])

Measured memory_bytes: 3064
n = int(input())
mod = 1000000007
dp = [0 for i in range(3001)]
dp[3] = 1
dp[4] = 1
dp[5] = 1
if n < 6:
  print(dp[n])
  exit()
for i in range(6, n + 1):
  dp[i] = sum(dp[:i-2]) + 1
  dp[i] %= mod
print(dp[i])

Measured memory_bytes: 9064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int hako=0;
		
		for(int i=0;i<n;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if(a==b) {
				ans++;
				if(ans==3){
					hako=1;
				}
			}
			else {
				ans=0;
			}
		}
		
		if(hako==1) {
			System.out.print("Yes");
		}
		else {
			System.out.print("No");
		}

	}
}


Measured memory_bytes: 35944
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
const constexpr int INF = 1e9;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;
struct Less{
   bool operator()(const pair<string, int>&a, const pair<string, int>&b){
        if(a.first==b.first){
            return a.second < b.second;
        }
       return a.first < b.first;
    }
};
const constexpr ll MOD = 1e9 + 7;


ll extGCD(ll a, ll b, ll& x, ll& y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}
ll GCD(ll a, ll b){
    if(b==0) return a;
    return GCD(b, a%b);
}

int main() {
    int N, T; cin >> N >> T;
    int ans=INF;
    for(int i=0; i<N; ++i){
        int c, t; cin >> c >> t;
        if(T>=t){
            ans = min(ans, c);
        }
    }
    if(ans==INF) cout << "TLE" << endl;
    else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def bubbleSort(A, N): # N 個の要素を含む 0-オリジンの配列 A
    A = list(map(int, A.split()))
    flag = 1 # 逆の隣接要素が存在する
    count = 0  # 交換回数
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                # A[j] と A[j-1] を交換
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
                count += 1
    print(" ".join(map(str,A)))
    print(count)

N = int(input())
A = input()
bubbleSort(A, N)


Measured memory_bytes: 5600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
int n,m,a,b;
char s[1010][1010];
bool check1(int x,int y)
{
	if(y==m||a==0) return false;
	return s[x][y+1]=='.';
}
bool check2(int x,int y)
{
	if(x==n||b==0) return false;
	if(b==1)
	{
		if(((m%2)&&(y%2==0))||((m%2==0)&&(y%2)))
		{
			s[n-1][m]='^';s[n][m]='v';b--;
			return false;
		}
	}
	return s[x+1][y]=='.';
}
void dfs(int x,int y)
{
	/*printf("x y:%d %d\n",x,y);
	for(int i=1;i<=n;i++) printf("%s\n",s[i]+1);
	printf("-----------------\n");*/
	if(x==n+1) return;
	if(s[x][y]=='.')
	{
		if(check2(x,y)) s[x][y]='^',s[x+1][y]='v',b--;
		else if(check1(x,y)) s[x][y]='<',s[x][y+1]='>',a--;
	}
	if(y==m) dfs(x+1,1);
	else dfs(x,y+1);
}
int main()
{
	scanf("%d %d %d %d",&n,&m,&a,&b);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) s[i][j]='.';
	if(m%2)
	{
		for(int i=1;i<=n;i+=2)
		{
			if(i==n-1)
			{
				if(b%2==1&&check2(i,1)) s[i][1]='^',s[i+1][1]='v',b--;
			}
			if(check2(i,1)) s[i][1]='^',s[i+1][1]='v',b--;
		}
		//for(int j=1;j<=m;j++) if(check1(n,j)) s[n][j]='<',s[n][j+1]='>',a--;
	}
	dfs(1,1);
	//for(int i=1;i<=n;i++) printf("%s\n",s[i]+1);
	if(a!=0||b!=0) printf("NO\n");
	else
	{
		printf("YES\n");
		for(int i=1;i<=n;i++) printf("%s\n",s[i]+1);
	}
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

vector<int> fac;

ll myabs(ll p){if(p>=0)return p; return -p;}

int main()
{
    int n,m,k,a,b,x,y;
    ll sum = 0;
    int cnt = 0;
    int mx = 0;
    ll mn = INF;
    int cur = 0, idx = -1;

    cin>>n>>k;

    for(int i=1;i<=n;i++)
        cin>>A[i];

    for(int i=1;i<=n;i++)
        sum+=A[i];

    for(int i=1;i*i<=sum;i++){
        if(!(sum%i)){
            fac.push_back(i);
            if(i*i!=sum){
                fac.push_back(sum/i);
            }
        }
    }

    sort(fac.begin(),fac.end());

    ll pl = 0,mi = 0;
    ll psum = 0;
    int nw;

    int res = 0;

    for(int runs=0;runs<fac.size();runs++){

        cur = fac[runs];

        vector<int> re;

        pl = 0;

        for(int i=1;i<=n;i++){
            re.push_back(A[i]%cur),pl+=(ll)(A[i]%cur);
        }

        sort(re.begin(),re.end());

        mn = n*(ll)cur-pl;
        psum = 0;
        for(int i=0;i<n;i++){
            psum+=re[i];
            mn = min(mn,max(psum,(n-i-1)*(ll)cur-(pl-psum)));
        }
        //cout<<mn<<" "<<cur<<"\n";
        if(mn<=k)res = cur;
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"Yes\n"; else cout<<"No\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


int main()
{
    ll n,x,ans=0,a,b;
    cin>>n>>b;
    map<ll,ll> q;
    q[b]++;
    rep(i,n-1) {
        cin>>x;
        a=b+x;
        b=a;
        q[a]++;
    }
    for(auto x:q)ans+=x.second*(x.second-1)/2;
    cout<<ans+q[0]<<endl;
    
    return 0;
}


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

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

vector<vector<int>> G;
vector<int> C;
vector<int> D;
vector<bool> visited;

void dfs(int u, int &i) {
    D[u] = C[i++];
    visited[u] = true;

    for (int v : G[u]) {
        if (visited[v]) continue;
        dfs(v, i);
    }
}

int main() {
    int N;
    cin >> N;
    G.resize(N, vector<int>());
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    C.resize(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        sum += C[i];
    }

    sort(C.begin(), C.end(), greater<int>());
    int res = sum - C[0];

    D.resize(N, 0);
    visited.resize(N, false);
    int i = 0;
    dfs(0, i);

    cout << res << endl;
    for (int n : D) cout << n << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int N; cin >> N;
    rep1(h, 3500) {
        rep1(n, 3500) {
            int x = 4 * h * n - N * n - N * h;
            if(x <= 0) continue;
            if((N * h * n) % x == 0) {
                cout << h << " " << n << " " << (N * h * n) / x << endl;
                return;
            }
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(m,n):
    while n!=0:
        l=n
        n=m%n
        m=l
    return m

def lcm(p,q):
    return p*q//gcd(p,q)

N=int(input())
a=list(map(int,input().split(' ')))
lcm_=lcm(a[0],a[1])
for i in range(2,len(a)):
    lcm_=lcm(lcm_,a[i])
result=0
m=lcm_-1
for i in a:
    result+=m%i
print(result)


Measured memory_bytes: 3316
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.numeric;   // gcd, fft

void main()
{
  auto n = readln.chomp.to!size_t;
  auto t = new long[](n);
  foreach (i; 0..n) t[i] = readln.chomp.to!long;
  writeln(t.reduce!lcm);
}

auto lcm(long a, long b) { return a / gcd(a, b) * b; }


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
array = list(map(int, input().split()))

sum = 0
max = 0

for i in range(K):
    sum += array[i]
    max = sum

for i in range(K, N):
    sum += array[i] - array[i - K]
    if sum > max:
        max = sum

E = (max + K) / 2
print(E)

Measured memory_bytes: 25060
using System;
using System.Collections.Generic;
using System.Linq;

namespace Problem0003
{
    class Program
    {
        static void Main(string[] args)
        {
            var triples =
                GetInputLines()
                .Skip(1)
                .Select(line => line.Split().Select(word => int.Parse(word)).ToArray());
            foreach (int[] triple in triples)
            {
                if (IsRightTriangle(triple))
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }

        static IEnumerable<string> GetInputLines()
        {
            string line;
            while (!string.IsNullOrEmpty(line = System.Console.ReadLine()))
            {
                yield return line;
            }
        }

        static bool IsRightTriangle(int[] triple)
        {
            int[] sortedTriple = triple.OrderBy(n => n).ToArray();
            int a = sortedTriple[0], b = sortedTriple[1], c = sortedTriple[2];
            return a * a + b * b == c * c;
        }
    }
}

Measured memory_bytes: 10060
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()] 
H = [int(_) for _ in stdin.readline().rstrip().split()] 
dp = [10**9] * (N+1)
dp[0] = 0
for i in range(N):
  for j in range(1, min(K+1, N-i)):
    dp[i+j] = min(dp[i] + abs(H[i]-H[i+j]), dp[i+j])
print(dp[N-1])

Measured memory_bytes: 52320
#include<cstdio>
#include<algorithm>
using namespace std;
int n, Q, w[3010];
long long Mod = 1000000007, D[3010][3010], TA[3010], TB[3010], SA[3010], SB[3010], I2 = Mod/2+1;
int main() {
	int i, j, a, b;
	scanf("%d%d", &n, &Q);
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
	}
	for (i = 1; i <= n; i++)for (j = 1; j <= n; j++)if (w[i] < w[j])D[i][j] = 1;
	for(int TT=0;TT<Q;TT++) {
		scanf("%d%d", &a, &b);
		for (i = 1; i <= n; i++) {
			TA[i] = D[a][i];
			TB[i] = D[b][i];
			SA[i] = D[i][a];
			SB[i] = D[i][b];
		}
		for (i = 1; i <= n; i++) {
			if (i != a && i != b) {
				D[a][i] = D[b][i] = (TA[i] + TB[i])*I2%Mod;
				D[i][a] = D[i][b] = (SA[i] + SB[i])*I2%Mod;
			}
		}
		D[a][b] = D[b][a] = (TA[b] + TB[a])*I2%Mod;
	}
	long long res = 0;
	for (i = 1; i <= n; i++)for (j = 1; j < i; j++)res = (res + D[i][j]) % Mod;
	while (Q--)res = res * 2 % Mod;
	printf("%lld\n", res);
}

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

using namespace std;

typedef long long int LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

#define PB push_back
#define MP make_pair
#define L first
#define R second
#define sz(x) ((int)(x).size())
#define smax(x, y) ((x) = max((x), (y)))
#define smin(x, y) ((x) = min((x), (y)))
#define all(x) x.begin(),x.end()

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if(a <= 0 and b >= 0){
		cout << "Zero" << endl;
		return 0;
	}
	if(a > 0){
		cout << "Positive" << endl;
		return 0;
	}
	if(b > 0){
		a = -a;
		if(a & 1)
			cout << "Negative" << endl;
		else
			cout << "Positive" << endl;
		return 0;
	}
	a += b+1;
		if(a & 1)
			cout << "Negative" << endl;
		else
			cout << "Positive" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

void bfs(ll h, ll w, vector<string> &grid, vector<vll> &cnt, ll ny, ll nx) {
  if (ny + 1 < h) {
    if (grid[ny + 1][nx] == '#') {
      cnt[ny + 1][nx] = min(cnt[ny + 1][nx], cnt[ny][nx] + 1);
    }
    else {
      cnt[ny + 1][nx] = min(cnt[ny + 1][nx], cnt[ny][nx]);
    }
    bfs(h, w, grid, cnt, ny + 1, nx);
  }
  if (nx + 1 < w) {
    if (grid[ny][nx + 1] == '#') {
      cnt[ny][nx + 1] = min(cnt[ny][nx + 1], cnt[ny][nx] + 1);
    }
    else {
      cnt[ny][nx + 1] = min(cnt[ny][nx + 1], cnt[ny][nx]);
    }
    bfs(h, w, grid, cnt, ny, nx + 1);
  }
  return;
}

int main() {
  ll h, w;
  cin >> h >> w;

  vector<string> grid(h);
  for (ll i = 0; i < h; i++) cin >> grid[i];

  vector<vll> cnt(h, vll(w, inf));
  if (grid[0][0] == '#') cnt[0][0] = 1;
  else cnt[0][0] = 0;
  for (ll i = 0; i < h; i++) {
    for (ll j = 0; j < w; j++) {
      if (h == 0 && w == 0) continue;
      if (grid[i][j] == '#') {
        if (i > 0 && grid[i - 1][j] == '.') {
          cnt[i][j] = min(cnt[i][j], cnt[i - 1][j] + 1);
        }
        else if (i > 0) {
          cnt[i][j] = min(cnt[i][j], cnt[i - 1][j]);
        }
        if (j > 0 && grid[i][j - 1] == '.') {
          cnt[i][j] = min(cnt[i][j], cnt[i][j - 1] + 1);
        }
        else if (j > 0) {
          cnt[i][j] = min(cnt[i][j], cnt[i][j - 1]);
        }
      }
      else {
        if (i > 0) cnt[i][j] = min(cnt[i][j], cnt[i - 1][j]);
        if (j > 0) cnt[i][j] = min(cnt[i][j], cnt[i][j - 1]);
      }
    }
  }

  cout << cnt[h - 1][w - 1] << endl;
}

Measured memory_bytes: 384
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main(){    
  int T[3];
  cin >> T[0] >> T[1] >> T[2];

  sort(T,T+3);
  
  cout << T[0]+T[1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;
/*
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
*/
#define pi 3.1415926

int main() {
    double r, area;
    cin >> r;
    area = 2 * pi * r;
    cout << setprecision(6) << area;
    return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    long long r = 0, g = 0, b = 0;
    for (int i = 0; i < N; ++i) {
        switch (S.at(i)) {
            case 'R':
                ++r;
                break;
            case 'G':
                ++g;
                break;
            case 'B':
                ++b;
                break;
        }
    }
    long long ans = r * g * b;
    for (int i = 0; i < N; ++i) {
        for (int res = 1; i + 2 * res < N; ++res) {
            int j = i + res;
            int k = j + res;
            if ((S.at(i) != S.at(j)) && (S.at(j) != S.at(k)) && (S.at(k) != S.at(i))) {
                --ans;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3660
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf8');

// Your code here!
const max = (a)=>{
    let i = a.length;
    let max=-Infinity;
    while (i--) {
        if (a[i] > max)max = a[i];
    }
    return max;
}
const min = (a)=>{
    let i = a.length;
    let max=Infinity;
    while (i--) {
        if (a[i] < max)max = a[i];
    }
    return max;
}
const Main = (p)=>{
	p = p.split("\n");//2 or more
	//let N = parseInt(p[0]);//N
	let N = parseInt(p[0].split(" ")[0]);//N M
	let W = parseInt(p[0].split(" ")[1]);//N M
	//let h = (p[1].split(" ").map(Number));//a1 a2 a3...
	
	let w = new Array(N);
	let v = new Array(N);
	//let c=new Array(N);
    //let z=new Array(N);
    for(let i=0;i<N;i++){
        let h = (p[i+1].split(" ").map(Number));
        w[i]=h[0];
        v[i]=h[1];
    }
	let m = new Array(N+1);
    //console.log(N,W,w,v);return;
    m[0]=new Array(W+1).fill(0);
    for(let i=0;i<N;i++){
        m[i+1]=m[i].concat();
        for(let j=0;j<=W;j++){
            if(j-w[i]>=0){
                //console.log(m[i][j-w[i]]+v[i],m[i][j])
                m[i+1][j]=Math.max(m[i][j-w[i]]+v[i],m[i][j]);
            }
            
        }
        //console.log(i,m[i])
    }
	//console.log(c);
	console.log(max(m[N]));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 120344
#include <iostream>
using namespace std;
int main(){
        int N,T;
        cin >> N >> T;
        int a[N],b[N],c[N];
        int ans=0;
        for(int i=0; i<N; i++) {
                cin >> a[i];
        }
        for(int i=0; i<N-1; i++) {
                b[i] = a[i+1]-a[i];
                c[i] = min(T,b[i]);
        }
        c[N-1] = T;
        for(int i=0; i<N; i++) {
                ans +=c[i];
        }
        cout << ans << endl;
}


Measured memory_bytes: 2560
a = input()
b = input()
c = input()
aIndex = 0
bIndex = 0
cIndex = 0
target = a[aIndex]
aIndex = aIndex + 1
winner = ''
while(True):
	if target == 'a':
		if aIndex >= len(a):
			winner = 'A'
			break
		target = a[aIndex]
		aIndex = aIndex + 1
	elif target == 'b':
		if bIndex >= len(b):
			winner = 'B'
			break
		target = b[bIndex]
		bIndex = bIndex + 1
	else:
		if cIndex >= len(c):
			winner = 'C'
			break
		target = c[cIndex]
		cIndex = cIndex + 1
print(winner)

Measured memory_bytes: 38384
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        
        int n=sc.nextInt();
        int k=sc.nextInt();
        int d[]=new int[n];
        for (int i = 0,w; i < k; i++) {
			w=sc.nextInt();
			for (int j = 0; j < w; j++) {
				d[sc.nextInt()-1]++;
			}
		}
        int r=0;
        for (int i = 0; i < d.length; i++) {
			if(d[i]==0)r++;
		}
   
        out.println(r);
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,c;long s;
//	P(int  x, int c, long s) {
//	  this.x=x;
//	  this.c=c;
//	  this.s=s;
//	}
//}


class P implements Comparable<P>{
	int x,c;long s;
	P(int  x, int c, long s) {
	  this.x=x;
	  this.c=c;
	  this.s=s;
	}

    public int compareTo(P p){
        return Long.signum(s-p.s);
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000


typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

int main()
{
	int n, cur, last;
	bool can_change = 1;

	cin >> n;
	cin >> last;

	lpi(i, 1, n){
		cin >> cur;
		if(cur < last){
			if(!can_change || cur+1 < last){
				cout << "No";
				return 0;
			}
			can_change = 0;
		}
		else if(cur > last)
			can_change = 1;
		last = cur;
	}
	cout << "Yes";
	return 0;
}


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

int main() {
  int a,b;
  cin>>a>>b;
  if(a==b) cout<<a+b<<endl;
  else if(a>b) cout<<a+a-1<<endl;
  else cout<<b+b-1<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(){
  int sm = 0;
  int mn = 100;
  int ans = 0;
  for(int i = 0;4 > i; i++){
    int tmp;cin>>tmp;
    sm += tmp;
    mn = min(mn,tmp);
  }
  ans = sm-mn;
  sm = 0;
  mn = 100;
  for(int i = 0; 2 > i; i++){
    int tmp;cin>>tmp;
    sm += tmp;
    mn = min(mn,tmp);
  }
  cout << ans+sm-mn << endl;
}


Measured memory_bytes: 3076
import bisect
n,m,k = map(int,input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

Sum_A = [0]
Sum_B = [0]
for i in range(n):
    Sum_A.append(Sum_A[-1]+A[i])
for i in range(m):
    Sum_B.append(Sum_B[-1]+B[i])
ans = 0
for i in range(n+1):
    nokori = k-Sum_A[i]
    if nokori<0:
        continue
    index = bisect.bisect_right(Sum_B,nokori)
    ans = max(ans,i+index-1)
print(ans)

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

using namespace std;

#define int long long
int good[61][2];
int mod = 1e9 + 7;

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        for (int j = 0; j <= 60; ++j) {
            if ((x&(1ll << j)) > 0) good[j][0]++;
            else good[j][1]++;
        }
    }
    for (int j = 0; j <= 60; ++j) {
        ans = (ans + (1ll << j) % mod * good[j][0] % mod * good[j][1]) % mod;
    }
    cout << ans;
    return 0;
}



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

int main(){
  int N,K; cin>>N>>K;
  if(K>(N-1)*(N-2)/2){
    cout<<-1<<endl;
    return 0;
  }
  
  set<pair<int,int>> st;
  
  for(int i=2;i<=N;i++){
    st.insert({1,i});
  }
  int cnt=0;
  int v=-1,u=-1;
  for(int i=2;i<=N;i++){
    for(int j=i+1;j<=N;j++){
      if(cnt==K){
        v=i,u=j;
        break;
      }
      cnt++;
    }
    if(v!=-1) break;
  }
  if(v!=-1){
    for(int j=u;j<=N;j++){
      st.insert({v,j});
    }
    for(int i=v+1;i<=N;i++){
      for(int j=i+1;j<=N;j++){
        st.insert({i,j});
      }
    }
  }

  cout<<st.size()<<endl;
  for(auto& p:st){
    cout<<p.first<<" "<<p.second<<endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
uint64_t gcd(uint64_t a, uint64_t b);
uint64_t lcm(uint64_t a, uint64_t b);

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main() {
  uint32_t N;
  cin >> N;
  vector<pair<int32_t, int32_t>> Robots(N);
  for (uint32_t i = 0; i < N; ++i) {
    pair<int32_t, int32_t> tmp;
    cin >> tmp.first >> tmp.second;
    Robots[i] = make_pair(tmp.first + tmp.second, tmp.first - tmp.second);
  }

  sort(Robots.begin(), Robots.end());
  uint32_t ans = 1;
  int32_t cur = Robots[0].first;
  for (uint32_t i = 1; i < N; ++i) {
    if (cur <= Robots[i].second) {
      ans++;
      cur = Robots[i].first;
    }
  }
  cout << ans << endl;

  return 0;
}

uint64_t gcd(uint64_t a, uint64_t b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

uint64_t lcm(uint64_t a, uint64_t b) { return a * b / gcd(a, b); }

Measured memory_bytes: 1024
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List

check1 :: [Integer] -> Bool
check1 (x:xs) = x == 0 && (length . filter (==0)) xs == 0

check2 :: [Integer] -> Bool
check2 [] = True
check2 [_] = True
check2 (x1:x2:xs) = succ x1 == x2 && check2 (x2:xs)

solve :: [Integer] -> Integer
solve [_] = 1
solve (x1:x2:xs) = ((x1^x2) `rem` 998244353) * (solve (x2:xs))

main :: IO ()
main = do
    _ <- getLine
    d <- map (fst . fromJust . BS.readInteger)
        . BS.words <$> BS.getLine :: IO [Integer]
    let d' = group $ sort d
    print $
        if check1 d && check2 (map head d')
            then solve (map (fromIntegral . length) d') `rem` 998244353
            else 0


Measured memory_bytes: 22908
n = gets.to_i
a = gets.split.map(&:to_i)
sum = 0
a.unshift(0)
a << 0
(n+1).times do |i|
  sum += (a[i+1] - a[i]).abs
end
(1..n).each do |i|
  puts sum - (a[i] - a[i-1]).abs - (a[i+1] - a[i]).abs + (a[i+1] - a[i-1]).abs
end

Measured memory_bytes: 12036
fun main(args: Array<String>) {
    abc154c()
}

fun abc154c() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }

    val answer = if (aList.size == aList.distinct().size) "YES" else "NO"

    return println(answer)
}


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

int main()
{
  string S;cin>>S;
  long long B=0,W=0,ans=0;
  for(int i=0;i<S.size();i++)if(S[i]=='W'){ans+=(i-W);W++;}
  printf("%lld",ans);
}

Measured memory_bytes: 3820