akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define fastcin  ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
 
int main(){
 
	fastcin
	
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	
	string v[n];
	
	for(int i=0; i<n; i++) cin >> v[i];
	
	
	bool flag = true;
	char ans[n];
	for(int i=0; i<n; i++){
		string s = v[i];
		
		if(s == "AB"){
			
			if(a == 0 and b == 0){
				flag = false;
				break;
			}
			
			if(a == 1 and b == 1 and c == 0 and i+1 < n){
				if(v[i+1] == "BC"){
					b++;
					a--;
					ans[i] = 'B';
				}
				else if(v[i+1] == "AC" or v[i+1] == "AB"){
					a++;
					b--;
					ans[i] = 'A';
				}
			}
			else if(a <= b){
				a++;
				b--;
				ans[i] = 'A';
			}
			else{
				b++;
				a--;
				ans[i] = 'B';
			}
			
		}
		else if(s == "AC"){
			
			if(a == 0 and c == 0){
				flag = false;
				break;
			}
			
			if(a == 1 and b == 0 and c == 1 and i+1 < n){
				if(v[i+1] == "BC"){
					c++;
					a--;
					ans[i] = 'C';
				}
				else if(v[i+1] == "AC" or v[i+1] == "AB"){
					a++;
					c--;
					ans[i] = 'A';
				}
			}
			else if(a <= c){
				a++;
				c--;
				ans[i] = 'A';
			}
			else{
				c++;
				a--;
				ans[i] = 'C';
			}
		}
		else{
			
			if(b == 0 and c == 0){
				flag = false;
				break;
			}
			
			if(a == 0 and b == 1 and c == 1 and i+1 < n){
				if(v[i+1] == "AB"){
					b++;
					c--;
					ans[i] = 'B';
				}
				else if(v[i+1] == "AC" or v[i+1] == "BC"){
					c++;
					b--;
					ans[i] = 'C';
				}
			}
			else if(b <= c){
				b++;
				c--;
				ans[i] = 'B';
			}
			else{
				c++;
				b--;
				ans[i] = 'C';
			}
		}	
		
		
	}
	
	if(!flag) cout << "No" << endl;
	else{
		cout << "Yes" << endl;
		
		for(int i=0; i<n; i++) cout << ans[i] << endl;
	}
	
	      
	return 0;
}


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

int main(){
    int n;
    long long int h;
    cin>>n>>h;
    long long int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    sort(a,a+n);
    long long int amax = a[n-1];
    sort(b,b+n);
    int count=0;
    long long int damage=0;
    int flag=0;
    while(1){
        long long int add;
        if(count>=0 && count<=n-1){
            add = b[n-1-count];
            if(add<=amax){
                add = amax;
            }
        }else{
            add = amax;
        }
        damage = damage + add;
        count = count + 1;
        if(damage >= h){
            break;
        }
    }
    cout<<count<<endl;
}

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

int H = 0, W = 0;
int main(void){
	while (1){

		cin >> H >> W;
		if (H == 0 && W == 0){ break; }
		for (int i = 0; i < H; i++){

			for (int j = 0; j < W; j++){

				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 1152
using System;
using System.Linq;

namespace ALDS1_2_A {
    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            bool flag = true;
            int count = 0;
            while (flag) {
                flag = false;
                for(int j = n - 1; j > 0; j--) {
                    if (A[j] < A[j - 1]) {
                        int temp = A[j];
                        A[j] = A[j - 1];
                        A[j - 1] = temp;
                        flag = true;
                        count++;
                    }
                }
            }

            Console.Write(A[0]);
            for(int i = 1; i < n; i++) {
                Console.Write(" {0}", A[i]);
            }
            Console.WriteLine("\n{0}",count);
        }
    }
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int sum = 0;
			int count = 1;
			for (int i = 0; i < n; i++) {
				int l = sc.nextInt();
				sum += l;
				if (x < sum) {
					System.out.println(count);
					return;
				}
				count++;
			}

			System.out.println(count);
		}
	}
}


Measured memory_bytes: 23380
// 20:11 - 20:13
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> pint;

const int N = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

int a[N];

int main(){
	ios::sync_with_stdio(0);

	int n; cin >> n;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		a[i] -= i;
	}
	sort(a+1, a+n+1);

	int m = a[(n+1)/2];
	ll ans = 0;
	for(int i=1; i<=n; i++)
		ans += abs(a[i] - m);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = [int(i) for i in input().split()]
flag = True
for i in A:
    if i % 2 == 0:
        if not (i % 3 == 0 or i % 5 == 0):
            flag = False
if flag:
    print("APPROVED")
else:
    print("DENIED")

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


int main(){
  //この問題簡単スギィ
  int n;
  cin>>n;
  vector<int> a(n-1);
  vector<int> x(n+1);
  rep(i,n-1){
    cin>>a.at(i);
    x.at(a.at(i))+=1;
  }
  for(int i=1;i<=n;++i){
    cout<<x.at(i)<<endl;
  }

}


Measured memory_bytes: 4836
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	ll flag = 1;
	ll t = 0;
	ll y = 0;
	ll x = 0;
	rep(i,0,n){
		ll t1,y1,x1;
		cin>>t1>>x1>>y1;
		ll t2 = t1-t;
		ll x2 = abs(x-x1);
		ll y2 = abs(y-y1);
		if(t2%2!=(x2+y2)%2)flag = 0;
		if(t2<x2+y2)flag = 0;
		t = t1;
		y = y1;
		x = x1;
	}
	if(flag==1){
	    cout << "Yes" << endl;
	}
	else{
	    cout << "No" << endl;
	}
	return 0;
}

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

public class Main {
	private final static StringBuilder sortedSeq = new StringBuilder();
	private final static String lb = System.getProperty("line.separator");

	private static int count;
	public static void main(String[] args) throws IOException {
		int[] seq = getSequence();
		shellSort(seq);
		printSequence(seq);
	}

	public static void insertionSort(final int[] seq, final int gap) {
		for (int i = gap; i < seq.length; ++i) {
			final int key = seq[i];
			int j = i - gap;
			while (0 <= j && key < seq[j]) {
				seq[j+gap] = seq[j];
				j = j - gap;
				++count;
			}
			seq[j+gap] = key;
		}
	}

	public static void shellSort(final int[] seq) {
		count = 0;
		
		final int greatestSize = seq.length/3 + 1;
		int gap = 0;
		int sizeOfGaps = 0;
		for (int tmp = 1; tmp <= greatestSize; tmp = 3*gap + 1) {
			gap = tmp;
			++sizeOfGaps;
		}
		sortedSeq.append(sizeOfGaps).append(lb);

		int[] gaps = new int[sizeOfGaps];
		for (int i = 0; i < sizeOfGaps; ++i) {
			gaps[i] = gap;
			sortedSeq.append(gap).append(i < sizeOfGaps-1 ? " " : lb);
			insertionSort(seq, gap);
			
			gap = (gap-1)/3;
		}
		sortedSeq.append(count).append(lb);
	}

	public static void printSequence(final int[] seq) {
		for (int i = 0; i < seq.length; i++) {
			sortedSeq.append(seq[i]).append(lb);
		}
		System.out.print(sortedSeq.toString());
	}

	public static int[] getSequence() throws IOException {
		final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		final int seqLength = Integer.parseInt(reader.readLine());

		final int[] seq = new int[seqLength];
		for (int i = 0; i < seqLength; ++i) {
			seq[i] = Integer.parseInt(reader.readLine());
		}
		reader.close();

		return seq;
	}
}

Measured memory_bytes: 120356
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>

#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]
#define Next(a,i) ((i)+1)%(a).size()
#define Curr(a,i) (i)%(a).size()
#define Prev(a, i) (i+a.size()-1) % a.size()

using namespace std;

int main(void){

  int n,m,x,dp[101][101];
  vector<int>a;

  cin >> n;

  while(n--){
    a.clear();

    for(int i=0;i<101;i++)
      for(int j=0;j<101;j++)dp[i][j]=0;

    cin >> m;
    for(int i=0;i<m;i++){
      cin >> x;
      a.push_back(x);
    }
    
    for(int i=1;i<m;i++){
      for(int j=0;j<m;j++){
	for(int k=0;k<i;k++){
	  dp[Curr(a,j)][Curr(a,i)]=max(dp[j][i],dp[Curr(a,j)][Curr(a,k)]+dp[Next(a,j+k)][Prev(a,i-k)]+abs(curr(a,j)-next(a,j+k))); 
	}
      }
    }
    int ans=0;
    for(int i=0;i<m;i++)
      for(int j=0;j<m;j++)
      ans=max(ans,dp[i][j]);
    
    cout << ans << endl;
    
  }

  return 0;
}

Measured memory_bytes: 1252
#include "bits/stdc++.h"
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
	double x[4], y[4], xp, yp;
	double vx, vy, vpx, vpy;
	double crossZ;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x[0], &y[0], &x[1], &y[1], &x[2], &y[2], &xp, &yp) != EOF)
	{
		bool ans = true;
		bool prev, sign;
		x[3] = x[0]; y[3] = y[0];
		for(int i = 0; i < 3; i++)
		{
			vx = x[i+1] - x[i];
			vy = y[i+1] - y[i];
			vpx = xp - x[i];
			vpy = yp - y[i];
			//printf("%d: vx=%lf vy=%lf vpx=%lf vpy=%lf\n\n",i,vx,vy,vpx,vpy);
			crossZ = vx * vpy - vy * vpx;
			sign = crossZ>0?true:false;
			//printf("cross = %lf\n", crossZ);
			if(i == 0)
			{
				prev = sign;
			}
			else
			{
				if(prev != sign)
				{
					ans = false;
					break;
				}
			}
		}
		cout << (ans?"YES":"NO") << endl;
	}
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	char c; cin >> c;
	if(c-'a'>=0&&c-'a'<=25)
		cout << 'a' << endl;
	else
		cout << 'A' << endl;
	return 0;
}


Measured memory_bytes: 3628
N = int(input())

total = (N + 1) * N // 2

sum3 = N // 3
sum3 = sum3 * (3 + sum3 * 3) // 2
sum5 = N // 5
sum5 = sum5 * (5 + sum5 * 5) // 2
sum15 = N // 15
sum15 = sum15 * (15 + sum15 * 15) // 2

print(total - sum3 - sum5 + sum15)

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

int main()
{
    long long N, A, B, n;
    cin >> N;
    cin >> A;
    cin >> B;
    n = N / (A + B);

    if (N % (A + B) <= A)
    {
        cout << n * A + N % (A + B);
    }
    else
    {
        cout << n * A + A;
    }
    return 0;
}

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

main()
{
  int n,h;
  int ans=0;
  int a_max=0;
  int a,b;

  priority_queue<int>que;
  que.push(0);

  cin >> n >> h;

  for(int i=0;i<n;i++){
    cin >> a >> b;
    a_max=max(a,a_max);
    que.push(b);
  }

  b=que.top();
  que.pop();
  
  while(b>a_max&&(!que.empty())&&h>0){
    ans++;
    h-=b;
    b=que.top();
    que.pop();
  }

  if(h>0){
    int d=h/a_max;
    if(d*a_max<h)
      ans++;
    ans+=d;
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint MOD = 1e9+7;

signed main(){
  lint N, K; cin >> N >> K;
  vector<lint> a(N);
  for(lint i = 0; i < N; i++) cin >> a[i];
  lint p = 0, q = 0, ans = 0;
  for(lint i = 0; i < N- 1; i++){
    for(lint j = i + 1; j < N; j++){
      if(a[i] > a[j]) p++;
    }
  }
  ans += p * K;
  ans %= MOD;
  for(lint i = 0; i < N; i++){
    for(lint j = 0; j < N; j++){
      if(a[i] > a[j]) q++;
    }
  }
  ans += q*((K*(K - 1)/2)%MOD);
  ans %= MOD;
  cout << ans << endl;
}

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

int main(){
  int N;
  long long int MOD = 1e9 + 7;
  
  cin >> N;
  
  long long int a = 1, b = 1, c = 1, ans;
  for(int i = 0;i < N;i++){
    a *= 10;
    a %= MOD;
    b *= 9;
    b %= MOD;
    c *= 8;
    c %= MOD;
  }
  ans = (a - b) % MOD;
  ans = (ans - b) % MOD;
  ans = (ans + c) % MOD;
  ans = (ans + MOD) % MOD;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3580
import heapq


class Dijkstra:

    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) != 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        if self.goal_point is not None:
            return self.get_path(self.goal_point, prev)
        else:
            return dist

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal

        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]

        return list(reversed(path))


if __name__ == '__main__':
    V_n, E_n, s = map(int, input().split())
    route_map = [dict() for _ in range(V_n)]

    for i in range(E_n):
        u, v, a = map(int, input().split())
        u, v = u, v
        route_map[u][v] = a

    # 返回从起点到每个顶点的最短距离的列表
    dijkstra_result = Dijkstra(route_map, s).execute()

    for v in dijkstra_result:
        if v == float('inf'):
            print('INF')
        else:
            print(v)


Measured memory_bytes: 87304
import std.array;
import std.conv;
import std.string;
import std.algorithm;
import std.stdio;

void readPair(T, U)(out T a, out U b) {
	readf("%s %s\n", &a, &b);
}

Num[] readArray(Num)() {
	return readln.chomp.split(' ').map!(to!Num).array;
}

void main() {
	int n, k;
	readPair(n, k);
	auto a = readArray!int;
	a.sort();

	auto dp = new int[](k + 1);
	dp[] = -1;
	foreach (i;0..a[0]) {
		dp[i] = 1; // ターンプレイヤーの敗北
	}
	dp[a[0]] = 0; // ターンプレイヤーの勝利

	while (dp[k] == -1) {
		foreach (e;a) {
			foreach (i;0..k + 1 - e) {
				if (dp[i] == 1) {
					dp[i + e] = 0;
				}
			}
		}

		foreach (i;a[0]..k + 1) {
			if (dp[i] != -1) {
				continue;
			}

			bool allLose = true;
			foreach (e;a) {
				if (i >= e && dp[i - e] == 1) {
					allLose = false;
					break;
				}
			}
			if (allLose) {
				dp[i] = 1;
			}
		}
	}

	if (dp[k] == 0) {
		writeln("First");
	} else {
		writeln("Second");
	}
}


Measured memory_bytes: 3204
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

/* -- template -- */
int main(){
    int N;cin >> N;
    int H[N];rep(i, N)cin >> H[i];
    bool flg = true;
    int maxv = 0;
    rep(i, N - 1){
        maxv = max(maxv, H[i]);
        if(maxv > H[i + 1] + 1)flg = false;
    }
    if(!flg)cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){

    int N,D,X,A;
    cin >> N >>D>>X;
    int cnt=0;
    for (int i=0;i<N;i++){
        cin >> A;
        if(A>D){
            cnt++;
            continue;
        }
       for (int dt=0;dt<D;dt+=A){
           cnt++;
       }

    }
    cout << cnt+X <<endl;
}


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

using namespace std;

int main(){
    long X,a;
    int y=0;
    cin >> X;
    long long P = 100;
    a = 100;
    while(P<X){
            P += P/100;
            y++;
    }
    cout << y << endl;
    return 0;

}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    
    int n;
    cin>>n;
    
    vector<int> h(n);
    for(int i=0; i<n; i++){
        cin>>h[i];
    }
    
    bool bb=true;
    for(int i=n-1; i>=1; i--){
        
        if(h[i-1]>h[i]){
            h[i-1]-=1;
            if(h[i-1]>h[i]){
                bb=false;
                break;
            }
        }
    }
    
    if(bb){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 640
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll s,w;
  cin >> s >> w;
  if(w>=s){
    cout <<"unsafe\n";
  }else{
    cout <<"safe\n";
  }
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(void){
    int m,f,b,a;
    cin >>m>>f>>b;
    a=b-m;
    if(a<=0){
        cout <<"0"<<endl;
    }
    else if(m+f>=b){
        cout <<a<<endl;
    }
    else{
        cout <<"NA"<<endl;
    }
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

const int  MAX = 100;

//ref : gfg
// Function to print Excel column name for a given column number 
void printString(int n) 
{ 
    char str[MAX]; // To store result (Excel column name) 
    int i = 0; // To store current index in str which is result 
  
    while (n > 0) { 
        // Find remainder 
        int rem = n % 26; 
  
        // If remainder is 0, then a 'Z' must be there in output 
        if (rem == 0) { 
            str[i++] = 'z'; 
            n = (n / 26) - 1; 
        } 
        else // If remainder is non-zero 
        { 
            str[i++] = (rem - 1) + 'a'; 
            n = n / 26; 
        } 
    } 
    str[i] = '\0'; 
  
    // Reverse the string and print result 
    reverse(str, str + strlen(str)); 
    cout << str << endl; 
  
    return; 
} 

int32_t main() {                                                                                                                        
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    
    int n; cin >> n;
    printString(n);

}  

Measured memory_bytes: 3648
import math
import fractions

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

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 5 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)



#a = list(map(int, input().split()))

n = int(input())
s = input()
a = []

def is2(n,r):
    if(n == r|(n-r)):
        return 1
    else:
        return 0

non1 = 1
for i in range(n):
    a.append(int(s[i])-1)
    if(a[i]==1):
        non1 = 0
total=0
#print("n",non1)
if(non1==0):
    for i in range(n):
        total += is2(n-1,i)*(a[i]%2)
    print(total%2)
               
else:
    for i in range(n):
        total += is2(n-1,i)*(a[i]//2)
    print((total%2)*2)
        
    






















Measured memory_bytes: 119132
N = int(input())
ds = set()
for d in range(1, N+1):
  if d*d > N:
    break
  if N%d == 0:
    ds.add(d)
    ds.add(N//d)
r = 0
for d in ds:
  m = d-1
  if m == 0:
    continue
  if N%m == N//m:
    r += m
print(r)


Measured memory_bytes: 3828
#include<iostream>
using namespace std;
int road[17][17];
int mem[17][17];
int a,b;
int n;
int solve(int x,int y);
int main(){
  int x,y;
  while(cin>> a>> b){
    if(a==0 && b==0){
      break;
    }
    road[a-1][b-1]=2;
    cin>> n;
    for(int i=0;i<17;i++){
      for(int j=0;j<17;j++){
	road[i][j]=0;
	mem[i][j]=0;
      }
    }
    
    for(int i=0;i<n;i++){
      cin>> x>> y;
      road[x-1][y-1]=1;
    }
    
    int ans;
    ans=solve(0,0);
    
    cout<< ans<< endl;
  }
  return 0;
}

int solve(int x,int y){
  if(road[x][y]==1) return 0;
  if(x>=a || y>=b) return 0;
  if(mem[x][y]>0) return mem[x][y];
  if(x==a-1 && y==b-1) return 1;
  return mem[x][y]=solve(x+1,y) + solve(x,y+1);
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

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

const int64 mod = 1e9+7;

int main(void){
	int32 N, M;
	while(cin >> N >> M && N+M){
		vector<int64> C(M), x(N);
		REP(i, M) cin >> C[i];
		REP(i, N) cin >> x[i];
		vector<int64> dp(300, INF_LL);
		dp[128] = 0;
		REP(i, N){
			vector<int64> dp2(300, INF_LL);
			REP(j, 256){
				REP(k, M){
					int64 nxt = min((int64)255, max((int64)0, j+C[k]));
					chmin(dp2[nxt], dp[j]+(nxt-x[i])*(nxt-x[i]));
				}
			}
			swap(dp, dp2);
		}
		cout << *min_element(all(dp)) << endl;
	}
}


Measured memory_bytes: 3268
n = int(input())
s = input()

res = 0

for i in range(1,n):
    temp =""
    x = s[:i]
    y = s[i:]
    for j in range(i):
        if s[j] in y:
            temp +=s[j]
    res = max(res,len(set(temp)))

print(res)

Measured memory_bytes: 9184
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
s = [0]
n.times do |i|
    s << s[i] + a[i]
end

h = Hash.new(0)
ans = 0

s.each do |i|
    h[i] += 1
end

h.each do |key, value|
    ans += value * (value-1) / 2 if 2 <= value
end
puts ans

Measured memory_bytes: 32644
#include<bits/stdc++.h>
using namespace std;
template<class T>inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}
int n;
const int N=1e5+10;
const int mod=1e9+7;
typedef long long ll;
char S[N];
template<class T>inline void Inc(T&x,int y){x+=y;if(x>=mod) x-=mod;return;}
template<class T>inline void Dec(T&x,int y){x-=y;if(x < 0 ) x+=mod;return;}
int cnt[26];
int main()
{
	init(n);cin>>(S+1);
	for(int i=n;i;--i) ++cnt[S[i]-'a'];
	int ans=1;
	for(int i=0;i<26;++i) {
		ans=(ll)ans*(cnt[i]+1)%mod;
	}
	Dec(ans,1);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

x1,y1,x2,y2=get_i
dx=(x1-x2)
dy=(y1-y2)
x3=x2+dy
y3=y2-dx
x4=x1+dy
y4=y1-dx
puts [x3,y3,x4,y4].join(" ")

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef __int128_t i128;
typedef long long i64;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define FPEN2 freopen("out.txt", "w", stdout);
#else
#define FPEN
#define FPEN2
#endif
#define Sz(a) ((int)(a).size())
const int maxn = 200009;
const int MOD = 998244353;
i64 dp[3333][3333],a[3333];
int main(){
  FPEN;
  ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
  int n,s;
  cin>>n>>s;
  for(int i=1;i<=n;++i)cin>>a[i];
  dp[0][0]=1;
  for(int i=1;i<=n;++i){
    for(int j=0;j<=s;++j){
      dp[i][j]=dp[i-1][j]*2;
      if(j-a[i]>=0)
        dp[i][j]+=dp[i-1][j-a[i]];
      dp[i][j]%=MOD;
    }
  }
  cout<<dp[n][s]<<"\n";
  
  return 0;
}
//2020.05.31 20:37:27


Measured memory_bytes: 81796
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

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

    int res = 0;
    for (int i = 0; i < n; i++) {
        int l,r; cin >>l>>r;
        res += r - l + 1;
    }

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
from functools import reduce
from operator import mul


def end_of_loop():
    raise StopIteration


def main():
    N, K = map(int, input().split())
    print(sum(reduce(mul, (0.5
                           if i << j < K
                           else end_of_loop()
                           for j in range(K)), 1 / N)
              for i in range(1, N + 1)))
    return


main()


Measured memory_bytes: 3572
#include <stdio.h>
#include <stdlib.h>

int solution(int *h, int n, int k)
{
    // A(n) = min_m abs(h(n) - h(n-m)) + A(n-m) for 1 <= m <= k
    int *memo = (int *)malloc(sizeof(int)*n);
    int i, m;
    
    memo[0] = 0;
    for (i = 1; i < n; i++)
    {
        memo[i] = -1;
    }
    
    for (i = 0; i < n-1; i++)
    {
        for (m = 1; m <= k && i+m < n; m++)
        {
            int cost = abs(h[i+m] - h[i]) + memo[i];
            if (memo[i+m] == -1 || cost < memo[i+m])
            {
                memo[i+m] = cost;
            }
        }
    }
    return memo[n-1];
}

int main(int argc, char **argv)
{
  int n, k;
  scanf("%d %d", &n, &k);
  
  int *h = (int *)malloc(sizeof(int)*n);
  int i;
  for (i = 0; i < n; i++)
  {
    scanf("%d", h+i);
  }
  int best = solution(h, n, k);
  printf("%d\n", best);
}

Measured memory_bytes: 896
K, N = map(int, input().split())
A = [int(x) for x in input().split()]

dis = []
for i in range(N):
  if i == 0: dis.append(K-A[-1]+A[0])
  else: dis.append(A[i]-A[i-1])

print(sum(dis) - max(dis))


Measured memory_bytes: 26420
#include<iostream>
#include<string>

int main(){
    int n, ans = 0;

    std::cin >> n;

    for(int a = 1; a <= n; a++){
       if(a >= 1 && a <= 9 || a >= 100 && a <= 999 || a >= 10000 && a <= 99999){
           ans++;
       }
    }
   
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7

N = int(input())

binN = list(map(int, bin(N)[2:]))
dp = [[0] * 3 for _ in range(len(binN) + 1)]
dp[0][0] = 1
for i, Ni in enumerate(binN):
    dp[i + 1][0] += dp[i][0] * 1
    dp[i + 1][1] += dp[i][0] * Ni
    dp[i + 1][0] += dp[i][1] * (1 - Ni)
    dp[i + 1][1] += dp[i][1] * 1
    dp[i + 1][2] += dp[i][1] * (1 + Ni)
    dp[i + 1][2] += dp[i][2] * 3
    dp[i + 1][0] %= MOD
    dp[i + 1][1] %= MOD
    dp[i + 1][2] %= MOD

print(sum(dp[-1]) % MOD)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
#define mp(x,y) make_pair((x),(y))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int N=2e5+5,mod=998244353;
int n,c[2],mxd[N],f[N][3][3],g[3][3];
vector<int> E[N];
inline void inc(int& x,int y){x=x+y<mod?x+y:x+y-mod;}

namespace getcore{
	int d[N],fa[N],stk[N],tp,tmp;
	void dfs(int u,int pa,int dis,int& rt){
		d[u]=dis,fa[u]=pa;if(d[u]>d[rt])rt=u;
		for(int v:E[u]){
			if(v==pa)continue;
			dfs(v,u,dis+1,rt);
		}
	}
	void Main(){
		dfs(1,0,0,tmp);
		dfs(tmp,0,0,tmp);
		while(tmp)stk[++tp]=tmp,tmp=fa[tmp];
		c[0]=stk[(tp+1)>>1];
		if(~tp&1)c[1]=stk[((tp+1)>>1)+1];//想清楚啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
	}
}

int dfs(int u,int pa,int dep){
	mxd[u]=dep;
	for(int v:E[u]){
		if(v==pa||v==c[0]||v==c[1])continue;
		mxd[u]=max(mxd[u],dfs(v,u,dep+1));
	}
	if(mxd[u]==dep)f[u][1][1]=1;
	else f[u][0][0]=1;
	for(int v:E[u]){
		if(v==pa||v==c[0]||v==c[1])continue;
		REP(i,0,2)REP(j,0,2)g[i][j]=0;
		REP(a,0,2)REP(b,0,2)REP(p,0,2)REP(q,0,2){
			int flg=mxd[u]==mxd[v];
			int s=a,t=b,val=1ll*f[u][a][b]*f[v][p][q]%mod;
			inc(g[s][t],val);
			s=flg?min(2,a+p):a,t=b;
			inc(g[s][t],val);
			s=a,t=flg?min(2,b+q):b;
			inc(g[s][t],val);
		}
		REP(i,0,2)REP(j,0,2)f[u][i][j]=g[i][j];
	}
	return mxd[u];
}

int main(){
	// freopen("in.in","r",stdin);
	// freopen("out.out","w",stdout);
	n=read();
	REP(i,1,n-1){
		int u=read(),v=read();
		E[u].pb(v),E[v].pb(u);
	}
	getcore::Main();
	int sum=0;
	dfs(c[0],0,0);
	if(!c[1])
		sum=f[c[0]][1][1];
	else{
		dfs(c[1],0,0);
		REP(i,0,2)REP(j,0,2)
			inc(sum,1ll*f[c[0]][1][i]*f[c[1]][j][1]%mod);
		REP(i,0,2)REP(j,0,2)
			inc(sum,1ll*f[c[0]][i][1]*f[c[1]][1][j]%mod);
	}
	sum=1ll*sum*(mod+1)/2%mod;
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 29696
x, y = [int(x) for x in input().split()]

if ({x, y} & {4, 6, 9, 11} == {x, y}) or ({x, y} & {1, 3, 5, 7, 8, 10, 12} == {x, y}):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000
int ax[N];
int ay[N];
vector<int>xx[N];
vector<int>yy[N];
vector<int>ex[N];
vector<int>ey[N];
int cx[N];
int cy[N];
int kkx;
int kky;
long long ccx;
long long ccy;

void dfsx(int k) {
	cx[k] = kkx;
	ccx++;
	f(i, ex[k].size()) {
		if (cx[ex[k][i]] == -1)dfsx(ex[k][i]);
	}
	return;
}

void dfsy(int k) {
	cy[k] = kky;
	ccy++;
	f(i, ey[k].size()) {
		if (cy[ey[k][i]] == -1)dfsy(ey[k][i]);
	}
	return;
}




int main() {
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	f(i, n) {
		scanf("%d %d", &x, &y);
		xx[y - 1].push_back(x - 1);
		yy[x - 1].push_back(y - 1);
		ax[i] = x - 1;
		ay[i] = y - 1;
	}
	f(i, N) {
		if (xx[i].size() > 1) {
			f(j, xx[i].size() - 1) {
				ex[xx[i][0]].push_back(xx[i][j + 1]);
				ex[xx[i][j+1]].push_back(xx[i][0]);
			}
		}
		if (yy[i].size() > 1) {
			f(j, yy[i].size() - 1) {
				ey[yy[i][0]].push_back(yy[i][j + 1]);
				ey[yy[i][j + 1]].push_back(yy[i][0]);
			}
		}
	}
	f(i, N) {
		cx[i] = -1;
		cy[i] = -1;
	}
	ans = 0;
	kkx = 1;
	kky = 1;
	f(i, n) {
		if (cx[ax[i]] == -1) {
			ccx = 0;
			ccy = 0;
			dfsx(ax[i]);
			dfsy(ay[i]);
			ans += (ccx*ccy);
			kkx++;
			kky++;
		}
	}
	ans -= (long long)n;
	printf("%lld\n", ans);


	return 0;
}


Measured memory_bytes: 29952
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int h, w;
    cin >> h >> w;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--,b--,c--,d--;
    string s[h];
    rep(i,h)cin >> s[i];
    int f[h][w];
    rep(i,h)rep(j,w)f[i][j] = 1001001001;

    f[a][b] = 0;
    priority_queue<P,vector<P>,greater<P>> que;
    que.push(P(f[a][b],a*1000+b));
    while(que.size()>0){
        P p = que.top();
        que.pop();
        int x = p.second / 1000;
        int y = p.second % 1000;
        if(f[x][y] < p.first)continue;
        srep(i,-2,3){
            srep(j,-2,3){
                int nx = x + i;
                int ny = y + j;
                if(nx < 0 || h <= nx || ny < 0 || w <= ny) continue;
                if(s[nx][ny] == '#')continue;
                if(i==0&&j==0)continue;
                if(abs(i)+abs(j)==1){
                    if(f[nx][ny] > f[x][y]){
                        f[nx][ny] = f[x][y];
                        que.push(P(f[nx][ny],nx*1000+ny));
                    }
                }else{
                    if(f[nx][ny] > f[x][y]+1){
                        f[nx][ny] = f[x][y]+1;
                        que.push(P(f[nx][ny],nx*1000+ny));
                    }
                }
            }
        }
    }

    int ans = f[c][d];
    if(ans>1001001)ans = -1;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 9472
import java.util.Scanner;
 
public class Main {
	
	public static void main(String[] args) throws Exception{	
		Scanner sc = new Scanner(System.in);
		
		
		String s = sc.next();
		s = sc.next();
		
		System.out.println("A" + s.substring(0, 1) + "C");
		
		
		
		sc.close();
	}
}

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


int main() {
  int N,r,l;
  int sum=0;
  cin >> N;
  
  for(int i=0;i<N;i++){
  	cin >> l >> r;
    sum += r-l+1;
  }
  cout << sum<< endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

using namespace std;
int main()
{
  int h, w;
  cin >> h >> w;
  int c[10][10];
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      cin >> c[i][j];
  int a[h][w];
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      cin >> a[i][j];

  bool isMin[10] = {};
  isMin[1] = true;
  int mincount = 1;
  while (true)
  {
    int mini = -1, min = 10000;
    for (int i = 0; i < 10; i++)
    {
      if (!isMin[i] && (c[i][1] < min))
      {
        mini = i;
        min = c[i][1];
      }
    }
    isMin[mini] = true;
    mincount++;

    for (int i = 0; i < 10; i++)
    {
      c[i][1] = MIN(c[i][1], c[i][mini] + c[mini][1]);
    }

    if (mincount == 10)
      break;
  }

  int ans = 0;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      if (a[i][j] != -1)
      {
        ans += c[a[i][j]][1];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

const int N = 200000;

s64 fac[N + 1], finv[N + 1];

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

void init()
{
    fac[0] = finv[0] = 1;
    rep (i, N)
    {
        fac[i + 1] = (fac[i] * (i + 1)) % MOD;
    }
    finv[N] = mypow(fac[N], MOD - 2);
    for (int i = N; i > 0; --i)
    {
        finv[i - 1] = (finv[i] * i) % MOD;
    }    
}

s64 com(s64 n, s64 r)
{
    if (n < r || n < 0 || r < 0) return 0;
    return fac[n] * finv[n - r] % MOD * finv[r] % MOD;
}

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

    init();

    s64 n, k;
    cin >> n >> k;
    if (n < k) k = n;

    s64 ans = 0;
    rep (i, k + 1)
    {
        ans = (ans + com(n, i) * com(n - 1, i) % MOD) % MOD;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = Integer.MAX_VALUE;
		int ans = 0;
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if(min >= a) {
				ans++;
				min = a;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 63972
#include <stdio.h>
int main(void){
    int N, X, L[105], i, D[105], c;
    scanf("%d %d", &N, &X);
    D[1]=0; c=0;
    for (i=1; i<=N; i++) {
        scanf("%d", &L[i]);
        D[i+1]=D[i]+L[i];
    }
    for (i=1; i<=N+1; i++) {
        if (D[i]<=X) c++;
    }
    printf("%d", c);
}


Measured memory_bytes: 128
using System;
 
class Program{
	static void Main(){
		int n = int.Parse(Console.ReadLine());
		double L2, ra, rb;
		int ans;

		while(n-- > 0){
			string[] s = Console.ReadLine().Split(' ');
			double[] p = Array.ConvertAll(s, Double.Parse);
			L2 = (p[0] - p[3]) * (p[0] - p[3]) + (p[1] - p[4]) * (p[1] - p[4]);
			ra = p[2];
			rb = p[5];
			
			if(L2 > (ra + rb) * (ra + rb)){
				ans = 0;
			}else if(L2 < (ra - rb) * (ra - rb)){
				if(ra > rb) ans = 2;
				else ans = -2;
			}else ans = 1;
			
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 9176
//edpc_a.cpp
//Sat Jan 12 14:59:23 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

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

	int dp[n+1];
	dp[0] = 0;
	dp[1] = 0;

	for (int i=2;i<n+1;i++){
		int step1 = dp[i-1]+abs(h[i]-h[i-1]);
		int step2;
		if (i>2){
			step2 = dp[i-2]+abs(h[i]-h[i-2]);
		}else{
			step2 = INTINF;
		}
		dp[i] = min(step1,step2);
	}

	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
ans = 0
MOD = 10 ** 9 + 7

for digit in range(60):
    one = np.count_nonzero((A >> digit) & 1)
    ans += (one * (N - one) * pow(2, digit, MOD)) % MOD
    ans %= MOD

print(ans)


Measured memory_bytes: 48824
#include <bits/stdc++.h>
using namespace std;
#define take freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);
#define speed ios_base::sync_with_stdio(false);
#define int long long
#define endl "\n"
#define maxi 10000007
#define rof(i,a,b) for(int i=a;i<b;i++)
int32_t main()
{
    speed
    //take
    string s;
    cin>>s;
    int cost=0;
    for(int i=0;i<s.size();i++)
    {
        cost+=(int)s[i]-'0';
    }
    if(cost%9==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
}

Measured memory_bytes: 3772
# A - Falling Asleep : 2020/01/11
N = int(input())
s = [0 for i in range(N)]
t = [0 for i in range(N)]
for i in range(N):
    l = input().split()
    s[i] = str(l[0])
    t[i] = int(l[1])
X = str(input())
for i in range(N):
    if s[i] == X:
        idx = i + 1
        break
time = 0
for j in range(idx, N):
    time = time + t[j]
print(time)

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

vector<int> num(200001);
vector<int> a(200001);
int main() {
	int n;
	cin >> n;
	long long result = 0;
	for (int i = 0, x; i < n; i++) {
		cin >> x;
		a[i] = x;
		num[x]++;
		result += num[x] - 1;
	}
	for (int i = 0; i < n; i++) {
		cout << result - num[a[i]] + 1 << endl;
	}
}


Measured memory_bytes: 4096
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

i64 N, S;

i64 sum(i64 b, i64 n)
{
	if (b == 1) return -1;
	i64 ret = 0;
	while (n) {
//		printf("%lld %lld\n", b, n);
		ret += n % b;
		n /= b;
	}
	return ret;
}

int main()
{
	scanf("%lld%lld", &N, &S);

	i64 ret = 1LL << 60LL;

	for (i64 b = 2; b <= 4e5; ++b) {
		if (sum(b, N) == S) {
			ret = min(ret, b);
		}
	}
	if (N < S) {
		puts("-1");
		return 0;
	}
	if (N == S) {
		printf("%lld\n", N + 1);
		return 0;
	}
	for (i64 i = 1; i <= 4e5; ++i) {
		if ((N - S) % i == 0) {
			{
				i64 b = i + 1;
				if (sum(b, N) == S) {
					ret = min(ret, b);
				}
			}
			{
				i64 b = (N - S) / i + 1;
				if (sum(b, N) == S) {
					ret = min(ret, b);
				}
			}
		}
	}

	if (ret == 1LL << 60LL) {
		ret = -1;
	}
	printf("%lld\n", ret);
	return 0;
}


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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    string s;
    cin>> s;
    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"ABC"<<endl;
    }
}
    



Measured memory_bytes: 3636
#include<stdio.h>

int main(){
  int i,j;
  int graph[150][150];
  int n,u,k,v;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      graph[u-1][v-1]=1;
    }
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",graph[i][j]);
      if(j<n-1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 660
#include <bits/stdc++.h> 
#define pb push_back
#define mp make_pair 
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
#define f(i, n) for (int i = 0; i < int(n); i++)
#define g(i, n) for (int i = 0; i < int(n-1); i++)
#define fj(j, n) for (int j = 0; j < int(n); j++)
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

// Driver function to sort the vector elements by 
// second element of pair in descending order 
bool sortbysecdesc(const pair<int,int> &a, 
                   const pair<int,int> &b) 
{ 
       return a.second>b.second; 
} 

// Function to return gcd of a and b 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

//Function to return lcm of a and b
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

int32_t main() {
    fio;

    // int t ;
    // cin >> t ;

    // while( t-- ) {
        ll k,p;
        string s;
        
        cin>>k;
        cin>>s;
        p=s.length();
        string a(s);
        if(k>=p)
        cout<<a<<endl;
        else
        {
        s=s.substr(0,k)+"...";
        cout<<s<<endl;
        }
        

    // }

    return 0 ;

}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a,b;
  cin>>a>>b;
  vector<int> c(a);
  rep(i,a)
    cin>>c[i];
  sort(all(c));
  reverse(all(c));
  int d=0;
  if(b<a){
  for(int i=b;i<a;i++){
  d+=c[i];
  }
    cout<<d<<endl;
    }
  else
    cout<<0;
}


Measured memory_bytes: 1792
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    if S[0] != 'A':
        print('WA')
        return

    if S[2 : len(S) - 1].count('C') != 1:
        print('WA')
        return

    if sum(1 for c in S if c.isupper()) != 2:
        print('WA')
        return

    print('AC')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9024
N  = int(input())
num3 = N//3
sum3 = 3*num3*(num3+1)//2
num5 = N//5
sum5 = 5*num5*(num5+1)//2
num15 = N//15
sum15 = 15*num15*(num15+1)//2

_sum = N*(N+1)//2

print(_sum-sum3-sum5+sum15)

Measured memory_bytes: 9180
fun main(args : Array<String>) {
    val (x1, y1, x2, y2) = readLine()!!.split(" ").map { it.toInt() }
    val (dx, dy) = Pair(x2-x1, y2-y1)

    val (x3, y3) = Pair(x2-dy, y2+dx)
    val (x4, y4) = Pair(x1-dy, y1+dx)

    val ans = listOf(x3, y3, x4, y4)
            .map { it.toString() }
            .joinToString(" ")
    println(ans)
}

Measured memory_bytes: 37704
def read_input():
    o = input().strip()
    e = input().strip()

    return o, e

def submit():
    o, e = read_input()

    result = []

    for oc, ec in zip(o, e):
        result.append(oc)
        result.append(ec)

    if len(o) != len(e):
        result.append(o[-1])

    print(''.join(result))

if __name__ == '__main__':
    submit()


Measured memory_bytes: 38512