akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=2e5+5;
const int mod=1e9+7;
int n,a[N],ans;

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
	return res;
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+1+n,greater<int>());
	for(int i=1;i<=n;i++) ans=(ans+a[i]*(i+1)%mod)%mod;
	write(ans*fpow(4,n-1)%mod);
}

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

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

  if (a + b == c) cout << "Yes" << endl;
  else if (b + c == a) cout << "Yes" << endl;
  else if (c + a == b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

int main(int argc, char* argv[])
{
    string S; cin >> S;

    string first = S.substr(0, 2), second = S.substr(2, 2);
    int first_num = atoi(first.c_str()), second_num = atoi(second.c_str());
    bool first_month = false, second_month = false;

    if (1 <= first_num && first_num <= 12) {
        first_month = true;
    }

    if (1 <= second_num && second_num <= 12) {
        second_month = true;
    }

    if (first_month && second_month) {
        cout << "AMBIGUOUS" << endl;
    } else if (first_month) {
        cout << "MMYY" << endl;
    } else if (second_month) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import sys


def solve(i, x, y):
    if i == N:
        global max_ans
        max_ans = max(max_ans, x-y)
        return
    solve(i+1, x, y)
    solve(i+1, x+V[i], y+C[i])


sys.setrecursionlimit(2**20)
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
max_ans = 0
solve(0, 0, 0)
print(max_ans)

Measured memory_bytes: 3064
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n:usize,
        mut s:[usize; n],
    }
    s.sort();
    let mut ans = s.iter().sum::<usize>();
    if ans % 10 == 0 {
        for i in s.iter() {
            if i % 10 != 0 {
                ans -= i;
                break;
            }
        }
    }
    if ans % 10 == 0 {
        println!("{}", 0);
    } else {
        println!("{}", ans);
    }
}


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

using namespace std;

typedef long long ll;
int main(){
	int N; cin >> N;
	vector<int> A(N), X(N);
	for(int i = 0; i < N; ++i) cin >> A[i];

	ll sum = 0, sum2 = 0;
	for(int i = 0; i < N; ++i){ sum += A[i]; if(i%2) sum2 += A[i]; }

	// x1
	X[0] = sum - 2*(sum2);
	cout << X[0];
	for(int i = 1; i < N; ++i){
		X[i] = 2*A[i-1] - X[i-1];
		cout << " " << X[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>
using namespace std;
const long long int mod=1000000009;
const long long int INF=1000000000;
const long long int MAX=1000000000;
int main()
{
	long long int n,a,b;
	vector<long long int> h;
	cin>>n>>a>>b;
	h.resize(n);
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	}
 
	long long int up=MAX,low=0;
	long long int mid=0;
 
	while(up-low>1)
	{
		mid=(up+low)/2;
		long long int t=0;
		for(int i=0;i<n;i++)
		{
			long long int x=h[i];
			x-=b*mid;
			if (x>0)
			{
				t+=ceil((double)x/(a-b));
			}
		}
        if(t<=mid)
		{
			up=mid;
		}else
		{
			low=mid;
		}
	}
	cout<<up<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		String S = in.next();
		StringBuilder sb = new StringBuilder();
		sb.append(S);
		if (!S.equals(sb.reverse().toString())) {
			System.out.println("No");
			return;
		}

		String s1 = S.substring(0,(S.length()-1)/2);
		sb = new StringBuilder();
		sb.append(s1);
		if (!s1.equals(sb.reverse().toString())) {
			System.out.println("No");
			return;
		}

		int idx1 = (S.length()+3)/2-1;
		int idx2 = S.length()-1;
		if(idx2 < idx1) {
			idx2 = idx1;
			idx1 = S.length()-1;
		}
		String s2 = S.substring((S.length()+3)/2-1, S.length());
		sb = new StringBuilder();
		sb.append(s2);
		if (!s2.equals(sb.reverse().toString())) {
			System.out.println("No");
			return;
		}

		System.out.println("Yes");
	}


	public static class MyScanner {
		Scanner sc = new Scanner(System.in);
		String next() { return sc.next();}
		int nextInt() { return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next()); }
	}
}

Measured memory_bytes: 23636
package main

import (
	"fmt"
)

func main() {
	var n int
	var s, t string
	fmt.Scanf("%d", &n)
	fmt.Scanf("%s %s", &s, &t)
	ans := ""
	for i := 0; i < n; i++ {
		ans = ans + string(s[i]) + string(t[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
//#define NUM 50

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)

int main(){
	string s;
	cin>>s;
	long long hoge;
	cin>>hoge;
	lp(i,hoge){
		if(s[i]!='1') {cout<<s[i]<<endl;break;}
		if(i==hoge-1) cout<<1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	while(true){
    		int a = in.nextInt();
    		String op = in.next();
    		int b = in.nextInt();
    		if(op.equals("/")){
    			System.out.println(a / b);
    		}else if(op.equals("*")){
    			System.out.println(a * b);
    		}else if(op.equals("-")){
    			System.out.println(a - b);
    		}else if(op.equals("+")){
    			System.out.println(a + b);
    		}else if(op.equals("?")){
    			break;
    		}
    	}
	}
}

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

double x1, x2, x3, x4, y1, y2, y3, y4;

bool check1(double x, double y)
{
	return x1<=x && x<=x2 && y1<=y && y<=y2;
}

bool check2(double x, double y)
{
	return x3<=x && x<=x4 && y3<=y && y<=y4;
}

int main()
{
	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4)
	{
		if (check1(x3, y3) || check1(x3, y4) || check1(x4, y3) || check1(x4, y4)
		||  check2(x1, y1) || check2(x1, y2) || check2(x2, y1) || check2(x2, y2)
		|| (x1 <= x3 && x4 <= x2 && y3 <= y1 && y2 <= y4) || (x3 <= x1 && x2 <= x4 && y1 <= y3 && y4 <= y2))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

struct Node {
  int key = INT_MIN;
  int parent = INT_MIN;
  int left = INT_MIN;
  int right = INT_MIN;
};

int main() {
  int n;
  cin >> n;
  vector<Node> nodes(n);
  FOR(i, 0, n) {
    cin >> nodes[i].key;
    int parent_id = (i + 1) / 2 - 1;
    if (parent_id >= 0) {
      nodes[i].parent = nodes[parent_id].key;
      bool is_parent_left = (i % 2 == 1);
      if (is_parent_left) {
        nodes[parent_id].left = nodes[i].key;
      } else {
        nodes[parent_id].right = nodes[i].key;
      }
    }
  }
  FOR(i, 0, n) {
    cout << "node " << (i + 1) << ": key = " << nodes[i].key << ", ";
    if (nodes[i].parent != INT_MIN) {
      cout << "parent key = " << nodes[i].parent << ", ";
    }
    if (nodes[i].left != INT_MIN) {
      cout << "left key = " << nodes[i].left << ", ";
    }
    if (nodes[i].right != INT_MIN) {
      cout << "right key = " << nodes[i].right << ", ";
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3096
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
    int n;
    int count = 0;
    string str,str1;
    char str_[110];
    char str1_[220];

    cin >> str;

    for(int i = 0;; i++){
        if(str[i] != '\0'){
            str_[i] = str[i];
        }
        else{
            str_[i] = '\0';
            break;
        }
    }
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> str1;
        str1 = str1 + str1;
        for(int j = 0;; j++){
            if(str1[j] != '\0'){
                str1_[j] = str1[j];
            }
            else{
                str1_[j] = '\0';
                break;
            }
        }
        if(strstr(str1_,str_) != '\0') count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1216
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e18;

int main(){
    ll n;
    cin >> n;
    vector<ll> ans;
    for(ll i=1;5*i+1<=55555;i++){
        ll v=5*i+1;
        for(ll j=2;j*j<=v;j++){
            if(v%j==0){
                v/=j;
                break;
            }
        }
        if(v==5*i+1){
            ans.push_back(5*i+1);
        }
    }
    rep(i,n){
        if(i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
} 

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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if( (a+b)%2 == 0){
    cout << (a+b)/2 << endl;
  }
  else if( (a+b)%2 != 0){
    cout << (a+b)/2 + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e5+17;
const int MOD = 1e9+7;
LL dp[MAXN][2],a[MAXN];
int main(int argc ,char const *argv[])
{
	#ifdef noob
	freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
	#endif	
	int n;
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	dp[0][0] = a[0]/2;
	dp[0][1] = (a[0]-1)/2;
	debug(dp[0][0]);
	debug(dp[0][1]);
	for (int i = 1; i < n; ++i)
	{
		dp[i][0] = a[i]/2+dp[i-1][0];
		if(a[i]>0&&dp[i-1][1]) dp[i][0] = max(((a[i]-1)/2)+dp[i-1][1]+1,a[i]/2+dp[i-1][0]);
		// dp[i][1] = max((a[i]-1)/2+dp[i-1][0],(a[i]-2)/2+dp[i-1][1]+1);
		if(a[i]>0) dp[i][1] = max(dp[i-1][1],dp[i-1][0]);
		if(a[i]>0) dp[i][1] = max((a[i]-1)/2+dp[i-1][0],dp[i][1]);
		if(a[i]>1) dp[i][1] = max((a[i]-2)/2+dp[i-1][1]+1,dp[i][1]);
		// debug(i);
		// debug(dp[i][0]);
		// debug(dp[i][1]);
	}
	cout<<max(dp[n-1][0],dp[n-1][1])<<endl;
	return 0;	
}

Measured memory_bytes: 2560
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        String[] a = new String[N];
        String[] b = new String[M];
        for(int i = 0;i < N;i++){
            a[i] = sc.next();
        }
        for(int i = 0;i < M;i++){
            b[i] = sc.next();
        }
        boolean exit = false;
        for(int i = 0;i <= N-M;i++){
            for(int j = 0;j <= N-M;j++){
                boolean can = true;
                for(int k = 0;k < M;k++){
                    for(int l = 0;l < M;l++){
                        if(a[i + k].charAt(j+l) != b[k].charAt(l)){
                            can = false;
                        }
                    }
                }
                if(can){
                    exit = true;
                    break;
                }
            }
        }
        if(exit){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23380
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 100005;

int n,a[maxn];
void No() {puts("No");exit(0);}
void Yes() {puts("Yes");exit(0);}
int main()
{
	#ifdef Amberframe
		freopen("agc016b.in","r",stdin);
		freopen("agc016b.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	
	int mx=a[1],mi=a[1];
	for (int i=1;i<=n;i++)
		mx=max(mx,a[i]),mi=min(mi,a[i]);
	if (mx>mi+1) No();
	if (mx==mi) {
		if (mi<1) No();
		if (mi==n-1) Yes();
		if (mi<=n/2) Yes();else No();
	}
	else {
		int cmi=0,cmx=0;
		for (int i=1;i<=n;i++)
			a[i]==mi?cmi++:cmx++;
		if (mx-cmi<1) No();
		if (mx-cmi<=(n-cmi)/2) Yes();else No();
	}
	return 0;
}

Measured memory_bytes: 640
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return read.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint, m = rint;
	int[][] af = rint(n, m);
	foreach(i; 0 .. n) foreach(j; 0 .. m) af[i][j] -= 1;
	log("n:", n, "m:", m, "af:", af);
	
	int best = n;
	bool[] isAlive = new bool[](m);
	foreach(k; 0 .. m) isAlive[k] = 1;
	log("best:", n, "isAlive:", isAlive);
	while(1){
		int[] count = new int[](m);
		foreach(i; 0 .. n) foreach(j; 0 .. m){
			int k = af[i][j];
			if(isAlive[k]){
				count[k] += 1;
				break;
			}
		}
		log("count:", count);
		
		int temp = 0;
		foreach(k, cnt; count){
			temp = max(temp, cnt);
		}
		best = min(best, temp);
		log("temp:", temp, "best:", best);
		
		foreach(k; 0 .. m){
			if(count[k] >= best) isAlive[k] = 0;
		}
		log("isAlive:", isAlive);
		
		int alivecount;
		foreach(k; 0 .. m) if(isAlive[k]) alivecount += 1;
		log("alivecount:", alivecount);
		if(alivecount == 0) break;
	}
	best.writeln;
}


Measured memory_bytes: 6908
#include<map>
#include<string>
#include<iostream>

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

using namespace std;

struct cube{
	int a[6];
	cube(){ rep(i,6) a[i]=i; }
	void rotx(){
		int tmp=a[0];
		a[0]=a[2];
		a[2]=a[5];
		a[5]=a[4];
		a[4]=tmp;
	}
	void roty(){
		int tmp=a[0];
		a[0]=a[1];
		a[1]=a[5];
		a[5]=a[3];
		a[3]=tmp;
	}
	void rotz(){
		int tmp=a[1];
		a[1]=a[2];
		a[2]=a[3];
		a[3]=a[4];
		a[4]=tmp;
	}
};

int dfs(int i,int n,cube C[4],const string color[4][6]){
	if(i==n-1){
		int res=0;
		rep(j,6){
			int cntmax=0;
			map<string,int> f;
			rep(k,n) cntmax=max(cntmax,++f[color[k][C[k].a[j]]]);
			res+=n-cntmax;
		}
		return res;
	}

	int res=6*n;
	rep(s,6){
		rep(t,4){
			res=min(res,dfs(i+1,n,C,color));
			C[i].rotz();
		}
		if(s&1) C[i].rotx();
		else    C[i].roty();
	}
	return res;
}

int main(){
	for(int n;cin>>n,n;){
		string color[4][6];
		rep(i,n){
			cin>>color[i][2];
			cin>>color[i][3];
			cin>>color[i][0];
			cin>>color[i][5];
			cin>>color[i][1];
			cin>>color[i][4];
		}

		cube C[4];
		cout<<dfs(0,n,C,color)<<endl;
	}

	return 0;
}

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

#define N 101
#define INF -1

int Q[N];
int head,tail;
int M[N][N] = {{}};
int d[N];
int n;
char color[N];

void enqueue(int key) {
	Q[tail] = key;
	if (tail == N-1) {
		tail = 0;
	}
	else {
		tail++;
	}
}

int dequeue() {
	int x;
	x = Q[head];
	if (head == N-1) {
		head = 0;
	}
	else {
		head++;
	}
	return x;
}

void bfs (int s) {
	int i,u;
	for(i=1;i<=n;i++) {
		d[i] = INF;
		color[i] = 'W';
	}

	color[s] = 'G';
	d[s] = 0;
	enqueue(s);
	while(head != tail) {
		u = dequeue();
		for (i=1;i<=n;i++) {
			if (M[u][i] == 1 && color[i] == 'W') {
			color[i] = 'G';
			d[i] = d[u] + 1;
			enqueue(i);
			}
		}
	color[u] = 'B';
	}
}

int main() {
	int i,j;
	int u,k,v;

	scanf("%d", &n);
	for (i=1;i<=n;i++) {
		scanf("%d%d",&u,&k);
		for (j=1;j<=k;j++) {
			scanf("%d",&v);
			M[u][v] = 1;
		}
	}

	bfs(1);

	for (i=1;i<=n;i++) {
		printf("%d %d\n",i,d[i]);
	}
	return 0;
}

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

int main(){
  int N; cin >> N;
  int ans = 0;
  for(int i=1;i<=N;i++){
    int keta = 0;
    int now = i;
    while(now>0){
      now /= 10;
      keta++;
    }
    if(keta %2 == 1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline


def main():
    N, Q = map(int, input().split())
    adj = [set() for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        adj[a-1].add(b-1)
        adj[b-1].add(a-1)
    cnt = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        cnt[p-1] += x
    ans = [0] * N
    q = deque([(0, 0, -1)])
    while len(q):
        cur, total, prev = q.popleft()
        total += cnt[cur]
        ans[cur] = total
        for a in adj[cur]:
            if a == prev:
                continue
            q.append((a, total, cur))
    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 121292
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, d[112345];
    cin >> n;
    REP(i, n)
    cin >> d[i];
    sort(d, d + n);

    int midm = d[n / 2 - 1];
    int midp = d[n / 2];

    cout << midp - midm << endl;

    return 0;
}

Measured memory_bytes: 640
#include <math.h>

#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int sum_(vector<int> v, int start, int end) {
  int num = 0;
  for (int i = start; i < end; i++) {
    num += v[i];
  }

  return num;
}

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

  vector<int> W;

  rep(i, N) {
    int a;
    cin >> a;
    W.push_back(a);
  }

  int ans = 100;
  rep(i, N) {
    int b_1 = accumulate(W.begin(), W.end() - (N - i), 0);
    int b_2 = accumulate(W.begin() + i, W.end(), 0);
    int ans_a = b_1 - b_2;
    ans = min(ans, abs(ans_a));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
s = []
r, g, b = [0] * 3
for c in input():
    if c == 'R':
        s.append(0)
        r += 1
    elif c == 'G':
        s.append(1)
        g += 1
    else:
        s.append(2)
        b += 1

c = r * g * b
for i in range(n):
    for j in range(i + 1, n):
        k = j + (j - i)
        if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            c -= 1

print(c)

Measured memory_bytes: 9240
import java.util.*;
public class Main {
    public static long mini(int a[],int []b,int[] c,int n)
    {
       int dp[][]=new int[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]+Math.max(dp[i-1][1],dp[i-1][2]);
           dp[i][1]=b[i]+Math.max(dp[i-1][0],dp[i-1][2]);
           dp[i][2]=c[i]+Math.max(dp[i-1][1],dp[i-1][0]);
       }
       return Math.max(dp[n-1][0],Math.max(dp[n-1][1],dp[n-1][2]));
    }
    public static void main(String args[]) {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int a[]=new int[n];
        int b[]=new int[n];
        int c[]=new int[n];
        for(int i=0;i<n;i++)
        {
            a[i]=s.nextInt();
            b[i]=s.nextInt();
            c[i]=s.nextInt();
        }
        System.out.println(mini(a,b,c,n));
    }
}

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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)

template<typename T, typename U>bool maxup(T& a, U&& b) { if (a < b) { a = b; return true; }; }
template<typename T, typename U>bool minup(T& a, U&& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	string w; cin >> w;
	map<char, int> mp;
	for (char c : w) mp[c]++;
	bool ok = true;
	for (P p : mp) ok = ok && p.second % 2 == 0;
	cout << (ok ? "Yes" : "No") << endl;
	system("pause");
}

Measured memory_bytes: 504
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	c, _ := strconv.Atoi(fmt.Sprintf("%d%d", a, b))

	for i := 0; i < c; i++ {
		if i*i == c {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main() {
    int n;
    cin >> n;
    vector<tuple<string, int, int>> restaurants(n);
    rep(i, n) {
        string s;
        int p;
        cin >> s >> p;
        restaurants[i] = make_tuple(s, -p, i + 1);
    }
    sort(restaurants.begin(), restaurants.end());
    rep(i, n) cout << get<2>(restaurants[i]) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define GODSPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;
inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){return (a%mod * b%mod)%mod;}
inline int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
int dp[51][51][3000];
signed main()
{
     GODSPEED;
     int n,a;
     cin>>n>>a;
     vi v(n);
     in(v,n);
     for(int i=0;i<=n;i++)
      dp[i][0][0]=1;
     for(int i=1;i<=n;i++)
     {
          for(int size=1;size<=n;size++)
          {
               for(int sum=0;sum<=2500;sum++)
               {
                     if(sum>=v[i-1])
                     {
                         dp[i][size][sum]+=dp[i-1][size-1][sum-v[i-1]];
                     }
                     dp[i][size][sum]+=dp[i-1][size][sum];
               }
          }
    }
    int res=0;
    for(int i=1;i<=n;i++)
    {
         res+=dp[n][i][i*a];
    }
    cout<<res<<endl;
}


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

int main() {
  string str;
  cin >> str;

  int count = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == '1') {
      count++;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 3624
#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, k;
    cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; i++) {
      double l = (double)1/n;
      if (i >= k) {
        ans += l;
        continue;
      }
      int is = i;
      while (is < k) {
        is *= 2;
        l *= 0.5;
      }
      ans += l;
    }
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 3716
/*Lucky_Glass*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=5000,M=200;

int n,m;
int rB[N+3][M+3][14],Log2[N+3];
long long rA[N+3];

inline int QRead(){
	register int resu=0;register char ch=getchar();
	while(ch<'0' || '9'<ch) ch=getchar();
	while('0'<=ch && ch<='9')
		resu=(resu<<1)+(resu<<3)+ch-'0',
		ch=getchar();
	return resu;
}
long long Calc(int l,int r){
	long long resu=0;
	int len=(int)Log2[r-l+1];
	for(int j=1;j<=m;j++){
		resu+=max(rB[l][j][len],rB[r-(1<<len)+1][j][len]);
	}
	return resu;
}
long long Solve(int il,int ir,int kl,int kr){
	if(il>ir) return -1;
	int i=(il+ir)>>1,tra=0;
	long long resu=0;
	for(int k=kl;k<=kr && k<=i;k++){
		long long now=Calc(k,i)-(rA[i-1]-rA[k-1]);
		if(now>resu){
			resu=now;
			tra=k;
		}
	}
	return max(resu,max(Solve(il,i-1,kl,tra),Solve(i+1,ir,tra,kr)));
}
int main(){
	// freopen("restaurants.in","r",stdin);
	// freopen("restaurants.out","w",stdout);
	n=QRead();m=QRead();
	for(int i=1;i<n;i++) rA[i]=QRead()+rA[i-1];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			rB[i][j][0]=QRead();
	Log2[1]=0;
	for(int i=2;i<=n;i++)
		Log2[i]=Log2[i>>1]+1;
	for(int k=1;k<14;k++){
		for(int j=1;j<=m;j++)
			for(int i=1;i<=n;i++){
				if(i+(1<<k-1)<=n)
					rB[i][j][k]=max(rB[i][j][k-1],rB[i+(1<<k-1)][j][k-1]);
				else
					rB[i][j][k]=rB[i][j][k-1];
				// printf("(%d,%d,%d) -> %d max(%d,%d)\n",i,j,k,rB[i][j][k],rB[i][j][k-1],rB[i+(1<<k-1)][j][k-1]);
			}
	}
//	memset(f,-1,sizeof f);
//	f[0][0]=0;
//	for(int j=1;j<=n;j++){
//		for(int i=1;i<=n;i++) f[i][j&1]=-1;
////		Solve(1,j,j&1,0,j-1);
//	}
	printf("%lld\n",Solve(1,n,1,n));
	return 0;
}


Measured memory_bytes: 55680
#include <bits/stdc++.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	int n,dr;
	cin>>n>>dr;
	if(n>=10)
	cout<<dr;
	else
	cout<<dr+100*(10-n);
}

Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;


int main(void){
    int n;
    cin>>n;
    set<string>s;
    for(int i=0;i<n;i++){
        string t;
        cin>>t;
        s.insert(t);
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 19120
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
 
#define int long long
 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
 
#define INF (3e15)
 
using namespace std;
 
struct edge
{
    int to, cost;
    edge(int _to, int _cost) : to(_to), cost(_cost) {}
    edge() {}
};
typedef pair<int, int> P;
 
int V;
vector<edge> G[100003];
int d[100003];
 
void dijkstra(int s)
{
    priority_queue<P, vector<P>, greater<P> > que;
    REPS(i, V) d[i] = INF;
    d[s] = 0;
    que.push(P(0, s));
 
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); ++i)
        {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost)
            {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
 
int Q, K;
 
signed main()
{
    cin >> V;
    REP(i, V-1)
    {
        int a, b, c;
        cin >> a >> b >> c;
 
        G[a].push_back(edge(b,c));
        G[b].push_back(edge(a,c));
    }
 
    cin >> Q >> K;
    dijkstra(K);
    REP(i, Q)
    {
        int x, y;
        cin >> x >> y;
        int ans = d[x] + d[y];
        printf("%lld\n", ans);
    }
 
    return 0;
}

Measured memory_bytes: 11120
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

vector<pint> fr;
int dis[1000];

int main() {
	int n,m;
	while(cin>>n>>m,n){
		fr.clear();
		int i;
		pint f;
		for(i=0;i<m;i++){
			cin>>f.first>>f.second;
			fr.push_back(f);
		}
		memset(dis,0,sizeof(dis));
		dis[1]=1;
		bool update=true;
		while(update){
			update=false;
			for(i=0;i<m;i++){
				if(dis[fr[i].first]==1||dis[fr[i].first]==2){
					if(dis[fr[i].second]==0||dis[fr[i].second]>dis[fr[i].first]+1){
						dis[fr[i].second]=dis[fr[i].first]+1;
						update=true;
					}
				}else if(dis[fr[i].second]==1||dis[fr[i].second]==2){
					if(dis[fr[i].first]==0||dis[fr[i].first]>dis[fr[i].second]+1){
						dis[fr[i].first]=dis[fr[i].second]+1;
						update=true;
					}
				}

			}
		}
		int res=0;
		for(i=2;i<=n;i++){
//cout<<i<<" "<<dis[i]<<endl;
			if(dis[i]!=0)res++;
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
signed main(){
   int x[5],i;
   for(i=0;i<5;i++){
       scanf("%d",&x[i]);
   }
    for(i=0;i<5;i++){
        if(x[i]==0){
            printf("%d\n",i+1);
             }
    }
return(0);
}    


Measured memory_bytes: 1660
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

int main() {
  ll n;
  cin>>n;
  
  ll a=2;
  map<ll,ll> m;
  while(a*a<=n){
    if(n%a==0){
      n/=a;
      m[a]++;
    }
    else a++;
  }
  m[n]++;
  
  ll sum=0;
  for(auto x:m){
    ll y=x.second;
    ll tmp=1;
    while(y-tmp>=0){
      y=y-tmp;
      tmp++;
      sum++;
    }
  }
  
  if(n==1) cout<<0<<endl;
  else cout<<sum<<endl;
    
  
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long
//#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	rep(i, 10000000) {
		if (a % 2 || b % 2 || c % 2) {
			cout << i << endl;
			endre;
		}
		int a1 = b / 2 + c / 2, b1 = a / 2 + c / 2, c1 = a / 2 + b / 2;
		a = a1, b = b1, c = c1;
	}
	cout << -1 << endl;
	endre;
}

Measured memory_bytes: 256
S = input()[:-1]

while len(S) > 0:
    S  = S[:len(S) // 2 * 2]
    S1 = S[:len(S)//2]
    S2 = S[ len(S)//2:]
    if S1 == S2:
        break
    S  = S[:-1]

print(len(S))


Measured memory_bytes: 2940
# -*- utf8 -*-

arg = gets.chomp

arg = arg.split(" ")

a = arg[0].to_i
b = arg[1].to_i
c = arg[2].to_i

# a b, c
# a c, b
# b c, a

if a + b == c || a + c == b || b + c == a 
    puts "Yes"
else
    puts "No"
end


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

typedef struct{int pos,size;}Lake;

void Push(Lake* s, int x, int y){
	int top;
	s[0].size++;
	top=s[0].size;

	s[top].pos=x;
	s[top].size=y;
}
void Pop(Lake* s){
	s[0].size--;
}
Lake Top(Lake* s){
	int top=s[0].size;
	return s[top];
}


int main(){
	Lake s1[20000],s2[20000];
	s1[0].size=s2[0].size=0;

	int L,R,tmp,sum=0,i;
	Lake a_lake;
	char ch;
	for(R=0;R<20000;R++){
		if(scanf("%c",&ch)!=1)break;

		if(ch=='\\'){
			Push(s1,R,0);

		}else if(ch=='/' && s1[0].size){
			a_lake=Top(s1);	Pop(s1);
			L=a_lake.pos;
			tmp=(R-L);
			sum+=tmp;
			while(s2[0].size>0 && L<Top(s2).pos){
				a_lake=Top(s2);	Pop(s2);
				tmp+=(a_lake.size);	
			}
			//s2[t2].pos=j;	s2[t2].size=tmp;	t2++;
			Push(s2,L,tmp);
		}
	}

	printf("%d\n%d",sum,s2[0].size);
	for(i=1;i<=s2[0].size; i++){
		printf(" %d",s2[i].size);
	}printf("\n");
	return 0;
}



Measured memory_bytes: 2784
s = input()
go = []
back = []
start = 0
end = len(s)-1
res = 0
while start<=end:
    gox = 0
    backx = 0
    while s[end] == 'x' or s[start] == 'x':
        if s[start] == 'x' and start<end:
            start+=1
            gox += 1
        if s[end] == 'x'and start<end:
            end -= 1
            backx +=1
        if start == end:break
    if start == end and s[start] == 'x':
        break
    if s[start] == s[end]:
        start += 1
        end -=1
        res += abs(gox-backx)
        gox = 0
        backx = 0
    else:
        res = -1
        break

print(res)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 998244353;

ll dp[305][90005];
ll dp2[305][90005];

int main(){
  int N;
  cin >> N;
  vector<int> v;

  int S = 0;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
    S += a;
  }

  ll ret = 1;
  rep(i,N){
    ret *= 3;
    ret %= MOD;
  }

  dp[0][0] = 1;
  rep(i,N){
    rep(j,90005){
      dp[i+1][j] += (2*dp[i][j])%MOD;
      dp[i+1][j] %= MOD;

      dp[i+1][j+v[i]] += dp[i][j];
      dp[i+1][j+v[i]] %= MOD;
    }
  }
  
  ll sum = 0;
  REP(i,(S+1)/2,90005){
    sum += dp[N][i];
    sum %= MOD;
  }

  sum *= 3;
  sum %= MOD;

  ret += MOD - sum;
  ret %= MOD;

  if(S%2==0){
    dp2[0][0] = 1;
    rep(i,N){
      rep(j,90005){
        dp2[i+1][j] += dp2[i][j]%MOD;
        dp2[i+1][j] %= MOD;
        
        dp2[i+1][j+v[i]] += dp2[i][j];
        dp2[i+1][j+v[i]] %= MOD;
      }
    }

    ret += 3 * dp2[N][S/2];
    ret %= MOD;
  }
  

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 427520
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class AtCoderC
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();

        string before = s.Substring(0, 1);
        int count = 0;
        for (int i = 1; i < n; i++)
        {
            string str = s.Substring(i, 1);
            if (str.Equals(before))
            {
                count++;
            }
            before = str;
        }

        Console.WriteLine(n - count);
    }
}

Measured memory_bytes: 13280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,a;cin>>h>>a;
    cout<<(h+a-1)/a;
    return 0;
}

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

int main(){
  int n; cin>>n;
  long long ans=0;
  vector<int> num,not10;
  for(int i=0;i<n;i++){
    int x; cin>>x;
    ans+=x;
    if(x%10==0){
      num.push_back(x);
    }else not10.push_back(x);
  }if(ans%10!=0){
    cout<<ans<<endl;
    return 0;
  }else{
  if(not10.empty()){
    cout<<0<<endl;
  }else{
    sort(not10.begin(),not10.end());
    cout<<ans-not10[0]<<endl;
  }
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
    
    
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int H = sc.nextInt();
		int L = sc.nextInt();
		int[] t = new int[N];
		int[] h = new int[N];
		for(int i = 0; i < N; i++) {
			t[i] = sc.nextInt();
			h[i] = sc.nextInt();
		}
		int now = 0;
		int money = 0;
		while(true) {
			now %= N;
			boolean B = false;
			boolean C = false;
			if(t[now] != 0) {
				if(T + 1 > L) B = true;
				T++;
				money += 10;
				t[now]--;
			}
			else if(h[now] != 0) {
				H++;
				money += 100;
				h[now]--;
			}
			else {
				C = true;
			}
			
			if(money >= 90) {
				money -= 90;
				if(T * 10 >= money) {
					T -= money/10;
					t[now] += money/10;
					money = 0;
				}
				else {
					B = true;
				}
			}
			if(B || C) {
				System.out.println((now+1));
				break;
			}
			now++;
		}
		
	}
}

Measured memory_bytes: 26432
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main() {
    int s;
    cin >> s;
    printf("%d:%d:%d\n", s/3600, (s%3600)/60, s%60);
    return 0;
}

Measured memory_bytes: 3192
'use strict'
const Main = (input) => {
  const S = input;
  // console.log({ S });
  let S01 = parseInt(S.slice(0, 2));
  let S23 = parseInt(S.slice(2));

  let S01J = (0 < S01 && S01 < 13) ? 'MM' : 'YY';
  let S23J = (0 < S23 && S23 < 13) ? 'MM' : 'YY';

  let SJ = S01J + S23J;
  if (SJ === 'MMMM') {
    SJ = 'AMBIGUOUS';
  } else if (SJ === 'YYYY') {
    SJ = 'NA';
  }

  console.log(SJ);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 11468
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	int n;
	cin >> n;
	vector<int> w(n);
	REP(i,n) cin >> w[i];
	
	int l=0, r=0;
	REP(i,n) r += w[i];
	int prev[2] = {l,r};
	REP(i,n){
		l += w[i];
		r -= w[i];
		if(abs(l-r) > abs(prev[0]-prev[1])){
			break;
		}
		prev[0] = l;
		prev[1] = r;
	}
	cout << abs(prev[0]-prev[1]) << endl;
	
	
	return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  ll n = s.size();
  ll m = t.size();
  
  ll ans = 10000000;
  rep(i,n-m+1) {
    string u = s.substr(i,m);
    ll cnt = 0;
    rep(j,m)
      if (u[j] != t[j]) cnt++;
    ans = min(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
module ABC086A
  sub Main(ByVal args() as String)
    dim a as integer
	a = Console.ReadLine()
    select a mod 10
    case 3:
        Console.WriteLine("bon")
    case 0,1,6,8:
        Console.WriteLine("pon")
    case else:
        Console.WriteLine("hon")
    end select
  end sub
end module

Measured memory_bytes: 28356
"""
at-abc164c.py
2020-05-06
/usr/bin/python3
Info Fields (opt.)
- Type: 
- Keywords: set,
- Notes:
"""
if __name__ == "__main__":
    fruits = set()
    n=int(input())
    for i in range(n):
        fruits.add(input())
    print(len(fruits))


Measured memory_bytes: 30984
#include<stdio.h>

int main(){
    int i,h,w,j,k;
    while(1){
        scanf("%d%d",&h,&w);
        if(h+w==0)break;
        for(j=0;j<h;j++){
               for(k=0;k<w;k++){
                    printf("#");
                    }
               printf("\n");
               }
        printf("\n");
        }
        return 0;
    }



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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N;
  cin >> N;
  ll ans = N*(N-1)/2;
  cout << ans << endl;
  return 0;
}


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

    int d[10]{};

    int main()
    {
        ll n{},k{};
        cin>>n>>k;
        for(ll i=0;i<k;i++){
            int t{};
            cin>>t;
            d[t] = 1;
        }
        for(ll i=n;i<1000005;i++){
            string s = to_string(i);
            for(ll j=0;j<s.size();j++){
                if(d[ s[j] - '0']){
                    goto j;
                }
            }
            cout<<i;
            break;
            j:;
        }

        return 0;
    }

Measured memory_bytes: 3700
n = int(input())

a = []

for i in range(1,n+1):
    if (i % 5 == 0) and (i % 3 == 0):
        continue
    elif i % 5==0:
        continue
    elif i % 3 ==0:
        continue
    else:
        a.append(i)
    
ans = sum(a)

print(ans)

Measured memory_bytes: 29896
import bisect

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
#print(A)

# Aの累積和を求めておく。
csum = [A[0] for _ in range(N+1)]
for i in range(1,N):
  csum[i] = csum[i-1]+A[i]

# M回以上握手できるとなる最小の幸福度を求める。
# l:幸福度l以上となる握手がMパターン以上存在する。
# r:幸福度r以上となる握手がMパターン以上存在しない。
l = 0
r = 10**6
while (l+1 < r):
  m = (l+r)//2
  p = 0 # 幸福度がm以上になる握手の回数
  for a in A:
    q = bisect.bisect_left(A,m-a)
    #print(q,m-a,A)
    p += N-q
  #print(l,m,r,p)
  if p >= M:
    l = m
  else:
    r = m
#print(l,m,r)

# 幸福度がl-1のときに握手ができる回数と幸福度を求める。
# その回数とMとの差の回数だけ、幸福度にlを追加する。
# (幸福度がlになる握手のパターンは複数ある可能性がある)
ans = 0
cnt = 0
for a in A:
  q = bisect.bisect_right(A,l-1-a)
  if q == 0:
    ans += csum[N-1]+a*N
  elif q < N:
    ans += csum[N-1]-csum[q-1]+a*(N-q)
  cnt += N-q
  #print(a,q,ans,cnt)
ans += l*(M-cnt)
print(ans)


Measured memory_bytes: 58972
#include <cstdio>
using namespace std;
char ch;
int main() {
    char ch;
    int s=0,cnt=0,len=0;
    while(1) {
        ch=getchar();
        int v=ch-'0';
        if(v==0 || v==1)
            len++;
        else
            break;
        if(v!=s)
            cnt++;
        s^=1;
    };
    if(cnt<=len-cnt)
        printf("%d\n",cnt);
    else
        printf("%d\n",len-cnt);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, p; cin >> n >> p;
	int ans = 1;
	map<int, int>mp;
	for (auto PA : prime_factor(p)) {
		while (PA.second--) {
			mp[PA.first]++;
		}
	}
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		ans *= pow(itr->first, itr->second / n);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256