akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=50005,M=100005,K=256;
int n,m,x[M],y[M],vis[N],to[N];
char ans[M];
void GG(){
	puts("-1"); exit(0);
}
int main(){
	
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read(),m=read(); int T=read();
	double t=clock();
	if(T==1){
		static bitset<N> s[N];
		For(i,1,n)s[i][i]=1;
		For(i,1,m){
			x[i]=read(); y[i]=read();
			s[x[i]]=s[y[i]]=s[x[i]]|s[y[i]];
		}
		For(i,1,n)if(s[i].count()==n){
			vis[i]=1;
			Rep(j,m,1){
				//cout<<x[i]<<" "<<vis[x[i]]<<endl;
				if(vis[x[j]])ans[j]='^'; else ans[j]='v';
				vis[x[j]]=vis[y[j]]=vis[x[j]]|vis[y[j]];
			}
			cout<<(ans+1)<<endl; return 0;
		}	
	}else{
		static bitset<K+2> s[M][K+2];
		For(i,1,m){
			x[i]=read(); y[i]=read();
		}
		For(i,1,n)For(j,i+1,min(n,K))s[0][i][j]=s[0][j][i]=1;
		For(o,0,1000){
			int node=0;
			For(j,0,511)to[j]=0;
			For(j,0,min(255,n-1)){
				int t=rnd()%min(n,500)+1;
				while(to[t])t=rnd()%min(n,500)+1;
				to[t]=++node;
			}
			For(i,1,m){
				memcpy(s[i],s[i-1],sizeof(s[i]));
				int X=to[x[i]],Y=to[y[i]];
				if(to[X]&&to[Y]){
					s[i][Y]=s[i][X]=s[i][Y]|s[i][X];
					For(j,1,K)s[i][j][X]=s[i][j][Y]=s[i][j][X]|s[i][j][Y];
					s[i][X][Y]=s[i][Y][X]=s[i][X][X]=s[i][Y][Y]=0;
				}
			}
			For(X,1,n)For(Y,X+1,min(n,500))if(to[X]&&to[Y]&&s[m][to[X]][to[Y]]){
				Rep(i,m,1){
					if(s[i-1][to[X]][to[Y]]){
						if(X==x[i]||Y==x[i])ans[i]='^';
						else ans[i]='v';
					}else{
						if(X==x[i]||Y==x[i]){
							ans[i]='^';
							if(X==x[i])X=y[i]; else Y=y[i];
						}else{
							ans[i]='v';
							if(X==y[i])X=x[i]; else Y=x[i];
						}
					}
				}
				cout<<(ans+1)<<endl;
				exit(0);
			}
			if((clock()-t)/CLOCKS_PER_SEC>1.6)GG();
		}
	}
	GG();
}

Measured memory_bytes: 1009664
/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define endl '\n'
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

ll n, a[555], mx=-inf, mn=inf, mxi , mni ;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

cin >> n;
rep(i, 1, n){

cin >> a[i];

if(mx<a[i]){
    mx = a[i];
    mxi = i;
}
if(mn>a[i]){
    mn = a[i];
    mni = i;
}

}
cout << 2*n - 1 << endl;
if(abs(mx)>=abs(mn)){

    rep(i, 1, n){
    cout << mxi << " " << i << endl;;
    }
    rep(i, 1, n-1){
    cout << i << " " << i+1 << endl;
    }

}

else {

    rep(i, 1, n){
    cout << mni << " " << i << endl;;
    }
    rep1(i, n, 2){
    cout << i << " " << i-1 << endl;
    }

}







return 0;}
///....


Measured memory_bytes: 256
from itertools import product

s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
L = [a, b, c, d]
kumiawase = list(product([1, 0], repeat=3))

for kumi in kumiawase:
    res = a
    for i in range(3):
        if kumi[i] == 0:
            res += L[i + 1]
        else:
            res -= L[i + 1]
    if res == 7:
        break
ans = s[0]
for i in range(3):
    if kumi[i] == 0:
        ans += "+"
    else:
        ans += "-"
    ans += s[i + 1]
ans += "=7"
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int m;
    cin>>m>>m;
    for(int i=0;i<(m+1)/2;i++)
        cout<<i+1<<' '<<(m+1)/2*2-i<<endl;
    for(int i=0;i<m/2;i++)
        cout<<(m+1)/2*2+1+i<<' '<<m*2+1-i<<endl;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;



signed main(){

	int N;
	cin >> N;
	P red[100], blue[100];
	rep(i, N)
		cin >> red[i].first >> red[i].second;
	rep(i, N)
		cin >> blue[i].first >> blue[i].second;

	sort(blue, blue + N);

	int ans = 0;
	rep(i, N){
		// blue[i].xとペアになれるものの中で、redのy座標最大なものをペアにする
		int max_y = -INF, max_y_idx;
		rep(j, N){
			if (red[j].first < blue[i].first && red[j].second < blue[i].second){
				if (red[j].second > max_y){
					max_y = red[j].second;
					max_y_idx = j;
				}
			}
		}
		if (max_y != -INF){
			red[max_y_idx] = { INF, INF };
			ans++;
		}
	}
	cout << ans << endl;


	return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int n = input[0];
            int a = input[1];
            int b = input[2];
            Console.WriteLine("{0}",
                Math.Min(a * n, b));
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, K, Q;
        cin >> N >> K >> Q;
        vll A(Q);
        rep(i, 0, Q) cin >> A[i];

        unordered_map<ll, ll> mp;
        rep(i, 0, Q) mp[A[i]]++;

        rep(i, 1, N+1) {
                ll ans = K + mp[i] - Q;
                if (ans > 0) {
                        cout << "Yes" << endl;
                } else {
                        cout << "No" << endl;
                }
        }
}

Measured memory_bytes: 8108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 1e4+5;
const int maxn = 1e9+5;
const dd eps = 1e-6;
const ll mod = 1e9+7;
int n;
int main(){
  // freopen("input.txt","r",stdin);
  cin>>n;
  cout<<n*n<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>

using namespace std;

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

	while (cin >> a >> b >> c >> d >> e >> f) {
		double x, y;
		x = (f - (e*c / b)) / (d - (a*e / b));
		y = (c - a * x) / b;

		if (x == 0) {
			x = 0;
		}

		if (y == 0) {
			y = 0;
		}

		printf("%.3f %.3f\n", x, y);
	}
}


Measured memory_bytes: 3204
//author: #theinfiniteboy aka @shaswatkumar362
#include <bits/stdc++.h>

//#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
#define ll long long int
#define bigint int64_t
#define endl '\n'
#define vll vector<ll>
#define it vector<ll>::iterator
#define pb push_back
#define mp make_pair
#define BAYBAY ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define test ll T;cin>>T;while(T--)
#define dbg(x) cout << #x << ":" << x << "\t";
#define deb(t) for(auto x: t) { cout << x << " "; } cout << "\t";
#define maxi(v) *max_element(v.begin(),v.end())
#define mini(v) *min_element(v.begin(), v.end())
#define F first
#define S second
#define fo(i,n) for(i=0;i<n;i++)

/*template<typename... T>
void read(T&...args) {
    ((cin>>args), ...);
}

template<typename... T>
void write(T&&... args) {
    ((cout << args << " "), ...);
}*/

ll fib(ll n) { 
  double phi = (1 + sqrt(5)) / 2; 
  return round(pow(phi, n) / sqrt(5)); 
}

void SieveOfEratosthenes(ll n, vector<ll> &v) 
{  
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        {  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          v.pb(p); 
} 

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    BAYBAY;
    string s;
    cin>>s;
    int n = s[s.length()-1]-'0';
    if (n==3)
    {
    	cout << "bon";
    } else if(n==0 || n==6|| n==1 || n==8)
    {
    	cout << "pon";
    } else cout << "hon";
	return 0;
} // farewell....

Measured memory_bytes: 3564
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>
#include <queue>

using namespace std;

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

	int N, M;
	cin >> N >> M;

	vector<vector<int>> adj(N, vector<int>());

	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;

		adj[a - 1].push_back(b - 1);
		adj[b - 1].push_back(a - 1);
	}

	vector<bool> visited(N, false);
	vector<int> parent(N, -1);

	queue<int> q;
	q.push(0);
	visited[0] = true;
	while (!q.empty())
	{
		int curr = q.front();
		q.pop();

		for (int next : adj[curr])
		{
			if (visited[next]) continue;

			visited[next] = true;
			parent[next] = curr;
			q.push(next);
		}
	}

	cout << "Yes" << "\n";
	for (int i = 1; i < N; i++)
	{
		cout << parent[i] + 1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 10156
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>


int ka[] = {1,1,2,6,24,120,720,5040};

int main(){
   int n,i,j,pp=0,qq=0,po,qo;
   scanf("%d", &n);
   int p[n],q[n],pn[n],qn[n];
   for(i=0;i<n;i++){
   	scanf("%d ", &p[i]);
     pn[i] = i+1;
   }
   for(i=0;i<n;i++){
   	scanf("%d ", &q[i]);
    qn[i] = i+1;
   }
   for(i=0,j=n-1 ; i<n ; i++,j--){
     po = 0; qo =0 ;
     if(i!=0){
      	for(int k=0;k<p[i]-1;k++){
        	if(pn[k]==0){ po++; }
        }
       for(int k=0;k<q[i]-1;k++){
        	if(qn[k]==0){ qo++;}
        }
     }
     //if(i==n-1 && po>0){po--;}
     //if(i==n-1 && qo>0){qo--;}
   	 pp = (p[i]-1-po)*ka[j] + pp;
     qq = (q[i]-1-qo)*ka[j] + qq;
     pn[p[i]-1]=0;
     qn[q[i]-1]=0;
     //printf("%d %d\n",  po,qo);
   }
   printf("%d", abs(qq-pp));
   return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
	int x=600;
	int d,limt,i;
	long a=0,b=0;
	while(scanf("%d",&d)!=EOF){
	    limt=600/d;
	    a=0;
	    for(i=0;i<limt;i++){
	        a+=d*d*i*i*d;
	    }
		printf("%ld\n",a);
	}
	return 0;
}

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

using namespace std;

long long power(int x, int y){
  long long n = 1;
  for(int i = 0; i < y; i++)
    n *= x;
  return n;
}

int log(int x, int y){
  int cnt = 0;
  while(y > 1){
    y /= x;
    cnt++;
  }
  return cnt;
}

int main() {
  long long n;
  cin >> n;
  
  cout << (n-1)*n/2 << endl;
}


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

int gcd(int x, int y){
    if(x<y) swap(x,y);
    if(!y) return x;
    return gcd(y, x%y);
    
}

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


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

int main(){
    string s,t; cin>>s>>t;
    int S=s.size(),T=t.size();
    mat dp(S+1,vec(T+1));
    //初期化
    for(int i=0;i<=T;i++){
        dp[0][i]=0;
    }
    //漸化式
    for(int i=1;i<=S;i++){
        for(int j=1;j<=T;j++){
            dp[i][0]=0;
            if(s[i-1]==t[j-1]) dp[i][j]=1+dp[i-1][j-1];
            else{
                if(dp[i-1][j]>=dp[i][j-1]) dp[i][j]=dp[i-1][j];
                else                       dp[i][j]=dp[i][j-1];
            }
        }
    }
    deque<int> LCS;
    int i=S,j=T;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            LCS.push_front(i-1);
            i--;j--;
        }
        else{
            if(dp[i-1][j]>=dp[i][j-1]) i--;
            else                       j--;
        }
    }
    string ans;
    for(int i=0;i<LCS.size();i++){
        ans+=s[LCS[i]];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long
//cout << fixed << setprecision (10);   小数点以下１０桁まで

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

  s[b-1]=tolower(s[b-1]);
  
  cout << s << endl;
  
  
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String s = stdIn.next();
		
		for(int i = 0; i < s.length(); i++) {
			System.out.print("x");
		}
		
		
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    string S; cin >> S;
    if (S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
INF = int(1e10)
def merge(A, left, mid, right):
    L = A[left: mid] + [[0, INF]]
    R = A[mid: right] + [[0, INF]]
    i = j = 0
    for k in range(left, right):
        if L[i][1] <= R[j][1]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
def partition(A, p, r):
    x = A[r][1]
    i = p - 1
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1
def quicksort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quicksort(A, p, q - 1)
        quicksort(A, q + 1, r)
n = int(input())
f = lambda a: (a[0], int(a[1]))
A = [f(input().split()) for _ in range(n)]
B = A[:]
mergeSort(A, 0, n)
quicksort(B, 0, n - 1)
print("Stable" if A == B else "Not stable")
print(*(f"{a} {b}" for a, b in B), sep="\n")



Measured memory_bytes: 23472
R, G, B, N = tuple(map(int, input().split()))
ans = 0
for i in range(N//R+1):
    for j in range(N//G+1):
        rest = (N - R * i - G * j)
        if rest < 0:
            break
        if rest % B == 0:
            ans += 1
print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  rep(i, n) cin >> a[i] >> b[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int L,R;
  if(n%2==1){
    L = a[n/2];
    R = b[n/2];
    cout<<( R-L+1 )<<endl;
  }else{
    L = a[n/2] + a[n/2-1];
    R = b[n/2] + b[n/2-1];
    cout<<( R-L+1 )<<endl;
  }
}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
#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, M;
    cin >> N >> M;
    vector<int> k(M), p(M);
    vector<vector<int>> s(M);
    for (int i = 0; i < M; i++)
    {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++)
        {
            int x;
            cin >> x;
            --x;
            s[i].push_back(x);
        }
        
    }
    for (int i = 0; i < M; i++)
    {
        cin >> p[i];
    }
    
    int ans = 0;
    for (int bit = 0; bit < (1 << N); bit++)
    {
        vector<int> x(M);
        for (int i = 0; i < N; i++)
        {
            if (bit & (1 << i))
            {
                for (int j = 0; j < M; j++)
                {
                    if (find(s[j].begin(), s[j].end(), i) != s[j].end())
                    {
                        x[j]++;
                    }
                }
            }
        }
        
        bool can = true;
        for (int i = 0; i < M; i++)
        {
            if (x[i] % 2 != p[i])
            {
                can = false;
                break;
            }
            
        }
        if (can)
        {
            ans++;
        }
    }
    cout << ans << endl;
  return 0;
}


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

typedef long long int ll;


int main()
{
	ios::sync_with_stdio(0);
	ll n,i,j,k;
	cin >> n >> k;
	ll a[n];
	for(i=0;i<n;i++)
		cin >> a[i];
	ll dp[n];
	dp[0]=0;
	if(k>=n)
		k=n;
	for(i=1;i<k;i++)
	{
		ll ma=1e18;
		for(j=0;j<i;j++)
		{
			ma = min(ma,dp[j]+abs(a[i]-a[j]));
		}	
		dp[i]=ma;
	}
	for(i=k;i<n;i++)
	{
		ll ma=1e18;
		for(j=1;j<=k;j++)
		{
			ma=min(ma,dp[i-j]+abs(a[i]-a[i-j]));
		}
		dp[i]=ma;
	}
	cout << dp[n-1] << "\n";
	return 0;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return 0;
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void calculate() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};

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

    CumulativeSum cs_w(n), cs_b(n);
    rep(i, n) if (s[i] == '.') cs_w.set(i, 1); else cs_b.set(i, 1);
    cs_w.calculate();
    cs_b.calculate();

    int ans = INT_MAX;
    // 全部黒
    cmin(ans, (int) cs_w.getSum(n - 1));

    for (int i = 0; i < n - 1; i++) {
        // 白の一番右 = i

        int bw = cs_b.getSectionSum(0, i);
        int wb = cs_w.getSectionSum(i + 1, n - 1);

        int now = bw + wb;
        cmin(ans, now);
    }

    // 全部白
    cmin(ans, (int) cs_b.getSum(n - 1));


    cout << ans << endl;

}

Measured memory_bytes: 6916
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++) 
    cin >> a[i] >> b[i] >> c[i];

    int dp[n][3]; 
    dp[0][0] = a[0]; 
    dp[0][1] = b[0]; 
    dp[0][2] = c[0];
    for (int i = 1; i < n; i++) { 
        dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]); 
        dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]); 
        dp[i][2] = c[i] + max(dp[i - 1][1], dp[i - 1][0]);
    }
    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}); 
    return 0;
}


Measured memory_bytes: 5964
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class Main {
  public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		String s = scn.next();
		String x = "ABC";
		int ans = 0;
		for (int i = 0; i + 3 <= n; i++) {
			if (s.substring(i, i + 3).equals(x))
				ans++;
		}
		System.out.println(ans);
  }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

struct xy{
  int x,y;
};

signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int h,w,d;
  xy a[90010];
  cin>>h>>w>>d;
  rep(i,h){
    rep(j,w){
      int num;
      cin>>num;
      a[num].x=i;
      a[num].y=j;
    }
  }
  int cost[90010]={0};
  rep(i,h*w){
    if(i+1+d <= h*w){
      cost[i+1+d]=cost[i+1]+abs(a[i+1].x-a[i+1+d].x)+abs(a[i+1].y-a[i+1+d].y);
    }
  }
  // debug(1);
  int q;
  cin>>q;
  rep(i,q){
    int l,r;
    cin>>l>>r;
    cout<<cost[r]-cost[l]<<endl;
  }
      

  return 0;
}






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

int main(){

    int x,a;
    cin >> x >> a;

    if(x<a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
 * Problem Description: Heaps - Priority Queue
 * Category:
 * Author: Khan
 * Date: 17th October, 2017
 */

#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
#define MAXN 2000000
#define INF (1 << 30)

int H, A[MAXN + 1];

void maxHeapify(int i)
{
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;

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

    if(largest != i)
    {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract()
{
    int maxv;
    if(H < 1)
        return -INF;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key)
{
    if(key < A[i])
        return;
    A[i] = key;
    while(i > 1 && A[i / 2] < A[i])
    {
        swap(A[i], A[i / 2]);
        i /= 2;
    }
}

void insert(int key)
{
    H++;
    A[H] = -INF;
    increaseKey(H, key);
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int key;
    string cmd;
    while(true)
    {
        cin >> cmd;
        if(cmd == "end")
            break;
        if(cmd == "insert")
        {
            cin >> key;
            insert(key);
        }
        else
        {
            cout << extract() << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7084
#include <iostream>
#include <stdio.h>

#define MAX_N 2000
#define MOD 1'000'000'007

typedef long long ll;

using namespace std;

int A[MAX_N];

int main() {
  ll N, K;
  cin >> N >> K;
  for (ll i = 0; i < N; ++i) {
    cin >> A[i];
  }
  ll res = 0;
  for (ll i = 0; i < N - 1; ++i) {
    ll _cnt = 0;
    ll cnt = 0;
    for (ll j = i + 1; j < N; ++j) {
      if (A[i] < A[j]) {
        ++cnt;
      } else if (A[i] > A[j]) {
        ++_cnt;
      }
    }
    res += (cnt * (((K - 1) * K / 2) % MOD) + _cnt * ((K * (K + 1) / 2) % MOD)) % MOD;
  }
  printf("%lld\n", res % MOD);
}

Measured memory_bytes: 3260
#include<stdio.h>
long gcd(long m,long n)
{
    if(n==0)
        return m;
        //printf("%ld %ld\n",n,m%n);
    return gcd(n,m%n);

}

int main()
{
    long  a,b,gCommon,i,j,k,cnt=1;
    scanf("%ld%ld",&a,&b);

    gCommon = gcd(a,b);
    //printf("%ld\n",gCommon);

        for(i=2; gCommon>1 && gCommon>=i*i ; )
        {
            for(j=0; gCommon%i==0; j++)
                gCommon/=i;
                    if(j>0)
                        cnt++;
                    if(i==2)
                        i++;
                    else
                        i+=2;
        }

        if(gCommon>=i)
            cnt++;
        printf("%ld\n",cnt);
        return 0;
}


Measured memory_bytes: 128
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893
                         
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

const double pi = acos(-1.0);

#define filename ""

int n;
int m;

int main () {
//  freopen (filename".in", "r", stdin);
//  freopen (filename".out", "w", stdout);
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    h = h * 60 + m;
    const int H = 12 * 60;
    const int M = 60;

    double ha = (double)h / H * 2 * pi;
    double ma = (double)m / M * 2 * pi;
    double hx = a * cos(ha);
    double hy = a * sin(ha);

    double mx = b * cos(ma);
    double my = b * sin(ma);

    double len = sqrt(sqr(mx - hx) + sqr(my - hy));
    cout << setprecision(20) << fixed << len << endl;
    return 0;
}


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

using namespace std;
#define pb push_back
const int mn=2e5+5;

int n,m;
char s[mn];

int a[mn],b[mn];
bool vis[mn];
vector<int> g[mn];
queue<int> q;

int main() {
    scanf("%d%d",&n,&m);
    scanf("%s",s+1);
    for(int i=1; i<=m; i++) {
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].pb(v);
        g[v].pb(u);
        if (s[u]=='A') a[v]++;
        else b[v]++;
        if (s[v]=='A') a[u]++;
        else b[u]++;
    }

    for(int i=1; i<=n; i++) {
        if (a[i]==0||b[i]==0) q.push(i),vis[i]=1;
    }
    while(!q.empty()) {
        int u=q.front();
        q.pop();
        for(auto &i:g[u]) {
            if (s[u]=='A') {
                a[i]--;
                if (!vis[i]&&a[i]==0) q.push(i),vis[i]=1;
            }
            else {
                b[i]--;
                if (!vis[i]&&b[i]==0) q.push(i),vis[i]=1;
            }
        }
    }
    int ans=0;
    for(int i=1; i<=n; i++)
        if (!vis[i]) ans=1;
    if (ans) puts("Yes");
    else puts("No");

    return 0;
}


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

#define int long long

signed main() {
    vector<string> d;
    for(int i=0; i<2; ++i) {
        string s;
        cin >> s;
        d.push_back(s);
    }
    if(d[0][0]==d[1][2]&&d[0][1]==d[1][1]&&d[0][2]==d[1][0])
        cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int cnt = 0;
            var mondaisuu = int.Parse(Console.ReadLine());
            var mondai = Console.ReadLine().Split().Select(x => int.Parse(x)).OrderBy(x => x).ToList();
            int K = mondai[mondaisuu / 2];
            var arcMondai = mondai.Where(x => x >= K);
            var abcMondai = mondai.Where(x => x < K);
            if (IsCountMatch(arcMondai, abcMondai))
            {
                cnt = arcMondai.Min() - abcMondai.Max();
            }

            Console.WriteLine(cnt);
        }

        private static bool IsCountMatch(IEnumerable<int> mondaiA, IEnumerable<int> mondaiB)
        {
            return mondaiA.Count() == mondaiB.Count();
        }

    }
}

Measured memory_bytes: 21600
#include <bits/stdc++.h>
#define N 100000
using namespace std;
vector<bool> SieveOfEratosthenes(int n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    vector<bool> prime(n+1,true);
    prime[0] = false;
    prime[1] = false;
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }
    return prime;
} 
int main() {
  vector<bool> prime = SieveOfEratosthenes(N);
  int x[N+1], Q, l, r;
  x[0] = 0;
  for (int i = 1; i <= N; i++) {
    x[i] = i%2 && prime[i] && prime[(i+1)/2];
  }
  for (int i = 1; i <= N; i++) {
    x[i] += x[i-1];
  }
  for (cin >> Q; Q; Q--) {
    cin >> l >> r;
    cout << x[r]-x[l-1] << endl;
  }
}

Measured memory_bytes: 4012
#include <iostream>

using namespace std;

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, N, K;
	cin >> N >> K;

	ans = K;
	for (i; i < N-1; i++) ans *= K - 1;

	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

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

static const int MAX = 200000;

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

  int maxv = -2000000000;
  int minv = R[0];

  rep2(i, 1, n) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;
  return 0;
}




Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int n,Max=0;
    cin >> n;
    vector<string > s(n);
    REP(i,n) cin >> s[i];
    map<string,int> m;
    REP(i,n){
       m[s[i]]++;
       int x = m[s[i]];
       Max = max(Max, x);
    }
    for(map<string,int>::iterator i=m.begin(); i != m.end(); ++i){
        if(i->second == Max) cout << i->first << endl;
    }
    
    return 0;
}

Measured memory_bytes: 26752
#include "bits/stdc++.h"
using namespace std;

int main(){
  vector<string> v = {"dream", "dreamer", "erase", "eraser"};
  // テスト用(たまたまはありえず必ずうまくいく)
  //vector<string> v = {"erase", "dreamer", "erased", "eraser", "ream"};
  vector<bool> check(100000);

  string S;
  cin >> S;

  check[0] = 1; // 次に調べる位置に1を代入
  for(int i = 0; i < S.size(); i++){
    if(!check[i])continue;  // 次に調べる位置までスキップ
    for(auto str: v){ // 次に調べる位置すべてに1を代入 
      if(S.substr(i, str.size()) == str){
        check[i + str.size()] = 1;
      }
    }
  }
  if(check[S.size()] == 1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}

Measured memory_bytes: 512
num_lines, max_num = map(int, input().split())

inp_sorted = [[int(st) for st in input().split()] for _ in range(num_lines)]
# print(inp_sorted)
inp_sorted.sort(key=lambda x: x[1], reverse=True)

inp_map = {}
for t, d in inp_sorted:
    if not t in inp_map:
        inp_map[t] = d

variety = set()
score = 0

dup = []
for i in range(max_num):
    t, d = inp_sorted[i]
    if t in variety:
        dup.append((t,d))
    variety.add(t)
    if t in inp_map:
        del inp_map[t]
    score += d

var_value = len(variety)
max_score = score + var_value*var_value

for t, d in sorted(inp_map.items(), key=lambda x: x[1], reverse=True):
    if (len(dup)):
        t2, d2 = dup.pop()
        var_value += 1
        score = score - d2 + d
        max_score = max(max_score, score + var_value*var_value)

print(max_score)


Measured memory_bytes: 33924
public class Main {
public static void main(String[] args){
	
	String[] input = new java.util.Scanner ( System.in ). nextLine().split(" ");
	int a = Integer.parseInt(input[0]);
	int b = Integer.parseInt(input[1]);
	int c = Integer.parseInt(input[2]);
	if (a < b && b < c)
		System.out.println("Yes");
	else
		System.out.println("No");
	
	
	
}
}

Measured memory_bytes: 17256
import java.util.*;

public class Main{
	public static void main(String args[]){
	
		Scanner ob = new Scanner(System.in);
		String str = ob.next();
		
		if(str.charAt(str.length() - 1) == 's'){
			str += "es";
		}else{
			str += 's';
		}

		System.out.println(str);
	}
}


Measured memory_bytes: 38472
S = input()
T = input()
 
ans = 10000
 
for i in range(len(S)-len(T)+1):
    s = S[i:i+len(T)]
    con = 0
    for j in range(len(T)):
        if s[j] != T[j]:
           con += 1
    if con <= ans:
        ans = con
 
print(ans)

Measured memory_bytes: 9124
H, W = map(int, input().split())
G = []
for i in range(H):
    G.append(list(input()))
fd = [[-1, 0], [1, 0], [0, 1], [0, -1]]
for i in range(H-1):
    for j in range(W-1):
        if G[i][j] == '#':
            boo = False
            for x, y in fd:
                if i+y < 0 or i+y >= H:
                    continue
                if j+x < 0 or j+y >= W:
                    continue
                if G[i+y][j+x] == '#':
                    boo = True
            if not boo:
                print('No')
                exit()
print('Yes')

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    static vector<int> edges[100000];
    static int deg[100000], removed[100000];
    for(int i=1;i<n;++i){
        int a, b;
        cin >> a >> b;
        --a; --b;
        edges[a].push_back(b);
        edges[b].push_back(a);
        ++deg[a]; ++deg[b];
    }
    queue<int> leaves;
    for(int i=0;i<n;++i) if(deg[i] == 1) leaves.push(i);
    while(!leaves.empty()){
        int l = leaves.front();
        leaves.pop();
        if(removed[l]) continue;
        int p = -1;
        for(int pc: edges[l]) if(removed[pc] == 0){ p = pc; break; }
        if(p == -1){ cout << "First" << endl; return 0; }
        removed[p] = removed[l] = true;
        for(int v: edges[p]){
            if(removed[v]) continue;
            --deg[v];
            if(deg[v] <= 1) leaves.push(v);
        }
    }
    cout << "Second" << endl;
    
    return 0;
}

Measured memory_bytes: 6784
#include <stdio.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
#define INF (long long int)(9223372036854775807)
#define IINF (int)(2147483647)

int main(void) {
  int n;
  double pi = 3.141592653589;
  scanf("%d", &n);
  printf("%lf\n", n * pi * 2.0);
}


Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
const long long MOD=1e09+7;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vi vector<int>


int main(){
  

  double w,h,x,y;
  
  cin>>w>>h>>x>>y;
  

  if (w/2==x and h/2==y){

    cout<<(w*h)/2<<" "<<1<<endl;
  }
  
  else {
    cout<<(w*h)/2<<" "<<0<<endl;
  }
  
    
  
  
  
      
 

  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n;
    cin >> n;
    vector<vector<ll>> a(2, vector<ll>(n));
    rep(i, 2) { rep(j, n) cin >> a[i][j]; }

    ll ans = 0;
    rep(i, n) {
        ll pri = 0;
        rep(j, i + 1) { pri += a[0][j]; }
        for (ll j = i; j < n; j++) {
            pri += a[1][j];
        }
        chmax(ans, pri);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b,c;
	int m=0;
	cin>>a>>b>>c;
	m=a;a=b;b=m;
	m=a;a=c;c=m;
	cout<<a<<" "<<b<<" "<<c;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=3000000;
int x,y,k;
char a[N],b[N];
void go(int s,int dis){
  for (int i=s+1;i<=s+dis;i++)
    if (a[i]||b[i]){
      a[i]++;b[i]++;
      a[s]=0;b[s]=0;
      int I=i+1,J=i+1;
      if (a[i]==2){
      	while (a[I]){a[I]=0;I++;}
      	a[i]=0;a[I]=1;
	  }
	  if (b[i]==2){
	  	while (b[J]){b[J]=0;J++;}
	  	b[i]=0;b[J]=1;
	  }
	  if (a[I]&b[I]) go(I,dis-i+s);
	  if (a[J]&b[J]) go(J,dis-i+s);
	  return;
    }
  a[s+dis]++;b[s+dis]++;
  a[s]--;b[s]--;
}
int main(){
  scanf("%d%d%d",&x,&y,&k);
  scanf("%s%s",a,b);
  for (int i=0;i<x;i++) a[i]-='0';
  for (int i=0;i<y;i++) b[i]-='0';
  reverse(a,a+x);reverse(b,b+y);
  for (int i=max(x-1,y-1);i>=0;i--) if (a[i]&b[i]) go(i,k);
  int i=N-1;while (!a[i]) i--;i++;while (i--) printf("%d",a[i]);puts("");
  int j=N-1;while (!b[j]) j--;j++;while (j--) printf("%d",b[j]);puts("");
  return 0;
}

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

double len(int x1,int x2, int y1,int y2){
    double res;
    double x=x1-x2;
    double y=y1-y2;
    res=pow(x*x+y*y,0.5);
    return res;
}

int main(){
    int n;
    cin>>n;
    int x[n],y[n];
    double ans=0;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i];
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=len(x[i],x[j],y[i],y[j])*2.0/n;
        }
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4188
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  const Int MAX = 114514;
  vector<Int> c(MAX),d(MAX);
  for(Int i=0;i<n;i++){
    if(i&1) c[a[i]]++;
    else d[a[i]]++;
  }
  Int x=max_element(c.begin(),c.end())-c.begin();
  Int y=max_element(d.begin(),d.end())-d.begin();
  if(x!=y){
    cout<<n-(c[x]+d[y])<<endl;
    return 0;
  }
  Int ans=n;
  {
    Int z=0;
    for(Int i=0;i<MAX;i++){
      if(i==x) continue;
      if(c[z]<c[i]) z=i;    
    }
    chmin(ans,n-(c[z]+d[y]));
  }
  {
    Int z=0;
    for(Int i=0;i<MAX;i++){
      if(i==y) continue;
      if(d[z]<d[i]) z=i;
    }
    chmin(ans,n-(c[x]+d[z]));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  vector<int> A(N); rep(i,N) cin >> A[i];
  int ans = 0;
  rep(i,N){
    if(i%2==1) continue;
    if(A[i]%2==1) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		if (n >= 30) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 32540
#include <iostream>
using namespace std;
#define diff(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))

int main(void){
    int ans, n;
    int *h;
    double total = 0, ave, di, min = 10000;


    scanf("%d", &n);

    h = new int[n];



    for(int i = 0; i < n; i++){
      scanf("%d", &h[i]);
      total += h[i];
      }

    ave = total / n;

    for(int i = 0; i < n; i++){
      di = diff(h[i], ave);

      if(di < min){
        min = di;
        ans = i;
        }

      }

    printf("%d", ans);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int h,w;
int a[26];
int hw1,hw2;

int main(){
	cin>>h>>w;
	REP(i,h)
		REP(j,w){
			char t;
			cin>>t;
			a[t-'a']++;
		}
	
	REP(i,26){
		if(a[i]%4==2)
			hw2++;
		if(a[i]%4==3){
			hw2++;
			hw1++;
		}
		if(a[i]%4==1)
			hw1++;
	}
	if(h%2==0&&w%2==0){
		if(hw1==0&&hw2==0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}else if(h%2==1&&w%2==1){
		if(hw1==1&&hw2<=h/2+w/2)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}else if(h%2==0){
		if(hw1==0&&hw2<=h/2)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}else{
		if(hw2<=w/2&&hw1==0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P=pair<int,int>;

int n;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if (a & 1) {
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
}


Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        String tl[][] = new String[n][2];

        ArrayList<Integer> slist = new ArrayList<>();
        ArrayList<Integer> hlist = new ArrayList<>();
        ArrayList<Integer> clist = new ArrayList<>();
        ArrayList<Integer> dlist = new ArrayList<>();

        if (n <= 52) {
            for (int i = 0; i < n; i++) {
                tl[i][0] = sc.next();
                tl[i][1] = sc.next();
            }

            for (int i = 0; i < n; i++) {
                if ("S".equals(tl[i][0])) {
                    for (int j = 1; j <= 13; j++) {
                        if (tl[i][1].equals(String.valueOf(j))) {
                            slist.add(j);
                        }
                    }
                } else if ("H".equals(tl[i][0])) {
                    for (int j = 1; j <= 13; j++) {
                        if (tl[i][1].equals(String.valueOf(j))) {
                            hlist.add(j);
                        }
                    }
                } else if ("C".equals(tl[i][0])) {
                    for (int j = 1; j <= 13; j++) {
                        if (tl[i][1].equals(String.valueOf(j))) {
                            clist.add(j);
                        }
                    }
                } else if ("D".equals(tl[i][0])) {
                    for (int j = 1; j <= 13; j++) {
                        if (tl[i][1].equals(String.valueOf(j))) {
                            dlist.add(j);
                        }
                    }
                }
            }
            Collections.sort(slist);
            Collections.sort(hlist);
            Collections.sort(clist);
            Collections.sort(dlist);
            
        }
        
        for (int k=1; k<=13; k++) {
            if (slist.indexOf(k) == -1) {
                System.out.println("S "+k);
            } 
        }
        for (int k=1; k<=13; k++) {
            if (hlist.indexOf(k) == -1) {
                System.out.println("H "+k);
            } 
        }
        for (int k=1; k<=13; k++) {
            if (clist.indexOf(k) == -1) {
                System.out.println("C "+k);
            } 
        }
        for (int k=1; k<=13; k++) {
            if (dlist.indexOf(k) == -1) {
                System.out.println("D "+k);
            } 
        }
    }
}

Measured memory_bytes: 26468
from sys import stdin

n = int(stdin.readline().rstrip())

li = [list(stdin.readline().rstrip().split()) for _ in range(n)]

for i in range(len(li)):
    li[i][1] = int(li[i][1])

li2 = sorted(li,key=lambda x:(x[0],x[1]*(-1)))

for s in range(len(li)):
    print(li.index(li2[s])+1)

Measured memory_bytes: 3060