akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  ll n,k;cin>>n>>k;
  COMinit();
  ll ans=0;
  for(int i=k;i<=n+1;i++){
    ans+=i*(n-i+1)+1;
    ans%=MOD;
  }
  cout<<ans%MOD<<endl;
}

Measured memory_bytes: 15592
import java.util.*;



class Main{

    public static void main(String[] args){

	int gyo,retu,n;
	String sc;
	Scanner in = new Scanner(System.in);


	gyo = in.nextInt();
	retu = in.nextInt();
	n = in.nextInt();
	int[][] jm = new int[gyo+1][retu+1];
	int[][] om = new int[gyo+1][retu+1];
	int[][] im = new int[gyo+1][retu+1];
	for(int i=0;i<=gyo;i++){
	    for(int j=0;j<=retu;j++){
		jm[i][j]=0;
		om[i][j]=0;
		im[i][j]=0;
	    }
	}

	//Arrays.fill(jm,0); //memsetツ的ツづ按閉ィ
	//Arrays.fill(om,0);
	//Arrays.fill(im,0);

	for(int i=1;i<=gyo;i++){
	    sc = in.next();
	    for(int j=0;j<retu;j++){
		char cc[] = sc.toCharArray();
		jm[i][j+1]=jm[i-1][j+1]+jm[i][j]-jm[i-1][j];
		om[i][j+1] = om[i-1][j+1]+om[i][j]-om[i-1][j];
		im[i][j+1]=im[i-1][j+1]+im[i][j]-im[i-1][j];
		if(cc[j] == 'J'){
		    jm[i][j+1]++;
		}else if(cc[j] == 'O'){
		    om[i][j+1]++;
		}else if(cc[j] == 'I'){
		    im[i][j+1]++;
		}


	    }
	}

	/*	
		for(int i=0;i<=gyo;i++){
		for(int j=0;j<=retu;j++)System.out.print(jm[i][j] + " ");
		System.out.printf("\n");
		}
	*/
	
	int a,b,c,d;
	for(int i=0;i<n;i++){
	    a = in.nextInt();
	    b = in.nextInt();
	    c = in.nextInt();
	    d = in.nextInt();
	    System.out.print(jm[c][d]-jm[a-1][d]-jm[c][b-1]+jm[a-1][b-1]);
	    System.out.print(" ");
	    System.out.print(om[c][d]-om[a-1][d]-om[c][b-1]+om[a-1][b-1]);
	    System.out.print(" ");
	    System.out.println(im[c][d]-im[a-1][d]-im[c][b-1]+im[a-1][b-1]);

	}
	


    }


}

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

int main() {
    int A,B,C,ans;
    cin >> A >> B >> C;
    for (int i=0 ; i<C ; i++){
        if (B>=A){
            B-=A;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int t=a;
  int ans=0;
  while (t<b+1){
    if (t%10==t/10000 && t/10%10 == t/1000%10){
      ans++;
    }
    t++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define P pair<ll, ll>
#define V vector<ll>
#define C vector<char>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007
#define rep(i, s, n) for (ll i = (ll)(s); i < (ll)(n); i++)


int power(ll x, unsigned int y)  
{  
	ll p=mod;
    ll res = 1;      
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    { 
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}  
ll gcdExtended(ll a, ll b, ll *x, ll *y)  
{ 
     
    if (a == 0)  
    {  
        *x = 0;  
        *y = 1;  
        return b;  
    }  
  
    ll x1, y1;  
    ll gcd = gcdExtended(b%a, a, &x1, &y1);  
      *x = y1 - (b/a) * x1;  
    *y = x1;  
  
    return gcd;  
}  
set<ll> fact(ll n){
  set<ll> res;
  for(ll i=2;i*i<=n;++i){
    if(n%i==0){
      res.insert(i);
      while(n%i==0) n /= i;
    }
  }
  if(n>1)res.insert(n);
  return res;
}
int main()
{
	ll a,b,x,y;
	cin>>a>>b;

	ll g=gcdExtended(a,b,&x,&y);
	cout<<fact(g).size()+1<<endl;
}


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

int N;
int A[110];
int ans = 10e9;

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d",&A[i]);
    }
    for(int i = -100; i <= 100; i++)
    {
        int res = 0;
        for(int j = 0; j < N; j++)
        {
            res += abs(A[j] - i) * abs(A[j] - i);
        }
        ans = min(ans,res);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val A = Array.fill(N)(0)
    for (i <- 0 until N) A(i) = sc.nextInt
    val mu = A.sum / N
    val min1 = A.map(x => (x - mu)*(x-mu)).sum
    val min2 = A.map(x => (x - mu-1)*(x-mu-1)).sum
    val min = if (min1 > min2) min2 else min1
    println(min)
  }
}

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

using namespace std;

const int N = 3e3 + 5;
const int mod = 1e9 + 7;

int n;
double a[N], dp[N][N];

void add (int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i][j] += dp[i - 1][j] * (1.0 - a[i]);
            if (j) dp[i][j] += dp[i - 1][j - 1] * a[i];
        }
    }
    
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++) ans += dp[n][i];
    cout << fixed << setprecision(10) << ans;
    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

#define MOD 1000000007

void add(int& a, int b){
	a+=b;
	if(a>=MOD)a-=MOD;
}

int n;
int f[1<<21];
int f2[1<<21];

int main(){
	scanf("%d",&n);
	f[0]=1;
	fore(i,0,n){
		mset(f2,0);
		fore(j,0,n){
			int a;
			scanf("%d",&a);
			if(a){
				fore(m,0,1<<n)if(!((m>>j)&1))
					add(f2[m|(1<<j)],f[m]);
			}
		}
		mcpy(f,f2);
	}
	printf("%d\n",f[(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 16640
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	cout << fixed << setprecision(8);
	for (double a; cin >> a;) {
		double s = a;
		for (int i = 2; i <= 10; i++)
			s += (i % 2) ? a = a / 3 : a = a * 2;
		cout << s << endl;
	}
	return 0;
}

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

void kurikaesi(int x){
    int i=1;
    while(true){
        cin>>x;
        if(x==0){
            break;
        }
        cout<<"Case "<<i<<": "<<x<<endl;
        
        i++;
    }
}

int main(){
    int x;
    kurikaesi(x);
}


Measured memory_bytes: 3012
#include <stdio.h>

int main()
{
	int N,H,W;
	scanf("%d %d %d",&N,&H,&W);
	int a[N],b[N];
	int ans=0;
	for (int i = 0; i < N; ++i)
	{
		scanf("%d %d",&a[i],&b[i]);
		if(a[i] >= H && b[i] >= W){
			ans++;
		} 
	}
	printf("%d",ans);	
	return 0;
}


Measured memory_bytes: 128
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# T,S,Zは使えない
# I,J,Lを1つずつ使うと偶奇の調整ができる

A = LI()
d = defaultdict()
name = ['I','O','T','J','L','S','Z']
for i,a in enumerate(A):
    d[name[i]] = a

ans = d['O']

use = ['I','J','L']
odd = []
even = []
for k in use:
    if d[k]%2:
        odd.append(k)
    else:
        even.append(k)

if len(odd) == 3:
    ans += 3
    for k in use:
        ans += ((d[k]-1)//2)*2
elif len(odd) == 2:
    if d[even[0]] > 0:
        ans += 3
        for k in use:
            ans += ((d[k]-1)//2)*2
    else:
        for k in use:
            ans += (d[k]//2)*2
elif len(odd) == 1:
    for k in use:
        ans += (d[k]//2)*2
else:
    for k in use:
        ans += (d[k]//2)*2

print(ans)

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

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> mp;
    for(int i=1;i<=n;i++){
        int a;
        cin >> a;
        mp.push_back(make_pair(a,i));
    }
    sort(mp.begin(),mp.end());
    for(pair<int,int> e:mp){
        int c,d;
        tie(c,d)=e;
        cout << d << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> > 

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int N=2e5+10, M=(ll)1e9+1 ;
const int mod = 998244353  ;

void work(){
 ll n,k;
 cin >> n >> k;
 if(k==1){  
   cout << 0;
 }
 else{
    cout << n-k;
 }
 return;
}
int main(){
 ios_base::sync_with_stdio(0);

    ll t;
    // cin >> t;
    t=1;
    while(t--){
            work();
    }
   return 0;

}

Measured memory_bytes: 256
c = {"#":0,
     "@":1,
     ".":2,
     "*":3}

d = [[0, -1],
     [0, 1],
     [-1, 0],
     [1, 0]]

output = []
while True:
    w, h = input().split()
    w = int(w)
    h = int(h)

    if w == 0:
        break

    tiles = [[0 for i in range(w)] for j in range(h)]
    for i in range(h):
        row = input()
        for j in range(w):
            tiles[i][j] = c[row[j]]
            if tiles[i][j] == 1:
                queue = [(j, i)]

    count = 1
    while queue:
        x, y = queue[0]
        queue.pop(0)

        for ud, rl in d:
            xt = x+ud
            yt = y+rl
            if xt >= 0 and xt <= w-1 and yt >= 0 and yt <= h-1:
                if tiles[yt][xt] == 2:
                    tiles[yt][xt] = 3
                    count += 1
                    queue.append((xt, yt))

    output.append(count)

for num in output:
    print(num)

Measured memory_bytes: 7828
n = int(input())
mod = pow(10, 9) + 7
alph = list("AGCT")
ng1 = [list("AGC"), list("ACG"), list("GAC")]
dp = [0] * 64
for i in range(4):
    for j in range(4):
        for k in range(4):
            if not [alph[i], alph[j], alph[k]] in ng1:
                dp[16 * i + 4 * j + k] = 1
for _ in range(n - 3):
    dp0 = [0] * 64
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    if not [alph[j], alph[k], alph[l]] in ng1:
                        if not ([alph[i], alph[l]] == list("AC") and (alph[j] == "G" or alph[k] == "G")):
                            dp0[16 * j + 4 * k + l] += dp[16 * i + 4 * j + k]
                            dp0[16 * j + 4 * k + l] %= mod
    for i in range(64):
        dp[i] = dp0[i]
ans = sum(dp) % mod
print(ans)

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

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

using namespace std;


ll gcd(ll m, ll n){
    if(m == 0) return 0;
    if(n == 0) return 0;
	
	while(m != n){
		if(m > n) m = m - n;
		else      n = n - m;
	}
	return m;
}

ll lcm(ll m, ll n){
    if(m == 0) return 0;
    if(n == 0) return 0;

	return ((m / gcd(m, n)) * n);
}

bool solve(string s, string t, ll l){
    ll n = s.size();
    ll m = t.size();

    ll nd = (l/n);
    ll md = (l/m);

    ll nx = 0;
    ll mx = 0;
    while(nx < l-nd && mx < l-md){
        if(nx == mx){
            if(s[nx/nd] != t[mx/md]) return false;
            nx += nd;
            mx += md;
            continue;
        }
        if(nx < mx) nx += nd;
        else        mx += md;
    }

    return true;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n, m;
    string s, t;
    cin >> n >> m;
    cin >> s >> t;

    if(s[0] != t[0]){
        cout << -1 << endl;
        return 0;
    }

    if(n%m == 0 || m%n == 0){
        int minn = max(n, m);
        bool res = solve(s, t, minn);
        if(res) cout << minn << endl;
        else    cout << -1 << endl;
        return 0;
    }

    ll minn = lcm(n, m);
    bool res = solve(s, t, minn);
    if(res){
        cout << minn << endl;
        return 0;
    }


    cout << -1 << endl;

    return 0;
}



Measured memory_bytes: 640
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

int testcase_ends() {
  size_t N;
  int Q;
  scanf("%zu %d", &N, &Q);
  if (N == 0 && Q == 0) return 1;

  std::vector<int> d(101);
  for (size_t i = 0; i < N; ++i) {
    size_t M;
    scanf("%zu", &M);
    for (size_t j = 0; j < M; ++j) {
      size_t d0;
      scanf("%zu", &d0);
      ++d[d0];
    }
  }

  auto it = std::max_element(d.begin(), d.end());
  if (*it < Q) return puts("0"), 0;
  printf("%td\n", it-d.begin());
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2680
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n;
  rd(n);
  auto s = readln.split
    .to!(int[])
    .reduce!((res, a) => (res + a - 1));
  writeln(s - 1);

}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 2428
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MAX_V = 205;


int d[MAX_V][MAX_V];
int V;
int r[9];
int R;
bool used[9];
int res = INF;

void warshall_floyd()
{
    FOR(k,1,V+1)
    {
        FOR(i,1,V+1)
        {
            FOR(j,1,V+1)
            {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

void dfs(int c, int las, int dist)
{
    if(c == R)
    {
        //FOR(k,1,R+1) cout << used[k] << ",";
        //cout << endl;
        //dump(dist)
        if(res>dist)res=dist;
        return;
    }
    else
    {
        for(int i = 1; i<= R; i++)if(!used[i])
        {
            used[i] = true;
            if(las==-1) dfs(c+1,i,0);
            else dfs(c+1,i,dist+d[r[las]][r[i]]);


            dump(las)
            dump(i)
            dump(r[las])
            dump(r[i])
            dump(d[r[las]][r[i]])
            used[i] = false;
        }

    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    REP(i,MAX_V)
    {
        REP(j,MAX_V) d[i][j] = INF;
    }
    REP(i,9) used[i] = false;
    int M; cin>>V>>M>>R;
    REP(i,R) cin >> r[i+1];
    REP(i,M)
    {
        int A,B,C; cin >>A>>B>>C;
        d[A][B] = d[B][A] = C;
    }
    warshall_floyd();
    dfs(0,-1,0);
    cout << res << endl;




}


Measured memory_bytes: 384
<?php
define("TOP",1);
define("FRONT",2);
define("RIGHT",3);
define("LEFT",4);
define("BEHIND",5);
define("BOTTOM",6);
class Dice{
    private $numbers;
    // before => after
    private $directions = [
        "E" => [TOP => RIGHT,RIGHT => BOTTOM,LEFT => TOP,BOTTOM => LEFT],
        "N" => [TOP => BEHIND,FRONT => TOP,BEHIND => BOTTOM,BOTTOM => FRONT],
        "S" => [TOP => FRONT,FRONT => BOTTOM,BEHIND => TOP,BOTTOM => BEHIND],
        "W" => [TOP => LEFT,RIGHT => TOP,LEFT => BOTTOM,BOTTOM => RIGHT]
    ];
    public function __construct($numbers){
        $this->numbers = $numbers;
    }
    public function roll($direction){
        $pos = $this->numbers;
        foreach($this->directions[$direction] as $before => $after){
            $this->numbers[$after] = $pos[$before];
        }
    }
    public function getTopNumber(){
        return $this->numbers[TOP];
    }
}
$numbers = explode(" ",getStdin());
$numbers = array_combine(range(1,6),$numbers);
$orders = str_split(getStdin());
$dice = new Dice($numbers);
foreach($orders as $direction){
    $dice->roll($direction);
}
echo $dice->getTopNumber()."\n";

function getStdin(){
    return trim(fgets(STDIN));
}

Measured memory_bytes: 15576
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
#define out(a) printf("%lld",a)
#define writeln printf("\n")
const int N=1e5+50;
const int mod=1e9+7;
using namespace std;
map<int,int>cnt;
int n,m;
int x[N],k;
ll ans=0;
ll sum[N];
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9'){if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9'){s=s*10+c-'0'; c=getchar();}
	return s*t;
}
ll readl()
{
	ll s=0,t=1; char c;
	while (c<'0'||c>'9'){if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9'){s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	n=read(); m=read(); ans=0;
	for (int i=1;i<=n;i++)
	  x[i]=read(),sum[i]=sum[i-1]+x[i];
	for (int i=0;i<=n;i++){
	  k=sum[i]%m;
	  if (cnt[k]>=1) ans+=cnt[k];
	  cnt[k]++;
	  //cout<<k<<' '<<cnt[k]<<endl;
	}
	out(ans);
	return 0;
}
	

Measured memory_bytes: 4352
#include <iostream>
#include <vector>

using namespace std;

int main(int argc,char **argv)
{
  static const int start = 0;
  static const int end = 1;
  vector<int> v;
  vector<bool> v2;


  int n;
  cin >> n ;

  for(int i=0;i<n;i++)
  {
    int s;
    cin >> s;
    v.push_back(s-1);
    v2.push_back(false);
  }

  bool loop = true;
  int cnt=1;
  int next=v[0];
  v2[0] = true;
  while(loop) 
  {
    if(next == end)
    {
      cout << cnt << endl;
      return 0;
    }
    cnt++;
    next = v[next];
    if(v2[next] == true)
    {
      cout << "-1" << endl;
      return 0;
    }
    v2[next] = true;
  }


}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

vector<int> adj[10000];
int res[10000], ans;
priority_queue<int> Q;

void dfs(int c)
{
	ans+=res[c]=Q.top();
	Q.pop();
	for(auto n: adj[c]) if(res[n]==0) dfs(n);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N;
	cin>>N;
	for(int i=1;i<N;i++) {
		int a, b;
		cin>>a>>b;
		adj[--a].push_back(--b);
		adj[b].push_back(a);
	}
	for(int i=0;i<N;i++) {
		int c;
		cin>>c;
		Q.push(c);
	}
	res[0]=Q.top();
	Q.pop();
	for(auto n: adj[0]) dfs(n);
	cout<<ans<<'\n';
	for(int i=0;i<N;i++) cout<<res[i]<<' ';
	return 0;
}

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

int main()
{
  map<string,int>red, blue;
  int n, m;
  string r_str[100], b_str[100];
  int ans = 0;

  cin >> n;
  for ( int i = 0; i < n; i++) {
    cin >> b_str[i];
    blue[b_str[i]]++;
  }

  cin >> m;
  for ( int i = 0; i < m; i++) {
    cin >> r_str[i];
    red[r_str[i]]++;
  }

  for ( int i = 0; i < n; i++) {
    ans = max(blue[b_str[i]] - red[b_str[i]], ans);
  }
  for ( int i = 0; i < m; i++) {
    ans = max(blue[r_str[i]] - red[r_str[i]], ans);
  }
  
  cout << ans << endl;
  
  return (0);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n, a, b, c=0;
	cin >> n >> a >> b;
	if(n==3) cin >> c;
	if(b>a) swap(a, b);
	if(c>a) swap(a, c);
	for(int i=1; i<=a; ++i){
		if(a%i==0 && b%i==0 && c%i==0) cout << i << "\n";
	}
	return 0;
}



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

int occ[27];
char str[100];
int main()
{
    scanf("%s",str);
    for (int i = 0; str[i]; i++)
    {
        occ[str[i]-'a']++;
        if (occ[str[i]-'a']>1)
        {
            printf("no");
            return 0;
        }
    }
    printf("yes");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<iomanip>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,ans=0;
  multiset<ll> idx_set;
  cin >> n;
  vector<ll> p(n),idx(n+1);

  for(int i=0;i<n;i++){
    cin >> p[i];
    idx[p[i]] = i+1;
  }

  idx_set.insert(0);
  idx_set.insert(0);
  idx_set.insert(n+1);
  idx_set.insert(n+1);

  for(int i=n;i>0;i--){
    auto it_x3 = idx_set.upper_bound(idx[i]);
    auto it_x2 = it_x3;
    it_x2--;
    auto it_x4 = it_x3;
    it_x4++;
    auto it_x1 = it_x2;
    it_x1--;

    ll x_1 = *it_x1,x_2 = *it_x2,x_3 = *it_x3,x_4 = *it_x4;
    
    ans += i*(x_2-x_1)*(x_3-idx[i]);

    ans += i*(x_4-x_3)*(idx[i]-x_2);
    idx_set.insert(idx[i]);

  }
  cout << ans << endl;
}



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

int main() {
    int a,b;
    cin>>a>>b;
    cout<<a*b+1-a-b<<endl;
}   


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

ll seg[600009];
int N;
void init(int _n){
	N = 1;
	while(N < _n){
		N*=2;
	}
	rep(i,2*N-1){
		seg[i] = 0;
	}
}

void increment(int ni){
	int now = 2*N-N-1 + ni;
	while(true){
		seg[now]++;
		if(now<=0) break;
		now = (now-1)/2;
	}
}

//[l,r)  a=0,b=N,now=0
ll kosu(int l, int r, int a, int b, int now){
	ll ret=0;
	if(l <= a && b <= r){
		return seg[now];
	}
	if(r <= a || b <= l){
		return 0;
	}
	ret += kosu(l,r,a,(a+b)/2,now*2+1);
	ret += kosu(l,r,(a+b)/2,b,now*2+2);
	return ret;
}



int main(void){
	ll n,a;
	vector<ll> A;
	cin>>n;
	rep(i,n){
		cin>>a;
		A.push_back(a);
	}
	
	//この数よりも大きい中央値を作れますか？の最大値
	int begin = 1;
	int end = 1000000001;
	while(end-begin > 1){
		int now = (begin+end)/2;
		init(2*n+1);
		int zero = n;
		ll count = 0;
		rep(i,n){
			a = A[i];
			if(a >= now){
				increment(zero);
				zero--;
			}else{
				increment(zero);
				zero++;
			}
			count += kosu(zero,N,0,N,0);
		}
		if(count >= ((n * (n-1) / 2 + n) + 1) / 2){
			begin = now;
		}else{
			end = now;
		}
	}
	cout<<begin<<endl;

	return 0;
}


Measured memory_bytes: 5236
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    ll a,b,n;
    cin>>a>>b>>n;
    ll x = min(b-1,n);
    ll res = floor((a*x)/b);
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 3624
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/3
Solved on 2019/3/3
@author: shinjisu
"""


# ABC 120
# import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**12


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def prob_B():
    A, B, K = getIntList()
    dmp((A, B, K))
    count = 0
    i = 100
    while count < K:
        if A % i == 0 and B % i ==0:
            count += 1
            if count == K:
                break
        i -= 1
    return i


def prob_C():
    S = input()
    red = 0
    blue = 0
    for cube in S:
        if cube == '0':
            red += 1
        else:
            blue += 1
    dmp((red, blue))
    return min(red, blue)*2


def prob_D():
    N, M = getIntList()
    dmp((N, M))
    A = zeros(M)
    B = zeros(M)
    for i in range(M):
        A[i], B[i] = getIntList()
    dmp(A, 'A')
    dmp(B, 'B')
    return 123


debug = False  # True False
ans = prob_B()
print(ans)
#for row in ans:
#    print(row)


def prob_A():
    A, B, C = getIntList()
    dmp((A, B, C))
    count = min(B // A, C)
    return count




Measured memory_bytes: 3192
#include<cstdio>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a>0)
		printf("Positive\n");
	else if(b>=0)
		printf("Zero\n");
	else if((b-a+1)%2==0)
		printf("Positive\n");
	else
		printf("Negative\n");
	return 0;
}

Measured memory_bytes: 128
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 5e3 + 10, inf = 1e9;

// struct balls {
// 	char color;
// 	int num;
// 	bool operator<(const balls &other) {
// 		return color == other.color and num < other.num;
// 	}
// } ball[N];

pair<char, int> ball[N];
int white[N], black[N], dp[N][N], color[N][N];

int main() {
	int n; cin >> n;
	for (int i = 1; i <= 2 * n; ++i) {
		cin >> ball[i].first >> ball[i].second;
		if (ball[i].first == 'W') {
			white[ball[i].second] = i;
		} else {
			black[ball[i].second] = i;
		}
	}
	int ans = 0;
	for (int i = 1; i <= 2 * n; ++i) {
		for (int j = 1; j < i; ++j) {
			if (ball[i].first != ball[j].first) {
				++color[i][ball[j].second];
			} else if (ball[j].second > ball[i].second) {
				++ans;
			}
		}
		for (int j = n - 1; j >= 0; --j) {
			color[i][j] += color[i][j + 1];
		}
	}
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			if (!i and !j) {
				continue;
			}
			dp[i][j] = inf;
			if (i > 0) {
				dp[i][j] = min(dp[i - 1][j] + color[white[i]][j + 1], dp[i][j]);
			}
			if (j > 0) {
				dp[i][j] = min(dp[i][j - 1] + color[black[j]][i + 1], dp[i][j]);
			}
		}
	}
	cout << ans + dp[n][n] << endl;
}

Measured memory_bytes: 120320
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

bool compare(tuple<string, int, int> &l, tuple<string, int, int> &r) {
    if (get<0>(l) != get<0>(r)) {
        return get<0>(l) < get<0>(r);
    } else if (get<1>(l) != get<1>(r)) {
        return get<1>(r) < get<1>(l);
    } else {
        return get<2>(l) < get<2>(r);
    }
}

void solve()
{
    int N;
    cin >> N;
    vector<tuple<string, int, int>> D(N);

    REP(i, N) {
        string key;
        int value;
        cin >> key >> value;
        //D[i].push_back(key);
        //D[i].push_back(value);
        //D[i].push_batck(i+1};
        D[i] = make_tuple(key, value, i+1);
    }
    
    sort(D.begin(), D.end(), compare);
  
    for (auto x : D) {
        int rank = get<2>(x);
        string city = get<0>(x);
        int score = get<1>(x);
        //print(rank << ", " << city << ", " << score);
        print(rank);
    }
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int inf = (int) 1e9;

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


Measured memory_bytes: 1408
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int group[12] = {0,2,0,1,0,1,0,0,1,0,1,0};
    int x,y; cin >> x >> y;
    cout << (group[x-1]==group[y-1] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}

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

    int N, M; cin >> N >> M;
    vi H(N);
    REP(i, N) cin >> H[i];
    vvi G(N);
    REP(i, M) {
        int u, v; cin >> u >> v; --u, --v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    int ans = 0;
    REP(i, N) {
        bool valid = 1;
        for (int u : G[i]) {
            if (H[i] <= H[u]) {
                valid = false;
            }
        }
        ans += valid;
    }
    cout << ans << endl;

    return 0;
}


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

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

    int s;
    cin >> s;

    unordered_map<int, bool> mp;
    mp[s] = true;
 
    int idx = 2;
    while(true){
        if(s % 2 == 0){
            if(mp[s / 2] == true){
                break;
            }else{
                mp[s / 2] = true;
                s = s / 2;
            }
        }else{
            if(mp[3 * s + 1] == true){
                break;
            }else{
                mp[3 * s + 1] = true;
                s = 3 * s + 1;
            }
        }
        idx++;
    }

    cout << idx << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string b;
	cin>>b;
	int k=b.size();
	if(b[0]==b[k-1])
	{
		if(k%2==0)
		    cout<<"First";
		else
		    cout<<"Second";
		return 0;
	}
	else
	{
		if(k%2==0)
		    cout<<"Second";
		else
		    cout<<"First";
		return 0;
	}
}

Measured memory_bytes: 512
#include<stdio.h>
int cmp[100010],r=0,f[10010]={0};
int Ta[110],To[1010],Co[1010],Nt[1010];
void sdfs(int e,int s,int k,int *ta,int *to,int *nt,int *id){
  int i;
  f[s]++;
  for(i=ta[s];i+1;i=nt[i]){
    if(i<e&&k<0&&f[to[i]]<0||i>=e&&k>=0&&!f[to[i]])sdfs(e,to[i],k,ta,to,nt,id);
  }
  k<0?(id[r++]=s):(cmp[s]=k);
}
void scc(int v,int e,int *a,int *b){
  int ta[10010],to[60010],nt[60010],id[10010],i,k;
  for(i=0;i<v;i++)f[i]=ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    ta[a[i]]=i;
    ta[b[i]]=i+e;
  }
  for(i=k=0;i<v;i++){
    if(f[i]==-1)sdfs(e,i,-1,ta,to,nt,id);
  }
  for(i=r;i;i--){
    if(f[id[i-1]]==0)sdfs(e,id[i-1],id[i-1],ta,to,nt,id);
  }
  }//*/
int mca(int v,int e,int k,int *a,int *b,int *c){
  int i,j,t,r,s,p=0,mi[110],q[10010],bk[110]={0};
  for(i=0;i<v;i++)Ta[i]=mi[i]=-1;//??£??\??????????????????
  for(i=0;i<e;i++){
    Nt[i]=Ta[a[i]];
    To[i]=b[i];
    Co[Ta[a[i]]=i]=c[i];
    bk[a[i]]=bk[b[i]]=1;
  }
  for(i=0;i<v;i++)p+=bk[i];
  for(i=0;i<e;i++){//?????????MIN???????±???????
    if(mi[To[i]]==-1||Co[mi[To[i]]]>c[i])mi[To[i]]=i;
  }
  mi[k]=-1;
  q[t=0]=k;
  for(r=1;r-t;t++){
    for(j=Ta[q[t]];j+1;j=Nt[j]){
      if(mi[To[j]]==j)q[r++]=To[j];
    }
  }
  if(r==p){
    for(i=s=0;i<e;i++){
      if(mi[To[i]]==i)s+=Co[i];
    }
    return s;
  }
  for(i=r=0;i<v;i++){
    bk[i]=0;
    for(j=Ta[i];j+1;j=Nt[j]){
      if(mi[To[j]]-j)continue;
      a[r]=i;
      b[r++]=To[j];
    }
  }
  scc(v,r,a,b);//?????£?????????????§£??§???????????????????????????
  for(i=0;i<v;i++)bk[cmp[i]]++;
  for(i=r=s=0;i<v;i++){
    for(j=Ta[i];j+1;j=Nt[j]){
      if((a[r]=cmp[i])==(b[r]=cmp[To[j]])){
	if(j==mi[To[j]])s+=Co[j];
      }
      else c[r++]=bk[cmp[To[j]]]-1?Co[j]-Co[mi[To[j]]]:Co[j];
    }
  }
  return mca(v,r,k,a,b,c)+s;
}
	 
int main(){
  int n,m,k,i,a[10010],b[10010],c[10010];
  scanf("%d %d %d",&n,&m,&k);
  for(i=0;i<m;i++)scanf("%d %d %d",&a[i],&b[i],&c[i]);
  printf("%d\n",mca(n,m,k,a,b,c));
  return 0;
}

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

using namespace std;

int main(){
 string S;
 cin>>S;
 int x=0;
 size_t size = S.length();
 if(size%2==0){
   for(int i=0;i<size/2;i++){
     if(S[i]!=S[size-1-i]){
       x=x+1;
     }
   }
 }else{
   for(int i=0;i<(size-1)/2;i++){
     if(S[i]!=S[size-1-i]){
       x=x+1;
     }
   }
 }
 cout<<x;
 return 0;
}


Measured memory_bytes: 256
// "include" {{{
#include <deque>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <utility>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long 
#define pii pair<int,int> 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

vector<int> t;
vector<int> a;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string t = "2019/04/30";
	cout << ((s <= t) ? "Heisei\n" : "TBD\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
#define MODD 1000000007
#define ll long long
using namespace std;

ll X[111111];

int main() {
    int N;
    ll A,B;
    cin>>N>>A>>B;
    for(int i=1;i<=N;i++)
        cin>>X[i];
    
    ll answer = 0;
    for(int i=2;i<=N;i++) {
        answer += min(B, (X[i]-X[i-1])*A);
    }
    cout << answer << endl;
}

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

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

    int A[M];
    long long assigndays = 0;

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

    if (assigndays <= N)
        cout << N - assigndays;

    else
        cout << -1;
}


Measured memory_bytes: 3228
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        var sc = new Scanner(System.in);
    
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        var a = new int[n];
        var b = new int[m];
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        for(int i = 0; i < m; i++){
            b[i] = Integer.parseInt(sc.next());
        }
        
        var a2 = new long[n+1];
        a2[1] = a[0];
        for(int i = 2; i <= n; i++){
            a2[i] = a2[i-1] + a[i-1];
        }
        
        var b2 = new Long[m];
        b2[0] = (long) b[0];
        for(int i = 1; i < m; i++){
            b2[i] = b2[i-1] + b[i];
        }
        
        int ans = 0;
        for(int i = 0; i <= n; i++){
            if(a2[i] > k) break;
            int j = upperBound(b2, k - a2[i]);
            ans = Math.max(i+j, ans);
        }
        System.out.println(ans);
    }
    
    static int upperBound(Long[] a, long key){
        return ~Arrays.binarySearch(a, key, (x, y) -> (x.compareTo(y) > 0) ? 1 : -1);
    }
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int x, y;
    cin >> x >> y;
    int ans = 0;
    if (x == 1 && y == 1)
    {
        ans += 400000;
    }
    ans += max(0, (4 - x) * 100000);
    ans += max(0, (4 - y) * 100000);
    cout << ans << endl;
}

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


Measured memory_bytes: 256
N,M = map(int,input().split())
pis=[]
wa,ac={},{}
for i in range(M):
    p  = input().split()
    pis += [(int(p[0]),p[1])]
for p in pis:
    wa[p[0]]=0
    ac[p[0]]=0
if __name__ == '__main__':
   for p in pis:
      if ac[p[0]]<1:
         if p[1]=='WA':
              wa[p[0]]+=1
         elif p[1]=='AC':
              ac[p[0]]=1
   for p in pis:
      if ac[p[0]]<1:
        wa[p[0]]=0
   a=sum(ac.values())
   w=sum(wa.values())
   print('{} {}'.format(a,w))

Measured memory_bytes: 34472
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct data{
	int x,y;
}q1[410001],q2[410001];
int i,j,k,n,m,c[410001],d1,d2,t1,t2,w[111],tmp;
int gv(int x,int y){
	return x*m+y;
}
void dfs1(int x,int y){
	int i,tx,ty,k=c[gv(x,y)];
	for (i=1;i<=t1;i++){
		tx=x+q1[i].x;ty=y+q1[i].y;
		if (tx>=0&&tx<m&&ty>=0&&ty<m&&!c[gv(tx,ty)]) c[gv(tx,ty)]=3-k,dfs1(tx,ty);
	}
}
void dfs2(int x,int y){
	int i,tx,ty,k=c[gv(x,y)]/10;
	for (i=1;i<=t2;i++){
		tx=x+q2[i].x;ty=y+q2[i].y;
		if (tx>=0&&tx<m&&ty>=0&&ty<m&&c[gv(tx,ty)]<10) c[gv(tx,ty)]+=(3-k)*10,dfs2(tx,ty);
	}
}
int main(){
	scanf("%d%d%d",&n,&d1,&d2);m=2*n;memset(c,0,sizeof(c));memset(w,0,sizeof(w));t1=t2=0;
	for (i=0;i<m;i++)
	 for (j=0;j<m;j++){
	 	k=i*i+j*j;
	 	if (k==d1){
	 		q1[++t1].x=i;q1[t1].y=j;
	 		q1[++t1].x=-i;q1[t1].y=j;
	 		q1[++t1].x=i;q1[t1].y=-j;
	 		q1[++t1].x=-i;q1[t1].y=-j;
		}
		if (k==d2){
			q2[++t2].x=i;q2[t2].y=j;
			q2[++t2].x=-i;q2[t2].y=j;
			q2[++t2].x=i;q2[t2].y=-j;
			q2[++t2].x=-i;q2[t2].y=-j;
		}
	 }
	for (i=0;i<m;i++)
	 for (j=0;j<m;j++)
	  if (!c[gv(i,j)]) c[gv(i,j)]=1,dfs1(i,j);
	for (i=0;i<m;i++)
	 for (j=0;j<m;j++)
	  if (c[gv(i,j)]<10) c[gv(i,j)]+=10,dfs2(i,j);
	for (i=0;i<m;i++)
	 for (j=0;j<m;j++) w[c[gv(i,j)]]++;
	for (k=i=1;i<=22;i++)
	 if (w[i]>w[k]) k=i;
	for (i=tmp=0;i<m&&tmp<n*n;i++)
	 for (j=0;j<m&&tmp<n*n;j++)
	  if (c[gv(i,j)]==k) printf("%d %d\n",i,j),tmp++;
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M,X,Y;
int x[111],y[111];

signed main(){
    cin>>N>>M>>X>>Y;
    rep(i,N)cin>>x[i];
    rep(i,M)cin>>y[i];
    sort(x,x+N);sort(y,y+M);

    int xx=x[N-1];
    int yy=y[0];
    if(xx<yy&&xx<Y&&X<yy){
        cout<<"No War"<<endl;
    }
    else{
        cout<<"War"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
# include<iostream>
# include<cstdio>
# include<string>
# include<map> 
using namespace std;
map<string,int> mp;
string p[201];
int main()
{
	int n,m;
	cin>>n;
	int Max=0;
	for(int i=1;i<=n;i++){
		cin>>p[i];
		mp[p[i]]++;
	}
	cin>>m;
	for(int i=n+1;i<=m+n;i++){
		cin>>p[i];
		mp[p[i]]--;
	}
	for(int i=1;i<=n+m;i++){
		if(mp[p[i]]>Max){
			Max=mp[p[i]];
		}
	}
	cout<<Max<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  for(int i=0; i<n; i++){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  int64_t ans = 0;
  for(auto p : mp){
    int s = p.second;
    ans += (int64_t)s*(s-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
int main() {
    char s;cin>>s;
    s=s+'b'-'a';
    cout<<s<<endl;
}

Measured memory_bytes: 256