akhauriyash/Code-Regression huggingface dataset:
int D[4][2]={/*{-1,-1},{-1,0},{-1,1},{0,-1},*/{0,1},{1,-1},{1,0},{1,1}};
char m[10][10];
int grid(){
	int i=1,j,k,l;
	for(;i<9;i++)for(j=1;j<9;j++)if(m[i][j]=='Q')for(k=0;k<4;k++)for(l=1;m[i+D[k][0]*l][j+D[k][1]*l];l++)if(m[i+D[k][0]*l][j+D[k][1]*l]=='Q')return 0;
	return 1;
}
void dfs(int depth){
	if(!grid())return;
	int i=1,j;
	if(depth==8){for(;i<9;i++)puts(m[i]+1);exit(0);}
	for(;i<9;i++)for(j=1;j<9;j++)if(m[i][j]!='Q'){
		m[i][j]='Q';
		dfs(depth+1);
		m[i][j]='.';
	}
}
main(){
	int N,i,j,x,y;
	for(i=1;i<=8;i++)for(j=1;j<=8;j++)m[i][j]='.';
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d%d",&y,&x),m[y+1][x+1]='Q';
	dfs(N);
	puts("No Answer");
	exit(0);
}



Measured memory_bytes: 2108
function main()
  
  (N,M) = map(x -> parse(BigInt,x), split(readline()))
  
  if abs(N-M) > 1
    println(0)
  elseif N-M == 0
    println((factorial(N)^2 * 2) % (10^9 + 7))
  else
    println((factorial(N)*factorial(M)) % (10^9 + 7))
  end
  
end

main()

Measured memory_bytes: 115080
from random import choice
from random import random
from time import time


class Optimizer:
    def __init__(self, C, S):
        self.C = C
        self.S = S
        X = []
        L = [-1] * 26
        for i in range(365):
            max_diff = -10**10
            best_j = 0
            for j in range(26):
                memo = L[j]
                L[j] = i
                diff = self.S[i][j] - \
                    sum([self.C[jj] * (i - L[jj]) for jj in range(26)])
                if diff > max_diff:
                    max_diff = diff
                    best_j = j
                L[j] = memo
            L[best_j] = i
            X.append(best_j)
        self.X = X

    def calc_score(self):
        score = 0
        L = [-1 for j in range(26)]
        A = [0 for j in range(26)]
        for i in range(365):
            score += self.S[i][self.X[i]]
            A[self.X[i]] += (i - L[self.X[i]]) * \
                (i - L[self.X[i]] - 1) // 2
            L[self.X[i]] = i
        for j in range(26):
            A[j] += (365 - L[j]) * (365 - L[j] - 1) // 2
            score -= self.C[j] * A[j]
        return score

    def optimize(self, temp, threp, interval, start_time, lim=1.8):
        max_score = self.calc_score()
        while True:
            t = (time() - start_time) / 2
            if random() < threp:
                i = choice(range(365))
                j = choice(range(26))
                memo = self.X[i]
                self.X[i] = j
                new_score = self.calc_score()
                if new_score > max_score:
                    max_score = new_score
                elif random() < pow(2.7, (new_score - max_score) / pow(2000, 1 - t)):
                    max_score = new_score
                else:
                    self.X[i] = memo
            else:
                a = choice(range(interval))
                i0 = choice(range(365 - a))
                i1 = i0 + a
                self.X[i0], self.X[i1] = self.X[i1], self.X[i0]
                new_score = self.calc_score()
                if new_score > max_score:
                    max_score = new_score
                elif random() < pow(2.7, (new_score - max_score) / pow(2000, 1 - t)):
                    max_score = new_score
                else:
                    self.X[i0], self.X[i1] = self.X[i1], self.X[i0]
            if time() - start_time > lim:
                break
        return max(max_score + 10**6, 0)


if __name__ == "__main__":
    d = int(input())
    *C, = map(int, input().split())
    S = [list(map(int, input().split())) for i in range(d)]
    opt = Optimizer(C, S)
    opt.optimize(800, 0.8, 11, time())
    for x in opt.X:
        print(x + 1)
    # print(opt.calc_score())


Measured memory_bytes: 90824
H, W = map(int, input().split())
s=[]

for i in range(0, H):
    s.append(input())

ans="Yes"
for y in range(0, H):
    for x in range(0, W):
        if s[y][x]==".":
            continue

        c=0
        for d in range(-1, 2, 2):
            xx = x + d
            if 0<=xx and xx<W:
                if s[y][xx]=="#":
                    c+=1
            yy = y + d
            if 0<=yy and yy<H:
                if s[yy][x]=="#":
                    c+=1
        if c==0:
            ans="No"
print(ans)    

Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
using namespace std;
#define INF 2400000000
long long int Min(long long int x,long long int y){
        return x>y?y:x;
}
int main(){
        int N;
        cin >> N;
        vector <vector <long long int> > adjancent(N,vector <long long int>(N,INF));
        for(int i=0 ; i<N ; i++ ){
                int n,degree,to,cost;
                cin >> n >> degree;
                for(int l=0 ; l<degree ; l++ ){
                        cin >> to >> cost;
                        adjancent[n][to]=cost;
                }
        }
        vector<long long int> dp(N,INF);
        dp[0]=0;
        bool sign=true;
        while(sign){
                sign=false;
                for(int now=0 ; now<N ; now++){
                        for(int i=0 ; i<N ; i++ ){
                                int tmp=dp[i];
                                dp[i]=Min(dp[i],dp[now]+adjancent[now][i]);
                                if(tmp!=dp[i])
                                        sign=true;
                        }
                }
        }
        for(int i=0 ; i<N ; i++ )
                cout <<i<<" "<<dp[i]<<endl;
        return 0;
}



Measured memory_bytes: 3188
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

double before_degree = 0;;

int main(void){

    int length = 0,degree = 0;
    double x = 0,y = 0;
    char c;
    double pi = M_PI;
    
    while(cin >> length  >> c >> degree){
        if(length == 0 && degree == 0){
            break;
        }
        
        x += (double)(length * sin((pi * before_degree) / 180));
        y += (double)(length * cos((pi * before_degree) / 180));
        before_degree = (double)(degree + before_degree);
        
    }

    printf("%d\n%d\n",(int)x,(int)y);

    return 0;
}

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


int main(){
  int n, m,X,Y;
  cin >> n >> m>>X>>Y;
  vector<int> x(n);
  vector<int> y(m);
  rep(i,n) cin >> x[i];
  rep(i,m) cin >> y[i];

  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  if(y[0]-x.back()<1) {
      cout << "War" <<endl;
      return 0;
  } 
  if(y.front()-X<1||Y-x.back()<1) {
      cout << "War" <<endl;
      return 0;
  }
cout << "No War" <<endl;

   }

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a;
  cin>>a;
  if(a==1)
    cout<<1.0;
  else if(a%2==0)
    cout<<0.5;
    else
     cout<<((a/2)+1)/(a*1.0);
     return 0;
}










Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	ll A,B,C,K,an;
	cin >>A>>B>>C>>K;
	if (A >= K) {
		an = K;
	}
	else if (A + B >= K) {
		an = A;
	}
	else {
		an = A - (K - A - B);
	}
	cout << an << endl;


}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;
int A[200010];

int main(){
	cin >> N;
	repp(i,0,N) cin >> A[i];
	int r = 0 , x = 0;
	LL ans = 0;
	repp(l,0,N){
		while(r < N && !(x&A[r])) x ^= A[r++];
		ans += r - l;
		x ^= A[l];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int l = in.nextInt(), n = 0;
		while(Math.pow(2, n) <= l) n++;
		List<Edge> list = new ArrayList<>();
		for(int i = 1; i < n; i++) {
			list.add(new Edge(i, i + 1, (int)Math.pow(2, i - 1)));
			list.add(new Edge(i, i + 1, 0));
		}
		int cost = (int)Math.pow(2, n - 1);
		int left = l - (int)Math.pow(2, n - 1);
		while(0 < left) {
			int t = 0;
			while(Math.pow(2, t + 1) <= left) t++;
			list.add(new Edge(t + 1, n, cost));
			cost += (int)Math.pow(2, t);
			left -= (int)Math.pow(2, t);
		}
		System.out.println(n + " " + list.size());
		list.forEach(System.out::println);
	}
}

class Edge {
	int from, to, cost;
	public Edge(int from, int to, int cost) {
		this.from = from; this.to = to; this.cost = cost;
	}
	public String toString() { return from + " " + to + " " + cost; }
}
	


Measured memory_bytes: 28884
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
//　25min
int main(void){
  int a, b, c, x, y;
  int sum_min = 0;
  int sum = 0;

  scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);

  sum_min = a * x + b * y;
  
  if(x > y){
    sum = x * 2 * c;
  }else{
    sum = y * 2 * c;
  }
  if(sum_min > sum){
    sum_min = sum;
  }

  if(x > y){
    sum = y * 2 * c + (x-y) * a;
  }else{
    sum = x * 2 * c + (y-x) * b;
  }

  if(sum_min > sum){
    sum_min = sum;
  }

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


Measured memory_bytes: 128
n = int(input())
mx = 200000
mem = set()
a = list(map(int,input().split()))
num = [0 for _ in range(mx+1)]
for v in a:
    num[v]+=1
start = 1
idex = 0
while idex <n:
    if num[start]>0:
        while a[idex]!=start and idex<n:
            num[a[idex]] -=1
            idex+=1
        num[start]-=1
        idex+=1
        start+=1
    else:
        idex+=1
ans =(n-(start-1))
if ans <= n-1:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 26140
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using PLL = pair<LL,LL>;
using VPI = vector<PII>;
using VPL = vector<PLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define RREP(i,m,n) for(int i=(m);i>=(n);i--)

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  while(a>0 && c>0){
    c -= b;
    if(c<=0){break;}
    a -= d;
  }
  
  if(a>0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#define ll long long 
using namespace std;
int n, x, t;
int a[100005], b[100005];
int Gcd(int M, int N)
{
	if (N == 0)
		return M;
	return Gcd(N, M % N);
}
int main()
{
int n;
cin >> n >> x;
for (int i = 0; i < n; i++)
	cin >> a[i];
a[n] = x;
sort(a, a + n + 1);
for (int i = 0; i < n; i++)
	b[i] = a[i + 1] - a[i];
t = b[0];
for (int i = 0; i < n; i++)
	t = min(t, Gcd(t, b[i]));
cout << t;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

int main(){
    ll i,n,tmp;
    cin >> n;
    tmp = sqrt(n);
    for(i=tmp;i>=0;i--){
        if(n%i == 0) break;
    }
    cout << i + n/i -2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if(A == B && B == C){
  cout << "No" << endl;
  }
  else if(A != B && B != C && C != A){
  cout << "No" << endl;
  }
  else{
  cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, K;
  cin >> N >> K;
  vector<lint> P(N);
  REP(i, N) cin >> P[i];
  REP(i, N) P[i]--;
  vector<lint> C(N);
  REP(i, N) cin >> C[i];
  lint ans = -1e15;
  REP(i, N) {
    vector<lint> score;
    lint now = P[i];
    lint tmp = 0;
    lint ma = -1e15;
    while(true) {
      tmp += C[now];
      ma = max(ma, tmp);
      score.push_back(tmp);
      if(now == i) break;
      now = P[now];
    }
    lint x = K / score.size();
    lint y = K % score.size();
    if(score[score.size()-1] <= 0) {
      ans = max(ans, ma);
    } else {
      if(x > 0) ans = max(ans, score[score.size()-1]*(x-1) + ma);
      REP(i, y) {
        ans = max(ans, score[score.size()-1]*x + score[i]);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3840
N,M = map(int,input().split())
D = [[]for _ in range(N)]#元の入力順と設立年数を県ごとに保持するリスト

for i in range(M):
    p,y = map(int,input().split())
    D[p-1].append((y,i))
ans = [0]*M
#print(D)

for i,d in enumerate(D):
    #print(i,d)
    d.sort()
    for k,(y,j)in enumerate(d):
        #print(k,(y,j))
        ans[j]=str(i+1).zfill(6)+str(k+1).zfill(6)

print('\n'.join(ans))




Measured memory_bytes: 41404
#include<stdio.h>
int main()
{
    int m,f,r,sum=0,i;
    for(;scanf("%d%d%d",&m,&f,&r);)

    {
    if(m==-1 && f==-1 && r==-1)
    break;
    else if(m<=50 && f<=50 && r<=100)
       { sum=m+f;
        if(m==-1 || f==-1 || m+f<30)
            printf("F\n");
        else if(sum>=80)
            printf("A\n");
        else if(sum>=65 && sum<80)
            printf("B\n");
        else if(sum>=50 && sum<65)
            printf("C\n");
            else if(sum>=30 && sum<50 && r>=50)
            printf("C\n");
        else if(sum>=30 && sum<50)
            printf("D\n");
         }
    }
    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    int cnt = 0;
    int ans = 0;
    for(int i = 100; i >= 1; i--){
        if(a%i==0 && b%i==0){
            cnt++;
        }
        if(cnt==k){
            ans = i;
            break;
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define fe(x)                   *(x.begin())
#define le(x)                   *(x.rbegin())
#define pb                      push_back
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x)                  find_by_order(x)
#define ook(x)                  order_of_key(x)
#define all(x)                  (x).begin(),(x).end()
#define FOR(i,n)                for(int i = 1; i<=n; i++)
#define REP(i,n)                for(int i = 0; i<n;  i++)
#define TT                      int TC;  scanf("%d",&TC);  while(TC--)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define dbg(...)                debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
using                           namespace __gnu_pbds;
using                           namespace std;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;

vector<string> vec_splitter(string s){
    s += ','; vector<string> res;
    while(!s.empty()) res.push_back(s.substr(0,s.find(','))), s = s.substr(s.find(',') + 1);
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused))int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T){
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") "; stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str(); debug_out(args, idx + 1, LINE_NUM, T...);
}




main(){
//read;

int cnt = 0;

int n;
cin>>n;
FOR(i,n){
    int a;
    cin>>a;
    if(i!=a)    cnt++;
}

if(cnt<=2)  cout<<"YES";
else cout<<"NO";

return 0;
}



Measured memory_bytes: 256
using System;

class A
{
	static void Main()
	{
		var s = Console.ReadLine();
		var k = long.Parse(Console.ReadLine());

		var sum = 0;
		var c = s[0];
		for (int i = 1; i < s.Length; i++)
		{
			if (c == s[i]) { sum++; c = '!'; }
			else c = s[i];
		}

		if (s[0] != s[s.Length - 1])
		{
			Console.WriteLine(k * sum);
		}
		else
		{
			var t1 = s.Length - s.TrimStart(s[0]).Length;
			if (t1 == s.Length)
			{
				Console.WriteLine(k * t1 / 2);
			}
			else
			{
				var t2 = s.Length - s.TrimEnd(s[0]).Length;
				Console.WriteLine(k * sum + (t1 % 2 == 1 && t2 % 2 == 1 ? k - 1 : 0));
			}
		}
	}
}


Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <utility>
#include <memory>
#include <valarray>

using namespace std;

using ll = long long int;
#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

constexpr int mod = 1000000007;

// modをとった和を返す
inline
int modPlus(int a, int b){return (a + b) % mod;}

// modをとった差を返す
inline
int modMinus(int a, int b){return (mod + a - b) % mod;}

// modをとった積を返す
inline
int modMultiple(int a, int b){return (static_cast<long long>(a) * b) % mod;}

int main()
{
    scanInt(N);
    vector<int> dpsum(N + 1);
    dpsum[0] = 0;
    dpsum[1] = N;
    // printf("%d ", N);
    for (int i = 2; i <= N; ++i){
        dpsum[i] = dpsum[i - 1];
        dpsum[i] = modPlus(dpsum[i], modMinus(dpsum[i - 1], dpsum[i - 2]));
        dpsum[i] = modPlus(dpsum[i], modMultiple(N - 1, N - 1));
        dpsum[i] = modPlus(dpsum[i], min(N - 1, N - 1 - (i - 3)));
        dpsum[i] = modPlus(dpsum[i], dpsum[max(0, i - 3)]);
        // printf("%d ", modMinus(dpsum[i], dpsum[i - 1]));
    } // puts("");
    printf("%d\n", modMinus(dpsum[N], dpsum[N - 1]));
}


Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {

	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	String op = sc.next();
	int b = sc.nextInt();
	
		if(op.equals("+")) {
			System.out.println(a + b);
		} else if(op.equals("-")) {
				System.out.println(a - b);
		} else {
			throw new Exception("Error");
		}
	}
}

Measured memory_bytes: 9804
n,m=map(int, input().split())
A=list()
b=list()
for i in range(n):
    A.append(list(map(int,input().split())))
for i in range(m):
    b.append(int(input()))
for i in range(n):
    c=0
    for j in range(m):
        c += A[i][j]*b[j]
    print(c)


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

int main(){
	int N, i, ans=0;
	cin >> N;

	int j=N, S=j, sum=0;
	do{
		j/=10;
		sum += S-j*10;
		S=j;
	}while(j>=10);
	sum += j;

	if(N%sum==0)	cout << "Yes" << endl;
	else		cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string s;
  ll k;
  cin >> s >> k;
  
  int oneCheck;
  
  rep(i,s.size()){
    if (s[i] != '1') {oneCheck = i; break;}
  }
  
  
  if (k-1 < oneCheck){
    cout << "1";
  }else{
    cout << s[oneCheck];
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{ 
    int n;  
   cin >> n;    
   while (n--) 
  {        
      int x;       
      cin >> x;        
      a[x]++;
      a[x-1]++;       
      a[x+1]++;    
  }   
  int max=0;
  for(int i=0;i<100005;i++)
  {
	if(max<a[i])
	{
		max=a[i];
	}
  }
     cout <<max<< endl;  
  return 0;
}

Measured memory_bytes: 3788
//W4P3R
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define re register int 
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pa pair<int,int>
#define fr first
#define sd second
#define Z(x) (x>=mod?x-mod:x)
#define lowbit(x) (x&(-x))
#define N 100010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
    char ch=getchar();
    ll s=0,w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*w;
}
char s[N];
int p[N],n;
int tot=1;
void Solve(int rt,int sz,int up)
{
	if(sz==0)return ;
	REP(i,up,2)
	{
		if(p[i])
		{
			++tot;int x=tot;
			cout<<rt<<" "<<x<<endl;
			Solve(x,i-1,i-1);sz-=i;break;
		}
	}
	while(sz--){cout<<rt<<" "<<++tot<<endl;}
}
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    scanf("%s",s+1);n=strlen(s+1);
    FOR(i,1,n)p[i]=s[i]-'0';
    if(!p[1]||p[n]){puts("-1");return 0;}
    FOR(i,1,n-1){if(p[i]&&!p[n-i]){puts("-1");return 0;}}
    Solve(1,n-1,n/2);
    return 0;
}

Measured memory_bytes: 7228
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
	int n;

	while (cin >> n, n){
		int p[n], joint[n-1];
		long long sum = 0;
		for (int i = 0; i < n; i++){
			cin >> p[i];
			sum += p[i];
		}
		for (int i = 0; i < n-1; i++){
			cin >> joint[i];
			sum += joint[i];
		}

		long long ret = sum;
		sort(joint, joint + n - 1);

		for (int i = 0; i < n-1; i++){
			sum -= joint[i];
			// cout << i+2 << " : " << sum << endl;
			ret = max(ret, sum * (i+2));
		}

		cout << ret << endl;
	}

	return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int a,b;cin>>a>>b;){
		if(b<0)
			cout<<((b-a+1)%2?"Negative":"Positive")<<endl;
		else if(0<a)
			cout<<"Positive"<<endl;
		else
			cout<<"Zero"<<endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String O = scan.next();
		String E = scan.next();
		String[] pass1 = O.split("");
		String[] pass2 = E.split("");
		if(pass1.length == pass2.length) {
			for(int i = 0; i < pass1.length; i++) {
				System.out.print(pass1[i]);
				System.out.print(pass2[i]);
			}
		}else if(pass1.length > pass2.length) {
			for(int i = 0; i < pass2.length; i++) {
				System.out.print(pass1[i]);
				System.out.print(pass2[i]);
			}
			System.out.print(pass1[pass1.length-1]);
		}else if(pass2.length > pass1.length) {
			for(int i = 0; i < pass1.length; i++) {
				System.out.print(pass1[i]);
				System.out.print(pass2[i]);
			}
			System.out.print(pass2[pass2.length-1]);
		}
		scan.close();
	}
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)



//block linked list
#define Bsize 900 /*2sqrt(n)*/
typedef struct block{
	int cnt;
	ll a[Bsize+1];
	struct block*pre;
	struct block*nxt;
}block;
void Bpush(block*b,ll x){
	//リストにxを追加する
	if((*b).nxt&&(*(*b).nxt).a[0]<x){
		//次へ
		Bpush((*b).nxt,x);
		return;
	}
	int i=(*b).cnt;
	for(;i>0&&(*b).a[i-1]>x;i--)(*b).a[i]=(*b).a[i-1];
	(*b).a[i]=x;
	(*b).cnt++;
	if((*b).cnt>=Bsize){
		//分割
		block*nn=(block*)malloc(sizeof(block));
		(*nn).cnt=Bsize-Bsize/2;
		rep(i,0,Bsize-Bsize/2)(*nn).a[i]=(*b).a[i+Bsize/2];
		(*nn).pre=b;
		(*nn).nxt=(*b).nxt;
		if((*b).nxt)(*(*b).nxt).pre=nn;
		(*b).cnt=Bsize/2;
		(*b).nxt=nn;
	}
}
void con(block*p,block*q){
	//qをpにマージしてqを消す
	rep(i,0,(*q).cnt)(*p).a[(*p).cnt+i]=(*q).a[i];
	(*p).cnt+=(*q).cnt;
	(*p).nxt=(*q).nxt;
	if((*q).nxt)(*(*q).nxt).pre=p;
	free(q);
}
void Bdel(block*b,int idx){
	//idx番目を削除する(必ずidx個以上ある)
	for(;idx<(*b).cnt-1;idx++)(*b).a[idx]=(*b).a[idx+1];
	(*b).cnt--;
	
	if((*b).cnt==0&&(*b).pre){
		(*(*b).pre).nxt=(*b).nxt;
		if((*b).nxt)(*(*b).nxt).pre=(*b).pre;
		free(b);
	}else if((*b).pre&&(*(*b).pre).cnt+(*b).cnt<Bsize/4)con((*b).pre,b);
	else if((*b).nxt&&(*(*b).nxt).cnt+(*b).cnt<Bsize/4)con(b,(*b).nxt);
}

ll Bans(block*b,int k,int flag){
	//リストのk番目を返す
	//リストにk個未満しかなければ適当に返す
	//flagがtrueなら削除する
	if((*b).cnt<=k){
		if((*b).nxt)return Bans((*b).nxt,k-(*b).cnt,flag);
		else return -1;//<-例外
	}
	ll ans=(*b).a[k];
	if(flag)Bdel(b,k);
	return ans;
}
int Bfind(block*b,ll k,int flag){
	//リストにkが存在すれか答える
	//flagがtrueなら削除する
	if((*b).cnt==0||(*b).a[(*b).cnt-1]<k){
		if((*b).nxt)return Bfind((*b).nxt,k,flag);
		else return 0;
	}
	int i=0;
	for(;(*b).a[i]<k;i++);
	if((*b).a[i]!=k)return 0;
	if(flag)Bdel(b,i);
	return 1;
}
#undef Bsize


 
ll a[400010],x[200010];
int c(const void*p,const void*q){
	if(a[*(ll*)p]<a[*(ll*)q])return -1;
	return 1;
}
block b;
ll idx[400010];
int main(){
	ll n,q;
	scanf("%lld%lld",&n,&q);
	rep(i,0,n){
		ll s,t;
		scanf("%lld%lld%lld",&s,&t,x+i);
		a[2*i  ]=s-x[i];
		a[2*i+1]=t-x[i];
	}
	rep(i,0,2*n)idx[i]=i;
	qsort(idx,2*n,sizeof(ll),c);
	
	ll crr=0;
	rep(_,0,q){
		ll d;
		scanf("%lld",&d);
		while(crr<2*n&&a[idx[crr]]<=d){
			if(idx[crr]%2)Bfind(&b,x[idx[crr]/2],1);
			else Bpush(&b,x[idx[crr]/2]);
			crr++;
		}
		printf("%lld\n",Bans(&b,0,0));
	}
}

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

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a < b && b < c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3176
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cctype>
#include <algorithm>
#include <functional>
#include <utility>
typedef long long ll;
const ll ha = 1000000007LL;
inline void upd(ll &p, const ll &v) {
  p = (p + v) % ha;
}

const int maxn = 605;
ll d[maxn][maxn >> 1][maxn >> 1];
int A[maxn], B[maxn], C[maxn];
int main() {
  int n; scanf("%d", &n);
  for(int i = 1; i <= (n << 1); i ++) scanf("%d", &A[i]);
  int cnt = 0;
  for(int i = 2; i <= (n << 1); i += 2) {
    if(A[i - 1] != -1) std::swap(A[i], A[i - 1]);
    if(A[i - 1] != -1 && A[i] != -1) {
      B[A[i - 1]] = B[A[i]] = 2;
    } else if(A[i - 1] == -1 && A[i] == -1) {
      cnt ++;
    } else {
      B[A[i]] = 1;
    }
  }
  int num = 0;
  for(int i = 1; i <= (n << 1); i ++) {
    if(B[i] <= 1) C[++ num] = B[i];
  }
  d[num][0][0] = 1;
  for(int i = num; i >= 1; i --) {
    for(int j = 0; j <= std::min(num, n); j ++) {
      for(int k = 0; k <= std::min(num, n); k ++) {
        ll th = d[i][j][k];
        if(!th) continue;
        if(C[i] == 1) {
          upd(d[i - 1][j + 1][k], th);
          if(k) upd(d[i - 1][j][k - 1], th);
        } else {
          upd(d[i - 1][j][k + 1], th);
          if(j) upd(d[i - 1][j - 1][k], th * (ll)j);
          if(k) upd(d[i - 1][j][k - 1], th);
        }
      }
    }
  }
  ll ans = d[0][0][0];
  for(int i = 2; i <= cnt; i ++) ans = ans * (ll)i % ha;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 428160
#include <stdio.h>
int gcd(int , int);
int main(){
    int x,y,d,a;
    scanf("%d%d",&x,&y);
    if(x<y){   /* x<yなら入れ替え */
        a=x;
        x=y;
        y=a;
    }
    d=gcd(x,y);
    printf("%d\n",d);
    return 0;
}

int gcd(int x, int y){  /* ユークリッドの互除法 */
    int d;
    d = x%y;
    while(1){
        if(d==0){
            break;
        }
        x=y;
        y=d;
        d=x%y;
    }
    return y;
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <string.h>
#define N 1000
int main(){
  char T[N],P[N];
  int i,j,l,m,count;
    
  scanf("%s",T);
  scanf("%s",P);
    
  l=strlen(T);
  m=strlen(P);
    
  for(i=0;i<l;i++){
    count=0;
    for(j=0;j<m;j++){
      if(T[i+j]==P[j]) count++;
    
    }
    if(count==m) printf("%d\n",i);
  }
  return 0; 
}  

Measured memory_bytes: 540
import java.util.* ; 
import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner (System.in);
	int n = scan.nextInt();
 	int x = n/2 ;
    int y = n - x ;
    if(n%2 != 0){
    System.out.println((int)Math.pow(x,2)+x);
    }else{
      System.out.println((int)Math.pow(x,2));
    }

  }
}


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

int main() {
	int N, M, X, A;
	cin >> N >> M >> X;
	int cost[2] = {0, 0};
	for (int i = 0;i < M;++ i) {
		cin >> A;
		++ cost[A < X ? 0 : 1];
	}
	cout << min(cost[0], cost[1]);
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

左右それぞれのコストを計算するだけ
*/

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		long pre = sc.nextLong();
		int ans = 0;
		int nowM = 0;
		for (int i = 1; i < N; i++) {
			long nowH = sc.nextLong();
			if (pre >= nowH) {
				nowM++;
			} else {
				if (ans < nowM) {
					ans = nowM;
				}
				nowM = 0;
			}
			pre = nowH;
		}
		if (ans < nowM) {
			ans = nowM;
		}
		System.out.println(ans);
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <queue>
#include <algorithm>

#define INF 1000000000;

using namespace std;

int dfs(int N, int cur, int a, int b, int c, int A, int B, int C, int * l){
    if(cur == N) {
        if(min({a, b, c}) > 0) return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        else return INF;
    }
    else{
        int ret0 = dfs(N, cur + 1, a, b, c, A, B, C, l);
        int ret1 = dfs(N, cur + 1, a + l[cur], b, c, A, B, C, l) + 10;
        int ret2 = dfs(N, cur + 1, a, b + l[cur], c, A, B, C, l) + 10;
        int ret3 = dfs(N, cur + 1, a ,b, c + l[cur], A, B, C, l) + 10;
        return min({ret0, ret1, ret2, ret3});
    }
}

int main(){
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    int l[N];
    for(int i=0; i<N; i++) cin >> l[i];
    cout << dfs(N, 0, 0, 0, 0, A, B, C, l) << endl;;
    return 0;
}

Measured memory_bytes: 256
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = input()

if int(N)>=10:
    size = len(N)
    top = int(N[0])
    ans = (size-1)*9 + top-1
    num = sum(map(int,list(N)))
    ans = max(ans,num)
else:
    ans = int(N)
    
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
H,W=gets.chomp.split(" ").map(&:to_i)
S=[]
dot_count = 0
H.times do
    s = gets.chomp
    dot_count += s.count(".")
    S.push(s)
end

nows=[[0,0]]
turn = 0
loop do
    nexts = []
    if nows.empty?
        puts -1
        exit
    end
    break if nows.include?([H-1,W-1])
    nows.each do |x,y|
        S[x][y] = "#"
        if x!=H-1 && S[x+1][y]=="."
            nexts.push([x+1,y])
            S[x+1][y] = "#"
        end
        if x!=0 && S[x-1][y]=="."
            nexts.push([x-1,y])
            S[x-1][y] = "#"
        end
        if y!=W-1 && S[x][y+1]=="."
            nexts.push([x,y+1])
            S[x][y+1] = "#"
        end
        if y!=0 && S[x][y-1]=="."
            nexts.push([x,y-1])
            S[x][y-1] = "#"
        end
    end
    nows = nexts
    turn+=1
end
puts dot_count - turn -1


Measured memory_bytes: 14292
import math
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

def didWin(idx, c):
    if c == 'r' and t[idx] == 's':
        return True
    if c == 's' and t[idx] == 'p':
        return True
    if c == 'p' and t[idx] == 'r':
        return True
    return False

def solve(mod):
    # print('mod:',mod)
    # tt = []
    #
    # for i in range(mod, n, k):
    #     tt.append(t[i])
    # print('tt:', tt)
    # print('n/k:', n / k)

    # tt[i] = t[i * k + mod]
    l = math.ceil((n - mod) / k)
    # print('l:', l)
    dp = [[0] * 4 for _ in range(l + 1)]

    for i in range(l):
        # Case rock
        if didWin(i * k + mod, 'r'):
            dp[i + 1][0] = max(dp[i][1], dp[i][2]) + r
        else:
            dp[i + 1][0] = max(dp[i][1], dp[i][2])
        # Case scissors
        if didWin(i * k + mod, 's'):
            dp[i + 1][1] = max(dp[i][0], dp[i][2]) + s
        else:
            dp[i + 1][1] = max(dp[i][0], dp[i][2])
        # Case paper
        if didWin(i * k + mod, 'p'):
            dp[i + 1][2] = max(dp[i][0], dp[i][1]) + p
        else:
            dp[i + 1][2] = max(dp[i][0], dp[i][1])

    # print('dp:', dp)
    # print('max:', max(dp[l][0], dp[l][1], dp[l][2]))
    return max(dp[l][0], dp[l][1], dp[l][2])

ans = 0
for i in range(k):
    ans += solve(i)

print(ans)

Measured memory_bytes: 69360
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=200005;
int n;
char c[maxn];
ll ans; 

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%s",c);
	n=strlen(c);
	int cnt=0;
	rep(i,n)if(c[i]=='B'){
		ans+=n-i-1-cnt;
		cnt++;
	} 
	printf("%lld\n",ans);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define ins insert
#define er erase
#define f(i,a,b) for(i=a;i<b;++i)
#define rf(i,a,b) for(i=a;i>=b;--i)
#define tc int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int> 
#define vll vector<ll> 
#define vull vector<ull>
#define vc vector<char>
#define vst vector<string>
#define bs bitset
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b) 
#define lb lower_bound
#define ub upper_bound
#define nl "\n" 
#define sp " "
using namespace std;

//LET'S PLAY THE GAME!!

int main(){
    fast;
    int x,a;cin>>x>>a;
    if(x<a)cout<<"0";
    else cout<<"10";
    return 0;
}
// AND THE GAME IS OVER!!

Measured memory_bytes: 256
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 < N; i++) {
            A[i] = sc.nextInt();
        }
        System.out.println( solve(N, A) );
    }

    private static long solve(int N, int[] A) {
        long ans = 0;
        Result prev = null;
        for (int i = 0; i < N; i++) {
            Result result = calc(i, prev, N, A);
            ans+= result.ret;
            prev = result;
        }
        return ans;
    }

    private static Result calc(int l, Result prevResult, int N, int[] A) {
        if( l == N-1 ) return new Result(1, l, l, A[l]);

        int ret;
        int r;
        int prev;
        if( prevResult != null ) {
            // prevResultのl-r間はいい感じなので
            // (sum)からA[l]を取り除き、いい感じにして処理を進める
            ret = prevResult.r - prevResult.l;
            r = prevResult.r + 1;
            prev = prevResult.sum ^ A[prevResult.l];

        } else {
            ret = 1;
            r = l+1;
            prev = A[l];
        }

        for (; r < N; r++) {
            int xor = prev ^ A[r];
            int sum = prev + A[r];
            if( xor == sum ) {
                ret++;
                prev = sum;
            } else {
                return new Result(ret, l, r-1, prev);
            }
        }

        return new Result(ret, l, N-1, prev);
    }

    private static class Result {
        private int ret;
        private int l;
        private int r; // このindexまでok
        private int sum; // l-rのときのsum

        public Result(int ret, int l, int r, int sum) {
            this.ret = ret;
            this.l = l;
            this.r = r;
            this.sum = sum;
        }
    }
}

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

int main() {
  long N;
  cin >> N;
  vector<long> A(N), B(N);
  for (long i = 0; i < N; i++) cin >> A.at(i) >> B.at(i);
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  if (N % 2) {
    cout << B.at(N / 2) - A.at(N / 2) + 1 << "\n";
  } else {
    cout << B.at(N / 2 - 1) + B.at(N / 2) - A.at(N / 2 - 1) - A.at(N / 2) + 1 << "\n";
  }
}

Measured memory_bytes: 6428
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int bols[100001];
int in[100001];

int main() {
    int n, m;
    cin >> n >> m;
    REP(i,100001) bols[i] = 1;
    in[0] = 1;
    REP(i,m) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        if (in[x]) {
            if (bols[x] == 1) {
                in[x] = false;
            }
            bols[x]--;
            in[y] = true;
            bols[y]++;
        } else {
            bols[x]--;
            bols[y]++;
        }
    }
    
    int cnt = 0;
    REP(i,n) {
        if (in[i]) cnt++;
    }
    cout << cnt << endl;
}


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

public class Main {
	static int[] f = new int[101];
	static int n;
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int m = ni();
		
		int[] p = new int[m];
		int[] y = new int[m];
		for(int i = 0; i < m; i++) {
			p[i] = ni();
			y[i] = ni();
		}
		ArrayList<ArrayList<Integer>> cl = new ArrayList<ArrayList<Integer>>() {
			{
				for(int i = 0; i < n; i++) {
					add(new ArrayList<Integer>());
				}
			}
		};

		for(int i = 0; i < m; i++) {
			cl.get(p[i] - 1).add(y[i]);
		}
		
		for(int i = 0; i < n; i++) {
			Collections.sort(cl.get(i));
		}

		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < m; i++) {
			int idx =Collections.binarySearch(cl.get(p[i] - 1), y[i]) + 1;
			sb.append(String.format("%06d", p[i]) + String.format("%06d", idx));
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb.toString());
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 123500
N, A, B, C, D = map(int, input().split())
S = input()

def solve():
    for i in range(A, C-3):
        if S[i:i+2] == "##":
            print("No")
            return
    for i in range(B, D-3):
        if S[i:i+2] == "##":
            print("No")
            return

    if C > D:
        for i in range(B-2, D-1):
            if S[i:i+3] == "...":
                print("Yes")
                return
        else:
            print("No")
            
    else:
        print("Yes")

solve()

Measured memory_bytes: 9396
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

bool is_integer( double x ){
  return std::floor(x)==x;
}

int main(void){
    // Your code here!
    int n,d;
    cin >> n >> d;
    int a[11][11];
    for(int i = 0;i < n;i++){
        for(int j = 0;j < d;j++){
            cin >> a[i][j];   
        }
    }
    int cnt = 0;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < i;j++){
            double ans = 0;
            for(int h = 0;h < d;h++){
                
                ans += pow(abs(a[i][h] - a[j][h]),2);   
            }
            
            ans = sqrt(ans);
            if(is_integer(ans)){
                    cnt++;
                }
                
        }
    }
    
    
    
    cout << cnt;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int N,M,C;
	int B[20];
	int A;
	int i,j;
	int siki=0;
	int ans=0;
	
	scanf("%d%d%d",&N,&M,&C);
	for(i=0;i<M;i++)
		scanf("%d",&B[i]);
	for(j=0;j<N;j++){
		for(i=0;i<M;i++){
			scanf("%d",&A);
			siki+=A*B[i];
		}
		siki+=C;
		if(siki>0)
			ans++;
		siki=0;
	}
	
	
	printf("%d",ans);
	
return 0;
}

Measured memory_bytes: 128