akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    int a,b;
    cin>>a>>b;

    cout<<a*b<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<math.h>
using namespace std;
int n,y,b,r,t,mxno;
double mx,x;
double tanri(){
  return 1.0+(double)y*(double)r/100.0;
}
double hukuri(){
  return pow((1.0+(double)r/100.0),y);
}
int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    cin>>y;
    mx=0.0;
    mxno=0;
    for(int i=0;i<n;i++){
      cin>>b>>r>>t;
      if(t==1){
	x=tanri();
	//cout<<x<<endl;
	if(x>mx){
	  mx=x;
	  mxno=b;
	}
      }else{
	x=hukuri();
	//cout<<x<<endl;
	if(x>mx){
	  mx=x;
	  mxno=b;
	}
      }
    }
    cout<<mxno<<endl;
  }
  return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <limits>
#include <cstdlib>
#include <regex>
using namespace std;

double inf = numeric_limits<double>::infinity();

#define REP(i,n) for(int i=0;i<n;i++)
using LL = long long int;
LL GCD(LL a,LL b){ if(a<b) return GCD(b,a); else if(a%b==0) return b; else return GCD(b,a%b); }
LL LCM(LL a,LL b){ return (a/GCD(a,b))*b; }

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size() - 8; i++) {
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
from string import ascii_lowercase


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def solve(s):
    indices = {c: [] for c in ascii_lowercase}
    for i, c in enumerate(s):
        indices[c].append(i)

    n = len(s)
    center = n // 2
    bubbles = [-1] * n
    odd_flag = False
    lefts, rights = [], []
    used = [False] * n
    for c, ids in indices.items():
        cnt = len(ids)
        if cnt & 1:
            if odd_flag:
                return -1
            odd_flag = True
            bubbles[ids[cnt // 2]] = center + 1
            used[center] = True
        for i in range(cnt // 2):
            li, ri = ids[i], ids[-i - 1]
            if li < center:
                lefts.append((li, ri))
                used[n - li - 1] = True
            else:
                rights.append((li, ri))
    lefts.sort()
    rights.sort()
    r_itr = iter(rights)
    # print(lefts)
    # print(rights)
    for i, (li, ri) in enumerate(lefts):
        bubbles[li] = i + 1
        bubbles[ri] = n - i
    for i in range(len(lefts), center):
        li, ri = next(r_itr)
        bubbles[li] = i + 1
        bubbles[ri] = n - i
    # print(bubbles)

    ans = 0
    bit = Bit(n)
    for i, m in enumerate(bubbles):
        ans += i - bit.sum(m)
        bit.add(m, 1)
    return ans


print(solve(input()))


Measured memory_bytes: 32868
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define NIL -1
#define MAX 610005
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int n;
int root;
int *p = new int[MAX];       //    p---|  Unit
int *left2 = new  int[MAX]; // left2 --|--------> T
int *right2 = new int[MAX]; //right2---|
int *key = new int[MAX];     // key----|
 
  
void Init(){
  rep(i,MAX){
    p[i]=left2[i]=right2[i]=key[i]=NIL;
  }
}
 
int TREE_MINIMUM(int x){
  while(left2[x] != NIL){
    x = left2[x];
  }
  return x;
}
 
 
int TREE_SUCCESSOR(int x){
  if(right2[x] != NIL)return TREE_MINIMUM(right2[x]);
  int y = p[x];
  while(y != NIL && x == right2[y]){
    x = y;
    y = p[y];
  }
  return y;
}
  
void TREE_DELETE(int z){
  int y,x;
  if(left2[z] == NIL || right2[z] == NIL)y = z;
  else y = TREE_SUCCESSOR(z);
 
  if(left2[y] != NIL)x = left2[y];
  else x = right2[y];
 
  if(x != NIL)p[x]=p[y];
  if(p[y] == NIL)root = x;
  else if(y == left2[p[y]])left2[p[y]] = x;
  else right2[p[y]] = x;
 
  if(y != z)key[z] = key[y];
 
}
 
 
bool SEARCH(int x,int k){
  if(k == key[x])return true;
  if(x == NIL)return false;
  if(k < key[x])return SEARCH(left2[x],k);
  else return SEARCH(right2[x],k);
}
 
  
void TREE_INSERT(int z){
  int y = NIL; 
  int x = root;
  
  while(x != NIL){
    y = x;
    if(key[z] < key[x]){
      x = left2[x];
    }
    else x = right2[x];
  }
  p[z]=y;
  if(y == NIL){
    root = z;
  }
  else if(key[z] < key[y]){
    left2[y] = z;
  }else{
    right2[y] = z;
  }
  
}
 
int IndexSearch(int x){
  for(int i=0;i<MAX;i++){
    if(key[i] == x)return i;
  }
  return -1;
}
 
 
void InorderTreeWalk(int x){
  if(x != NIL){
    InorderTreeWalk(left2[x]);
    printf(" %d",key[x]);
    InorderTreeWalk(right2[x]);
  }
}
  
void PreorderTreeWalk(int x){
  if(x != NIL){
    printf(" %d",key[x]);
    PreorderTreeWalk(left2[x]);
    PreorderTreeWalk(right2[x]);
  }
}
  
  
int main(){
  int val;
  string op;
  long long zr;                    
 
  
  scanf("%d",&n);
  Init(); 
  root = -1;
  zr=0;
  while(n-- > 0){
    cin >> op;
    if(op == "insert"){
      scanf("%d",&val);
      key[zr]=val;        
      TREE_INSERT(zr);
      zr++;
    }else if(op == "print"){
      InorderTreeWalk(root);
      printf("\n");
      PreorderTreeWalk(root);
      printf("\n");
    }
    else if(op == "find"){
      scanf("%d",&val);
      if(SEARCH(root,val)){
    printf("yes\n");
      }else{
    printf("no\n");
      }
        
  
    }
    else if(op == "delete"){
      scanf("%d",&val);
      int inthis = IndexSearch(val);
      if(inthis != -1){
      TREE_DELETE(inthis);
      }
    }
 
  }
  
  delete [] p;
  delete [] left2;
  delete [] right2;
  delete [] key;
 
  return 0;
}



Measured memory_bytes: 12356
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve(){
	string s;
	cin >> s;
	int hoge = 0;
	for (int i = 0; i < s.length()-1; ++i) {
		if (s[i] == 'm')hoge++;
		else if (s[i] == 'w')hoge--;
		if (hoge <= 0) {
			cout << "Rabbit" << endl;
			return;
		}
	}
	for (int i = 0; i < (int)s.length() - 2; ++i,i = max(i,0LL)) {
		if (s[i] == 'm' && s[i + 1] == 'e' && s[i + 2] == 'w') {
			REP(t,3)
			s.erase(s.begin() + i);
			i -= 3;
		}
	}
	if (s.length() == 0) {
		cout << "Cat" << endl;
	}
	else {
		cout << "Rabbit" << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3216
#include <cstdio>
using namespace std;

int main(){
	int s, sum[2] = { 0 };
	for (int j = 0; j < 2; j++) {
		for (int i = 0; i < 4; i++) {
			scanf("%d", &s);
			sum[j] += s;
		}
	}
	printf("%d\n", sum[0] > sum[1] ? sum[0] : sum[1]);


	return 0;
}

Measured memory_bytes: 2668
def multiplier(N,maxx,time):
  if N%maxx==0 :
    return N//maxx
  else :
    return N//maxx+1
  
def main():
	N,maxx,time = map(int, input().split())
	if N!=0 :
		ans = time * multiplier(N,maxx,time)
	else:
		ans=0  
	print(ans)
    
if __name__ == '__main__':
  main()
  

Measured memory_bytes: 9164
N,M,K=map(int, input().split())
par=[-1 for _ in range(N)]
nums=[-1 for _ in range(N)]
#実装
def find(x):
    if par[x]<0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def size(x):
    return -par[find(x)]

def unite(x,y):
    x,y=find(x),find(y)
    if x==y:
        return
    if x>y:
        x,y=y,x
    par[x]+=par[y]
    par[y]=x

def same(x,y):
    return find(x)==find(y)


for _ in range(M):
    a1,a2=map(int, input().split())
    a1-=1
    a2-=1
    unite(a1,a2)
    nums[a1]-=1
    nums[a2]-=1

for _ in range(K):
    a1,a2=map(int, input().split())
    a1-=1
    a2-=1
    if same(a1,a2):
        nums[a1]-=1
        nums[a2]-=1


for i in range(N):
    nums[i]+=size(i)

print(" ".join(list(map(str,nums))))

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

public class Main{
    static class Reader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
 
        public Reader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
 
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
    }

    public static void main(String[] args) throws IOException{
        Reader in = new Reader(System.in);
        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
        if(b-a == c-b) System.out.println("YES");
        else System.out.println("NO");
    }
}


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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n & 1 ==1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n=n>>1;
    }
    return result;
}



int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    ll n,k;
    cin>>n>>k;
    ll a[n];

    for(ll i=0;i<n;i++)
    {
    	ll x;
        cin>>x;
        a[i]=x-1;
    }

    ll p=0,count=0,rep=0;
    bool vis[n]={false};

    while(true)
    {
        if(vis[p])
        {
            rep=p;
            break;
        }
        vis[p]=true;
        p=a[p];
        count++;
    }

    ll q=0,steps=0,loop=0;
    while(q!=rep)
    {
        q=a[q];
        steps++;
    }

    loop=count-steps;

    ll t=0;
    if(k<steps)
    { 
        for(ll i=0;i<k;i++)
            t=a[t];
        cout<<t+1<<endl;
        return 0;
    }

    t=rep;
    k-=steps;
    k=k%loop;   
    for(ll i=0;i<k;i++)
        t=a[t];
    cout<<t+1<<endl;

    return 0;
}

Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
char a[101],b[101];
int cmp(char x,char y){return x>y;}
int main()
{
	cin>>a>>b;
	sort(a,a+strlen(a));
	sort(b,b+strlen(b),cmp);
	if(strcmp(a,b)<0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int A;
int n, en;

bool check(int m) {
    auto str = std::to_string(m);
    
    for(auto&& c : str) {
        if((1 << (c - '0')) & en) {
            
        }else {
            
            return false;
        }
    }
    
    return true;
}

int main() {
    
    std::cin >> A;
    
    std::cin >> n;
    
    for(int i = 0; i < n; ++i) {
        int tmp;
        
        std::cin >> tmp;
        
        en |= 1 << tmp;
    }
    
    en = ~en;
    
    for(int i = A; ; ++i) {
        if(check(i)) {
            std::cout << i << std::endl;
            
            return 0;
        }
    }
    
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc066/tasks/arc077_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll n, a;
deque<ll> lst;

int main()
{
  cin >> n;
  REP(i, n)
  {
    cin >> a;
    if (i % 2 == 0)
      lst.push_front(a);
    else
      lst.push_back(a);
  }

  if (n % 2 == 0)
    reverse(ALL(lst));

  for (auto &it : lst)
    cout << it << " ";

  cout << '\n';

  return 0;
}


Measured memory_bytes: 3840
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int N = sc.nextInt();
        int A[][] = new int[2][N];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < N; j++) {
                A[i][j] = sc.nextInt();
            }
        }

        int max = 0;
        for (int i = 0; i < N; i++) {
            int sum = 0;
            for (int j = 0; j < N; j++) {
                if (j < i) {
                    sum += A[0][j];
                } else if (i == j) {
                    sum += A[0][j] + A[1][j];
                } else {
                    sum += A[1][j];
                }
            }
            max = Math.max(sum, max);
        }
        System.out.println(max);
    }
}


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

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

    vector<vector<int>> A(N, vector<int>(M));
    for (vector<int>& xs : A)
    {
        for (int& x : xs)
        {
            cin >> x;
            x--;
        }
        reverse(begin(xs), end(xs));
    }

    const auto works = [&](const int limit)
    {
        vector<vector<int>> preferences = A;
        for (int i = 0; i < M; i++)
        {
            vector<int> counts(M);
            for (vector<int>& xs : preferences)
            {
                if (xs.empty()) return false;
                else counts[xs.back()]++;
            }

            bool ok = true;
            for (int j = 0; j < M; j++)
            {
                if (counts[j] > limit)
                {
                    ok = false;
                    for (vector<int>& xs : preferences)
                        xs.erase(remove(begin(xs), end(xs), j), end(xs));
                    break;
                }
            }
            if (ok) return true;
        }
        return false;
    };

    int lower = 1, upper = N;
    while (lower < upper)
    {
        const int guess = (lower + upper) / 2;
        if (works(guess)) upper = guess;
        else lower = guess+1;
    }
    cout << lower << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; int D[100010] = {}; cin >> N; 
	int cnt[100010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> D[i]; cnt[D[i]] ++; 
	}
	if(D[0] != 0 || cnt[0] > 1){
		cout << 0 << endl; return 0; 
	}
	long long int ans = 1LL; 
	for(int i = 1; i < N; i++){
		for(int j = 0; j < cnt[i]; j++){
			ans *= (long long) cnt[i-1]; 
			ans %= 998244353; 
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  int i,j,k,n,x,l;
  l = 0;

  for ( ; ; ){
    scanf("%d %d",&n,&x);
    if (n == 0 && x == 0){
      break;
    }

    for (i = 1; i < n - 1; i++){
      for (j = i + 1; j < n; j++){
        for (k = j + 1; k < n + 1; k++){
          if (i + j + k == x){
            l++;
          }
        }
      }
    }
    printf("%d\n",l);
    l = 0;
  }

  return 0;
}



Measured memory_bytes: 2700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long A = Long.parseLong(sc.next());
		String str = sc.next();

		int[] tmp = new int[3];
		tmp[0] = Integer.parseInt(String.valueOf(str.charAt(0)));
		tmp[1] = Integer.parseInt(String.valueOf(str.charAt(2)));
		tmp[2] = Integer.parseInt(String.valueOf(str.charAt(3)));
		sc.close();


		long a = A * tmp[0];
		long b = A * tmp[1];
		long c = A * tmp[2];

		long tmpb = b / 10;
		long tmpc = c / 100;

		//小数点以下の計算
		long tmpb2 = (b % 10) * 10;
		long tmpc2 = c % 100;
		//繰り上がりで1足されるかどうか確認
		long tmpx = (tmpb2 + tmpc2) / 100;

		long ans = a + tmpb + tmpc + tmpx;
		System.out.println(ans);

	}

}

Measured memory_bytes: 35672
R, C, K = map(int, input().split())
T = [[0]*(C+2) for _ in range(R+2)]
dp = [[[0]*(C+2) for _ in range(R+2)] for _ in range(4)]
for i in range(K):
    r, c, v = map(int, input().split())
    T[r][c] = v
dp[1][1][1] = T[1][1]
dp[0][1][1] = 0

for i in range(1, R+1):
    for j in range(1, C+1):
        for k in range(4):
            dp[0][i+1][j] = max(dp[0][i+1][j], dp[k][i][j])
            dp[1][i+1][j] = max(dp[1][i+1][j], dp[k][i][j] + T[i+1][j])
            dp[k][i][j+1] = max(dp[k][i][j+1], dp[k][i][j])
            if k <= 2:
                dp[k+1][i][j+1] = max(dp[k+1][i][j+1], dp[k][i][j] + T[i][j+1])
ans = 0
for k in range(4):
    ans = max(ans, dp[k][R][C])
print(ans)

Measured memory_bytes: 430712
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0
ans += sum(b)
for i in range(n-1):
    if a[i] + 1 == a[i+1]:
        ans += c[a[i]-1]

print(ans)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var k = a.Max();
        var b = new int[n];
        var c = new int[k + 1];
        for (int j = 0; j < n; j++)
        {
            c[a[j]]++;
        }
        for (int i = 0; i < k; i++)
        {
            c[i + 1] += c[i];
        }
        for (int j = n - 1; j >= 0; j--)
        {
            b[c[a[j]] - 1] = a[j];
            c[a[j]]--;
        }
        Console.WriteLine(string.Join(" ", b));
    }
}


Measured memory_bytes: 173976
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int main(void){
    string n,ans;
    cin>>n;
    for(int i=0;i<n.length();i++){
        if(n[i]==n[i+1]&& n[i]==n[i+2]){
            if(n[i+1]==n[i+2]) ans="Yes";
            break;
        }else{
            ans="No";
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine().Trim());
        var t = 0;
        while (n > 0)
        {
            n /= 2;
            t++;
        }
        Console.WriteLine((long)Pow(2, t) - 1);
    }
}


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

int main(){
    char c;
    cin >> c;
    if (((c=='a') || (c=='e')) || ((c=='i') || (c=='o')) || (c=='u')) {
        cout << "vowel";
    }
    else {
        cout << "consonant";
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    REP(i,111,1000){
        if(i>=n && i%111==0){
            cout<<i<<endl;
            break;
        }
    }
    return  0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
   int A, B, C, D, E, F;
   std::cin >> A >> B >> C >> D >> E >> F;

   double max_dens = -1;
   int max_total, max_sugar;
   for(int i=0; i<F/100/A+1; ++i){
      for(int j=0; j<F/100/B+1; ++j){
	 int water = i*100*A + j*100*B;
	 if(water==0 || water>F) continue;
	 for(int k=0; k*C*100<=water*E; ++k){
	    for(int l=0; l*D*100<=water*E; ++l){
	       int sugar = k*C + l*D;
	       if(water+sugar>F || sugar*100>water*E) continue;
	       double dens = 100.*sugar/(water+sugar);
	       if(dens>max_dens){
		  max_dens = dens;
		  max_total = water+sugar;
		  max_sugar = sugar;
	       }
	    }
	 }
      }
   }
   std::cout << max_total << ' ' << max_sugar << std::endl;
   return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1e9 + 7;

ll al = 0, ar = 0, bl = 0;

void down(priority_queue<ll> &lowers, priority_queue<ll, vector<ll>, greater<ll>> &uppers, ll a);

void up(priority_queue<ll> &lowers, priority_queue<ll, vector<ll>, greater<ll>> &uppers);

void center(priority_queue<ll> &lowers, priority_queue<ll, vector<ll>, greater<ll>> &uppers);

int main() {

    ll qc;
    cin >> qc;

    priority_queue<ll> lowers;
    priority_queue<ll, vector<ll>, greater<ll>> uppers;
    for (ll i = 0; i < qc; i++) {
        ll q;
        cin >> q;

        if (q == 1) {
            ll a, b;
            cin >> a >> b;
            bl += b;

            down(lowers, uppers, a);

            up(lowers, uppers);
            center(lowers, uppers);
        } else {
            ll x = lowers.top();
            ll ans = (x * lowers.size() - al) + (ar - x * uppers.size()) + bl;
            cout << x << ' ' << ans << endl;
        }
    }

}

void center(priority_queue<ll> &lowers, priority_queue<ll, vector<ll>, greater<ll>> &uppers) {
    if (uppers.size() - lowers.size() == 1) {
        ll a1 = uppers.top();
        uppers.pop();
        lowers.push(a1);
        al += a1, ar -= a1;
    }
}

void up(priority_queue<ll> &lowers, priority_queue<ll, vector<ll>, greater<ll>> &uppers) {
    if (lowers.size() - uppers.size() == 2) {
        ll a0 = lowers.top();
        lowers.pop();
        uppers.push(a0);
        ar += a0, al -= a0;
    }
}

void down(priority_queue<ll> &lowers, priority_queue<ll, vector<ll>, greater<ll>> &uppers, ll a) {
    if (!lowers.empty() && a > lowers.top()) {
        uppers.push(a);
        ar += a;
    } else {
        lowers.push(a);
        al += a;
    }
}


Measured memory_bytes: 3828
//hi
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long int LL;
map<LL,LL> mp;
int main(void){
    int n;
    int i;
    scanf("%d",&n);
    LL sum=0;
    LL ans=0;
    mp[0]++;
    for(i=0;i<n;i++){
		int d;
		scanf("%d",&d);
		sum+=d;
		if(mp.find(sum)!=mp.end()) ans+=mp[sum];
		//printf("%lld\n",ans);
		mp[sum]++;
	}
	printf("%lld\n",ans);
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int p[300000][26];
int dp[300000];

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

	// p[i][j]:i番目以降で文字jが出てくる最も早い番目
	// dp[i]:i文字目以降で何回アルファベットをコンプしているか

	string s;cin>>s;
	rep(i,26) p[s.size()][i]=s.size()+1;
	memset(dp,0x3f,sizeof(dp));
	dp[s.size()+1]=0;
	dp[s.size()]=1;
	for(int i=s.size()-1;i>=0;i--){
		rep(j,26){
			if(s[i]-'a'==j){
				p[i][j]=i+1;
			}
			else p[i][j]=p[i+1][j];
			if(dp[p[i][j]]+1 < dp[i]){
				dp[i]=min(dp[i],dp[p[i][j]]+1);
			}
		}
	}

	//　コンプ回数が小さくなる最も早い文字で文字列を作っていく

	int pos=0;
	string ans;
	while(pos!=s.size()+1){
		rep(i,26){
			if(dp[p[pos][i]]==dp[pos]-1){
				ans+='a'+i;
				pos=p[pos][i];
				break;
			}
		}
	}
	cout<<ans<<endl;
}

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


int main()
{
  int N , A[100] , cnt = 0;

  cin >> N;
  for( int i = 0; i < N; i++ )
    {
      cin >> A[i];
    }
  
  for( int i = 0; i < N; i++ )
    {
      for ( int j = 0; j < N-1; j++ )
	{
	  if( A[j] > A[j+1])
	    {
	      swap(A[j],A[j+1]);
	      cnt++;
	    }
	}
    }

   for( int i = 0; i < N; i++ )
    {
      cout <<  A[i];
      if( i != N-1 ) cout << " ";
      
    }
   cout << endl;
   cout << cnt << endl;
   


  return 0;
}

   

Measured memory_bytes: 1160
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
const int MAXN = (int) 10 + 20;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int n;
int a[MAXN][MAXN];
int mark1[MAXN],mark2[MAXN];
int mark3[MAXN],mark4[MAXN];
int cnt;

void print(){
    for(int i=1;i<=8;i++){
        for(int j=1;j<=8;j++){
            if(a[i][j]==1) printf("Q");
            else printf(".");
        }
        printf("\n");
    }
}

void DFS(int x,int y){
    if(mark1[x]||mark2[y]||mark3[x+y]||mark4[x+9-y]){
//        printf("(%d,%d):%d %d %d %d\n",x,y,mark1[x],mark2[y],mark3[x+y],mark4[x+9-y]);
        return;
    }
//    printf("(%d,%d):%d %d %d %d\n",x,y,mark1[x],mark2[y],mark3[x+y],mark4[x+9-y]);
    a[x][y]=1;
//    print();
//    system("pause");
    mark1[x]=mark2[y]=mark3[x+y]=mark4[x+9-y]=1;
    cnt++;
//    printf("cnt = %d\n",cnt);
    if(cnt==8) return;
    for(int i=1;i<=8;i++){
        for(int j=1;j<=8;j++){
            DFS(i,j);
            if(cnt==8) return;
        }
    }
    if(cnt==8) return;
    cnt--;
    a[x][y]=0;
    mark1[x]=mark2[y]=mark3[x+y]=mark4[x+9-y]=0;
}

void work(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int x,y; scanf("%d%d",&x,&y);
        x++,y++;
        a[x][y]=1;
        mark1[x]=1;
        mark2[y]=1;
        mark3[x+y]=1;
        mark4[x+9-y]=1;
    }
    for(int i=1;i<=8;i++){
        int ok=0;
        for(int j=1;j<=8;j++){
            cnt=n;
            DFS(i,j);
            if(cnt==8){
                ok=1; break;
            }
        }
        if(ok) break;
    }
    print();
}

int main(){
    work();
    return 0;
}












Measured memory_bytes: 2704
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int t = sc.nextInt();

		int ans = t > x ? 0 : x - t;

		System.out.println(ans);

		sc.close();
	}
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, a,b,ans =0;
	cin >>n >>a >>b;

	ans = min(a*n, b) ;

	cout << ans <<"\n";

	return 0;
}


Measured memory_bytes: 256
def PrimeNumber(N):
    f=[1]*(N+1)
    f[0]=0
    f[1]=0

    for i in range(2,N+1):
        if f[i]==0:
            continue
        j = 2
        temp = i
        while temp * j <= N:
            f[temp*j]=0
            j += 1

    return f

PN=PrimeNumber(100000)
C=[0]*100001

C[1]=0

for i in range(2,100001):
    if PN[i]==1 and PN[(i+1)//2]==1:
        C[i]=C[i-1]+1
    else:
        C[i]=C[i-1]

Q=int(input())

for i in range(Q):
    l,r=map(int,input().split())
    print(C[r]-C[l-1])

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

int main() {
  int N;
  cin >> N;
  vector<char> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  string ans = "Three";
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'Y') {
      ans = "Four";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
$_=<>;
chomp;
my($n,$x)=split/ /;
$_=<>;
chomp;
my@l=split/ /;
my$c=1;
my$s=0;
foreach(@l){
 $s+=$_;
 if($s<=$x){
  $c++;
 }else{
  last;
 }
}
print$c;

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int32 i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int32 i = (b) - 1; i >= (a); --i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using uint16 = uint_fast16_t;
using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;


inline uint16 popcount(uint16 c) {
	c = (c & 0x5555) + ((c >> 1) & 0x5555);
	c = (c & 0x3333) + ((c >> 2) & 0x3333);
	c = (c & 0x0f0f) + ((c >> 4) & 0x0f0f);
	c = (c & 0x00ff) + ((c >> 8) & 0x00ff);
	return c;
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	cin >> n;
	uint16 f[100] = {};
	int32 p[100][11] = {};
	int32 a;
	rep(i, 0, n) {
		rep(j, 0, 10) {
			cin >> a;
			if (a) f[i] |= 1 << j;
		}
	}
	rep(i, 0, n) {
		rep(j, 0, 11)
			cin >> p[i][j];
	}
	int32 ans = -INF;
	for (uint16 i=1023;i;--i) {
		a = 0;
		rep(j, 0, n) {
			a += p[j][popcount(i&f[j])];
		}
		ans = max(ans, a);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
W = get_ints

total = W.sum

sa = total
sub_total = 0
W.each do |w|
  sub_total += w
  amari = total - sub_total
  stock = (amari - sub_total).abs
  sa = stock if stock < sa
end

puts sa


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
typedef ll i1;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    vector<P> items;
    rep(i, N-1) {
        ll u, v;
        cin >> u >> v;
        if (v > u) swap(u, v);
        items.push_back({u, v});
    }
    ll ans = 0;
    rep(i, N) {
        ll m = N - i;
        ans += ((m + 1 ) * m) / 2;
    }
    rep(i, N - 1) {
        ll u = items[i].first;
        ll v = items[i].second;
        ans -= v * (N - u + 1);
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
using ll =long long;

int main (void) {
  int W,a,b;
  cin >> W >> a >> b;
  if (abs(a-b)<=W){
    cout << 0;
  }
  else{
    cout << abs(a-b)-W;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.nio.*;
public class Main{
    public static void main(String[] args){
        int n=8;
        int s[]=new int[n];
        for(int i=0;i<n;i++)s[i]=i;
        Deque<IntBuffer>que=new ArrayDeque<>();
        que.add(IntBuffer.wrap(s));
        Map<IntBuffer,Integer>m=new TreeMap<>();
        m.put(IntBuffer.wrap(s),0);
        int idx=0;
        while(!que.isEmpty()){
            idx++;
            int v[]=que.remove().array();
            int c=0;
            for(int i=0;i<n;i++)if(v[i]==0)c=i;
            {
                int v2[]=v.clone();
                v2[c]^=v2[c^4];
                v2[c^4]^=v2[c];
                v2[c]^=v2[c^4];
                if(!m.containsKey(IntBuffer.wrap(v2))){
                    m.put(IntBuffer.wrap(v2),m.get(IntBuffer.wrap(v))+1);
                    que.add(IntBuffer.wrap(v2));
                }
            }
            if(c%4!=0){
                int v2[]=v.clone();
                v2[c]^=v2[c-1];
                v2[c-1]^=v2[c];
                v2[c]^=v2[c-1];
                if(!m.containsKey(IntBuffer.wrap(v2))){
                    m.put(IntBuffer.wrap(v2),m.get(IntBuffer.wrap(v))+1);
                    que.add(IntBuffer.wrap(v2));
                }
            }
            if(c%4!=3){
                int v2[]=v.clone();
                v2[c]^=v2[c+1];
                v2[c+1]^=v2[c];
                v2[c]^=v2[c+1];
                if(!m.containsKey(IntBuffer.wrap(v2))){
                    m.put(IntBuffer.wrap(v2),m.get(IntBuffer.wrap(v))+1);
                    que.add(IntBuffer.wrap(v2));
                }
            }
        }
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            int v[]=new int[n];
            for(int i=0;i<n;i++)v[i]=sc.nextInt();
            System.out.println(m.get(IntBuffer.wrap(v)));
        }
    }
}


Measured memory_bytes: 52868
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector


deque<int>ans[200];
int dos[20000];
signed main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int H,W;
    cin>>H>>W;
    
    int ind=1;
    
    int n;
    cin>>n;
    int bb=1;
    forn(i,1,n)
    {
        int a;
        cin>>a;
        forn(j,1,a)
        dos[bb++]=i;
    }
    
    forn(i,1,H*W)
    {
        if(ind%2)ans[ind].push_back(dos[i]);
        else ans[ind].push_front(dos[i]);
        
        if(i%W==0)ind++;
    }
    
    forn(i,1,H)
    {
        for(auto t : ans[i])cout<<t<<" ";
        nl;
    }
     




     return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 640
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int main(void){
	char c;
	char k=0;
	while(isdigit(c=getchar())){
		k=(k+c-'0')%9;
	}
	puts(k==0?"Yes":"No");
}


Measured memory_bytes: 1556
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static long Calc(long x, long y) {
        if (x == y) return 0;

        if (x < y) {
            if (x >= 0) return y - x;

            if (y <= 0) {
                return y - x;
            }
            else if (x > -y) {
                return y - (-x) + 1;
            }
            else {
                return -y - x + 1;
            }
        }
        else { // x > y
            if (y >= 0) {
                if (y == 0) return Math.Abs(x) + 1;

                return x - y + 2;
            }

            // y < 0
            if (x >= 0) {
                if (x > -y) {
                    return x - (-y) + 1;
                }
                return -y - x + 1;
            }
            else { // x < 0
                if (-x <= -y) {
                    return -y - (-x) + 2;
                }
                return -x - (-y) + 1;
            }
        }
    }

    static void Main() {
        var xy = ReadInts();
        long x = xy[0];
        long y = xy[1];

        var ans = Calc(x, y);
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
int main() {

	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);

	
	for (int i = 0;i < M;i++) {
		cin >> B[i];

	}
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < M;j++) {
			cin >> A[i][j];

		}

	}
	int ans = 0;
	
	for (int i = 0;i < N;i++) {
		int sum = 0;
		for (int j = 0;j < M;j++) {

			sum += A[i][j] * B[j];
		}
		if (sum + C > 0) ans++;


	}
	cout << ans << endl;

}

Measured memory_bytes: 256
/* Filename: AGC004A.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		while (input.hasNext()) {
			int A = input.nextInt(), B = input.nextInt(), C = input.nextInt();

			if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
				System.out.println(0);
			} else {
				long AxB = (long) A * B;
				long BxC = (long) B * C;
				long AxC = (long) A * C;
				long minDiff = Math.min(AxB, Math.min(AxC, BxC));
				
				System.out.println(minDiff);
			}
		}
	}

}


Measured memory_bytes: 8788
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using Graph = vector<vector<int> >;
using P = pair<int, int>; 
// MOD
const int MOD = 1000000007;
using ll = long long;
long long INF = 1<<30;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
//int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int H, W;
int field[100][100];

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double PI=3.14159265358979323846;
bool seen[100][100];

bool memo[110];
bool flag;
Graph G;

int dist[100][100];

bool compare_f(pair<int, int> &x, pair<int, int> &y) {
  return x.second< y.second;
}

struct Unionfind{
    vector<int> par;

    Unionfind(int n) : par(n, -1){}

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    } 

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x]>par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

int main() {
    string s, t; cin >> s >> t;
    int n = s.size();
    string res = "Yes";
    for(int i=0; i<n; i++){
        if(s[i] != t[i]) res = "No";
    }
    cout << res << endl;
}



Measured memory_bytes: 3044
//#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()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int F;
    cin >> F;
    vi a(3*F);
    rep(i, 3*F) {
        cin >> a[i];
    }

    sort(rall(a));
    ll ans = 0;
    rep(i, F) {
        ans += a[i*2+1];
    }

    cout << ans << endl;
}

Measured memory_bytes: 4520
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()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}
const NUM: usize = 2019; 
fn main() {
    let lr = read_vec::<usize>();
    let (l, r) = (lr[0], lr[1]);

    let mut ans = NUM;
    'outer: for i in l..r {
        for j in i+1..r+1 {
            ans = std::cmp::min(i * j % NUM, ans);
            if ans == 0 {
                break 'outer;
            }
        }
    }

    println!("{}", ans);
}

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

int n, k;
int a[100005];
int dp[100005];


bool f(int stones) {
    if(dp[stones] != -1) return dp[stones];
    if(stones == 0) return dp[stones] = false;
    
    bool res = false;
    for(int i = 0; i < n; i++) {
        if(a[i] <= stones) {
            res = res or not f(stones-a[i]);
        }
    }
    return dp[stones] = res;
}


int main() {
	// your code goes here
	cin >> n >> k;
	
	for(int i = 0; i < n; i++) {
	    cin >> a[i];
	}
	memset(dp, -1, sizeof dp);
	cout << ((f(k) == true) ? "First" : "Second");
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstring>
using namespace std;
const int maxn=2e5+10;
char s[maxn];
int main()
{
    cin>>(s+1);//cout << "Hello world!" << endl;
    int ans=0,len=strlen(s+1);
    for(int i=1; i<=len; i++)ans+=s[i]-'0';
    if(ans%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3232
// 119_D_LazyFaith.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <fstream>

#include <algorithm>
#include <iostream>
#include <vector>

#include <chrono>


using namespace std;

typedef long long ll;

const ll INF = 1000000000001;

#define rep(i, n) for(int i=0;i<n;i++)
#define setCinIntoVector(vec, n, typ) rep(i, n){ typ tmp; cin >> tmp; vec.emplace_back(tmp);}


ll CalcDistance(ll x, ll s1, ll s2, ll t1, ll t2)
{
	ll distance = INF;

	for (auto s : { s1, s2 })
	{
		for (auto t : { t1, t2 })
		{
			//1次元なので、三角不等式が常に等号で成り立つ。
			ll d1 = abs(s - x) + abs(t - s);
			ll d2 = abs(t - x) + abs(s - t);

			distance = min(distance, min(d1, d2));
		}
	}

	return distance;
}

int main()
{
	//std::ifstream in("C:\\Users\\Owner\\Downloads\\D\\in\\b06");
	//std::cin.rdbuf(in.rdbuf());

	int a, b, q;
	cin >> a >> b >> q;

	vector<ll> ss;
	ss.emplace_back(-INF);
	setCinIntoVector(ss, a, ll)
	ss.emplace_back(INF);

	vector<ll> ts;
	ts.emplace_back(-INF);
	setCinIntoVector(ts, b, ll)
	ts.emplace_back(INF);

	vector<ll> xs;
	setCinIntoVector(xs, q, ll)

	vector<ll> distances;
	for (auto x : xs)
	{
		auto si = lower_bound(ss.begin(), ss.end(), x);
		auto ti = lower_bound(ts.begin(), ts.end(), x);

		ll s1 = *si;
		ll s2 = (si == ss.begin()) ? *si : *(--si);

		ll t1 = *ti;
		ll t2 = (ti == ts.begin()) ? *ti : *(--ti);

		cout << CalcDistance(x, s1, s2, t1, t2) << endl;

	}

	return 0;
}


Measured memory_bytes: 3828