akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int h, w;

	cin >> h >> w;

	string s;

	int i, j;

	rep(i, h) {
		rep(j, w) {
			cin >> s;

			if (s == "snuke") {
				cout << (char)(j + 'A') << i + 1 << End;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
/*
 * Aizu Online Judge
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author yoshkur
 */
public class Main {

	/**
	 * @param args the command line arguments
	 */
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			DataController controller = new DataController();
			controller.setDataFromLine(br);
			br.close();
			System.out.println(controller.getResult());

		} catch (IOException | NumberFormatException e) {
			System.err.println(e.getLocalizedMessage());
		}
	}
}

class DataService {

	private List<DataEntity> entities = new ArrayList<>();
	private DataEntity entity;

	public DataService() {
	}

	public List<DataEntity> getEntities() {
		return entities;
	}

	public void setEntities(List<DataEntity> entities) {
		this.entities = entities;
	}

	public DataEntity getEntity() {
		if (this.entity == null) {
			this.entity = new DataEntity();
		}
		return entity;
	}

	public void setEntity(DataEntity entity) {
		this.entity = entity;
	}
}

class DataEntity {
	private Integer number;

	public DataEntity() {
	}

	public DataEntity(Integer number) {
		this.number = number;
	}

	public Integer getNumber() {
		return number;
	}

	public void setNumber(Integer number) {
		this.number = number;
	}
}

class DataController {

	private static final String RETCODE = System.getProperty("line.separator");
	public static final String SEPARATOR = " ";

	private final DataService ejb;

	public DataController() {
		this.ejb = new DataService();
	}

	public void setDataFromLine(BufferedReader br) throws IOException {
		Integer count = Integer.valueOf(br.readLine().trim());
		String[] values = br.readLine().trim().split(SEPARATOR);
		for (String str : values) {
			this.ejb.getEntities().add(new DataEntity(Integer.valueOf(str)));
		}
	}

	public void setDataFromLines(BufferedReader br) throws IOException {
		String line;
		while ((line = br.readLine()) != null) {
//			DataEntity entity = new DataEntity();
//			String[] values = line.trim().split(SEPARATOR);
//			entity.setNum0(Integer.valueOf(values[0]));
//			entity.setNum1(Integer.valueOf(values[1]));
//			this.ejb.getEntities().add(entity);
		}
	}

	public String getResult() {
		String result = null;
		Integer min = 1000000;
		Integer max = -1000000;
		Long sum = 0L;
		
		for (DataEntity entity : this.ejb.getEntities()) {
			min = Math.min(min, entity.getNumber());
			max = Math.max(max, entity.getNumber());
			sum += entity.getNumber();
		}
		
		StringBuilder sb = new StringBuilder();
		sb.append(min);
		sb.append(SEPARATOR);
		sb.append(max);
		sb.append(SEPARATOR);
		sb.append(sum);
		result = sb.toString().trim();
		return result;
	}
}

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

using namespace std;

int main()
{
    int N, acCnt = 0, waCnt = 0, tleCnt = 0, reCnt = 0;
    cin >> N;
    string AC = "AC", WA = "WA", TLE = "TLE", RE = "RE", x;
    for(int i = 0; i < N; i++)
    {
        cin >> x;
        if(x == AC)
            acCnt++;
        else if(x == WA)
            waCnt++;
        else if(x == TLE)
            tleCnt++;
        else if(x == RE)
            reCnt++;
    }
    cout << "AC x " << acCnt << endl;
    cout << "WA x " << waCnt << endl;
    cout << "TLE x " << tleCnt << endl;
    cout << "RE x " << reCnt << endl;
    return 0;
}


Measured memory_bytes: 3612
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

const int N = 18;
const int M = 1 << N;

int dp[N + 1][N + 1][M];
int a[N + 1], b[N + 1];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int topkek = 1 << n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
    }
    a[0] = b[0] = -1e9;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            fill(dp[i][j], dp[i][j] + topkek, 1e9);
        }
    }
    dp[0][0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int mask = 0; mask < topkek; mask++) {
                if (dp[i][j][mask] == 1e9) {
                    continue;
                }
                for (int k = 1; k <= n; k++) {
                    if (mask & (1 << (k - 1))) {
                        continue;
                    }
                    int cur = a[k];
                    if (abs(i + 1 - k) & 1) {
                        cur = b[k];
                    }
                    int prev = a[j];
                    if (abs(i - j) & 1) {
                        prev = b[j];
                    }
                    if (cur >= prev) {
                        int dist = 0;
                        for (int x = 0; x + 1 < k; x++) {
                            if (!(mask & (1 << x))) {
                                dist++;
                            }
                        }
                        dp[i + 1][k][mask | (1 << (k - 1))] = min(dp[i + 1][k][mask | (1 << (k - 1))], dp[i][j][mask] + dist);
                    }
                }
            }
        }
    }
    int best = 1e9;
    for (int i = 1; i <= n; i++) {
        best = min(best, dp[n][i][topkek - 1]);
    }
    if (best < 1e9) {
        cout << best;
    } else {
        cout << -1;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 370048
N,K = gets.split.map(&:to_i)

if K == 0
    p N*N
    exit
end

ans = 0
(K+1).upto(N) do |b|
    # a % b
    #cnt = b - K
    
    cnt = (b-K)*(N/b)
    cnt += [N-N/b*b-K+1, 0].max
    
    ans += cnt
    
    # +plus...
    
    
end

p ans

Measured memory_bytes: 1788
package main

import (
	"fmt"
)

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

const (
	A = iota
	B
	C
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	S, T := len(s), len(t)

	dp := make([][]int, S+1)
	for i := 0; i <= S; i++ {
		dp[i] = make([]int, T+1)
	}

	grid := make([][]int, S+1)
	for i := 0; i <= S; i++ {
		grid[i] = make([]int, T+1)
	}

	for i := 1; i <= S; i++ {
		for j := 1; j <= T; j++ {
			if dp[i-1][j] > dp[i][j] {
				dp[i][j] = dp[i-1][j]
				grid[i][j] = A
			}
			if dp[i][j-1] > dp[i][j] {
				dp[i][j] = dp[i][j-1]
				grid[i][j] = B
			}
			if s[i-1] == t[j-1] {
				if dp[i-1][j-1]+1 > dp[i][j] {
					dp[i][j] = dp[i-1][j-1] + 1
					grid[i][j] = C
				}
			}
		}
	}
	var i, j int
	i = S
	j = T
	out := ""
	for i != 0 && j != 0 {
		switch grid[i][j] {
		case A:
			i--
		case B:
			j--
		case C:
			out += string(s[i-1])
			i--
			j--
		}
	}
	for i := len(out) - 1; i >= 0; i-- {
		fmt.Printf("%c", out[i])
	}
	fmt.Println()
}

Measured memory_bytes: 155264
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	string s;
	cin >> s;
	int n = s.size() + 1;
	vector<long long> l(n, 0), r(n , 0);
	rep(i, n - 1) {
		if (s[i] == '<') {
			l[i] = r[i] = 1;
		}
		else {
			l[i] = r[i] = -1;
		}
	}

	for (int i = 1; i < n - 1; i++) {
		if (l[i - 1] * l[i] > 0) {
			l[i] += l[i - 1];
		}
	}
	for (int i = n - 2; i >= 0; i--) {
		if (r[i + 1] * r[i] > 0) {
			r[i] += r[i + 1];
		}
	}
	long long ans = 0;

	ans += max(0LL, -r[0]);
	rep(i, n - 1) {
		long long v = 0;
		v = max(v, l[i]);
		v = max(v, -r[i + 1]);
		ans += v;
	}





	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8732
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  string s;cin>>s;
  int ans=0;
  for(int i=0;i<s.size();i++)
  {
    if(s.at(i)=='+')
      ans++;
    else
      ans--;
  }
cout<<ans;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

perm :: [Int] -> [a] -> [a]
perm y x = [ x!!i | i <- y ]
hRoll = [0,2,4,1,3,5]
toTop = [[0,1,2,3,4,5]
        ,[1,5,2,3,0,4]
        ,[2,1,5,0,4,3]
        ,[3,1,0,5,4,2]
        ,[4,0,2,3,5,1]
        ,[5,1,3,2,4,0]]
hRotate :: [a] -> [[a]]
hRotate d = [d, h d, (h.h) d, (h.h.h) d] where h = (perm hRoll)

allRotate :: [a] -> [[a]]
allRotate d = concat[ hRotate x | x <- map(\ x -> perm x d) toTop]

-- TSEWNB
main = do
    n <- readLn
    l <- replicateM n $ words <$> getLine
    let c = if foldr (&&) True [elemIndex (l!!x) (allRotate (l!!y)) == Nothing | x <- [0..n-2],y <- [x+1..n-1]]
              then "Yes" else "No"
    putStrLn $ c

Measured memory_bytes: 4076
//By Vlgd
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
class Point{
	public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y){}
	Point operator + (Point p){return Point(x+p.x,y+p.y);}
	Point operator - (Point p){return Point(x-p.x,y-p.y);}
	Point operator * (double a){return Point(a*x,a*y);}
	Point operator / (double a){return Point(x/a,y/a);}
	double abs() {return sqrt(norm());}
	double norm() {return x*x+y*y;}
	bool operator < (const Point &p) const{
		return y!=p.y ? y<p.y : x<p.x	;
	}
	bool operator == (const Point &p) const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};
typedef Point Vector;
double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}
typedef vector<Point> Polygon; 
int ck(Point p0,Point p1,Point p2){
	Vector a=p1-p0,b=p2-p0;
	if(cross(a,b)<EPS) return 1;//cw
	return 0;//
}
Polygon Andrew(Polygon s){
	Polygon u,l;
	if(s.size()<3) return s;
	sort(s.begin(),s.end());
	
	u.push_back(s[0]);
	u.push_back(s[1]);
	
	l.push_back(s[s.size()-1]);
	l.push_back(s[s.size()-2]);
	
	for(int i=2;i<s.size();i++){
		for(int v=u.size(); v>=2 && ck(u[v-2],u[v-1],s[i])!=1;v--) {u.pop_back();}
		u.push_back(s[i]);
	}
	for(int i=s.size()-3;i>=0;i--){
		for(int v=l.size(); v>=2 && ck(l[v-2],l[v-1],s[i])!=1;v--) {l.pop_back();}
		l.push_back(s[i]);
	}
//	printf("u\n");for(int i=0;i<u.size();i++) printf("%d %d\n",(int)u[i].x,(int)u[i].y);printf("\n");
//	printf("l\n");for(int i=0;i<l.size();i++) printf("%d %d\n",(int)l[i].x,(int)l[i].y);printf("\n");
	reverse(l.begin(),l.end());
	for(int i=u.size()-2;i>=1;i--) l.push_back(u[i]);
	return l;
}
int main(){
	int n,x,y;
	Polygon s,ans;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		Point a(x,y);
		s.push_back(a);
	}
	ans=Andrew(s);
	printf("%d\n",ans.size());
	for(int i=0;i<ans.size();i++){
		printf("%d %d\n",(int)ans[i].x,(int)ans[i].y);
	}
	return 0;
}



Measured memory_bytes: 10336
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	const mod = 1000000007

	n := nextInt()
	s := []string{next(), next()}

	ans := 1
	for i := 0; i < n; i++ {
		if s[0][i] == s[1][i] { // 縦
			if i == 0 {
				ans = 3
			} else if s[0][i-1] == s[1][i-1] { // 1つ前も縦
				ans = (ans * 2) % mod
			}
		} else {
			if i == 0 {
				ans = 3 * 2
			} else if s[0][i-1] == s[1][i-1] {
				ans = (ans * 2) % mod
			} else {
				ans = (ans * 3) % mod
			}
			i++
		}
	}

	puts(ans)
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
int main (void){
int S,i,s[5];
scanf("%d",&S);
for(i=0;i<4;i++){
s[i]=S%10;
S=(int)S/10;
}
if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
printf("Bad");
}else{
printf("Good");
}
return 0;

}

Measured memory_bytes: 128
N = int(input())
S = input()
r = 0
g = 0
b = 0
for i in range(N):
    if S[i] == "R":
        r += 1
    elif S[i] == "G":
        g += 1
    else:
        b += 1
ans = r * g * b
 
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        x = j + j - i
        if S[i] != S[j] and x <= N - 1:
            if S[i] != S[x] and S[x] != S[j]:
                ans -= 1
 
print(ans)

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

if y == 0:
    print(abs(x) + (x>0))
elif x < y < 0:
    print(y-x)
elif 0 < y < x:
    print(x-y+2)
else:
    print(abs(abs(y) - abs(x)) + (x < 0) + (y < 0))

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define int long long
#define all(x) x.begin(), x.end()
#ifdef ONLINE_JUDGE
const int maxn = 3e5 + 10;
#else
const int maxn = 2e5 + 10;
#endif
//__builtin_popcount
int N, arr[maxn];
map<int, int> mp, jishu;
signed main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    // freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    cin >> N;

    for (ri i = 1; i <= N; ++i) {
        cin >> arr[i];
        mp[arr[i]]++;
    }
    int total = 0;
    for (auto it : mp) {
        int key = it.first;
        int val = it.second;
        jishu[key] = val * (val - 1) / 2;
        total += val * (val - 1) / 2;
    }

    for (int i = 1; i <= N; ++i) {
        int val = mp[arr[i]];
        int x = total - jishu[arr[i]];
        val--;
        x += val * (val - 1) / 2;
        cout << x << endl;
    }

#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 19968
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  int d = log10(N)+1;
  int ans = 0;
  int val[] = {7, 5, 3};
  vector<int> cnt(3);
  function<void(int, ll)> dfs = [&](int i, ll tmp) {
    if(tmp <= N && cnt[0] && cnt[1] && cnt[2]) ans++;
    if(i == d) return;
    rep(j, 3) {
      cnt[j]++;
      dfs(i+1, tmp*10+val[j]);
      cnt[j]--;
    }
  };
  dfs(0, 0);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3828
import java.util.*;
 
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] as = new long[n];
		long[] plus = new long[n];
		long[] minus = new long[n];
		for(int i=0; i<n; i++){
			as[i] = sc.nextLong();
			plus[i] = i+1+as[i];
			minus[i] = i+1-as[i];
		}
		Map<Long, Integer> map = new HashMap<>();
		for(long i: minus){
			Integer value = map.get(i);
			if(value == null) map.put(i, 1);
			else map.put(i, value+1);
		}
		long ans = 0;
		for(int i=0; i<plus.length; i++){
			Integer value = map.get(plus[i]);
			if(value != null){
				// ここで配列plusのindexに対応した配列minusの値をmapから引きたくなるが、
				// そのような値は式変形するとAj=-Aiになるため、その必要がないことがわかる
				ans += value;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 63108
#include<stdio.h>
int main(void)
{
	int a,b,c,x,y,i,cnt;
	scanf("%d %d %d",&a,&b,&c);
	y=0;
	cnt=0;
	while(1){
		cnt++;
		if(cnt%7==0){
			y+=b;
		}
		y+=a;
		if(c<=y){
			break;
		}
	}
	printf("%d\n",cnt);
	return 0;
}



Measured memory_bytes: 2108
import java.util.ArrayList;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		
//		必要なパラメータを用意する処理
		ArrayList<Integer> arrA = new ArrayList<Integer>();
		int max = 0, min = 0;
//		入力値を取得する処理
		Scanner scInputData = new Scanner(System.in);
		while(scInputData.hasNext()) {
			arrA.add(scInputData.nextInt());
		}
		max = Math.max(arrA.get(0), arrA.get(1));
		max = Math.max(arrA.get(2), max);
		
		min = Math.min(arrA.get(0), arrA.get(1));
		min = Math.min(arrA.get(2), min);

		System.out.println(min + " " + max);
		
		
		scInputData.close();

	}

}



Measured memory_bytes: 26352
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
// #define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007



void solve()
{
  string s;
  stack<int> stk;
  while(cin>>s)
  {
    if(s=="+")
    {
      int A,B;
      A = stk.top();
      stk.pop();
      B = stk.top();
      stk.pop();
      stk.push(A+B);
    }
    else if(s =="-")
    {
      int A,B;
      A = stk.top();
      stk.pop();
      B = stk.top();
      stk.pop();
      stk.push(B - A);      
    }
    else if (s =="*")
    {
      int A,B;
      A = stk.top();
      stk.pop();
      B = stk.top();
      stk.pop();
      stk.push(A*B);
    }
    else
    {
      int num = stoi(s);
      stk.push(num);
    }
  }
    cout<<stk.top()<<endl;
  
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solve();
 
  return 0;
}


Measured memory_bytes: 3184
def d2(d,p1,p2):
  return sum([(p2[i]-p1[i])**2 for i in range(d)])
def judge(x):
  return int(x) == int(x**(1/2))**2

N,D = map(int,input().split())

l = [list(map(int,input().split())) for _ in range(N)]
s = 0
for i in range(N):
  for j in range(i+1,N):
    s += judge(d2(D,l[i],l[j]))
    
print(s)
    


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll a,b,x;
cin >> a >> b >> x;
ll rangea = (a - 1) / x +1;
if (a == 0) rangea = 0;
ll rangeb = b / x +1;
cout << rangeb - rangea << endl;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

sum = sum(a)
avg = sum/N

result = 0
tmp = 0

for i in range(len(a)):
  ans = avg - a[i]
  ans = ans if ans > 0 else ans * -1
  if i == 0:
    result = i
    tmp = ans
  elif tmp > ans:
    result = i
    tmp = ans

print(result)

Measured memory_bytes: 3064
import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    (N, K) = map(int, input().split())
    A = np.array([0] + list(map(int, input().split())))

    B = [1]
    s = [True]*(N+1)
    s[1] = False
    nextTown = A[1]
    while s[nextTown]:
        B += nextTown,
        s[nextTown] = False
        nextTown = A[nextTown]
        
    B = np.array(B)
    loopIndex = np.where(B == nextTown)[0][0]
    loopLen = len(B) - loopIndex

    if K >= loopIndex:
        print(B[(K-loopIndex)%loopLen + loopIndex])
    else:
        print(B[K])

main()


Measured memory_bytes: 50952
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll X, Y;
    cin >> X >> Y;

    if (abs(X - Y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
    return 0;
}

Measured memory_bytes: 3608
# coding: utf-8
# Your code here!
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n)) #親ノード
        self.size = [1]*n #グループの要素数
 
    def root(self, x): #root(x): xの根ノードを返す．
        while self.parent[x] != x:
            self.parent[x] = self.parent[self.parent[x]]
            x = self.parent[x]
        return x 
 
    def merge(self, x, y): #merge(x,y): xのいる組とyのいる組をまとめる
        x, y = self.root(x), self.root(y)
        if x == y: return False
        if self.size[x] < self.size[y]: x,y=y,x #xの要素数が大きいように
        self.size[x] += self.size[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        return True
 
    def issame(self, x, y): #same(x,y): xとyが同じ組ならTrue
        return self.root(x) == self.root(y)
        
    def getsize(self,x): #size(x): xのいるグループの要素数を返す
        return self.size[self.root(x)]


import sys
input = sys.stdin.readline

n,k,l = [int(i) for i in input().split()]

UF1 = UnionFind(n)
for _ in range(k):
    p,q = [int(i)-1 for i in input().split()]
    UF1.merge(p,q)

UF2 = UnionFind(n)
for _ in range(l):
    p,q = [int(i)-1 for i in input().split()]
    UF2.merge(p,q)

a = dict()
for i in range(n):
    r1,r2 = UF1.root(i), UF2.root(i)
    if (r1,r2) not in a:
        a[(r1,r2)] = 1
    else:
        a[(r1,r2)] += 1

print(*[a[(UF1.root(i), UF2.root(i))] for i in range(n)])



Measured memory_bytes: 101204
class Stack:
    def __init__(self):
        self.values = []

    def push(self,v):
        self.values.append(v)

    def pop(self):
        if len(self.values) == 0:
            raise
        else:
            v = self.values[len(self.values)-1]
            del self.values[len(self.values)-1]
            return v

symbols = raw_input().split(' ')

stack = Stack()
for s in symbols:
    if not s in ['+', '-', '*']:
        stack.push(s)
    else:
        v1 = int(stack.pop())
        v2 = int(stack.pop())
        if s == '+':
            stack.push(v1+v2)
        elif s == '-':
            stack.push(v2-v1)
        elif s == '*':
            stack.push(v1*v2)

print stack.pop()

Measured memory_bytes: 6420
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>

const char *anss(bool b)
{
	return b ? "Yes" : "No";
}

const char *ansp(bool b)
{
	return b ? "APPROVED" : "DENIED";
}

using smap = std::map<std::string, int>;
using smap_v = const smap::value_type&;

int main()
{
	int N;
	std::cin >> N;
	std::vector<std::string> S(N);
	for (int i = 0; i < N; i++)
	{
		std::cin >> S[i];
	}

	smap bucket;
	for (int i = 0; i < N; i++)
	{
		bucket[S[i]]++;
	}

	auto max_S = std::max_element(begin(bucket), end(bucket), [](smap_v l, smap_v r) { return l.second < r.second; });
	int max_vote = max_S->second;

	std::vector<std::string> answers;
	for (auto it = begin(bucket); it != end(bucket); it++)
	{
		if (it->second == max_vote)
		{
			std::cout << it->first << std::endl;
		}
	}
}

Measured memory_bytes: 26752
s = input()
t = input()


s_to_t = {}
t_to_s = {}

for i in range(len(s)):
    if s[i] not in s_to_t:
        if t[i] not in t_to_s:
            s_to_t[s[i]] = t[i]
            t_to_s[t[i]] = s[i]
            continue
        else:
            print('No')
            exit(0)
    elif s_to_t[s[i]] == t[i] and t_to_s[t[i]] == s[i]:
        continue
    else:
        print('No')
        exit(0)
        
print('Yes')            
    


Measured memory_bytes: 3632
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    from fractions import gcd
    N=I()
    ans=1
    for i in range(N):
        T=I()
        ans=(ans*T)//(gcd(ans,T))
        
        
    print(ans)

main()


Measured memory_bytes: 64012
L = input()
mod = 10 ** 9 + 7

dp = [[0, 0] for i in range(1000005)]
dp[0][0] = 1

for i in range(len(L)):
    # a + b = 0
    if L[i] == "0":
        dp[i+1][0] += dp[i][0] % mod
        dp[i+1][1] += dp[i][1] % mod
    else:
        dp[i+1][1] += (dp[i][1]+dp[i][0]) % mod
    # a + b = 1
    if L[i] == "1":
        dp[i+1][0] += (dp[i][0]*2) % mod
        dp[i+1][1] += (dp[i][1]*2) % mod
    else:
        dp[i+1][1] += dp[i][1]*2%mod
print((dp[len(L)][0]+dp[len(L)][1])%mod)

Measured memory_bytes: 134648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(){
  ll n,ans=1;
  cin>>n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  for(ll i=0;i<n;i++){
    if(1000000000000000000/ans<a[i]||ans<0){
      ans=-1;
    }else{
      ans*=a[i];
    }
    if(a[i]==0){
      ans=0; break;
    }
  }
  cout<<ans<<endl;
 
}

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

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

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/10/08  Problem: codefestival2017_qual C  / Link:   ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

const int N = 100100;
int n;
vector<int> g[N];
int col[N];

bool dfs(int v) {
	for (int u : g[v]) {
		if (col[u] != -1) {
			if (col[v] == col[u]) return false;
		}
		else {
			col[u] = col[v] ^ 1;
			if (!dfs(u)) return false;
		}
	}
	return true;
}

int main()
{

	int m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		v--; u--;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	for (int i = 0; i < n; i++)
		col[i] = -1;
	col[0] = 0;
	ll ans = 0;
	if (!dfs(0))
		ans = (ll)n * (n - 1) / 2;
	else {
		ans = 0;
		for (int i = 0; i < n; i++)
			ans += col[i];
		ans *= n - ans;
	}
	ans -= m;
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 6400
s= gets.chomp
acgt = ['A','C','G','T']
count = 0
max_num = []
s.length.times do |a|
    if acgt.include?(s[a])
        count += 1
        max_num.push(count)
    else
        max_num.push(count)
        count = 0
    end
end
puts max_num.max


Measured memory_bytes: 1788
import math

sample1 = [ [0, 0, 0], [0, 0, 255], [0, 255, 0], [0, 255, 255], [255, 0, 0], [255, 0, 255], [255, 255, 0], [255, 255, 255] ]
sample2 = ['black', 'blue', 'lime', 'aqua', 'red', 'fuchsia', 'yellow', 'white']

while True:
    color = input()
    
    if color=='0':
        break
    
    Color = list(color)
    Color.pop(0)
    for i in range(6):
        if Color[i]=='a':
            Color.pop(i)
            Color.insert(i,10)
        if Color[i]=='b':
            Color.pop(i)
            Color.insert(i,11)
        if Color[i]=='c':
            Color.pop(i)
            Color.insert(i,12)
        if Color[i]=='d':
            Color.pop(i)
            Color.insert(i,13)
        if Color[i]=='e':
            Color.pop(i)
            Color.insert(i,14)
        if Color[i]=='f':
            Color.pop(i)
            Color.insert(i,15)
    
    R = int(Color[0])*16 + int(Color[1])
    G = int(Color[2])*16 + int(Color[3])
    B = int(Color[4])*16 + int(Color[5])
    
    D = []
    for i in range(8):
        d = math.sqrt( (R-sample1[i][0])**2 + (G-sample1[i][1])**2 + (B-sample1[i][2])**2 )
        D.append(d)
    dmin = min(D)
    index = D.index(dmin)
    print(sample2[index])


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

#define MONEY_MAX 4901

typedef pair<int, int> pii;

int main()
{
  while(1){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    if(X == 0 && Y == 0 && Z == 0){
      break;
    }else{
      int V[X];
      for(int i = 0; i < X; i++)
        cin >> V[i];
      pii event[Y + 1];
      fill(&event[0].first, &event[Y + 1].first, -1);
      for(int i = 0; i < Z; i++){
        int N;
        cin >> N;
        cin >> event[N].first >> event[N].second;
      }
      double dp[Y + 1][MONEY_MAX];
      fill(&dp[0][0], &dp[Y + 1][0], 0.0);
      dp[0][0] = 1.0;
      double ans = 0;
      for(int i = 0; i < Y; i++){
        for(int j = 0; j < MONEY_MAX; j++){
          if(dp[i][j] == 0)
            continue;
          for(int k = 0; k < X; k++){
            if(i + V[k] >= Y){
              ans += dp[i][j] * j / (double)X;
            }else if(event[i + V[k]].first == 1){
              if(i + V[k] + event[i + V[k]].second >= Y)
                ans += dp[i][j] * j / (double)X;
              else
                dp[i + V[k] + event[i + V[k]].second][j] += dp[i][j] / (double)X;
            }else if(event[i + V[k]].first == 2){
              dp[i + V[k]][j + event[i + V[k]].second] += dp[i][j] / (double)X;
            }else if(event[i + V[k]].first == 3){
              if(j <= event[i + V[k]].second)
                dp[i + V[k]][0] += dp[i][j] / (double)X;
              else
                dp[i + V[k]][j - event[i + V[k]].second] += dp[i][j] / (double)X;
            }else{
              dp[i + V[k]][j] += dp[i][j] / (double)X;
            }
          }
        }
      }
      cout << (int)ans << endl;
    }
  }
}

Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
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 long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n;
    cin>>n;
    map<string,int> memo;
    rep(i,n){
        string s;
        cin>>s;
        memo[s]+=1;
    }
    int maxs=0;
    for(auto it=memo.begin();it!=memo.end();it++){
        maxs=max(maxs,it->second);
    }
    for(auto it=memo.begin();it!=memo.end();it++){
        if(it->second==maxs){
            cout<<it->first<<endl;
        }
    }
}


Measured memory_bytes: 25216
def main():
    L, R = map(int, input().split(" "))
    if R - L >= 2019:
        # 部屋割り論法でn%2019=0なるnが存在
        print(0)
    else:
        l = []
        for i in range(L, R + 1):
            l.append(i % 2019)
        l.sort()
        minimum = 2018
        for j in range(len(l)):
            for k in range(j + 1, len(l)):
                minimum = min(minimum, l[j] * l[k] % 2019)
        print(minimum)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
$#q=$N=<>;$q[1]=1;
/ /,push@{$`},$' for<>;
map$q[$_]+=$q[$i]/@$i,@{$i=$_}for 1..$N;
while(--$N){$s=$m=0;$m=$e[$_]>$m?$e[$_]:$m,$s+=$e[$_]for@$N;$e[$N]=1+$s/(@$N||1);@$N>1and$a>($t=$q[$N]*=($s-$m)/$#$N-$s/@$N)and$a=$t}
print$e[1]+$a

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
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;}

int main(){
	ll N; cin>>N;
	vector<ll> V(N);
	rep(i,N) cin>>V[i];
	map<ll,ll> m0;
	m0[0];
	map<ll,ll> m1;
	m1[0];
	for(int i=0;i<N;i+=2){
		m0[V[i]]++;
	}
	for(int i=1;i<N;i+=2){
		m1[V[i]]++;
	}
	
	ll m0max=0,m0sec=0,m1sec=0,m1max=0,m0re,m1re;
	for(auto itr=m0.bg;itr!=m0.ed;itr++){
		if(chmax(m0max,itr->b)) m0re=itr->a;
	}
	for(auto itr=m0.bg;itr!=m0.ed;itr++){
		if(itr->a!=m0re) chmax(m0sec,itr->b);
	}
	for(auto itr=m1.bg;itr!=m1.ed;itr++){
		if(chmax(m1max,itr->b)) m1re=itr->a;
	}
	for(auto itr=m1.bg;itr!=m1.ed;itr++){
		if(itr->a!=m1re) chmax(m1sec,itr->b);
	}
	if(m0re!=m1re) cout<<N-m0max-m1max;
	else{
		cout<<min(N-m0max-m1sec,N-m0sec-m1max);
	}
}

Measured memory_bytes: 7296
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
	int a, b;
	while (cin >> a >> b, a)
	{
		vector<vector<int>>data;
		data.resize(a + 2);
		for (size_t i = 0; i < a + 2; i++)
		{
			data[i].resize(b + 2);
		}
		for (size_t i = 1; i <= a; i++)
		{
			for (size_t j = 1; j <= b; j++)
			{
				char c;
				cin >> c;
				switch (c)
				{
					case '#':
						data[i][j] = 1;
						break;
					case '*':
						data[i][j] = 2;
						break;
					case '@':
						data[i][j] = 3;
						break;
					default:
						break;
				}
			}
		}
		int ans = 0;
		queue<pair<int, int>>d;
		for (size_t i = 1; i <= a; i++)
		{
			for (size_t j = 1; j <= b; j++)
			{
				if (data[i][j])
				{
					ans++;
					int memo = data[i][j];
					data[i][j] = 0;
					d.push(pair<int, int>(i, j));
					while (!d.empty())
					{
						pair<int, int>p = d.front();
						d.pop();
						for (size_t k = 0; k < 4; k++)
						{
							if (data[p.first + dx[k]][p.second + dy[k]] == memo)
							{
								data[p.first + dx[k]][p.second + dy[k]] = 0;
								d.push(pair<int, int>(p.first + dx[k], p.second + dy[k]));
							}
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1256
a = int(input())
A = list(map(int,input().split()))

if a == 0 and A[0] == 1:
    print(1)
    exit()
ch = [1]

cH = [1]
if A[0]>0:
    print(-1)
    exit()
for e,i in enumerate(A[1:]):
    cH.append(cH[-1]*2-i)
    # ch.append((cH[-1]*2)//(2**i))
# print(ch)
# print(cH)

# ch = ch[:-1]
# ch = ch[::-1]
# ch[0]*=2
# print(ch)
cH = cH[:-1]
cH.append(cH[-1]*2)
cH = cH[::-1]
# print(cH)
if 0 in cH:
    print(-1)
    exit()
A = A[::-1]

ans = 0
n = 0
for e,i in enumerate(A[:]):
    # print(n,ch[e],-1)
    if n//2+(n%2!=0)>cH[e]:
        print(-1)
        exit()
    if n  <= cH[e]:
        # print('ans:',ans,'n:',n)
        ans += n+i
        n+=i
    else:
        # print('ans:',ans,'ch:',cH[e],'i:',i)
        ans +=cH[e]+i
        n = cH[e]+i

    # print('ans:',ans,'n:',n)
print(ans)


Measured memory_bytes: 670020
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    while(test--)
    {
       int temp;
       cin>>temp;
       if(temp>=30)
       {
        cout<<"Yes\n";
       }
       else cout<<"No\n";
       //cout<<ans<<"\n";
    }
} 

Measured memory_bytes: 3612
/**
 * 本番中に投げたコードは嘘解法でした・・・。これが嘘解法じゃないといいんですけど。
 */

#include <bits/stdc++.h>

using namespace std;

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

void solve(long long N, long long K, std::vector<long long> A) {
    int c[64][2] = {};
    for (int i = 0; i < A.size(); i++) {
        for (int j = 0; j < 60; j++) {
            c[j][A[i] >> j & 1]++;
        }
    }

    // func(k) := Kのk番目のビットを1を0にして、上からk未満番目のビット割当の自由度を得る場合のスコア
    auto func = [&](int k) {
        if ((K >> k & 1) == 0) return (ll)(-1e18); // k番目が1じゃないとき

        ll x = K & ~((1ll << (k + 1)) - 1);

        for (int i = k - 1; i >= 0; i--) {
            if (c[i][0] > c[i][1]) {
                x |= (1ll << i);
            }
        }

        assert(x <= K);

        ll sum = 0;
        for (long long i : A) {
            sum += i ^ x;
        }

        return sum;
    };

    ll ans = 0;
    // X = K のケース
    for(int i = 0 ; i < N ; i++){
        ans += A[i] ^ K;
    }

    for (int i = 0; i < 50; i++) {
        ans = max(ans, func(i));
    }
    cout << ans << endl;
}


int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 1000005
using namespace std;
int n;
int t[maxn],x[maxn],y[maxn];
int myabs(int now)
{
	return now>0 ? now : -now;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
	for(int i=1;i<=n;i++)
	{
		int len=myabs(x[i]-x[i-1])+myabs(y[i]-y[i-1]);
		if(len>t[i]-t[i-1])
			return printf("No\n"),0;
		if((t[i]-t[i-1]-len)&1)
			return printf("No\n"),0;
	}
	return printf("Yes\n"),0;
}

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

int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; ++i) cin >> a[i];
  vector<long long> s(N+1, 0);
  for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];
  
  long long res = s[N];
  for (int i = 0; i < N; ++i) {
    res = min(res, abs(s[i] - (s[N] - s[i])));
  }
  cout << res << endl;
}
              

Measured memory_bytes: 3620
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;

char mapp[111][111];
int flag[111][111];
int W,H;
int ans;

void dfs(int x,int y,char ch){
    if(x<0||x>=H||y<0||y>=W)return;
    if(mapp[x][y]!=ch||flag[x][y]==1)return;
    flag[x][y]=1;


    dfs(x+1,y,ch);
    dfs(x,y+1,ch);
    dfs(x-1,y,ch);
    dfs(x,y-1,ch);
}


int main(){
    while(~scanf("%d%d",&H,&W)){
        if(W==0)break;

        for(int i=0;i<H;i++){
            scanf("%s",mapp[i]);
        }


        ans=0;
        memset(flag,0,sizeof(flag));

        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(flag[i][j]==0){
                    ans++;
                    dfs(i,j,mapp[i][j]);
                }
            }
        }


        printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 3448
N = int(input())
W = [ [] for _ in range(N) ]
dist = [-1] * N
dist[0] = 0

for i in range(N-1):
    u,v,w = map(int,input().split(" "))
    W[u-1].append(( v-1, w))
    W[v-1].append((u-1, w))

lst = [ ( 0 ,0, -1)]
idx = 0
while len(lst) > idx:
    cur, d, prev = lst[idx]
    idx += 1
    for v, w in W[cur]:
        if v == prev:
            continue
        dist[v] = d + w
        lst.append( (v, dist[v], cur))

for ans in dist:
    print(ans % 2)

Measured memory_bytes: 80928
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S, T;
	string subS;
	int tlen, slen;
	bool found = false;

	cin >> S >> T;

	slen = S.length();
	tlen = T.length();

	if (tlen > slen) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	for (int i = slen - tlen; i >= 0; i--) {
		subS = S.substr(i, tlen);

		rep(j, tlen) {
			if (subS[j] != '?' && subS[j] != T[j]) break;
			else if (j == tlen - 1) {
				found = true;
				rep(k, tlen) S[i + k] = T[k];
				break;
			}
		}
		if (found) break;
	}

	rep(i, slen) {
		if (S[i] == '?') S[i] = 'a';
	}

	if (found) cout << S << endl;
	else cout << "UNRESTORABLE" << endl;

	return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    int64 a = 0;
    for (int x = 1; x <= N; x++) {
        if (x%K == 0) {
            a++;
        }
    }
    int64 b = 0;
    for (int x = 1; x <= N; x++) {
        if (x%K == K/2) {
            b++;
        }
    }
    int64 result = a*a*a;
    if (K%2 == 0) {
        result += b*b*b;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  int d, t, s;
  cin >> d >> t >> s;

  if (s * t >= d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
import math
t = int(input())
if t%2==0 or t%5==0:
    print(-1)
else:
    i=1
    s=7%t
    while 1:
        if (s%t)==0:
            print(i)
            break
        i += 1

        s = (s * 10 + 7)%t

        continue

Measured memory_bytes: 9176
def main():
    N = int(input())
    S = input()
    max = 0;
    for i in range(1, N):
        l = S[:i]
        r = S[i:]
        used = []
        for k in l:
            if k in r and k not in used:
                used.append(k)
        if len(used) > max: max = len(used)
    print(max)

if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
using System;

class program
{

    public static void Main()
    {
        var faces = new int[6];
        var nums = Console.ReadLine().Split(' ');

        for (var i = 0; i < 6; i++)
        {
            faces[i] = int.Parse(nums[i]);
        }

        var dice = new Dice(faces);

        var q = int.Parse(Console.ReadLine());

        for (var i = 0; i < q; i++)
        {
            var str = Console.ReadLine().Split(' ');
            Console.WriteLine(
                dice.findRightNum(int.Parse(str[0]), int.Parse(str[1]))
                );
        }
    }
}

public class Dice
{
    private int front;
    private int back; // rear
    private int up;
    private int down;
    private int left;
    private int right;

    public int FrontNum() { return this.front; }

    public Dice(int[] faces)
    {
        this.front = faces[0];
        this.down = faces[1];
        this.right = faces[2];
        this.left = faces[3];
        this.up = faces[4];
        this.back = faces[5];
    }

    public int findRightNum(int front, int down)
    {
        for (int i = 0; i < 5; i++)
        {
            if (front == this.front) break;

            if (i < 3) // 0..2
            {
                doE();
            }
            else if (i == 3)
            {
                doN();
            }
            else // 4
            {
                doS(); doS();
            }

        }

        for (int i = 0; i < 3; i++)
        {
            if (down == this.down) break;
            doRotateR();
        }

        return this.right;
    }

    public void next(string command)
    {
        switch (command)
        {
            case "N":
                doN();
                break;
            case "E":
                doE();
                break;
            case "S":
                doS();
                break;
            case "W":
                doW();
                break;
        }
    }

    private void doN()
    {
        var buf = this.down;
        this.down = this.back;
        this.back = this.up;
        this.up = this.front;
        this.front = buf;
    }

    private void doE()
    {
        var buf = this.left;
        this.left = this.back;
        this.back = this.right;
        this.right = this.front;
        this.front = buf;
    }

    private void doS()
    {
        var buf = this.up;
        this.up = this.back;
        this.back = this.down;
        this.down = this.front;
        this.front = buf;
    }

    private void doW()
    {
        var buf = this.right;
        this.right = this.back;
        this.back = this.left;
        this.left = this.front;
        this.front = buf;
    }

    private void doRotateR()
    {
        var buf = this.up;
        this.up = this.left;
        this.left = this.down;
        this.down = this.right;
        this.right = buf;
    }
}

Measured memory_bytes: 5620
# coding: utf-8

rectangle = 0
lozenge = 0


while (str = STDIN.gets)!=nil do
	str.delete!("\n")
	edges = str.split(",")

	#print "#{edges}\n"

	edges.map!{|edge| edge.to_i}



	sum = edges[0]**2 + edges[1]**2

	if sum == edges[2]**2 then
			rectangle += 1
	elsif edges[0] == edges[1] then
			lozenge += 1
	end

end

print "#{rectangle}\n#{lozenge}\n"

Measured memory_bytes: 6104