akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    s = input()

    if s == 'ABC':
        print('ARC')
    else:
        print('ABC')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9092
import java.util.*;
public class Main{
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
    	int m=sc.nextInt();
    	String s;
    	if(n>m){
    		s=">";
    	}else if(n<m){
    		s="<";
    	}else{
    		s="==";
    	}
    	
    	System.out.println("a "+s+" b");
    }
}



Measured memory_bytes: 26204
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const ll INF = 1e9+10;
const int MOD = 1000000007;
ll n,a,b;
vector<ll> h(100005);

bool ok(ll k){
  ll res = 0;
  rep(i,n){
    res += max((h.at(i)-k*b+a-b-1)/(a-b),0LL);
  }
  return res <= k;
}
 
int main() {
  cin >> n >> a >> b;
  rep(i,n) cin >> h.at(i);
  ll right = INF,left = 0;
  while(right-left > 1){
    ll mid = (right + left)/2;
    if(ok(mid)) right = mid;
    else left = mid;
  }
  
  cout << right << endl;
  
  return 0;
}




Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, i321) => {
        read_value!($next, i32) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input! { a: usize, b: usize }
    if a%3 == 0 || b%3==0 || (a+b)%3==0 {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}

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

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

    string s;
    cin >> s;
    int n = s.size();

    vector<int> l, r, ans;
    l.resize(n, -1);
    r.resize(n, -1);
    ans.resize(n, 0);

    // fill left
    for (int i = 1; i < n; ++i) {
        if (s[i] == 'L') {
            l[i] = s[i - 1] == 'L' ? l[i - 1] + 1 : 0;
        }
    }

    // fill right
    for (int i = n - 2; i >= 0; --i) {
        if (s[i] == 'R') {
            r[i] = s[i + 1] == 'R' ? r[i + 1] + 1 : 0;
        }
    }

    // fill ans
    for (int i = 0; i < n; ++i) {
        int index = i;
        if (s[i] == 'L') {
            index -= l[i] + l[i] % 2;
        } else {
            index += r[i] + r[i] % 2;
        }
        ans[index]++;
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i];
        if (i < n - 1) cout << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1872
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = Integer.parseInt(in.nextLine());
        final String word = in.nextLine();
        int red = 0;
        for (char c : word.toCharArray()) {
            if (c == 'R') {
                red++;
            }
        }
        System.out.println(Math.min(red, getSwaps(n, word, red)));
    }

    private static int getSwaps(int n, String word, int color) {
        int swaps = 0;
        for (int i = 0; i < n; i++) {
            if (word.charAt(i) == 'W') {
                swaps++;
            }
            if (--color == 0) {
                break;
            }
        }
        return swaps;
    }
}


Measured memory_bytes: 42080
N, K = map(int, input().split())
A = list(map(int, input().split()))

t_zero = [-1] * N

t = 0
a = 1

while t_zero[a-1] == -1:
  if t == K:
    break
  t_zero[a-1] = t
  t += 1
  a = A[a-1]
  #print(t_zero,a)
else:
  k = (K - t_zero[a-1]) % (t - t_zero[a-1])
  a = a = t_zero.index(t_zero[a-1] + k) + 1
print(a)

Measured memory_bytes: 32320
N,X,Y=map(int,input().split())
ans=0
right=X-1
cycle=Y-X+1
left=N-Y
import copy
ring=copy.copy(cycle)
branchr=copy.copy(right)
if right>0:
    branchr+=1
branchl=copy.copy(left)
if left>0:
    branchl+=1
ring_branchr=0
ring_branchl=0
branchrl=0
count=0
if cycle%2==0:
    for k in range(1,max(left+cycle//2,right+cycle//2,left+right+1)+1):
        if k==cycle//2:
            ring = cycle//2
        if k>cycle//2:
            ring = 0
        if right>0:
            branchr-=1
            if k>right:
                branchr=0
        if left>0:
            branchl-=1
            if k>left:
                branchl=0
        if right>0:
            ring_branchr=min(2*(k-1),right*2)
            if k>cycle//2:
                ring_branchr-=2*(k-cycle//2)-1
            if ring_branchr<0:
                ring_branchr=0
        if left>0:
            ring_branchl=min(2*(k-1),left*2)
            if k>cycle//2:
                ring_branchl-=2*(k-cycle//2)-1
            if ring_branchl<0:
                ring_branchl=0
        if right>0 and left>0:
            if 3<=k<min(right,left)+3:
                branchrl+=1
            if k>max(right,left)+2:
                branchrl-=1
            if branchrl<0:
                branchrl=0
        ans=ring+branchr+branchl+ring_branchr+ring_branchl+branchrl
        print(ans)
        count+=1
if cycle%2==1:
    for k in range(1,max(left+cycle//2,right+cycle//2,left+right+1)+1):
        if k>cycle//2:
            ring = 0
        if right>0:
            branchr-=1
            if k>right:
                branchr=0
        if left>0:
            branchl-=1
            if k>left:
                branchl=0
        if right>0:
            ring_branchr=min(2*(k-1),right*2)
            if k>cycle//2+1:
                ring_branchr-=2*(k-cycle//2-1)
            if ring_branchr<0:
                ring_branchr=0
        if left>0:
            ring_branchl=min(2*(k-1),left*2)
            if k>cycle//2+1:
                ring_branchl-=2*(k-cycle//2-1)
            if ring_branchl<0:
                ring_branchl=0
        if right>0 and left>0:
            if 3<=k<min(right,left)+3:
                branchrl+=1
            if k>max(right,left)+2:
                branchrl-=1
            if branchrl<0:
                branchrl=0
        ans=ring+branchr+branchl+ring_branchr+ring_branchl+branchrl
        print(ans)
        count+=1
for k in range(count+1,N):
    print(0)

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

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

	vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin >> n;

	cout << v[n-1] << '\n';
}


Measured memory_bytes: 256
n = int(input())
s = [ input()  for i in range(n)]
#print(s)

from collections import Counter
s = Counter(s)
v_max = s.most_common()[0][1]
s2 = sorted(s.items())
#s.sort(key=lambda pair: pair[0])
ans = []
for k,v in s2:
  if v_max == v:
    print(k)



Measured memory_bytes: 124292
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <queue>

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;

const int INF = 1e9;
const ll MOD = 1e9 + 7;

struct edge
{
    int to, cost;
};

int di_n; //頂点数
vector<edge> G[1123456];
int di_dis[1123456] = {INF};

void dijkstra(int s)
{
    priority_queue<P, vector<P>, greater<P>> que;
    fill(di_dis, di_dis + 1123456, INF);
    di_dis[s] = 0;
    que.push(P(0, s));

    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        int di_n_ = p.second;
        if (di_dis[di_n_] < p.first)
            continue;
        for (int i = 0; i < G[di_n_].size(); i++)
        {
            edge e = G[di_n_][i];
            if (di_dis[e.to] > di_dis[di_n_] + e.cost)
            {
                di_dis[e.to] = di_dis[di_n_] + e.cost;
                que.push(P(di_dis[e.to], e.to));
            }
        }
    }
}

int main()
{
    int n, m, p[212345], q[212345], c[212345];
    map<P, int> mp, ga;
    cin >> n >> m;

    di_n = 0;

    REP(i, m)
    {
        cin >> p[i] >> q[i] >> c[i];

        if (mp[P(p[i], c[i])] == 0)
        {
            di_n++;
            mp[P(p[i], c[i])] = di_n;
        }
        if (mp[P(q[i], c[i])] == 0)
        {
            di_n++;
            mp[P(q[i], c[i])] = di_n;
        }
        if (mp[P(p[i], -1)] == 0)
        {
            di_n++;
            mp[P(p[i], -1)] = di_n;
        }
        if (mp[P(q[i], -1)] == 0)
        {
            di_n++;
            mp[P(q[i], -1)] = di_n;
        }

        G[mp[P(p[i], c[i])]].push_back(edge{mp[P(q[i], c[i])], 0});
        G[mp[P(p[i], c[i])]].push_back(edge{mp[P(p[i], -1)], 0});

        if (ga[P(p[i], c[i])] == 0)
        {
            G[mp[P(p[i], -1)]].push_back(edge{mp[P(p[i], c[i])], 1});
            ga[P(p[i], c[i])] = 1;
        }

        G[mp[P(q[i], c[i])]].push_back(edge{mp[P(p[i], c[i])], 0});
        G[mp[P(q[i], c[i])]].push_back(edge{mp[P(q[i], -1)], 0});

        if (ga[P(q[i], c[i])] == 0)
        {
            G[mp[P(q[i], -1)]].push_back(edge{mp[P(q[i], c[i])], 1});
            ga[P(q[i], c[i])] = 1;
        }
    }

    dijkstra(mp[P(1, -1)]);

    if (di_dis[mp[P(n, -1)]] == INF || mp[P(n, -1)] == 0)
    {
        cout << -1 << endl;
        return 0;
    }

    cout << di_dis[mp[P(n, -1)]] << endl;

    return 0;
}

Measured memory_bytes: 109688
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
std::istream& operator>>(std::istream &is, std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}

using namespace std;

const uint64_t M = 26;

int main()
{
  uint64_t D;
  cin >> D;

  vector<int64_t> c(M);
  cin >> c;

  vector<vector<int64_t>> s(D, vector<int64_t>(M));
  N_TIMES(d, D) {
    cin >> s[d];
  }

  vector<int64_t> t(D);
  cin >> t;

  vector<int64_t> last(M, 0);
  int64_t S = 0;
  N_TIMES(d, D) {
    S += s[d][t[d] - 1];
    last[t[d] - 1] = d + 1;
    N_TIMES(m, M) {
      S -= c[m] * ((d + 1) - last[m]);
    }
    cout << S << endl;
  }

  return 0;
}

Measured memory_bytes: 3720
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>
#include <math.h>
using namespace std;
double eps = 1e-10;

double add(double a, double b) {
	if (abs(a + b) < eps*(abs(a) + abs(b)))return 0;
	return a + b;
}

struct P {
	double x, y;
	int num;
	P() :x(0), y(0), num(INT32_MAX){
	}
	P(double x, double y) :x(x), y(y), num(INT32_MAX){
	}
	P operator-(P p) {
		return P(add(x, -p.x), add(y, -p.y));
	}
	double dot(P p) {//内積
		return add(x*p.x, y*p.y);
	}
	double det(P p) {//外積
		return add(x*p.y, -y*p.x);
	}
	double dist() {
		return sqrt(x*x + y*y);
	}
};

int n;
double ans[100];
P ps[100];

bool cmp_x(const P& p, const P& q) {
	if (p.x != q.x)return p.x < q.x;
	return p.y < q.y;
}

vector<P> convex_hull() {
	sort(ps, ps + n, cmp_x);
	int k = 0;
	vector<P> qs(n * 2);

	//下側の作成
	for (int i = 0; i < n; i++) {
		while (k > 1 && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= 0)k--;
		qs[k++] = ps[i];
	}

	//上側の作成
	for (int i = n - 2, t = k; i >= 0; i--) {
		while (k > t && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= 0)k--;
		qs[k++] = ps[i];
	}
	qs.resize(k - 1);

	return qs;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		P& p = ps[i];
		cin >> p.x >> p.y;
		p.num = i;
	}
	vector<P>qs = convex_hull();

	//for (int i = 0; i < qs.size();i++)cout << "num:" << qs[i].num << endl;
	
	//ここでそれぞれの割合を求める
	for (int i = 0; i < qs.size(); i++) {
		P x{ -1, 0 }, y{ 0, 1 };

		//ここが間違えてる
		//垂直2等分線のベクトルを作成
		P vec[2];
		for (int j = 0; j < 2; j++) {
			P v = qs[((i + j - 1 < 0)?qs.size()-1:i+j-1)] - qs[(i + j) % qs.size()];
			double ang = acos((v.dot(y)) / (v.dist()));
			if (v.x >= 0)ang *= -1;
			double x2 = x.x*cos(ang) - x.y*sin(ang);
			double y2 = x.x*sin(ang) + x.y*cos(ang);
			vec[j] = P{ x2, y2 };
			//cout << "j:" << j << " x:" << vec[i].x << " y:" << vec[i].y << endl;
		}
		//cout << endl;

		//両ベクトルの内角を求める
		double ang = acos(vec[0].dot(vec[1]));

		//円の割合を求める
		ans[qs[i].num] = ang / (2*M_PI);
	}

	//答えを出力
	cout.precision(20);
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
}

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

int main(){
	int n,m;	cin>>n>>m;
	int gate[1000001]={0};
	
	int l,r;

	int maxl=0,minr=1000001;
	for(int i=0;i<m;i++){
		cin>>l>>r;

		if(maxl<l)maxl=l;
		if(r<minr)minr=r;
	}

	int ans=0;
	if(minr-maxl>=0) ans=1+minr-maxl;

	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <unordered_map>

using namespace std;
const int INF = 0x3f3f3f3f;
//static const auto _____ = []()
//{
//	ios::sync_with_stdio(false);
//	cin.tie(nullptr);
//	return nullptr;
//}();

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    vector<double> prob(N + 2, 0.0);
    for (int i = 1; i <= N; i++) {
        cin >> prob[i];
    }
    vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0.0));// 前i+1个硬币中，j个向上的概率
    //base case
    dp[1][0] = 1.00 - prob[1];
    dp[1][1] = prob[1];
    for (int i = 2; i <= N; i++) {
        dp[i][0] = dp[i - 1][0] * (1.00 - prob[i]);
        for (int j = 1; j <= i; j++) {
            dp[i][j] = dp[i - 1][j - 1] * prob[i] + dp[i - 1][j] * (1.00 - prob[i]);
        }
    }
    double res = 0.00;
    for (int j = 0; j <= N; j++) {
        if (j > N - j) res += dp[N][j];
    }
    printf("%.10lf\n",res);
    return 0;
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n],dp[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=min(i,k);j++)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]) );
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];

    sort(all(p));
    p[n-1] = p[n-1]/2;

    int ans=0;
    rep(i,n) ans += p[i];

    cout << ans << endl;
}

Measured memory_bytes: 3604
n=int(input())
b = list(map(int, input().split()))
ans=[]
for num in range(n):
    dl=-1
    for i in range(len(b)):
        if b[i] == i+1:
            dl=i
    if dl==-1:
        print(-1)
        exit()
    b.pop(dl)
    ans.append(dl+1)
ans = list(reversed(ans))
for i in ans:
    print(i)

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

int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int dp[n];
    dp[n-1]=0;
    dp[n-2]=abs(arr[n-2]-arr[n-1]);
    for(int i=n-3;i>=0;i--)
        dp[i]=min(dp[i+1]+abs(arr[i+1]-arr[i]),dp[i+2]+abs(arr[i+2]-arr[i]));
    cout<<dp[0]<<endl;
}

Measured memory_bytes: 4332
n,m = map(int,input().split())
s = input()[::-1]
idx = 0
ans = [0]
while True:
    flg = False
    step = 0
    for i in range(1, m+1):
        if idx+i <= n:
            if s[idx+i]=='0':
                step = i
                flg = True
    if flg==False:
        break
    else:
        idx += step
    ans.append(idx)

if ans[-1]!=n:
    print(-1)
else:
    ret = []
    for i in range(1,len(ans)):
        ret.append(ans[i]-ans[i-1])
    print(*ret[::-1])

Measured memory_bytes: 51552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	long double n;
	cin>>n;
	ll x[8],y[8];
	for(ll i=0;i<n;i++){
		ll a,b;
		cin>>a>>b;
		x[i]=a;
		y[i]=b;
	}
	long double sum=0;
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++){
			long double dx=x[i]-x[j];
			long double dy=y[i]-y[j];
			sum+=sqrt(dx*dx+dy*dy);
		}
	}
	long double ans=2*sum/n;
	printf("%.9Lf",ans);
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
c_rec = 0
c_rho = 0
while True:
    try:
        a,b,c = map(int, input().split(","))
        if a**2 + b**2 == c**2:
            c_rec += 1
        elif a == b:
            c_rho += 1
    except:
        break
print(c_rec)
print(c_rho)



Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
   string s;
   cin >> s;
    vector<char> buffer;
    for (auto x:s){
        buffer.push_back(x);
        if (buffer[buffer.size()-1] == 'T' && buffer[buffer.size()-2] == 'S'){
            buffer.pop_back();
            buffer.pop_back();
        }
    }
    cout << buffer.size() << endl;
}

Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
struct Matrix{
    mint val[50][50];
    Matrix(){
        rep(i,50){
            rep(j,50){
                val[i][j]=0;
            }
        }
    }
};
Matrix I;
Matrix operator*(Matrix a,Matrix b){
    Matrix c;
    rep(i,50){
        rep(j,50){
            rep(k,50){
                c.val[i][j]+=a.val[i][k]*b.val[k][j];
            }
        }
    }
    return c;
}
Matrix matrix_power(Matrix A, ll k){
    if(k==0) return I;
    Matrix res=matrix_power(A,k/2);
    res=res*res;
    if(k%2==1) res=res*A;
    return res;
}
ll n,k;
int main(){
    rep(i,50) I.val[i][i]=1;
    cin >> n >> k;
    Matrix A;
    rep(i,n){
        rep(j,n){
            cin >> A.val[i][j].x;
        }
    }
    Matrix A_k=matrix_power(A,k);
    mint ans=0;
    rep(i,n){
        rep(j,n){
            ans+=A_k.val[i][j];
        }
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 3840
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    vector<string> s(n);
    rep(i, n) {
        cin >> s[i];
    }
    bool four = false;
    rep(i, n) {
        if (s[i] == "Y") four = true;
    }
    cout << (four ? "Four" : "Three") << endl;
}


Measured memory_bytes: 888
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();

      int an  = a*b*1;
      int ann = a*b*2;
      int annn = a*b*3;
      if((an%2!=0)&&an<10||(a*b*2%2!=0)&&ann<10||(a*b*3%2!=0)&&annn<10){
        System.out.print("Yes");
              System.exit(0);
      }
      System.out.println("No");
      }

  }

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int W,N;
int x[100001];
int sum[100001];

bool ok(int mx){
  rep(i,N)sum[i+1]=sum[i]+x[i];
  vector<bool> dp(N+1,false);
  dp[0]=true;
  int l=0,r=0;
  int cnt=0;
  repl(i,1,N+1){
    while(r<i-1&&(W-(sum[i]-sum[r])+(i-2-r))/(i-1-r)<=mx){
      cnt+=dp[r];
      r++;
    }
    while(sum[i]-sum[l]+(i-1-l)>W){
      cnt-=dp[l];
      l++;
    }
    dp[i]=cnt>0;
  }
  bool ok=false;
  for(int i=N;i>=0&&sum[N]-sum[i]+(N-1-i)<=W;i--)ok|=dp[i];
  return ok;
}

int main(){
  while(1){
    cin>>W>>N;
    if(W==0)break;
    rep(i,N)cin>>x[i];
    int lb=0,ub=W;
    while(ub-lb>1){
      int mid=(lb+ub)/2;
      if(ok(mid))ub=mid;
      else lb=mid;
    }
    cout<<ub<<endl;
  }
  return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

ll g(ll n) {return n * (n+1) / 2;}


int main()
{   
    int h, w, k;
    cin >> h >> w >> k;
    vs s(h);
    rep(i, h) cin >> s[i];

    int ans = 0;
    rep(ybit, (1<<h)) rep(xbit, (1<<w)) {
        int cnt = 0;
        rep(i, h) rep(j, w) {
            if(ybit>>i&1) continue;
            if(xbit>>j&1) continue;
            if(s[i][j] == '#') cnt++;
        }
        if(cnt == k) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N;
    cin >> K;
    int sum = 0;
    for(int i = N;i >= N && i <= K;i++){
        if(i / 10000 == i % 10 && ( i % 10000 ) / 1000 == (i % 100) /10){
            sum ++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#pragma GCC optimize(3)   
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define rep(i,n) for(int i=0 ; i<n ; i++)
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
#define N (ll)2e5+10
#define M (ll)1e18 
#define matrix vector<vector<ll> >
#define sz(x) (int)x.size()
 

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    
    int n ;
    cin >> n ;
    int x = n/1000 ;
    if(x*1000<n)x++ ;
    cout << x*1000 - n ;

     return 0 ;
    
    
 }

Measured memory_bytes: 3644
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int n,fa[N],a[N];
struct LY { int x,y,id; }b[N];
bool operator < (LY A,LY B)
{
	LL g1=(LL)A.x*B.y,g2=(LL)A.y*B.x;
	return g1==g2?A.id< B.id:g1< g2;
}
set <LY> s;
struct UNION
{
	int fa[N];
	void init (int n) { for (int i=1; i<=n; i++) fa[i]=i; }
	int getf (int x) { return fa[x]==x?x:fa[x]=getf (fa[x]); }
}U;
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n);
	for (int i=2; i<=n; i++)
		sc(fa[i]);
	for (int i=1; i<=n; i++)
		sc(a[i]);
	U.init (n);
	LL ans=0;
	for (int i=1; i<=n; i++)
	{
		b[i]=(LY){a[i]==1,a[i]==0,i};
		if (i> 1) s.insert (b[i]);
	}
	for (int T=1; T< n; T++)
	{
		int x=(*s.begin ()).id,f=U.getf (fa[x]);
		ans+=(LL)b[f].x*b[x].y;
		s.erase (b[x]),s.erase (b[f]);
		b[f].x+=b[x].x,b[f].y+=b[x].y;
		if (f> 1) s.insert (b[f]);
		U.fa[x]=f;
	}
	pr(ans);

    return 0;
}

Measured memory_bytes: 34048
import java.util.*;
import java.io.*;

public class Main 
{
	static int a;static int b;static int c;static int n;
	static int[]bamboos;
	public static void main(String[] args) throws IOException 
	{ 
		Scanner s = new Scanner(System.in);
		 n=s.nextInt();
		 a=s.nextInt();
		 b=s.nextInt();
		 c=s.nextInt();
		 bamboos=new int[n];
		for(int i=0;i<n;i++)
			bamboos[i]=s.nextInt();
		System.out.println(syntheticBamboos(0,0,0,0));
	}
	private static long syntheticBamboos(int x, int y, int z, int i) {
		if(i==n) {
			if(x==0 ||y==0 ||z==0)return Integer.MAX_VALUE;
			return Math.abs(x-a)+Math.abs(y-b)+Math.abs(z-c); ///cost to form orignal bamboos
		}
		
		long op1=syntheticBamboos(x, y, z, i+1); //exculde
		long op2=syntheticBamboos(x+bamboos[i], y, z, i+1)+((x>0)?10:0);//include and add 10 if x already have some value
		long op3=syntheticBamboos(x, y+bamboos[i], z, i+1)+ ((y>0)?10:0);
		long op4=syntheticBamboos(x, y, z+bamboos[i], i+1)+ ((z>0)?10:0);
		
		return Math.min(op1, Math.min(op2,Math.min(op3, op4)));
	}
	
}


Measured memory_bytes: 38028
fun main(args: Array<String>) {
    val mod = 1000000007L
//    val (N,D) = readLine()!!.split(" ").map { it.toInt() }
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toInt() }.toList()

    val set = mutableSetOf<Int>()

    for (i in N downTo 1) {
        var tmp = A[i-1]
        for (j in 2 until N/i+1) {
            if (set.contains(i*j)) tmp++
        }

        if (tmp%2 == 1)
            set.add(i)
    }

    println(set.size)
    println(set.joinToString(" "))
}



Measured memory_bytes: 99812
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define fep(i,n) for(i=0;i<(n);i++)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define N 1000000007
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t,r,j,i,n,m,k;
    cin>>n>>m>>k;
    vi a(n),b(m),sa(n+1,0),sb(m+1,0);
    for(i=0;i<n;i++){
        cin>>a[i];
        sa[i+1]=sa[i]+a[i];
    }
    for(i=0;i<m;i++){
        cin>>b[i];
        sb[i+1]=sb[i]+b[i];
    }
    int ans=0;
    for(i=0;i<=n;i++){
        if(sa[i]>k)
        break;
        int r=k-sa[i];
        int lo=0,hi=m;
        j=0;
        while(lo<=hi){
            int mid=lo+(hi-lo)/2;
            if(sb[mid]<=r){
                j=mid;
                lo=mid+1;
            }
            else{
                hi=mid-1;
            }
        }
        ans=max(ans,i+j);
    }
    cout<<ans<<endl;
   
   
   
}

    



Measured memory_bytes: 9524
printMark row col = if( mod (row + col) 2 == 0) then "#" else "."

printChess :: [Int] -> IO()
printChess [0,0] = return()
printChess [h,w] = printChess [h,w,1,1]
printChess [h,w,row,col]
    | row == h && col == w = do
        putStrLn $ printMark row col
        putStr "\n"
    | col == w = do
        putStr $ printMark row col
        putStr "\n"
        printChess [h,w,row + 1,1]
    | otherwise = do
        putStr $ printMark row col
        printChess [h,w,row,col + 1]

main = getContents >>= mapM_ printChess . map (map read) . (map words) .  lines


Measured memory_bytes: 5448
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll A[int(2e5 + 5)];
map<ll, ll> mp;

int main(){
  scanf("%d", &N);
  for (ll i = 0; i < N; i++) {
    scanf("%lld", A + i);
    mp[i - A[i]]++;
  }

  ll ans = 0;
  for (ll i = 0; i < N; i++){
    mp[i - A[i]]--;
    ans += mp[i + A[i]];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 27784
import numpy as np
N=int(input())
if N>81:
    print('No')
elif N==1:
    print('Yes')
else:
    for i in range(2,10):
        if N%i==0 and N//i<=9:
            print('Yes')
            break
        elif i==9:
            if N%i==0 and N//i<=9:
                print('Yes')
            else:
                print('No')

Measured memory_bytes: 12500
n = int(input())
s = [0]*n
for i in range(n):
    s[i] = int(input())
s.sort()
ans = sum(s)
if all(i%10==0 for i in s):
    print(0)
    exit(0)
else:
    for i in s:
        if ans%10==0 and i%10!=0:
            ans -= i
print(ans)

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

const int N = 200005;

int h, w, n;
int r, c;
char s[N], t[N];

int find_optimal(int st, int en, char l, char r) {
  int ll = 0, rr = en-1, ans = -1;
  while (ll <= rr) {
    int mid = ll + rr >> 1;
    
    bool can = true;
    int cur = st;
    
    for (int i=0; i<n; i++) {
      if (s[i] == l) --cur;
      if (cur < 0) {
        can = false;
        break;
      }
      
      if (t[i] == r) cur = min(cur+1, max(cur, mid));
    }
    
    if (can) {
      ans = mid;
      rr = mid - 1;
    } else ll = mid + 1;
  }
  
  return ans;
}


bool okay(int st, int en, int opt, char l, char r) {
  vector<int> v;
  for (int i=0; i<n; i++) {
    if (s[i] == r) v.push_back(1);
    else v.push_back(0);
    
    if (t[i] == l) v.push_back(-1);
    else v.push_back(0);
  }
}

int solve(int st, int en, char l, char r) {
  int tmp1 = find_optimal(st, en, l, r);
  if (tmp1 == -1) return 0;
  
  int tmp2 = find_optimal(en - st - 1, en, r, l);
  if (tmp2 == -1) return 0;
  tmp2 = en - tmp2 - 1;
    
  return 1;
}



int main() {
  scanf("%d %d %d", &h, &w, &n);
  scanf("%d %d", &r, &c);
  scanf("%s", s);
  scanf("%s", t);
  
  --r, --c;
  
  if (solve(r, h, 'U', 'D') && solve(c, w, 'L', 'R')) {
    printf("YES\n");
  } else printf("NO\n");
  
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    int mn = 10000000;

    for(int i = 1; i < N; i++) {
            int result = 0;
            int A = i;
            int B = N - i;
            while(A > 0 || B > 0) {
                result += (A % 10) + (B % 10);
                A /= 10;
                B /= 10;
            }
            mn = min(mn, result);
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005]={0};
int main()
{
	int n,k,q;
	cin>>n>>k>>q;
	for (int i=1;i<=q;i++)
	{
		cin>>a[i];
		b[a[i]]++;
	}
	for (int i=1;i<=n;i++)  b[i]=k-(q-b[i]);
	for (int i=1;i<=n;i++)
	{
		if (b[i]>0)  cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let s: Vec<char> = it.next().unwrap().chars().collect();
    let d: usize = it.next().unwrap().parse().unwrap();
    const MOD: u32 = 1_000_000_007;
    let mut dp = vec![0; d];
    let mut sup = 0;
    for c in s {
        let k = c.to_digit(10).unwrap() as usize;
        let mut next = vec![0; d];
        for i in 0..d {
            for j in 0..10 {
                let x = (i + j) % d;
                next[x] += dp[i];
                next[x] %= MOD;
            }
        }
        for i in 0..k {
            let x = (sup + i) % d;
            next[x] += 1;
            next[x] %= MOD;
        }
        dp = next;
        sup = (sup + k) % d;
    }
    let ans = (dp[0] + MOD - 1 + if sup == 0 {1} else {0}) % MOD;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
int k;
string s;
int main()
{
	cin>>k>>s;
	if(s.size()<=k) cout<<s<<endl;
	else{
		for(int i=0;i<k;++i) cout<<s[i];
		cout<<"..."<<endl;
	}
}

Measured memory_bytes: 3592
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        int search = 1;
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < a.length; i++) {
            if (a[i] == search) {
                list.add(search);
                search++;
            }
        }
        if (list.size() == 0) {
            System.out.println(-1);
        } else {
            System.out.println(N - list.size());
        }
        sc.close();
    }
}

Measured memory_bytes: 91492
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

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

struct Node {
	int x, y, d;
	Node(int a, int b, int c) {
		x = a, y = b, d = c;
	}
	bool operator<(const Node&n)const {
		return make_pair(x, y) < make_pair(n.x, n.y);
	}
};

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

	while (cin >> H >> W, H) {
		vector<string>s(H);
		for (auto &i : s)cin >> i;
		map<string, set<Node>>st;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				for (int k = 0; k < 8; k++) {
					string box;
					vector<vector<int>>visited(H, vector<int>(W));
					int ny = i, nx = j;
					while (!visited[ny][nx]) {
						visited[ny][nx] = 1;
						box.push_back(s[ny][nx]);
						ny += dy[k];
						nx += dx[k];
						if (ny < 0)ny += H;
						if (ny >= H)ny -= H;
						if (nx < 0)nx += W;
						if (nx >= W)nx -= W;
						st[box].insert(Node(i, j, k));
					}
				}
			}
		}
		string ans = "";
		for (auto i : st) {
			if (i.second.size() == 1)continue;
			if (ans.size() < i.first.size())ans = i.first;
		}
		if (ans.size() <= 1) {
			cout << 0 << endl;
		}
		else cout << ans << endl;
	}
}


Measured memory_bytes: 52160
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n; cin >> n;
	string s; cin >> s;
	if(n%2!=0)
	{
		cout << "No";
		return 0;
	}
	string a, b;
	a = s.substr(0,n/2);
	b = s.substr(n/2,n/2);
	if(a==b)
		cout << "Yes";
	else
		cout <<"No" ;
}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();

		System.out.print(a*b);

	}

}

Measured memory_bytes: 35484
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 

ll dp[10000001];

void f(ll n) 
{
    for (ll i = 2; i <= n; i++) {
        ll num = i;
        while(num<=n) {
            dp[num]++;
            num += i;
        } 
    }
} 
 
int32_t main() {
    fastio;
    ll n,ans=0;
    cin>>n;
    f(10000000);
    for(ll i=1;i<=n;i++) {
        ans += i * (dp[i]+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 81760
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::collections::BTreeSet;

fn main() {
    let n: usize = read();
    let s: String = read();
    let nv: Vec<usize> = s.chars().map(|c| c as usize - 48).collect();
    let mut lcnt: Vec<u32> = vec![0; 10];
    let mut rcnt: Vec<u32> = vec![0; 10];
    let mut ans: BTreeSet<usize> = BTreeSet::new();
    lcnt[nv[0]] += 1;
    for i in 2..n {
        rcnt[nv[i]] += 1;
    }
    for i in 1..n - 1 {
        for l in 0..10 {
            for r in 0..10 {
                if lcnt[l] > 0 && rcnt[r] > 0 {
                    ans.insert(l * 100 + nv[i] * 10 + r);
                }
            }
        }

        lcnt[nv[i]] += 1;
        rcnt[nv[i + 1]] -= 1;
    }
    println!("{}", ans.len());
}


Measured memory_bytes: 4352
/* ***********************************************
Author        :xiaowuga
Created Time  :2017年10月21日 星期六 00时26分57秒
File Name     :text.cpp
************************************************ */
#include <bits/stdc++.h>
typedef long long LL; 
#define endl "\n" 
#define inf 0x3f3f3f3f 
const long long N=1000000;
const long long mod=1e9+7;
using namespace std;
int dfn[N],low[N],tot=0;
int ct=0;
vector<int>G[N];
void tarjan(int u,int fa){
	dfn[u]=low[u]=++tot;
	int cnt=0;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==fa) continue;
		if(!dfn[v]){
			tarjan(v,u);
			low[u]=min(low[u],low[v]);
			if(low[v]>dfn[u]) ct++;
		}
		else{
			low[u]=min(low[u],dfn[v]);
		}
	}
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	for(int i=1;i<=n;i++){
		if(!dfn[i]) tarjan(i,-1);
	}
	cout<<ct<<endl;
    return 0;
}


Measured memory_bytes: 26880
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

const int MAX=INT_MAX/10;
int main(){
	int T;
	while(cin>>T,T){
		vi t(T);
		REP(i,T){
			cin>>t[i];
		}
		int n;
		cin>>n;
		vi d(n),m(n);
		REP(i,n){
			cin>>d[i]>>m[i];
		}
		vvi dp(101,vi(31,MAX));
		dp[1][0]=0;
		FOR(i,1,100){
			int hour=MAX;
			REP(j,n){
				if(d[j]==i+1&&hour>m[j]){
					hour=m[j];
				}
			}
			REP(j,T){
				if(hour<MAX&&hour<t[(j+1)%T]){
					dp[i+1][0]=min(dp[i+1][0],dp[i][j]+1);
				}else{
					REP(k,2){
						if(k){
							dp[i+1][0]=min(dp[i+1][0],dp[i][j]+1);
						}else{
							dp[i+1][(j+1)%T]=min(dp[i+1][(j+1)%T],dp[i][j]);
						}
					}
				}
			}
		}
		int ans=MAX;
		REP(i,T){
			ans=min(ans,dp[100][i]);
		}
		cout<<ans<<endl;
	}
}

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

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int cnt_ab = 0;
    int cnt_b = 0;
    rep(i, n) {
        if ( s[i] == 'a' ) {
            if ( cnt_ab < a + b ) {
                cout << "Yes" << endl;
                ++cnt_ab;
            }
            else {
                cout << "No" << endl;
            }
        }
        else if ( s[i] == 'b' ) {
            if ( cnt_ab < a + b && cnt_b < b ) {
                cout << "Yes" << endl;
                ++cnt_ab;
                ++cnt_b;
            }
            else {
                cout << "No" << endl;
            }
        }
        if ( s[i] == 'c' ) {
            cout << "No" << endl;
        }
//        cout << cnt_ab << " " << cnt_b << endl;
    }
    return 0;
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

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

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

		int h[] = new int[n];

		String str[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			h[i] = Integer.parseInt(str[i]);
		}

		int ans = 0;
		int j = 0;

		for (int i = 0; i < n; i++) {
			while (j < n - 1 && h[j] >= h[j + 1]) {
				j++;
			}
			ans = Math.max(ans, j - i);
			if (i == j) {
				j++;
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 45596
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll d; cin >> d;
  
  if(d==25) cout << "Christmas" << endl;
  else if(d==24) cout << "Christmas Eve" << endl;
  else if(d==23) cout << "Christmas Eve Eve" << endl;
  else if(d==22) cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
N=int(input())
S=list(range(1, N+1))#頂点の数
H = [sorted(list(map(int,input().split()))) for i in range(N-1)]#辺のリスト。頂点は右にいくほど大きい
F = 0
tyouten = int(N*(N+1)*(N+2)/6)
for i in range(len(H)):
    F += H[i][0]*(N-H[i][1]+1)#uVの組み合わせによって得られる辺の数をFに追加
print(tyouten-F)#頂点数からHselectの要素数を引いた数＝連結成分数

Measured memory_bytes: 53264