akhauriyash/Code-Regression huggingface dataset:
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int D;
int C[26];
int S[365][26];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand26(1, 26);

  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];

  REP(i,D) cout << (i%26) + 1 << '\n';

  return 0;
}


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

int main(){
  vector<int> b;
  int n;

  while(1){
    cin >> n;
    if(n==0) break;
    b.resize(n);
    for(int i=0;i<n;i++) cin >> b[i];
    int id;
    for(id=0;id<=10000;id++){
      bool f=1;
      if(b[0] == 1){
	f=0;
	for(int i=0;i<b.size()-1;i++)
	  if(b[i]+1 != b[i+1]) f=1;
      }
      if(f==0) break; 
      b.push_back(b.size());
      for(int i=0;i<b.size()-1;i++){
	b[i]--;
	if(b[i] == 0){
	  b.erase(b.begin()+i);
	  i--;
	}
      }
    }
    if(id<=10000) cout << id<< endl;
    else cout << -1<< endl;
  }
  return 0;
} 
    

Measured memory_bytes: 1240
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(A: int, B: int):
    x = {1,2,3}-{A,B}
    print(x.pop())
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
x = int(input())

is_true = False
for i in range(1000):
    for j in range(-1000, 1000):
        key = i ** 5 - j ** 5
        if x == key:
            print(i, j)
            is_true = True
            break
    if is_true:
        break

#     key = (i ** 5) - x

#     if key % (5 ** 5) == 0:
#         print(i, key / (5 ** 5))


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    int index = a[0] / 2;
    int ans;
    int diff = 1000000001;

    repd(i, 1, n) {
        if (a[0] % 2 == 0) {
            if (a[i] == index) {
                ans = index;
                break;
            }
            else {
                if (diff > abs(a[i] - index)) {
                    diff = abs(a[i] - index);
                    ans = a[i];
                }
            }
        }
        else if (a[0] % 2 == 1) {
            if (a[i] == index) {
                ans = index;
                break;
            }
            else if (a[i] == index + 1) {
                ans = index + 1;
                break;
            }
            else {
                if (diff > abs(a[i] - index)) {
                    diff = abs(a[i] - index);
                    ans = a[i];
                }
                if (diff > abs(a[i] - (index + 1))) {
                    diff = abs(a[i] - (index + 1));
                    ans = a[i];
                }
            }
        }
    }

    cout << a[0] << " " << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    x, y, z = [int(s) for s in input().strip().split()]
    print(z, x, y)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


ll dp[110][310][110];

class DSimpleKnapsack {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        ll W;
        in >> n >> W;
        ll w[110], v[110];
        rep(i, n){
            in >> w[i] >> v[i];
        }

        ll w1 = w[0];
        Fill(dp, 0);
        rep(i, n){
            reps(k, 0, 100) {
                reps(j, 0, 300) {
                    if(j + w[i]-w1 <= W - w1*(k+1)){
                        chmax(dp[i+1][j + w[i]-w1][k+1], dp[i][j][k] + v[i]);
                    }
                    chmax(dp[i+1][j][k], dp[i][j][k]);
                }
            }
        }

        ll res = 0;
        reps(k, 1, 100){
            reps(j, 0, 300){
                chmax(res, dp[n][j][k]);
            }
        }

        out << res << endl;
	}
};


int main() {
	DSimpleKnapsack solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 29568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int N;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();

        System.out.println(solve());
    }

    static String solve() {
        long[] from = new long[32];
        long[] to = new long[32];
        from[0] = 1;
        to[0] = 1;
        from[1] = -2;
        to[1] = -1;

        for (int i = 2; i < 32; i++) {
            long b = (long)Math.pow(-2, i);

            if( b > 0 ) {
                from[i] = to[i-2] + 1;
                to[i] = to[i-2] + b;

            } else {
                from[i] = from[i-2] + b;
                to[i] = from[i-2] - 1;
            }
        }

        StringBuilder ans = new StringBuilder();
        int n = N;
        for (int i = 31; i >= 0; i--) {
            long b = (long)Math.pow(-2, i);
            if( from[i] <= n && n <= to[i] ) {
                n -= b;
                ans.append("1");
            } else {
                ans.append("0");
            }
        }

        int idx = ans.indexOf("1");
        if( idx == -1 ) {
            return "0";
        } else {
            return ans.substring(idx);
        }
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

int main(){
    string str; cin>> str;
    int n = str.size();
    int s[n];
    char op[n];
    for(int i=0;i<n;i++) s[i] = str[i]-'0';

    int sum;
    for(int bit=0;bit<(1<<n-1);bit++){
        sum = s[0];
        for(int i=0;i<n-1;i++){
            if(bit & (1<<i)){
                sum += s[i+1];
                op[i] = '+';
            }
            else{
                sum -=s[i+1];
                op[i] = '-';
            }                
        }
        if(sum == 7) break;
    }
  cout<<s[0]<<op[0]<<s[1]<<op[1]<<s[2]<<op[2]<<s[3]<<'='<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, m;
vector<int> g[1000];
pair<bool, vector<int>> r[1001];

pair<bool, vector<int>> f(int v) {
	vector<int> par(n, -1);
	queue<int> q;
	q.push(v);
	while(! q.empty()) {
		int w = q.front(); q.pop();
		RF(e, g[w]) {
			if(e == v) {
				vector<int> x;
				int y = w;
				while(y != -1) { x.PB(y); y = par[y]; }
				return { true, x };
			}
			if(par[e] == -1) {
				par[e] = w;
				q.push(e);
			}
		}
	}
	return { false, vector<int>(n + 1) };
}

int main() {
	cin >> n >> m;
	inc(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].PB(b);
	}
	
	inc(i, n) { r[i] = f(i); }
	r[n] = { false, vector<int>(n + 1) };
	
	pair<int, int> ans = { n + 1, n }; // size, index
	inc(i, n) {
		if(r[i].FI) { setmin(ans, { SI(r[i].SE), i }); }
	}
	
	if(ans.FI > n) { cout << -1 << endl; } else {
		cout << ans.FI << endl;
		RF(e, r[ans.SE].SE) { cout << e + 1 << "\n"; }
	}
	
	return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
int taro[100];
int hanako[100];
int tarosum;
int hanakosum;
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		tarosum=hanakosum=0;
		for(int i=0;i<a;i++){
			scanf("%d",taro+i);
			tarosum+=taro[i];
		}
		for(int i=0;i<b;i++){
			scanf("%d",hanako+i);
			hanakosum+=hanako[i];
		}
		int min=99999999;
		int rett=0;
		int reth=0;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				if(tarosum-taro[i]+hanako[j]==hanakosum-hanako[j]+taro[i]&&min>taro[i]+hanako[j]){
					min=taro[i]+hanako[j];
					rett=taro[i];
					reth=hanako[j];
				}
			}
		}
		if(min==99999999)printf("-1\n");
		else printf("%d %d\n",rett,reth);
	}
}

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

const int MOD = 1e9 + 7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int64_t> v(n + 1);
	for(int i = 1; i <= n; i++) cin >> v[i];
	vector<int64_t> sum(n + 1);
	for(int i = 1; i <= n; i++){
		sum[i] = sum[i-1] + v[i];
	}
	int64_t T = 0;
	for(int i = 1; i <= n - 1; i++){
		T += v[i] * (sum[n] % MOD - sum[i] % MOD + MOD) % MOD;
		T %= MOD;
	}
	cout << T << '\n';
	return 0;
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  for(int i=1;i<=b;i++){
    if(i*a%b==c){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		scanner.close();
		
		if (a <= 8 && b <= 8) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
		
		
	}

}


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

using namespace std;

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

	int ans = 0;
	for (int i = a; i <= b; i++)
	{
		string s = to_string(i);
		if (s[0] == s[4] && s[1] == s[3]) ans++;
	}

	cout << ans << endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  long long count=0;
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      for(int k=j+1;k<N;k++){
        int A=L.at(i);
        int B=L.at(j);
        int C=L.at(k);
        if(A==B || B==C || C==A){
          continue;
        }
        if(A<B+C && B<C+A && C<A+B){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define int ll
#define pb push_back
#define sz(i) (int)(i.size())
#define fi first
#define se second
#define ld long double
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = 1e9 + 7;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << std::endl;}template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = 1e5 + 10;
// make sure N size is correctttt!!!!!!!!!
template<typename T>inline std::ostream &operator << (std::ostream & os,const std::set<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}

int n, m;
std::vector<int> v[N];
bool vis[N];

// set<int> ms[N];
stack<int> topo;
int parent[N], dp[N];

void dfs(int s, int p){
   vis[s] = 1;
   parent[s] = p;
   for(auto it: v[s]){
      if(vis[it])continue;
      dfs(it, s);
   }
   topo.push(s);
}

std::vector<int> rev[N];
int Pans;

void WOW(int s){
   // tr(s, rev[s]);
   for(auto i: rev[s]){
      smax(dp[i], dp[s] + 1);
      smax(Pans, dp[i]);
      WOW(i);
   }
}

int32_t main(){_

   cin>>n;
   cin>>m;

   for (int i = 0; i < m; ++i)
   {
      int x, y;
      cin>>x>>y;
      v[x].pb(y);
      rev[y].pb(x);
      // ms[x].insert(y);
      parent[y] = x;
   }

   int ans = 0;
   for (int i = 1; i <= n; ++i)
   {
      if(vis[i])continue;      
      dfs(i, -1);
   }

   std::vector<int> v;
   while(!topo.empty()){
      v.pb(topo.top());
      topo.pop();
   }

   reverse(v.begin(), v.end());
   for (int i = 1; i <= n; ++i)
   {
      dp[i] = 0;
   }

   Pans = 0;

   // cout<<v<<endl;
   for (int i = 0; i < sz(v); ++i)
   {
      for(auto tt : rev[v[i]]){
         smax(dp[tt], dp[v[i]]+1);
         smax(Pans, dp[tt]);
      }
   }

   cout<<Pans;
   return 0;   
   // // cout<<v<<endl;
   // memset(vis, 0, sizeof vis);
   
   // for (int i = 0; i < sz(v); ++i)
   // {
   //    if(vis[v[i]])continue;
   //    WOW(v[i]);
   // }

   // for (int i = 0; i < sz(v); ++i)
   // {
      // for(auto j: rev[i]){
         // smax(dp[j], dp[v[i]]+1);
         // smax(Pans, dp[j]);
      // }
   // }

   cout<<max(Pans-1,1LL);
   //make sure N size is correct!!!!!!!!!
   return 0;
}

Measured memory_bytes: 16676
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	if (s.size() % 2 == 1) return cout << "No", 0;
	for (int i = 0; i < s.size(); i += 2){
		if (s[i] != 'h') return cout << "No", 0;
	}
	for (int i = 1; i < s.size(); i += 2){
		if (s[i] != 'i') return cout << "No", 0;
	}
	cout << "Yes";









	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int A, B; cin >> A >> B;
  cout << max(0, A-B*2) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		int n = s.length() - 1;
		long ans = 0;
		int end = 1 << n;
		for (int i = 0; i < end; i++) {
			long sum = 0;
			int pre = 0;
			for (int j = 0; j < n; j++) {
				if ((i >> j & 1) == 1) {
					sum += Long.parseLong(s.substring(pre, j + 1));
					pre = j + 1;
				}
			}
			sum += Long.parseLong(s.substring(pre));
			ans += sum;
		}
		System.out.println(ans);
	}
}


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

int main(void) {
    int n, k;
    cin >> n >> k;
    bool check[10];
    for (int i = 0; i < 10; ++i) {
        check[i] = true;
    }

    for (int i = 0; i < k; ++i) {
        int j;
        cin >> j;
        check[j] = false;
    }
    for (int i = n; ;++i) {
        string s = to_string(i);
        bool c = true;
        for (int j = 0; j < s.length(); ++j) {
            if (check[(int)(s[j]) - '0'] == false) {
                c = false;
            }
        }
        if (c == true) {
            cout << s << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;
const ll MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  cout << (n/2)*((n+1)/2) <<endl;
}

Measured memory_bytes: 256
import string

alphabets = {}

for i in string.ascii_lowercase:
    alphabets[i] = 0

try:
    while True:
        string = str.lower(input())
        
        for i in range(len(string)):
            if string[i] in alphabets:
                alphabets[string[i]] += 1
        
except Exception:
    for i, j in alphabets.items():
        print('{} : {}'.format(i, j))


Measured memory_bytes: 6680
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


int main(){
  int n, m;

  cin >> n >> m;

  if(n <= 8 && m <= 8)
    printf("Yay!\n");
  else
    printf(":(\n");




  return 0;
}

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

namespace Contest
{
    class ABC
    {
        static void Main()
        {
            Solve();
        }

        private static void Solve()
        {
            int N = int.Parse(Console.ReadLine());
            int[] INPUT = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int res = 0;
            for (int i = 0; i < N; ++i)
            {
                for (int j = i; j < N; ++j)
                {
                    if (i == j) continue;
                    res += INPUT[i] * INPUT[j];
                }
            }
            Console.WriteLine(res);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13396
x = int(input())
def f(a,b):
    return pow(a,4) + b*pow(a,3) + pow(a*b,2) + a*pow(b,3) + pow(b,4)

def divisor(n):
    tank = []
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            tank.append(i)
            if i!=n//i:
                tank.append(n//i)
    tank.sort()
    return tank

lst = divisor(x)
for y in lst:
    for a in range(10000):
        div = x//y
        
        b = a - y
        if f(a,b) == div:
            print(a, b)
            exit()
            
        b = a + y
        if f(a, b) == (-1)*div:
            print(a,b)
            exit()

Measured memory_bytes: 9428
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  double n, res = 0;
  cin >> n;
  REP(i,n) {
    double a;
    string s;
    cin >> a >> s;
    if(s == "JPY") res += a;
    if(s == "BTC") res += (a*380000);
  }
  cout << PREC(10) << res << endl;
  return 0;
}
//templete by private_yusuke

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

int main(){
    int N; cin >> N;
    vector<int> p;
    for(int i=0; i<N; i++){
        int v; cin >> v;
        p.push_back(v);
    }
    int m = INT_MAX;
    int count = 1;
    for(int i=1; i<N; i++){
        m = min(m, p[i-1]);
        if(m>=p[i]) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 1400
/**
 *   author: sahushivam
 *   created: 23 November 2019 (Saturday)  17:38:02
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,a,b) for(int i = a; i<b; i++)
#define MOD 1000000007
#define INF 1e18
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t=1;
    int n;
    cin>>n;
    vector<int> a(n),pre(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int sum=0;
	pre[0]=a[0];
	for(int i=0;i<n;i++) sum+=a[i];
	for(int i=1;i<n;i++)
	{
		pre[i]=pre[i-1]+a[i];
	}
	int mini=INT_MAX;
	for(int i=0;i<n;i++)
	{
		mini=min(mini,abs(sum-2*pre[i]));
	}
	cout<<mini;

return 0;
}

Measured memory_bytes: 3328
use proconio::input;

fn main() {
    input! {
        x: usize,
    }

    let y2 = if x * 2 % 11 > 0 {
        x / 11 + 1
    } else {
        x / 11
    };


    
    let y = if y2 * 11 - 5 >= x {
        y2 * 2 - 1
    } else {
        y2 * 2
    };

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


Measured memory_bytes: 2176
from statistics import median
n=int(input())
A,B=[],[]
for _ in range(n):
  a,b=map(int,input().split())
  A.append(a*2)
  B.append(b*2)
ma,mb = int(median(A)),int(median(B))
#print(ma,mb)
if n%2 == 0:
  print(mb-ma+1)
else:
  print((mb-ma)//2+1)


Measured memory_bytes: 28804
n,m=map(int,input().split())
l0,r0=1,n
for i in range(m):
  l,r=map(int,input().split())
  if l>r0 or r<l0:
    print(0)
    exit()
  else:
    l0=max(l0,l)
    r0=min(r0,r)
print(r0-l0+1)

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

bool is_prime(int N) {
    for(int i = 2; i * i <= N; i++) {
        if(N % i == 0) {
            return false;
        }
    }
    return true;
}
int main() {
    int X; cin >> X;
    while(!is_prime(X)) {
        X++;
    }
    cout << X << endl;
}

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

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

int main(){
  int H, W;
  cin >> H >> W;
  
  for(int i = 0; i < H; i++){
	scanf("%s", &s[i]);
  }
  
  bool ans = true;
  for(int i = 0; i < H; i++){
	for(int j = 0; j < W; j++){
      if(s[i][j] == '#'){
		bool found = false;
        for(int k = 0; k < 4; k++){
          int x = i + dx[k];
          int y = j + dy[k];
          if(0 <= x && x < H && 0 <= y && y < W && s[x][y] == '#'){
            found = true;
          }
        }
        if(!found) ans = false;
      }
    }
  }
  
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
#define int long long
#define inf 1e17
using namespace std;
int n;
signed main()
{
	scanf("%lld",&n);
	printf("%lld",(1000-n%1000)%1000);
	return 0;
}

Measured memory_bytes: 3816
from collections import deque
h,w=map(int,input().split())
S=[input() for _ in range(h)]
inf=float("inf")
ans=0
for i in range(h):
   for j in range(w):
      if S[i][j]=="#":
         continue
      else:
         D=[[inf for _ in range(w)]for _ in range(h)]
         D[i][j]=0
         que=deque([(i,j)])
         while que:
            si,sj=que.popleft()
            for ni,nj in [(si+1,sj),(si-1,sj),(si,sj+1),(si,sj-1)]:
               if 0<=ni<h and 0<=nj<w and S[ni][nj]!="#":
                  if D[ni][nj]>D[si][sj]+1:
                     D[ni][nj]=D[si][sj]+1
                     que.append((ni,nj))
                     ans=max(ans,D[si][sj]+1)
print(ans)     

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

using namespace std;

string s[100000];
int counts[5];

int main()
{
	for (size_t i = 0; i < 5; i++)
	{
		counts[i] = 0;
	}

	int N;
	cin >> N;

	string march = "MARCH";
	for (size_t i = 0; i < N; i++)
	{
		cin >> s[i];

		auto p = march.find(s[i][0]);
		if (p == string::npos)
			continue;

		counts[p]++;
	}

	long long ans = 0;
	for (size_t i = 0; i < 5; i++)
	{
		for (size_t j = i + 1; j < 5; j++)
		{
			for (size_t k = j + 1; k < 5; k++)
			{
				ans += 1LL * counts[i] * counts[j] * counts[k];
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6144
#include<iostream>
using namespace std;
int n, m, a, b, sum;
int main() {
	while (true) {
		cin >> n;
		if (!n) { break; }
		cin >> m; sum = 0;
		for (int i = 0; i < m; i++) {
			cin >> a >> b;
			sum += b - a;
		}
		if (sum >= n) { cout << "OK" << endl; }
		else { cout << n - sum << endl; }
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cingroup(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfgroup(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
typedef unsigned long long ull;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	ll a,b;
	cin>>a>>b;
	int ans=0;
	while(a<=b)
	{
		a*=2;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val aArr = readInputLine().split(" ").map { it.toInt() - 1 }.toIntArray()

    var cnt = 0
    
    var i = 0
    
    while (i < N) {
        if (aArr[i] == i) {
            cnt++
            i++
        }
        i++
    }
    
    println(cnt)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 51836
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
    
int main(){
  int k,n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> dis(n-1);
  rep(i,n-1) dis[i] = a[i+1] - a[i];
  dis[n-1] = a[0] + k - a[n-1];
  int curMax = 0;
  rep(i,n) curMax = max(curMax, dis[i]);
  cout << k - curMax << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
constexpr ll INF = 1e18+7;
int T, ks[] = {2,3,5};
ll n, a[3], d;
map<ll, ll> mp;
ll rec(ll u){
	if(mp[u] || !u) return mp[u];
	if(u == 1) return mp[u] = d;
	ll ret = INF;
	rep(i,3){
		ret = min(ret, rec(u/ks[i]) + u%ks[i] * d + a[i]);
		ret = min(ret, rec((u-1)/ks[i]+1) + (ks[i]-1-(u-1)%ks[i]) * d + a[i]);
	}
	if(u < (ll)2e9+7) ret = min(ret, u * d);
	return mp[u] = ret;
}
int main(){
	scanf("%d", &T);
	rep(i,T){
		mp.clear();
		scanf("%lld%lld%lld%lld%lld", &n, a, a+1, a+2, &d);
		printf("%lld\n", rec(n));
	}
}

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

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

	vector<int> p( N );
	for( auto& v: p ) { cin >> v; }

	int M;
	cin >> M;

	for( int i = 0; i < M; ++i ) {
		int A;
		cin >> A;

		auto& p1 = p.at( A-1 );
		if( p1 == 2019 ) {
			continue;
		}

		bool stop = false;

		for( int j = 0; j < N; ++j ) {
			if( p1+1 == p.at( j ) ) {
				stop = true;
				break;
			}
		}

		if( !stop ) {
			p1 += 1;
		}
	}

	for( auto& v: p ) {
		cout << v << endl;
	}
}



Measured memory_bytes: 3096
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,a;cin>>n>>a;
    vector<int>x(n+1);
    for(int i=1;i<=n;i++)cin>>x[i];
    ll dp[55][55][2600];
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<i;j++){
            for(int k=0;k<=50*j;k++){
                dp[i][j][k]+=dp[i-1][j][k];
                dp[i][j+1][k+x[i]]+=dp[i-1][j][k];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=dp[n][i][i*a];
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

int main() {
	int n, a, b; cin >> n >> a >> b;
	int cnt[3] = {};
	rep(i, n) {
		int p; cin >> p;
		if (p <= a) {
			++cnt[0];
		} else if (p <= b) {
			++cnt[1];
		} else {
			++cnt[2];
		}
	}
	cout << min({cnt[0], cnt[1], cnt[2]}) << endl;

	return 0;
}

Measured memory_bytes: 768
#include<iostream>

using namespace std;
int n;
int S[5000];
int a[5000];
int mss(int x){
    int max=a[0];
    int lp=0;
    int rp=x;
    for(int l=lp;l<rp;l++){
        for(int r=l;r<rp;r++){
            int sum=0;
            if (l!=0){
                sum=S[r]-S[l-1];
            }
            else{
                sum =S[r];
            }
            if(sum>max){
                max=sum;
            }
        }
    }
    return (max);
}
int main(){
    while(cin>>n&&n){
        for(int i=0;i<n;i++){
            cin>>a[i];
            
            S[0]=a[0];
            for(int j=1;j<n;j++){
                S[j]=S[j-1]+a[j];
            }
        }
        cout<<mss(n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3112
import Control.Applicative
import Data.Char

main = do
  [n, k] <- map (read::String -> Int) . words <$> getLine
  s <- getLine
  let new_s = map (\i-> if i == k - 1 then (toLower $ s !! i)  else (s !! i)) [0..(n - 1)]
  putStrLn $ new_s

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

int main(){
  string s;
  cin >> s;
  if((s[0] == s[1] && s[1] == s[2])||(s[1] == s[2] && s[2] == s[3])) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main() {
  int N;
  cin >> N;
  int count=100;
  int count2;
  int A;
  int flag;
  for(int i=0; i<N; i++){
    cin >> A;
    count2 = 0;
    flag = true;
    while(flag){
      if(A%2 != 0){
        flag = false;
      }
      if(flag){
        A /= 2;
        count2++;
      }
    }
    if(count>count2){
      count=count2;
    }
  }
  cout << count << endl;
}

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


int main() {
    int n,a[100],r1=0,r2=0;
    float s = 0;
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> a[i];
        s += a[i];
    }
    s /= n;
    for (int i=0; i<n; i++){
        r1 += (a[i]-ceil(s))*(a[i]-ceil(s));
        r2 += (a[i]-floor(s))*(a[i]-floor(s));
    }
    r1 = r1>r2?r2:r1;
    cout << r1;
    return 0;
}


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

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		final int N = sc.nextInt();
		int[] d = new int[N];
		for (int i = 0; i < N; i++)
			d[i] = sc.nextInt();

		Arrays.sort(d);

		int K = d[N / 2] - d[N / 2 - 1];

		System.out.println(K);

	}

}

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: 24852
// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^63.
// NOTE: This function does not handle error cases.
// Verified: ARC096D
fun fastReadLongs(n: Int): LongArray {
  val xs = LongArray(n)
  val s = readLine()!!
  var currentValue = 0L
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1L else 1L
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1L else 1L
  return xs
}


fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val xs = fastReadLongs(n)
  var sum = 0L
  val countMap = mutableMapOf<Long, Long>()
  countMap[sum] = 1L
  for (x in xs) {
    sum += x
    if (countMap[sum] == null) {
      countMap[sum] = 1L
    } else {
      countMap[sum] = countMap[sum]!! + 1
    }
  }

  var ans = 0L
  for ((key, value) in countMap) {
    if (value >= 2) {
      ans += value * (value - 1) / 2
    }
  }
  println(ans)
}


Measured memory_bytes: 72160
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
ll dpuest[2001][2001];
ll dpsayu[2001][2001];
int main() {
  int h,w;
  cin>>h>>w;
  string s[h];
  for(int i=0;i<h;i++){
    cin>>s[i];
  }
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='.') {
        dpsayu[i][j]=1;
        dpuest[i][j]=1;
      }
      if(i!=0){
        if(s[i-1][j]=='.'){
          dpuest[i][j]+=dpuest[i-1][j];
        }else{
          dpuest[i][j]+=0;
        }
      }
      if(j!=0){
        if(s[i][j-1]=='.'){
          dpsayu[i][j]+=dpsayu[i][j-1];
        }else{
          dpsayu[i][j]+=0;
        }
      }
    }
  }
 for(int i=h-1;i>=0;i--){
    for(int j=w-1;j>=0;j--){
      if(i!=h-1){
        if(s[i][j]=='.'&&s[i+1][j]=='.'){
          dpuest[i][j]=dpuest[i+1][j];
        }
      }
      if(j!=w-1){
        if(s[i][j]=='.'&&s[i][j+1]=='.'){
          dpsayu[i][j]=dpsayu[i][j+1];
        }
      }
    }
  }
  ll ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='.'){
        ans=max(ans,dpuest[i][j]+dpsayu[i][j]-1);
      }
    }
  }
  /*for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<dpuest[i][j]<<" "<<dpsayu[i][j]<<" | ";
    }
    cout<<endl;
  }*/
  cout<<ans;
  return 0;
}

Measured memory_bytes: 66944
import java.io.PrintStream
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`);
    try {
        solve(sc, System.out);
    } finally {
        sc.close();
    }
}

fun solve(sc: Scanner, wr: PrintStream) {
    val N = sc.nextInt()

    if (N == 1) {
        wr.println(0)
        return
    }

    val MOD = 1e9.toLong() + 7
    val dp = Array(N + 1) { Array(2) { LongArray(2) { 0L } } }
    dp[0][0][0] = 1
    for (i in 0 until N) {
        for (j in 0..1) {
            for (k in 0..1) {
                for (d in 0..9) {
                    val jj = if (j == 1 || d == 0) 1 else 0
                    val kk = if (k == 1 || d == 9) 1 else 0

                    dp[i + 1][jj][kk] += dp[i][j][k];
                    dp[i + 1][jj][kk] %= MOD
                }
            }
        }
    }

    wr.println(dp[N][1][1])
}


Measured memory_bytes: 142388
using System;
using System.Collections.Generic;

namespace ABC096C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input=Console.ReadLine().Split(' ');
            var H = int.Parse(input[0]);
            var W = int.Parse(input[1]);
            var s = new List<string>();
            for(var i = 0; i < H; i++)
            {
                s.Add(Console.ReadLine());
            }

            var answer = "Yes";
            for (var x = 0; x < W; x++)
            {
                for (var y = 0; y < H; y++)
                {
                    if (s[y][x] == '#')
                    {
                        if (!CanPaint(s, H, W, x, y))
                        {
                            answer = "No";
                            break;
                        }
                    }
                }
            }
            Console.WriteLine(answer);
        }

        static bool CanPaint(List<string> s, int H, int W,int x, int y)
        {
            if (x > 0 && s[y][x - 1] == '#') return true;
            if (y > 0 && s[y - 1][x] == '#') return true;
            if (x + 1 < W && s[y][x + 1] == '#') return true;
            if (y + 1 < H && s[y + 1][x] == '#') return true;
            return false;
        }
    }
}


Measured memory_bytes: 27804