akhauriyash/Code-Regression huggingface dataset:
#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;
  cin >> n;

  int ans = 0;
  int d = 1;
  while(d<=n){
    if(n>=d*10){
      ans += 9*d;
    }else{
      ans += n-(d-1);
    }
    d*=100;
  }
  cout << ans << endl;
}


Measured memory_bytes: 888
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,d = [int(i) for i in readline().split()]
x = [[int(i) for i in readline().split()] for _ in range(n)]

sq = {i*i for i in range(1000)}

ans = 0
for i in range(n):
    for j in range(i+1,n):
        dist = sum((x[i][k] - x[j][k])**2 for k in range(d))
        if dist in sq: ans += 1


print(ans)


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

int main()
{
    int prev[1000] = {};
    int current[1000] = {};
    string in_str;
    while(getline(cin,in_str), in_str != "")
    {
        int c;
        int d;
        sscanf(in_str.c_str(),"%d,%d",&c,&d);
        prev[c - 1]++;
    }
    while(getline(cin,in_str) && in_str != "")
    {
        int c;
        int d;
        sscanf(in_str.c_str(),"%d,%d",&c,&d);
        current[c - 1]++;
    }
    for(unsigned int i = 0; i < 1000; i++)
    {
        if(prev[i] > 0 && current[i] > 0)
        {
            cout << i + 1 << " " << prev[i] + current[i] << endl;
        }
    }
    return 0;
}


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

int main(){
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double x;
  if(h>m/5){
    x=(h-(m/5)+(m/60))*30;
  }else{
    x=((m/5)-h-(m/60))*30;
  }
  double y=cos(x*M_PI/180);
  double z=a*a+b*b-2*a*b*y;
  cout << fixed << setprecision(20);
  cout << sqrt(z) << endl;
}

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

void solve(vector<ll> &a,vector<ll> &dp,vector<ll> &prev){
  int n=a.size();
  for(int i=0;i<n;i++)prev[i]=-1;
  
  for(int i=0;i<n;i++){
    dp[i]=a[i];
    for(int j=i-2;j>=0;j-=2){
      if(dp[i] < dp[j]+a[i]){
        dp[i]=dp[j]+a[i];
        prev[i]=j;
      }
    }
  }
}

int main(){
  int N;
  vector<ll> A;
  cin>>N;
  A.resize(N);
  for(int i=0;i<N;i++)cin>>A[i];

  vector<ll> dp(N),prev(N);
  solve(A,dp,prev);
  ll maxm=-INF;
  int target;
  for(int i=0;i<N;i++){
    if(maxm<dp[i]){
      maxm=dp[i];
      target=i;
    }
  }
  
  vector<int> t;
  set<int> st;
  while(target!=-1){
    t.push_back(target);
    st.insert(target);
    target=prev[target];
  }
  sort(t.begin(),t.end());
  
  vector<int> ans;

  int len=N;
  for(int i=0;i<t[0];i++){
    ans.push_back(1);
    len--;
  }
  
  for(int i=0;i<N-1-t.back();i++){
    ans.push_back(len);
    len--;
  }

  for(int i=0;i+1<t.size();i++){
    int cnt=t[i+1]-t[i]-1;
    while(cnt>1){
      ans.push_back(3);
      cnt-=2;
      len-=2;
    }
    ans.push_back(2);
    len-=2;
  }

  cout<<maxm<<endl;
  cout<<ans.size()<<endl;
  for(int x:ans)cout<<x<<endl;
  return 0;
}


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

void print_hash_line(int n){
    
    for(int i=0;i<n+2;i++)
        cout<<"#";
    cout<<endl;
}

int main()
{
    int m,n;
    char x;
    cin>>m>>n;
    
    print_hash_line(n);
    
    for(int i=0;i<m;i++){
        cout<<'#';
        for(int j=0;j<n;j++){
            cin>>x;
            cout<<x;
        }
        cout<<'#'<<endl;
    }
    
    print_hash_line(n);

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;

  int c = b - a;

  int trueA = 0;
  for(int i=1;i<=c-1;i++){
    trueA += i;
  }

  cout << trueA - a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h,n;
	cin>>h>>n;
	int x,sum=0;
	for(int i =0;i<n;i++)
	{
		cin>>x;
		sum+=x;
	}
	if(sum>=h)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}



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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    string X,Y; cin >> X>>Y;
    //cout << FMT2(X,Y) << endl;
    cout << (X<Y?'<':(X>Y?'>':'=')) << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N,K=map(int,input().split())
A=list(map(int,input().split()))
A_m=[x for x in A if x<0]
A_pz=[x for x in A if x>=0]
A_m.sort()
A_pz.sort(reverse=1)
if N==K:
    ans=1
    for x in A:
        ans*=x
        ans%=MOD
elif not A_pz and K%2==1:
    ans=1
    for x in A_m[::-1][:K]:
        ans*=x
        ans%=MOD
else:
    B=[]
    for i in range(len(A_m)//2):
        B.append(A_m[i*2]*A_m[i*2+1])
    B.sort(reverse=1)
    i,j=0,0
    ans=1
    while i+j*2<=K-2:
        if i<len(A_pz)-1 and j<len(B):
            if A_pz[i]*A_pz[i+1]>B[j]:
                ans*=A_pz[i]*A_pz[i+1]
                i+=2
            else:
                ans*=B[j]
                j+=1
        elif i<len(A_pz)-1:
            ans*=A_pz[i]*A_pz[i+1]
            i+=2
        else:
            ans*=B[j]
            j+=1
        ans%=MOD
    if i+j*2==K-2:
        if i<len(A_pz)-1 and j<len(B):
            ans*=max(A_pz[i]*A_pz[i+1],B[j])
        elif i<len(A_pz)-1:
            ans*=A_pz[i]*A_pz[i+1]
        else:
            ans*=B[j]
    elif i+j*2==K-1:
        if i<len(A_pz):
            ans*=A_pz[i]
        else:
            ans*=A_m[-1]
    ans%=MOD
ans%=MOD
print(ans)

Measured memory_bytes: 111080
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

int main(void){
  int a,b;
  cin>>a>>b;
  if(
    (a<=0 && 0<=b) ||
    (b<=0 && 0<=a) ||
    a==0 || b==0){
    cout<<"Zero"<<endl;
  }else if(a<0){
    cout<<(abs(a-b)%2==1?"Positive":"Negative")<<endl;
  }else{
    cout<<"Positive"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];
        for(int i = 1; i <= n; i++) {
            int num = sc.nextInt();
            a[i] = num;
        }
        int count = 0;
        int[] b = new int[n+1];
        for(int i = n; i >= 1; i--) {
          int sum = 0;
          int j = i + i;
          while(j <= n) {
            sum += b[j];
            j += i;
          }
          if(sum % 2 != a[i]) {
            b[i] = 1;
            count++;
          }
          else b[i] = 0;
        }
        System.out.println(count);
      for(int i = 1; i <= n; i++) {
        if(b[i] == 1) System.out.print(i + " ");
      }
    }
}

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

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int t = Integer.parseInt(sl[1]);
    s = r.readLine();
    sl = s.split(" ");
    int n3 = Integer.parseInt(sl[0]);
    int t3 = Integer.parseInt(sl[1]);

//    for(int i = 0; i < n; i++)
//    {
//      s = r.readLine();
//      sl = s.split(" ");
//      time[i] = Integer.parseInt(sl[0]);
//      deli[i] = Integer.parseInt(sl[1]);
//    }
//
//    int dp[][] = new int[3001][3001];
//
//    for(int i = 1; i <= t; i++)
//    {
//      dp[i][0] = deli[0];
//    }
//
//    for(int j = 0; j <= n; j++)
//    {
//      for(int i = time[j]; i <= t; i++)
//      {
//          dp[i][j] = Math.max(dp[i - time[j]][j - 1] + deli[j], dp[i - 1][j]);
//      }
//    }

    System.out.println(n == n3 ? 0 : 1);

  }

}




class RemRing
{
 long module;
 public RemRing(long module)
 {
   this.module = module;
 }

 public long sum(long a, long b)
 {
   return (a + b + module) % module;
 }

 public long sub(long a, long b)
 {
   return (a - b + module) % module;
 }

 public long prod(long a, long b)
 {
   return (a * b) % module;
 }

 public long div(long a, long b)
 {
   return (a * inv(b)) % module;
 }

 public long inv(long a)
 {
   long b = this.module;
   long u = 1;
   long v = 0;
   while(b > 0)
   {
     long t = a / b;
     a -= t * b;
     u -= t * v;
     long z = a;
     a = b;
     b = z;
     z = u;
     u = v;
     v = z;
   }
   u %= this.module;
   if(u < 0) u += this.module;
   return u;
 }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (long long i = l; i < r; i++)
using namespace std;
typedef pair<int, int> P;

struct edge {
	int to, cost;
};
class dijkstra {
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<P>> que;
	void update(int s, vector<edge> G[]) {
		fill(d, d + V + 1, 100000000000ll);
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first) continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
	}

  public:
	dijkstra(int v, int s, vector<edge> G[]) {
		V = v;
		update(s, G);
	}
	int find(int e) {
		return d[e];
	}
};
int gcd(int a, int b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
bool prime(int a) {
	if (a == 1) return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0) return false;
	}
	return true;
}
class Union_Find {
  private:
	vector<int> t, s;

  public:
	Union_Find(int max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}
	void Union(int x, int y) {
		if (same(x, y)) return;
		int tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}
	int Find(int n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}
	bool same(int x, int y) {
		return Find(x) == Find(y);
	}
	int get_Size(int a) {
		return s[a];
	}
};
signed main() {
	int n,m,a[100000];
	P b[100000];
	cin>>n>>m;
	rep(i,n)cin>>a[i];
	rep(i,m)cin>>b[i].second>>b[i].first;
	sort(a,a+n);
	sort(b,b+m,greater<P>());
	int l=0;
	int ans=0;
	rep(i,m){
		rep(j,b[i].second){
			if(l+j==n){
				l=n;
				goto ioi;
			}
			if(a[j+l]<b[i].first){
				ans+=b[i].first;
			}
			else{
				l+=j;
				goto ioi;
			}
		}
		l+=b[i].second;
	}
	ioi:;
	REP(i,l,n)ans+=a[i];
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
import warnings

#data = map(int, raw_input().split())

r = input()

sq = 1.0 * r *r * 3.14159265358979323846264338327950288419716939937510

l = 2.0 * 3.14159265358979323846264338327950288419716939937510 * r

print "%.30f %.30f" % (sq, l) 

Measured memory_bytes: 4216
package main

import (
	"fmt"
	"strings"
)

func printHash(cnt int) {
	fmt.Println(strings.Repeat("#",cnt))
}

func main() {
	var h,w int
	fmt.Scan(&h,&w)
	
	printHash(w+2)

	for i := 0; i < h; i++ {
		ans,tmp := "#",""
		fmt.Scan(&tmp)
		ans += tmp
		ans += "#"
		fmt.Println(ans)
	}
	
	printHash(w+2)
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 200005;
const ll mod = 1e9 + 7;
int n, k;
ll a[maxn], b[maxn], tot;

ll quickpow(ll a, ll x) {
	ll ret = 1;
	while (x) {
		if (x & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		x >>= 1;
	}
	return ret;
}

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	if (k == n) {
		ll ans = 1;
		for (int i = 1; i <= n; i++) ans = ((ans * a[i]) % mod + mod) % mod;
		printf("%lld\n", ((ans % mod) + mod) % mod);
		return 0;
	}
	sort(a + 1, a + n + 1);
	int fir = 0;
	for (int i = n; i >= 1; i--) {
		if (a[i] < 0) b[++tot] = a[i];
	}
	fir = tot;
	for (int i = n; i >= 1; i--) {
		if (a[i] >= 0) b[++tot] = a[i];
	}
	ll ans = 1;
	if ((fir == n && k & 1) || (fir == 0)) {
		for (int i = 1; i <= k; i++) ans = ((ans * b[i]) % mod + mod) % mod;
		printf("%lld\n", ((ans % mod) + mod) % mod);
		return 0;
	} else if (fir == n && !(k & 1)) {
		for (int i = n - k + 1; i <= n; i++) ans = ((ans * b[i]) % mod + mod) % mod;
		printf("%lld\n", ((ans % mod) + mod) % mod);
		return 0;
	}
	ans = 1; int st = (k & 1) ? fir - k + 2 : fir - k + 1;
	if (st <= 0) {
		if (fir & 1) st = 2;
		else st = 1;
	}
	for (int i = st; i <= st + k - 1; i++) ans = ((ans * b[i]) % mod + mod) % mod;
	for (int i = st + k + 1; i <= n; i += 2) {
		if (b[i - k - 1] * b[i - k] > b[i - 1] * b[i]) break;
		ll inv = quickpow((b[i - k - 1] * b[i - k]) % mod, mod - 2);
		ans = ((((ans * inv) % mod * b[i - 1]) % mod) * b[i]) % mod;
	}
	printf("%lld\n", ((ans % mod) + mod) % mod);
	return 0;
}

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

int A, B, C, D;

int main() {
    cin >> A >> B >> C >> D;
    
    if (A+B < C+D) cout << "Right" << endl;
    else if (A+B == C+D) cout << "Balanced" << endl;
    else cout << "Left" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL A , B , C , D , N;

int main() {
    cin >> A >> B >> C >> D >> N;
    N *= 4;
    LL p = min(min(8 * A , 4 * B) , min(C * 2 , D));
    LL sum = N / 8 * p; N %= 8 ;LL res = 1LL << 60;
    // N < 8
    for (int i = 0 ; i < 10 ; ++ i) {
        for (int j = 0 ; j < 10 ; ++ j) {
            for (int k = 0 ; k < 10 ; ++ k) {
                if (i + j * 2 + k * 4 >= N) {
                    res = min(res , A * i + B * j + C * k);
                }
            }
        }
    }
    cout << res + sum << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import Counter
(n, m), *d = [list(map(int, o.split())) for o in open(0)]
a = n
for _ in [0] * m:
    k = []
    for i in range(n):
        k += d[i][0],
    ind, w = Counter(k).most_common()[0]
    a = min(a, w)
    for j in range(n):
        d[j].remove(ind)
print(a)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define int long long
#define pb       push_back
#define io    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define all(a)      (a).begin(),(a).end()
#define endl        '\n'
#define F    first
#define S second
#define mod 1000000007 
#define N 200005
#define pii pair<int,int>
using namespace std;
int n;
int dp[N][3]; 
vector<int> a(N),b(N),c(N);
void fun(int x)
{
    if(x<=0)
        return ;
    fun(x-1);  
    dp[x][0]+=max(dp[x-1][1],dp[x-1][2]);
    dp[x][1]+=max(dp[x-1][0],dp[x-1][2]);
    dp[x][2]+=max(dp[x-1][1],dp[x-1][0]);
    

}
void solve()
{
    cin>>n;
    
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
        dp[i][0]=a[i];
        dp[i][1]=b[i];
        dp[i][2]=c[i];
    }
    
    fun(n-1);
    cout<<max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2]));
}

signed main(){
    io;
    int t=1;
    //cin>>t;
    while(t--){
      solve();
    }
    return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#define PI 3.14159265359
typedef long long ll;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
using namespace std;


ll llmin(ll x, ll y){
	if (x < y) return x;
	return y;
}

ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}

map<pair<int, int>, int> mp;
vector<pair<int, int> > xb(350000);
vector<pair<int, int> > yb(350000);


int main(){
	int h, w, m;
	cin >> h >> w >> m;
	if (h == 1 || w == 1){
		cout << m << endl;
		return 0;
	}

	for (int i = 0; i <= h; i++){
		xb[i] = make_pair(0, i);
	}
	for (int i = 0; i <= w; i++){
		yb[i] = make_pair(0, i);
	}
	for (int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		xb[x].first++;
		yb[y].first++;
		mp[make_pair(x, y)]++;
	}
	sort(xb.begin(), xb.begin() + h + 1, greater<pair<int, int> >());
	sort(yb.begin(), yb.begin() + w + 1, greater<pair<int, int> >());

	ll xx = 1, yy = 1;
	for (int i = 1; i <= h; i++){
		if (xb[0].first == xb[i].first) xx++;
	}
	for (int i = 1; i <= h; i++){
		if (yb[0].first == yb[i].first) yy++;
	}

	ll prod = xx*yy;

	if (prod > m){
		cout << xb[0].first + yb[0].first << endl;
		return 0;
	}else{
		for (int i = 0; i < xx; i++){
			for (int j = 0; j < yy; j++){
				if (!mp[make_pair(xb[i].second, yb[j].second)]){
					cout << xb[0].first + yb[0].first << endl;
					return 0;
				}
			}
		}
	}
	cout << xb[0].first + yb[0].first - 1 << endl;
	return 0;
}


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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    ll n;
    cin>>n;
    ll i=n;
    int s=0;
    while(i>0){
        s+=i%10;
        i/=10;
    }
    cout<<(n%s==0?"Yes":"No")<<endl;

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long m,n,s=0,a,i;
int main()
{
    cin>>n>>m;
    for (i=1;i<=m;i++)
    {
        cin>>a;
        s+=a;
    }
    if (n-s>=0) cout<<n-s;
    else cout<<"-1";
}


Measured memory_bytes: 3636
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using pint = tuple<int64_t, int64_t>;
using vint = vector<int64_t>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    int a, b, c, d; cin >> a >> b >> c >> d;
    while(a > 0 && c > 0) {
        c -= b;
        if(c <= 0) {
            break;
        }
        a -= d;
    }
    if(a > 0) {
        println("Yes");
    } else {
        println("No");
    }

    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << (a-c)*(b-d);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, std::string S){
    vll  white(N,0), black(N, 0);
    white[0] = ((S[0]=='#')? 1:0);
    for(ll i=1; i< N; i++){
        white[i] = white[i-1]+ ((S[i]=='#')? 1:0);
    }
    black[N-1] = ((S[N-1]=='.')?1:0);
    for(ll i= N-2; i>= 0; i--){
        black[i] = black[i+1]+ ((S[i]=='.')? 1:0);
    }
    ll ans = black[0];
    for(ll i=0; i< N-1; i++){
        ans = min(white[i]+black[i+1], ans);
    }
    ans = min(ans, white[N-1]);
    cout << ans << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 3844
#!/usr/bin/python3
# -*- coding: utf-8 -*-

MAX_K = 5000

ans = -1
tot = -1
rate = -1
F = [False] * MAX_K
G = [False] * MAX_K

if __name__ == "__main__":
    global a, b, c, d, e, f
    a, b, c, d, e, f = map(int, input().split())
    F[0] = True
    G[0] = True
    for i in range(0, f):
        if F[i]:
            if i + a <= f:
                F[i + a] = True
            if i + b <= f:
                F[i + b] = True
        if G[i]:
            if i + c <= f:
                G[i + c] = True
            if i + d <= f:
                G[i + d] = True
    i = 1
    while i * 100 <= f:
        if F[i]:
            j = 0
            while i * 100 + j <= f and j <= i * e:
                if G[j]:
                    r = 100.0 * j / (i * 100.0 + j)
                    if r > rate:
                        rate = r
                        tot = i * 100 + j
                        ans = j
                j += 1
        i += 1
    print(" ".join(map(str, (tot, ans))))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

	ll n, x, m;
	cin >> n >> x >> m;

	vector<ll> v(m+10, 0);
	v[1] = x;
	map<ll, int> mp;
	mp[v[1]] = 1;
	vector<ll> s(m+10, 0);
	s[1] = v[1];
	int l = -1, r = -1;
	for(int i = 2; i <= min(m + 9, n); i++){
		v[i] = v[i-1] * v[i-1];
		v[i] %= m;
		s[i] = s[i-1] + v[i];

		if(mp.count(v[i]) == 1){
			l = mp[v[i]];
			r = i;
			break;
		}

		mp[v[i]] = i;
	}

	if(l == -1){
		cout << s[n] << endl;
		exit(0);
	}else{
		ll ans = s[l-1];
		ll qu = (n - l + 1) / (r - l);

		ll re = (n - l + 1) % (r - l);

		ans += (s[r-1]- s[l-1]) * qu;
		rep(i, re) {
			ans += v[l + i];
		}

		cout << ans << endl;
	}

}


Measured memory_bytes: 7856
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n, m;
    cin >> n >> m;
    if(n == m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int N(0);
    cin >> N;
    
    long long result(0);
    
    for(int i(1); i <= N; ++i)
    {
        if(i % 3 == 0 and i % 5 == 0)
            continue;
        if(i % 3 == 0)
            continue;
        if(i % 5 == 0)
            continue;
        //cout << i << endl;
        result += i;
    }
    
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

int main ()
{
    #ifdef Lollipop
        //freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    string s;
    cin >> s;
    bool flag = false;
    for (auto it : s){
        if (it == '7')  flag = true;
    }
    if (flag)   cout << "Yes\n";
    else    cout << "No\n";
    return 0;
}




Measured memory_bytes: 3620
n=int(input())
a= list(map(int,input().split()))

#for i in a:
#i=0
b=[0]*(10**5+10)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1

print(max(b))

Measured memory_bytes: 52780
import java.util.*;
public class Main {
    static long INF = 1000000000000L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int q = sc.nextInt();
        long[] s = new long[a + 2];
        long[] t = new long[b + 2];
        long[] x = new long[q + 2];
        s[0] = -INF;
        for (int i = 1; i <= a; i++) {
            s[i] = sc.nextLong();
        }
        s[a + 1] = INF;

        t[0] = -INF;
        for (int i = 1; i <= b; i++) {
            t[i] = sc.nextLong();
        }
        t[b + 1] = INF;

        for (int i = 0; i < q; i++) {
            x[i] = sc.nextLong();
        }
        Arrays.sort(s);
        Arrays.sort(t);
        for (int i = 0; i < q; i++) {
            long ok = a + 1;
            long ng = -1;
            while (Math.abs(ok - ng) > 1) {
                long mid = (ok + ng) / 2;
                if (solve(s[(int) mid], x[i])) {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }

            long sb = s[(int) ok];
            long sa = s[(int) ok - 1];
            ok = b + 1;
            ng = -1;
            while (Math.abs(ok - ng) > 1) {
                long mid = (ok + ng) / 2;
                if (solve(t[(int) mid], x[i])) {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }
            long tb = t[(int) ok];
            long ta = t[(int) ok - 1];

            // System.out.println("sa = " + sa);
            // System.out.println("ta = " + ta);
            // System.out.println("sb = " + sb);
            // System.out.println("tb = " + tb);
            long res1 = Math.abs(tb - x[i]) * 2 + Math.abs(sa - x[i]);
            long res2 = Math.abs(sa - x[i]) * 2 + Math.abs(tb - x[i]);
            long res3 = Math.abs(ta - x[i]) * 2 + Math.abs(sb - x[i]);
            long res4 = Math.abs(sb - x[i]) * 2 + Math.abs(ta - x[i]);
            long res5 = Math.abs(ta - x[i]) + Math.abs(sa - ta);
            long res6 = Math.abs(sa - x[i]) + Math.abs(ta - sa);
            long res7 = Math.abs(tb - x[i]) + Math.abs(sb - tb);
            long res8 = Math.abs(sb - x[i]) + Math.abs(tb - sb);
            // System.out.println("res1 = " + res1);
            // System.out.println("res2 = " + res2);
            // System.out.println("res3 = " + res3);
            // System.out.println("res4 = " + res4);
            // System.out.println("res5 = " + res5);
            // System.out.println("res6 = " + res6);
            // System.out.println("res7 = " + res7);
            // System.out.println("res8 = " + res8);
            long ans = Math.min(res1,
                Math.min(res2,
                    Math.min(res3,
                        Math.min(res4, Math.min(res5, Math.min(res6, Math.min(res7, res8)))))));
            System.out.println(ans);
        }
    }
    public static boolean solve(long s, long x) {
        if (s > x) {
            return true;
        }
        return false;
    }
}


Measured memory_bytes: 112884
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main ()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> v;
    for(ll i=0;i<n;i++)
    {
        ll h;
        cin>>h;
        v.push_back(h);
    }
    ll a[n]={0};
    a[n-2]=abs(v[n-2]-v[n-1]);
    for(ll i=n-3;i>=0;i--)
    {ll c=abs(v[i]-v[i+1])+a[i+1];
      for(ll j=1;j<=k;j++)
      {
          if(i+j<=n)
          {
              c=min(c,abs(v[i]-v[i+j])+a[i+j]);
          }
          else break;
      }  
    a[i]=c;
    }
    cout<<a[0]<<endl;
}

Measured memory_bytes: 1908
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
const int INF = 10000000;

int main(){
    int n; cin >> n;
    string s, t; cin >> s >> t;

    rep(i, n){
        cout << s[i];
        cout << t[i];
    }
    cout << endl;
    return 0;
}


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

const int MAX_N = 1e5 + 5;
int n, k;
int Arr[MAX_N];

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> Arr[i];
  sort(Arr, Arr + n);
  k--;
  int ans = 1000 * 1000 * 1000;
  for (int i = 0; i + k < n; i++)
    ans = min(ans, Arr[i + k] - Arr[i]);
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n, x;
  int m[100];

  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> m[i];
  }

  int min = m[0];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    x -= m[i];
    ans++;
    if (min > m[i]) {
      min = m[i];
    }
  }

  while (true) {
    if (x < min) {
      break;
    }
    x -= min;
    ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int input;
    cin >> input;
    long long res = 0;
 
    int fh = 0;
    int five = 0;
 
    if(input >= 500 ) {
        fh = input / 500;
        input -= 500 * fh;
        res += fh * 1000;
    }
    if(input >= 5) {
        five = input / 5;
        res += five * 5;
    }
     cout << res << endl;
}

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


int main()
{
    int min_cost = 1001;
    int N, T;
    int ct[1100][2];

    cin >> N >> T;
    for (int i = 0; i < N; ++i) cin >> ct[i][0] >> ct[i][1];

    for (int j = 0; j < N; ++j) {
        if (ct[j][1] <= T )
            if (min_cost > ct[j][0])
                min_cost = ct[j][0];
    }

    if (min_cost == 1001) cout << "TLE";
    else cout << min_cost;

    return 0;
}

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


bool solve(){
    int n;
    cin >> n;
    if(!n)
        return false;
    vector<vector<pair<int,int>>> edges(n);
    vector<int> p(n), d(n);
    for(int i = 1; i < n; ++i)
        cin >> p[i];
    for(int i = 1; i < n; ++i)
        cin >> d[i];
    for(int i = 1; i < n; ++i){
        int par = p[i] - 1;
        int dist = d[i];
        edges[i].emplace_back(par, dist);
        edges[par].emplace_back(i, dist);
    }

    i64 sum = accumulate(d.begin(), d.end(), 0LL);

    vector<vector<pair<int,int>>> min_edges(n);
    for(int i = 0; i < n; ++i){
        if(edges[i].size() == 1)
            continue;
        for(auto& ed : edges[i]){
            if(edges[ed.first].size() != 1){
                min_edges[i].emplace_back(ed);
                sum += ed.second;
            }
        }
    }

    vector<i64> v(n, INF);
    function<void(int)> f = [&](i64 x){
        for(auto& ed : min_edges[x]){
            if(chmin(v[ed.first], v[x] + ed.second))
                f(ed.first);
        }
    };
    i64 val = 0;
    for(int i = 0; i < n; ++i){
        if(!min_edges[i].empty()){
            v[i] = 0;
            f(i);
            int min_idx = 0;
            i64 mi = 0;
            for(int j = 0; j < n; ++j)
                if(v[j] != INF && chmax(mi, v[j]))
                    min_idx = j;
            v.assign(n, INF);
            v[min_idx] = 0;
            f(min_idx);
            for(int j = 0; j < n; ++j)
                if(v[j] != INF)
                    chmax(val, v[j]);
            break;
        }
    }

    cout << sum - val << endl;

    return true;
}

signed main(){
    while(solve());
}



Measured memory_bytes: 3264
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	string s;
	int n, k;
	cin >> n >> s >> k;
	for(int i=0; i<n; i++){
		if(s[i]!=s[k-1]) cout << "*";
		else cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<ll> l(n);
	rep(i, n) {
		cin >> l[i];
	}
	vector<ll> dp(n + 10, INF);
	dp[0] = 0;
	rep(i, n) {
		ll h1 = l[i];
		repi(j, 1, k + 1) {
			if (i + j < l.size()) chmin(dp[i + j], dp[i] + abs(h1 - l[i + j]));
		}
	}
	cout << dp[n - 1] << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}

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

using namespace std;

typedef long long ll;

const int MX = 200002;
const ll oo = 1000000;

template<typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template<typename T> void read(T &x)
{
	x = 0;
	char c = getchar();
	bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

struct NODE
{
	int id, c0, c1;

	NODE (const int &i0 = 0, const int &x = 0, const int &y = 0) : id(i0), c0(x), c1(y) {}

	bool operator < (const NODE &t) const {return oo*c0*t.c1+id > oo*t.c0*c1+t.id;}
};

struct UNION
{
	int fa[MX];

	UNION (int n = 0) {for(int i=1; i<=n; i++) fa[i] = i;}

	int id(int x)
	{
		return (x==fa[x]) ? (x) : (fa[x]=id(fa[x]));
	}
};

int n, fa[MX], val[MX];
multiset<NODE> que;
int c0[MX], c1[MX], t[MX], nxt[MX];

void input()
{
	read(n);
	for(int i=2; i<=n; i++) read(fa[i]);
	for(int i=1; i<=n; i++) read(val[i]);
}

void work()
{
	UNION ufs(n);
	for(int i=1; i<=n; i++) t[i] = i;
	for(int i=2; i<=n; i++) que.insert(NODE(i, c0[i] = (val[i]==0), c1[i] = (val[i]==1)));
	for(int i=1; i<n; i++)
	{
		NODE tmp = *que.begin();
		//cout<<tmp.id<<" "<<tmp.c0<<" "<<tmp.c1<<endl;
		que.erase(que.begin());
		int f = ufs.id(fa[tmp.id]);
		nxt[t[f]] = tmp.id;
		ufs.fa[tmp.id] = f;
		t[f] = t[tmp.id];
		if(f != 1)
		{
			que.erase(que.find(NODE(f, c0[f], c1[f])));
			c0[f] += c0[tmp.id], c1[f] += c1[tmp.id];
			que.insert(NODE(f, c0[f], c1[f]));
		}
	}
	int x = 1, tot1 = 0;
	ll rev = 0;
	while(x)
	{
		if(val[x] == 0) rev += tot1;
		else tot1++;
		x = nxt[x];
	}
	printf("%lld\n", rev);
}

int main()
{
	input();
	work();
	return 0;
}

Measured memory_bytes: 18176
#include<stdio.h>
#include<string.h>

int main(void)
{
	int i,n;
	int len;
	char s[10000];
	
	scanf("%d%s",&n,s);
	
	len=strlen(s);
	
	for(i=0;i<len;i++){
		s[i]+=n;
		if(s[i]>'Z')
			s[i]=s[i]-26;
	}
	
	printf("%s",s);
	
	return 0;
}
	

Measured memory_bytes: 128
BIG_NUM=10000000
while True:
    n=int(input())
    if n==0:
        break
    else:
        a=sorted(list(map(int,input().split())))
        tmp=BIG_NUM
        for i in range(n-1):
            tmp=min(tmp,a[i+1]-a[i])
        print(tmp)



Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;	
map<int,int>m;
int main(){
	int n;
	ll cnt=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		m[x+i]++; 
		cnt+=m[i-x];
	}
	cout<<cnt<<endl;
} 

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


int dp[1000][1000];
int d[1000][1000];

void main_(istream &cin) {
    int H, W, N;
    while (cin >> H >> W >> N && H) {
        memset(dp, 0, sizeof(dp));
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> d[i][j];
            }
        }
        dp[0][0] = N - 1;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i + 1 < H)
                    dp[i + 1][j] += (dp[i][j] + (d[i][j] == 0)) / 2;
                if (j + 1 < W)
                    dp[i][j + 1] += (dp[i][j] + (d[i][j] == 1)) / 2;

            }
        }
        int w = 0, h = 0;
        while (w < W && h < H) {
            d[h][w] ^= dp[h][w] % 2;
            if (d[h][w]) w++;
            else h++;
        }
        cout << h + 1 << " " << w + 1 << endl;
    }
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}






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

int main() {
  string weathers[4] = {"Sunny", "Cloudy", "Rainy", "Sunny"};
  string S; cin >> S;
  for(int i = 0; i < 4; i++) {
    if(S == weathers[i]) {
      cout << weathers[i+1] << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
N = input()
if len(N) == 1:
    print(N)
elif len(N) == 2:
    print(9)
elif len(N) == 3:
    print(9 + int(N[0])*100 - 100 + int(N[1:]) + 1)
elif len(N) == 4:
    print(9 + 900)
elif len(N) == 5:
    print(9 + 900 + 10000*int(N[0]) - 10000 + int(N[1:]) + 1)
elif len(N) == 6:
    print(9 + 900 + 90000)

Measured memory_bytes: 3064
# Code for C - Traveling Salesman around Lake
# Use input() to fetch data from STDIN
[k, n] = list(map(int, input().split()))
a = list(map(int, input().split()))

s = [k - a[-1] + a[0]]
for i in range(len(a) - 1):
    s.append(a[i + 1] - a[i])

print(k - max(s))


Measured memory_bytes: 26420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(long long i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());
bool prime[10000010];
vint v(10000010);
int main(){
	rep(i,10000010) prime[i]=true;
	prime[0]=prime[1]=false;
	for(ll i=2;i*i<10000010;i++){
		if(prime[i]){
			for(ll j=i*i;j<10000010;j+=i){
				prime[j]=false;
			}
		}
	}
	// rep(i,20){
		// cout<<i<<" "<<prime[i]<<endl;
	// }
	reep(i,13,10000010){
		if(prime[i]&&prime[i-2]&&prime[i-6]&&prime[i-8]){
			v[i]=i;
		}
		else v[i]=v[i-1];
	}
	int n;
	while(cin>>n,n){
		cout<<v[n]<<endl;
	}
}

Measured memory_bytes: 49740
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

template <typename T, int N>
int ArraySize(const T(&)[N]) {
    return N;
}


int main() {
    constexpr double Pi = 3.1415926535;

    long double x {}, y {}, radianAngle {Pi / 2.0};
    
    char c;

    for(int steps, rotate, currentRotation{90}; cin >> steps >> c >> rotate;) {
        if(steps == 0 && rotate == 0) break;


        x += steps * cos(radianAngle);
        y += steps * sin(radianAngle);

        currentRotation += -rotate < 0 ? -rotate : 360 - rotate;
        radianAngle = 2 * Pi * currentRotation / 360;

    }

    

    std::cout << static_cast<int>(x) << '\n' << static_cast<int>(y) << endl;

    return 0;
}

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

int n;
int m[100];
long long dp[100][21];

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>m[i];

	memset(dp,0,sizeof(dp));dp[0][m[0]]=1;
	for(int i=1;i<n-1;i++){
		for(int j=0;j<=20;j++){
			if(j+m[i]<=20) dp[i][j+m[i]]+=dp[i-1][j];
			if(0<=j-m[i]) dp[i][j-m[i]]+=dp[i-1][j];
		}
	}

	cout<<dp[n-2][m[n-1]]<<endl;
	return 0;
}

Measured memory_bytes: 3124
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int counter = 0;
        for (int i = 0; i < 3; i++) {
            if (s.charAt(i) == t.charAt(i)) {
                counter++;
            }
        }
        System.out.println(counter);
        sc.close();
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define vll vector<pll>
#define vl vector<ll>
#define f first
#define s second
#define N 50000
#define pb push_back
#define mp make_pair
#define MAP map<ll,ll>
#define INF 1000000000
#define mod 1000000007
#define foo(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,a,b) for(ll i=(a);i>=(b);i--)
#define sl set<ll> 
#define sll set<pll>
#define ub upper_bound
#define lb lower_bound
using namespace std;

//<<-----Declare Variable Here------->>//
string S;
 
//<<-----Implement Functions Here---->>//
 
 
//<<-----Start of Main--------------->>//
void MAIN(){
	cin>>S;
	if(S[2]==S[3] and S[4]==S[5]) cout<<"Yes\n";
	else cout<<"No\n";

}

int main(){
	fastio;
 	ll t=1;
	//cin>>t;
	while(t--){
		MAIN();
	}
 
    // #ifndef ONLINE_JUDGE
    // cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    // #endif
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str[10];

int main(int argc, char* argv[])
{
    scanf("%s", str);

    int ans=0;
    switch(str[0]) {
    case 'S':
        if(str[1]=='U') ans=7;
        else ans=1;
        break;
    case 'M':
        ans=6;
        break;
    case 'T':
        if(str[1]=='U') ans=5;
        else ans=3;
        break;
    case 'W':
        ans=4;
        break;
    case 'F':
        ans=2;
        break;
    default:
        return 11;
    }

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


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int n;
    scanf("%d", &n);
    vector<string> w(n);
    rep(i, n) cin >> w[i];
    bool ans = true;
    rep(i, n - 1)
    {
        int l = w[i].size();
        if (w[i][l - 1] != w[i + 1][0])
        {
            ans = false;
            break;
        }
    }
    sort(w.begin(), w.end());
    rep(i, n) {
        for(int j = i + 1; j < n; j++) {
            if(w[i] == w[j]) ans = false;
            break;
        }
    }

    if (ans)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
  ll n;
  ll i,j;
  cin>>n;
  ll w[n];
  for(i=0;i<n;i++){
    cin>>w[i];
  }
  ll s=0;
  for(i=0;i<n;i++){
    s+=w[i];
  }
  ll ans=s;
  ll p=w[0];
  ll left=0;
  for(i=0;i<n;i++){
      ans=min(ans,abs(2*left-s));
      p=w[i];
    left+=w[i];
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256