akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#include<stdlib.h>
#include<iostream>
#include<math.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define INF 2000000000
#define Min(a,b) (a<b?a:b)
#define Max(a,b) (a>b?a:b)
#define PI 3.1415926535897932
using namespace std;

int main()
{
IOS;
long long  n;
cin>>n;
if(n<=1000)
{
	cout<<1000-n<<endl;
	return 0;
}
if(n%1000==0){
	cout<<0<<endl;
	return 0;
}


cout<<((n/1000 +1)*1000)%n;


return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod= 1e9+7;
const ll INF= 1e18L+5;

void sub_self(ll& a, ll b){
	a -=b;
	if(a<0){
		a += mod;
	}
}

int main() {
	ll n,k;
	cin >> n >> k;
	ll a[n];
	ll dp[k+1] = {0};
	dp[0]=1;
		
	for(ll i=0; i<n; i++){
		cin >> a[i];
		ll temp[k+1] = {0};
	
		for(ll used = k; used>=0; used--){
			ll l = used+1;
			ll r = used+min(a[i],k-used);
			if(l<=r){
				temp[l] = (temp[l]%mod+dp[used]%mod)%mod;
				if(r<k){
					// temp[r+1] = (temp[r+1]%mod-dp[used]%mod)%mod;
					sub_self(temp[r+1],dp[used]);
				}
			}
			// for(ll j=l; j<=r && j<=k; j++){
			// 	dp[j] = (dp[used]+dp[j])%mod;
			// }
		}
		ll sum = 0;
		for(ll j=0;j<=k; j++){
			// temp[j] = j==0 ? temp[j] : (temp[j]+temp[j-1])%mod;
			// dp[j] = (dp[j]+temp[j])%mod;
			sum = (sum%mod + temp[j]%mod)%mod;
			dp[j] = (dp[j]%mod+sum)%mod;
		}
	}
	cout<<dp[k]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 2*int(1e5)+5
#define endl '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define int long long
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;

int32_t main() {
	int n;
	cin >> n;
	map<string, int> mapa;
	while(n--) {
		string s;
		cin >> s;
		mapa[s]++;
	}
	int ans = 0;
	for(auto i : mapa)
		ans++;
	cout << ans << endl;
}






Measured memory_bytes: 19200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <unordered_set>
#include <unordered_map>

typedef long long ll;
using namespace std;

int main(void) {
  ll N; cin >> N;
  ll b1 = 0, b2 = 0, b4 = 0;
  for (int i = 0; i < N; i++) {
    ll tmp; cin >> tmp;
    if (tmp % 2 != 0 && tmp % 4 != 0)
      b1++;
    else if (tmp % 2 == 0 && tmp % 4 != 0)
      b2++;
    else
      b4++;
  }

  if (b2 == 0) {
    cout << (b1 <= b4 + 1 ? "Yes" : "No") << endl;
  } else {
    cout << (b1 <= b4 ? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define MOD 1000000007

int main()
{
  ll n;
  ll res = 0;
  cin >> n;
  if (n % 2 == 0) {
    n /= 2;
    while (n > 0) {
      n /= 5;
      res += n;
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
const int MN=2005;
int N,f[MN][MN],g[2][MN][MN],T[2][MN];
void C(int x,int y){for(;x<=N;x+=(x&(-x)))T[y][x]++;}
int G(int x,int y){int r=0;for(;x;x-=(x&(-x)))r+=T[y][x];return r;}
int main()
{
	N=read();
	reg int i,j;char c;
	for(i=1;i<=N*2;++i)
	{
		scanf("%c",&c);
		if(c=='W')
		{
			int x=read();C(x,0);
			for(j=0;j<=N;++j) g[0][x][j]=x+j-G(x,0)-G(j,1);
		}
		else
		{
			int x=read();C(x,1);
			for(j=0;j<=N;++j) g[1][j][x]=x+j-G(x,1)-G(j,0);
		}
	}
	for(i=1;i<=N;++i) f[i][0]=f[i-1][0]+g[0][i][0];
	for(i=1;i<=N;++i) f[0][i]=f[0][i-1]+g[1][0][i];
	for(i=1;i<=N;++i)for(j=1;j<=N;++j)
		f[i][j]=min(f[i-1][j]+g[0][i][j],f[i][j-1]+g[1][i][j]);
	return 0*printf("%d\n",f[N][N]);
}

Measured memory_bytes: 47360
import java.util.HashSet;
import java.util.Set;

public class Main {


  private static void solve() {
    int n = ni();
    int m = ni();
    
    int[] a = na(m);
    Set<Integer> set = new HashSet<>();
    for (int v : a) {
      set.add(v);
    }
    int mod = (int)1e9 + 7;
    
    long[] dp  =new long[n + 2];
    dp[0] = 1;
    
    for (int i = 0 ;i < n; i ++) {
      if (!set.contains(i + 2)) {
        dp[i + 2] += dp[i];
        dp[i + 2] %= mod;
      }
      if (!set.contains(i + 1)) {
        dp[i + 1] += dp[i];
        dp[i + 1] %= mod;
      }
      
    }
    System.out.println(dp[n]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 47012
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>
#include <map>

using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	if ((a*b)%2 == 0){
		cout<<"Even"<<endl;
	}
	else{
		cout<<"Odd"<<endl;	
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

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

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


class UnionFind {
public:
    vector<int> Parent;
    UnionFind(int N){
        Parent.resize(N, -1);
        return;
    }

    bool unite(int A, int B){
        A = root(A);
        B = root(B);
        if(A==B) return false;
        
        if(size(A) < size(B)) swap(A, B);
        Parent[A] += Parent[B];
        Parent[B] = A;
        return true;
    }
    
    bool same(int a, int b){
        if(root(a) == root(b)) return true;
        return false;
    }
    
    int root(int a){
        if(Parent[a] < 0) return a;
        return Parent[a] = root(Parent[a]);
    }
    
    int size(int a){
        return -Parent[root(a)];
    }
    
};


int main() {
    int N, M; cin >> N >> M;
    vector<int> A(M);
    vector<int> B(M);
    for(int i=0; i<M; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        A[i] = a; B[i] = b;
    }
    
    vector<ll> Ans(M+1);
    Ans[M] = (ll)N * (N-1) / 2;
    UnionFind U(N);
    for(int i=M-1; i>=0; i--){
        if(U.same(A[i], B[i])){
            Ans[i] = Ans[i+1];
        }else{
            Ans[i] = Ans[i+1] - (ll)U.size(A[i]) * U.size(B[i]);
            U.unite(A[i], B[i]);
        }
    }
    
    for(int i=1; i<M+1; i++){
        cout << Ans[i] << endl;
    }
    
    return 0;
}


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

int main() {
	int n,g=0;
	cin >> n;
	vector<int> a(n),b(n),c(n);
	for(int i=0;i<n;i++)
	{
		cin >> a.at(i);
	}
	for(int i=0;i<n;i++)
	{
		if(i==0)
		{
			b.at(i)=a.at(i);
			c.at(n-1-i)=a.at(n-1-i);
		}
		else if(i==1)
		{
			b.at(i)=gcd(a.at(i-1),a.at(i));
			c.at(n-1-i)=gcd(a.at(n-1),a.at(n-1-i));
		}
		else
		{
			b.at(i)=gcd(b.at(i-1),a.at(i));
			c.at(n-1-i)=gcd(c.at(n-i),a.at(n-1-i));
		}
	}
	for(int i=0;i<n;i++)
	{
		if(i==0)
		{
			g=max(g,c.at(i+1));
		}
		else if(i==n-1)
		{
			g=max(g,b.at(i-1));
		}
		else
		{
			g=max(g,gcd(b.at(i-1),c.at(i+1)));
		}
	}
	cout << g << endl;
	return 0;
}


Measured memory_bytes: 4552
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from functools import reduce
# table_size = 510000
table_size = 2*10**5+1  # 200001
mod = 10**9+7


# Combination の計算を最適化する必要がある?
# def nCr(n, r):
#     numerator = reduce(lambda x, y: x * y % mod, range(n, n - r, -1), 1)
#     denominator = reduce(lambda x, y: x * y % mod, range(1, r + 1), 1)
#     return numerator * pow(denominator, mod-2, mod) % mod

class Combination:
    def __init__(self):
        self.fac = [None for _ in range(table_size)]
        self.finv = [None for _ in range(table_size)]
        self.inv = [None for _ in range(table_size)]

        self.fac[0] = self.fac[1] = 1
        self.finv[0] = self.finv[1] = 1
        self.inv[1] = 1

        for i in range(2, table_size):
            self.fac[i] = self.fac[i - 1] * i % mod
            self.inv[i] = mod - self.inv[mod % i] * (mod // i) % mod
            self.finv[i] = self.finv[i - 1] * self.inv[i] % mod

    def nCr(self, n, r):
        if n < r:
            return 0
        if n < 0 or r < 0:
            return 0

        return self.fac[n] * (self.finv[r] * self.finv[n - r] % mod) % mod


n, k = map(int, input().split())
# n, k = 3, 2  # Expected: 10
# n, k = 200000, 1000000000  # Expected: 607923868
# n, k = 15, 6  # Expected: 22583772

c = Combination()

k = min(k, n - 1)
total = 0
for i in range(k + 1):
    total += c.nCr(n - 1, i) * c.nCr(n, i)
    total %= mod

print(total)


Measured memory_bytes: 29472
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
b = [[1]*n for i in range(n)]

for i in range(n):
    for j in range(n):
        for k in range(n):
            if a[i][k] + a[k][j] < a[i][j]:
                print(-1)
                exit()
            elif a[i][k] + a[k][j] == a[i][j] and i!=k!=j:
                b[i][j] = 0

ans = 0
for i in range(n):
    for j in range(n):
        if b[i][j]:
            ans += a[i][j]
print(ans//2)

Measured memory_bytes: 44892
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;

template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}
template <typename T> T lcm(T a, T b) {return a*b/gcd(a,b);}
template <typename T> T extgcd(T a, T b, T& x, T& y){
    T d = a;
    if(b != 0){
        d = extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else x=1,y=0;
    return d;
}
template <typename T> T modpow(T x, T n, T m) {
    if(n==0) return 1;
    T resp = modpow(x*x%m,n/2,m);
    if(n&1) resp = resp*x%m;
    return resp;
}
template <typename T> T modinverse(T a, T m) {
    T x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

struct prime {
    vector<int> f,prime_list;
    prime(int n=1):f(n+1){
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i){
            if(f[i]) continue;
            f[i] = i;
            prime_list.pb(i);
            for (ll j = i*i; j <= n; j+=i){
                if(!f[j]) f[j] = i;
            }
        }
    }
    
    bool is_prime(int a){return f[a] == a;}
    
    vector<int> ve_prime(int a){
        vector<int> res;
        while (a != 1) {
            res.pb(f[a]);
            a /= f[a];
        }
        return res;
    }
    
    vector<pair<int,int>> num_prime(int a){
        vector<int> flist = ve_prime(a);
        if(flist.size() == 0) return {};
        vector<pii> res(1,{flist[0],0});
        for(int p : flist){
            if(res.back().fi == p) res.back().se++;
            else res.pb({p,1});
        }
        return res;
    }
    
};



int main()
{

    int N;
    cin >> N;
    vi A(N);
    in(N,A);
    
    prime P(1000000);
    
    map<int,ll> B;
    
    ll alcm = 1;
    
    rep(i,N){
        ve<pii> C = P.num_prime(A[i]);
        for(pii a : C){
            ll aa = 1;
            rep(i,a.se) aa *= (ll)a.fi;
            if(B.count(a.fi)) B[a.fi] = max(B[a.fi],aa);
            else B[a.fi] = aa;
        }
    }
    
    for(auto p : B){
        alcm *= p.se%mod;
        alcm %= mod;
    }
    
    ll ans = 0;
    rep(i,N){
        ans += alcm*modinverse(A[i],mod)%mod;
        ans %= mod;
    }
    
    out(ans);
    

    return 0;
}


Measured memory_bytes: 5116
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<double,double> PAIR;
const int N = 2e3+5;
const int INF = 0x3f3f3f3f;

int ans[N];

int main(){
	int n,x,y;
	cin >> n >> x >> y;
	
	for(int i = 1;i <= n;++i){
		for(int j = i+1;j <= n;++j){
			int len = min(j-i,abs(x-i)+abs(y-j)+1);
			//printf("%d %d %d %d %d\n",i,j,j-i,x-i+y-j+1,len);
			ans[len]++;
		}
	}
	
	for(int i = 1;i < n;++i) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 256
<?php
$input = explode(" ",trim(fgets(STDIN)));
$num = $input[0];
$min = $input[1];
$max = $input[2];
$n=0;

//各桁の和が$min以上$max未満になる
for($i=1; $i<=$num; $i++){
    $total[] = $i;
}

// var_dump($total);

for($j=0; $j<$num; $j++){
    $s = str_split($total[$j]);
    $s = array_sum($s);
    if($min <= $s && $s <= $max){
        $n += $total[$j];
    }
}
echo $n;

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  map<ll, ll> mp;
  rep(i, n) {
    cin >> a[i];
    mp[a[i]]++;
  }
  ll baseAns = 0;
  for(auto m: mp) {
    baseAns += m.second * (m.second-1) / 2;
  }
  vector<ll> ans;
  rep(i, n) {
    ll tmp = baseAns;
    tmp -= mp[a[i]] * (mp[a[i]]-1)/2;
    mp[a[i]]--;
    tmp += mp[a[i]] * (mp[a[i]]-1)/2;
    ans.push_back(tmp);
    mp[a[i]]++;
  }
  rep(i, n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 12784
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a+b>=a-b&&a+b>=a*b){
    cout<<a+b;
  }
  else if(a-b>=a+b&&a-b>=a*b){
    cout<<a-b;
  }
  else if(a*b>=a+b&&a*b>=a-b){
    cout<<a*b;
  }
}
    
      

Measured memory_bytes: 3604
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1001001001;

ll dp[310][310];
ll dp2[310][310];

int main(){
  int n,m,l; cin >> n >> m >> l;
  rep(i,n)rep(j,n) dp[i][j]=inf;
  rep(i,n) dp[i][i]=0;
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c; a--; b--;
    //if(c<=l){
      dp[a][b]=c;
      dp[b][a]=c;
    //}
  }
  rep(k,n)rep(i,n)rep(j,n) chmin(dp[i][j],dp[i][k]+dp[k][j]);
  //以下dp2
  rep(i,n)rep(j,n) dp2[i][j]=inf;
  rep(i,n) dp2[i][i]=0;
  rep(i,n)rep(j,n) if(dp[i][j]<=l) dp2[i][j]=1;
  rep(k,n)rep(i,n)rep(j,n) chmin(dp2[i][j],dp2[i][k]+dp2[k][j]);
  int q; cin >> q;
  vector<ll> ans(q);
  rep(i,q){
    int s,t; cin >> s >> t; s--; t--;
    ans[i]=dp2[s][t]==inf?-1:dp2[s][t]-1;
  }
  rep(i,q){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define ep emplace_back
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define find(a,b) find(a.begin(),a.end())
typedef long long ll;

using namespace std;

int main()
{
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    int need,t,s;
    cin >> need >> t >> s;
    if (t * s >= need) cout<< "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void) {
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);

	if (a >= 13) {
		printf("%d\n", b);
	}
	else if(a >= 6 && a <= 12){
		printf("%d\n", b / 2);
	}
	else {
		printf("0\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

double dp[2][1000000];

int main() {
  int n, m, k;
  while (scanf("%d %d %d", &n, &m, &k), n|m|k) {
    MEMSET(dp, 0);
    dp[0][0] = 1.0;
    REP(iter, n) {
      int prev = iter & 1;
      int next = (iter + 1) & 1;
      MEMSET(dp[next], 0);
      FOREQ(i, 0, iter * m) {
        FOREQ(j, 1, m) {
          dp[next][i + j] += dp[prev][i] / m;
        }
      }
    }
    double ans = 0;
    FOREQ(i, 1, n * m) {
      ans += max(i - k, 1) * dp[n & 1][i];
    }
    printf("%.7lf\n", ans);
  }
}

Measured memory_bytes: 16000
use std::io::{Read, stdin};
use std::str::FromStr;

fn main() {
    let h: i64 = read();
    let _w: i64 = read();
    let mut v: Vec<String> = Vec::new();
    for _i in 0..h {
        let s: String = read();
        v.push(s.clone());
        v.push(s);
    }
    for ss in &v{
        println!("{}", *ss);
    }

}


fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
def main():
  core = {5: 2, 7:1}
  data = {}
  for x in [int(x) for x in raw_input().split(' ')]:
    if x not in data:
      data[x] = 0
    data[x] += 1
  for key, val in data.items():
    if not (core.get(key, 0) > 0 and core[key] == val):
      print("NO")
      return
  print("YES")
      

main()

Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int A, B; cin >> A >> B;
    cout << A * B << endl;
    return 0;
}


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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 # 出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(N-K+1):
    ans += A[-1-i]*cmb(N-1-i, K-1, mod)
    ans %= mod
    ans -= A[i]*cmb(N-1-i, K-1, mod)
    ans %= mod

print(ans)

Measured memory_bytes: 104276
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
X = LIST()

# dist = 0
s = []
l = []
s = deque(s)
l = deque(l)
for x in X:
    if x < 0:
        s.appendleft(-1 * x)
    else:
        l.append(x)
# s.sort()
# print(s, l)

left = 0
right = 0
q = []
ans = INF
for i in range(N-K+1):
    left = i
    right = i + K - 1
    ans = min(ans, min(abs(X[left]), abs(X[right])) + X[right] - X[left])
print(ans)


Measured memory_bytes: 16364
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  ull h, w, n;
  cin >> h >> w >> n;

  ull oo = max(h, w);
  ull blacks = 0;
  ull result = 0;
  while (blacks < n) {
    blacks += oo;
    result++;
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int l[10];
	int v[2];
		
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v[0], &v[1]) != EOF) {
		int i;
		int sum[10] = {};
		double t;
		
		sum[0] = l[0];
		for(i = 1; i < 10; i++)
			sum[i] += sum[i - 1] + l[i];
		t = (double)sum[9] / (v[0] + v[1]);
		for(i = 0; i < 10; i++)
			if(sum[i] >= t * v[0]) break;
		
		printf("%d\n", i + 1);
		
	}
	
	return 0;
}


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

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

    vector<int> per(8);
    rep(i, 8) per[i] = i;

    bool mas[8][8];
    do {
        //条件
        bool ch = false;
        rep(i, n) {
            if (per[p[i].first] != p[i].second) {
                ch = true;
                break;
            }
        }
        if (ch)
            continue;

        //初期化
        rep(i, 8) rep(j, 8) mas[i][j] = false;
        rep(i, 8) mas[i][per[i]] = true;

        //チェック
        bool flag = true;
        rep(i, 8) {
            int j = per[i];
            
            for (int k = 1; k < 8; ++k) {
                if (i + k < 8 && j + k < 8 && mas[i + k][j + k])
                    flag = false;
                if (i - k >= 0 && j + k < 8 && mas[i - k][j + k])
                    flag = false;
                if (i + k < 8 && j - k >= 0 && mas[i + k][j - k])
                    flag = false;
                if (i - k >= 0 && j - k >= 0 && mas[i - k][j - k])
                    flag = false;
            }
        }

        //出力
        if (flag) {
            rep(i, 8) {
                rep(j, 8) {
                    if (mas[i][j])
                        cout << "Q";
                    else
                        cout << ".";
                }
                cout << endl;
            }
            break;
        }
    } while (next_permutation(per.begin(), per.end()));

    return 0;
}


Measured memory_bytes: 3124
n = int(input())
#a = int(input())
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
#a,b = list(map(int,input().split(" ")))
#a,b,c = list(input().split())
#string = input()

if n >= 1200:
  print("ARC")
else:
  print("ABC")

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

int main(void)
{
	int k, s;
	cin >> k >> s;
	
	int count = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= x; y++) {
			for (int z = 0; z <= y; z++) {
				if (x+y+z == s) {
					if (x == y && y == z) {
						count++;
					} else if ((x == y && y != z) ||
							(y == z && x != y) ||
							(z == x && z != x)) {
						count += 3;
					} else {
						count += 6;
					}
				}
			}
		}
	}


	cout << count << endl;
	return 0;
}


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

int main(){
  int N = 0;
  int a,b,c,d = 0;
  cin >> N;
  d = N %10;
  c = N /10 %10;
  b = N /100 %10;
  a = N /1000 %10;
  if((a == b && b == c) || (b == c && c == d))
	cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (ll i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N, K;
    cin >> N >> K;
    int cnt = 0;
    int ans = 0;
    vector<int> A(N+1);
    rep(i, N){
        int a;
        cin >> a;
        if(A[a]==0) cnt++;
        A[a]++;
    }
    if(cnt<=K){
        cout << 0 << endl;
        return 0;
    }
    sort(all(A));
    rep(i, N){
        if(A[i]!=0){
            cnt--;
            ans+=A[i];
            if(cnt<=K) break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

ll X[1010], Y[1010];
int dx[4]={1,-1,1,-1};
int dy[4]={1,-1,-1,1};
char m[4]={'R','L','U','D'};

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int N; cin>>N;
  cin>>X[0]>>Y[0];
  int f=(abs(X[0])+abs(Y[0]))%2;
  for(int i=1;i<N;i++){
    cin>>X[i]>>Y[i];
    if(f!=(abs(X[i])+abs(Y[i]))%2){
      cout<<-1<<endl;
      return 0;
    }
  }
  
  
  vector<ll> D;
  if(f==0) D.push_back(1);
  rep(i,33) D.push_back(1LL<<i);
  sort(D.rbegin(),D.rend());
  cout<<D.size()<<endl;
  for(ll d:D) cout<<d<<" ";
  cout<<endl;

  rep(i,N){
    ll x=X[i]+Y[i], y=X[i]-Y[i];
    ll xx=0,yy=0;
    for(ll d:D){
      ll best=LLONG_MAX;
      int b=-1;
      rep(k,4){
        ll tx=xx+d*dx[k], ty=yy+d*dy[k];
        if(abs(tx-x)+abs(ty-y)<best){
          b=k;
          best=abs(tx-x)+abs(ty-y);
        }
      }
      xx+=d*dx[b], yy+=d*dy[b];
      cout<<m[b];
    }
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll n;cin>>n;
    string s;cin>>s;
    ll ans=0;
    rep(i,10){
        rep(j,10){
            rep(k,10){
                ll idx=0;
                rep(l,n){
                    ll x=s[l]-'0';
                    if(idx==0&&i==x||idx==1&&j==x||idx==2&&k==x)idx++;
                }
                if(idx==3)ans++;
            }
        }
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 384
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<utility>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define inf 0x7f7f7f
#define p(x) (x)*(x)
#define PI 3.14159265358979
using namespace std;

typedef vector<vector<int> > vtype;
typedef long long ll;
ll *a = nullptr, *istrue = nullptr;
vector<ll> v1, v;

int main()
{
	//ios::sync_with_stdio(false);
	ll n = 0, k = 0, loc = 1, num = 0;
	cin >> n >> k;
	a = new ll[n+5]{0};
	istrue = new ll[n+5]{0};
	for(ll i = 1; i <= n; ++i)
		cin >> a[i];
	while(!istrue[loc]){
		istrue[loc] = 1;
		v1.push_back(loc);
		loc = a[loc];
		num++;
		if(k > 0)
			k--;
		else{
			cout << v1[v1.size()-1] << endl;
			return 0;
		}
	}
	ll mid = 0;
	for(ll i = 0; i < v1.size(); ++i)
		if(v1[i] == loc){
			mid = i;
			break;
		}
	for(ll i = mid; i < num; ++i)
		v.push_back(v1[i]);
	mid = num - mid;
	k %= mid;
	//cout << k << endl;
	cout << v[k] << endl;
	delete[] a;
	delete[] istrue;
	a = nullptr;
	istrue = nullptr;
    return 0;
}












Measured memory_bytes: 10712
import sys
from math import *
N = int(input().strip())
A = list(map(int, input().split()))
B = [A[i] - (i+1) for i in range(0, N)]

if N == 1:
  print(0)
  sys.exit()

def s(b):
    return sum([abs(Bi - b) for Bi in B])

def check():
    left = s(bmin) - s(bmin+1) >= 0
    right = s(bmax-1) - s(bmax) <= 0
    if right and left:
        # 極値ある
        return 0
    if left:
        # 単調減少
        return 1
    # 単調増加
    return 2

bmin = min(B)
bmax = max(B)
stype = check()
if stype == 0:
    bnow = bmin
    for i in range(0, 40):
        if s(bnow) - s(bnow+1) < 0:
            bmax = bnow
            bnext = round((bnow + bmin) / 2)
        else:
            bmin = bnow
            bnext = round((bnow + bmax) / 2)
        if bnext == bnow:
            break
        bnow = bnext
    smin = s(bnow)
elif stype == 1:
    smin = s(bmax)
elif stype == 2:
    smin = s(bmin)

print(smin)

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

long long memo[91];
long long lucus(int x) {
    if(memo[x]!=0) return memo[x];
  if (x==0){
    return memo[x]=2;
}
  if (x==1){
    return memo[x]=1;
} 
  long long sum = lucus(x-1) + lucus(x-2);
 return memo[x]=sum;
}

int main(){
  int N;
  cin >> N;
  cout << lucus(N) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main(){
    char s[110], t[110], ch, k = 0,i = 0, j = 0;
    char str[220];
    scanf("%s", s);
    scanf("%s", t);
    printf("%s", t);
    printf("%s", s);
    printf("\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
template <class Key, class Compare = less<Key>>
using Tree = __gnu_pbds::tree<Key, __gnu_pbds::null_type, Compare, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;




int N, M;
vector<int> G[100000];
int dp[100000];

int dfs(int u) {
  int& res = dp[u];
  if (res != -1) {
    return res;
  }
  res = 0;
  for (int v : G[u]) {
    res = max(res, 1 + dfs(v));
  }
  return res;
}

void Main() {
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    G[x].push_back(y);
  }
  memset(dp, -1, sizeof(dp));
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans = max(ans, dfs(i));
  }
  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
//  cin.tie(nullptr);
  #ifdef _DEBUG
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  #endif
  Main();
  return 0;
}


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

namespace program
{
    class Program
    {
        static void Main()
        {
            int N = Input.ScanInt();
          int K = Input.ScanInt();
          int X = Input.ScanInt();
          int Y = Input.ScanInt();
          
          int sum = 0;
          for(int i=0;i<N;i++) sum += i>=K ? Y : X;
          
          Console.WriteLine(sum);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11092
a, b, c, x, y = map(int, input().split())
# print(f"{a} {b} {c} {x} {y}")

ax = a * x
by = b * y

# print(f"{ax}")
# print(f"{by}")

cxy = c * (2 * (max(x, y)))
# print(f"{cxy}")

c_maisu_max = 2 * (max(x, y))
# print(f"{c_maisu_max}")

ans = 9999999999
for c_maisu in range(c_maisu_max, -1, -2):
    kingaku = 0
    if c_maisu // 2 >= max(x, y):
        kingaku = c * c_maisu
        # print(kingaku)
    else:
        a_maisu = 0
        b_maisu = 0
        # print(x - (c_maisu // 2))
        # print(y - (c_maisu // 2))
        if x - (c_maisu // 2) > 0:
            a_maisu = x - (c_maisu // 2)
        if y - (c_maisu // 2) > 0:
            b_maisu = y - (c_maisu // 2)
            
        kingaku = (a * a_maisu) + (b * b_maisu) + (c * c_maisu)
        
        # print(kingaku)
        
    ans = min(ans, kingaku)
    
print(ans)

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

int dp[500001][6];

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

    for(int i=0; i<N; i++){
        for(int j=0; j<6; j++) dp[i][j] = -1e9;
    }
    dp[0][0] = 0;

    for(int i=0; i<N; i++){
        if(S[i] == '0'){
            dp[i+1][0] = max(dp[i][0], dp[i][5]);
            dp[i+1][2] = dp[i][1];
            dp[i+1][4] = dp[i][3];
        }else{
            dp[i+1][0] = max(dp[i][0], dp[i][2]);
            dp[i+1][1] = 1 + max({dp[i][0], dp[i][1], dp[i][5]});
            dp[i+1][3] = max(dp[i][0], dp[i][5]);
            dp[i+1][5] = 1 + max({dp[i][4], dp[i][5]});
        }
    }
    
    int ans = max(dp[N][0], dp[N][5]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12548
from collections import Counter

s = list(map(int, list(input())))[::-1]
N = len(s)
cusum = [0]*(N+1)
cusum[0] = s[0] % 2019
for i in range(1, N):
    power = pow(10, i, 2019)
    cusum[i] = (cusum[i-1] + power * s[i]) % 2019
counter = Counter(cusum)
print(sum(x*(x-1)//2 for x in counter.values()))


Measured memory_bytes: 18028
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<utility>
#include<cctype>
using namespace std;

#define ull unsigned long long
#define stt(it,order) sort(it.begin(),it.end(),order)
#define st(it) sort(it.begin(),it.end())
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
/*
ifstream fin("input.txt");
ofstream fout("output.txt");
#define cin fin
#define cout fout
*/

int main(){
   int n;
   while(scanf("%d",&n) , n ){
      int m;
      scanf("%d",&m);
      int data[n][3];
      rep(i,n){
         scanf("%d %d %d",&data[i][0],&data[i][1],&data[i][2]);
      }
      double maxi = 0;
      int sol = -1;
      rep(i,n){
         if( data[i][2] == 1){
            if( maxi < ( 1+m*data[i][1]/100.0 ) ){
               maxi = ( 1+m*data[i][1]/100.0 );
               sol = data[i][0];
            }
         }else{
            if( maxi < pow( 1+data[i][1]/100.0  ,m ) ){
               maxi = pow( 1+data[i][1]/100.0  ,m );
               sol = data[i][0];
            }
         }
      }
         printf("%d\n",sol);
   }
   return 0;
}

Measured memory_bytes: 1192
from statistics import median


N = int(input())
X = list(map(int, input().split()))
medi_X = median(X)
sort_X = sorted(X)

for x in X:
    if x < medi_X:
        print(sort_X[int((N + 1) / 2)])
    else:
        print(sort_X[int(((N + 1) / 2) - 1)])

Measured memory_bytes: 27192
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int s = scanner.nextInt();
        int roop = 1000000;
        Integer[] li = new Integer[roop];
        li[0] = 0;

        for(int i=1;i<roop;i++) {
        	if(i == 1) {
        		li[i] = s;
        	}else {
        		int n = li[i-1];
        		if(n % 2 == 0) {
        			li[i] = n/2;
        		}else {
        			li[i] = 3*n+1;
        		}
        	}
        }

        int rs = 0;
        for(int i=1;i<roop-1;i++) {
        	for(int k=i+1;k<roop;k++) {
        		if(li[i] ==li[k]) {
        			rs = k;
        			System.out.println(rs);
        			break;
            	}
        	}
    		if(rs > 0) {
    			break;
    		}
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}




Measured memory_bytes: 26068
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int 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 COMB(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;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int n;
int a[114514];
P cnta[114514];
P cntb[114514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	for (int i = 0; i < n; i += 2) {
		cnta[a[i] - 1].first++; cnta[a[i] - 1].second = a[i];
	}
	for (int i = 1; i < n; i += 2) {
		cntb[a[i] - 1].first++; cntb[a[i] - 1].second = a[i];
	}
	sort(cnta, cnta + 114514); sort(cntb, cntb + 114514);
	reverse(cnta, cnta + 114514); reverse(cntb, cntb + 114514);
	if (cnta[0].second == cntb[0].second)cout << n - max(cnta[0].first + cntb[1].first, cnta[1].first + cntb[0].first) << endl;
	else cout << n - (cnta[0].first + cntb[0].first) << endl;
	ggr
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
string S;
void zle() {
    cout<<"WA";
    exit(0);
}
int32_t main(void) {
    boost;
    cin>>S;
    if(S[0]!='A') zle();
    int nw=0;
    for(int i=2;i<S.size()-1;i++) {
        if(S[i]=='C') nw++;
    }
    if(nw!=1) zle();
    sort(ALL(S));
    //cout<<S;
    if(S[2]<'a') zle();
    cout<<"AC";
}


Measured memory_bytes: 256
program sequence_sum
  implicit none
  integer(8) :: n, x, m, num, a(0:100000) = 0
  integer :: b(0:100000) = 0, period, offset, rem, i, j
  read(*,*) n, x, m
  if (n == 1) then
    write(*,'(i0)') x
    stop
  end if
  a(1) = x
  b(int(x)) = 1
  do i = 2, int(m) + 1
    x = mod(x * x, m)
    a(i) = a(i - 1) + x
    if (i == n) then
      write(*,'(i0)') a(i)
      stop
    end if
    j = x
    if (b(j) > 0) then
      offset = b(j) - 1
      period = i - offset - 1
      exit
    end if
    b(j) = i
  end do
  num = (n - offset) / period
  rem = int(n - offset - num * period)
  write(*,'(i0)') (a(offset + period) - a(offset)) * num + a(offset + rem)
end program sequence_sum

Measured memory_bytes: 3476