akhauriyash/Code-Regression huggingface dataset:
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
int n, m, s;
vector<P1>edge[55];
ll c[55], d[55];
ll dist[55][2505];

int main(){
	cin >> n >> m >> s;
	s = min(s, 2502);
	rep(i, m){
		int u, v, a, b; cin >> u >> v >> a >> b;
		edge[u].pb(mp(v, mp(a, b)));
		edge[v].pb(mp(u, mp(a, b)));
	}
	repn(i, n){
		cin >> c[i] >> d[i];
	}
	rep(i, 55) rep(j, 2505) dist[i][j] = 1e18;
	dist[1][s] = 0;
	priority_queue<pair<ll,P> , vector<pair<ll,P>>, greater<pair<ll,P>>>que;
	que.push(mp(0, mp(1, s)));
	while(!que.empty()){
		pair<ll, P>p = que.top(); que.pop();
		int v = p.sc.fi, zan = p.sc.sc;
		if(dist[v][zan] != p.fi) continue;
		if(dist[v][min(2502ll, zan+c[v])] > dist[v][zan] + d[v]){
			dist[v][min(2502ll, zan+c[v])] = dist[v][zan] + d[v];
			que.push(mp(dist[v][zan]+d[v], mp(v, min(2502ll, zan+c[v]))));
		}
		rep(i, edge[v].size()){
			int to = edge[v][i].fi;
			int use = edge[v][i].sc.fi;
			int cs = edge[v][i].sc.sc;
			if(use > zan) continue;
			if(dist[to][zan-use] > dist[v][zan]+cs){
				dist[to][zan-use] = dist[v][zan] + cs;
				que.push(mp(dist[to][zan-use], mp(to, zan-use)));
			}
		}
	}
	for(int i=2;i<=n;i++){
		ll ans = 1e18;
		rep(j, 2505) ans = min(dist[i][j], ans);
		cout << ans << endl;
	}
}

Measured memory_bytes: 6392
def one_percent():
    X = int(input())
    needed_year_is = 0
    your_deposit = 100
    
    flag = True
    while flag:
        if your_deposit >= X:
            print(needed_year_is)
            return
        
        needed_year_is += 1
        your_deposit = int(your_deposit * 1.01)

one_percent()

Measured memory_bytes: 9064
#include<iostream>
#include <set>

using namespace std;

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

bool flag = false;
set<int> orgList;
set<int> destList;

for (auto i = 0; i < M; ++i) {
int a;
int b;
cin >> a >> b;
if (a == 1) {
orgList.insert(b);
}
if (b == N) {
destList.insert(a);
}
}

for (auto entry : orgList) {
if (destList.count(entry) > 0) {
flag = true;
break;
}
}

if (!flag) {
cout << "IM";
}

cout << "POSSIBLE" << endl;

return 0;
}

Measured memory_bytes: 9600
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e5 + 10;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}
int n;
int val[maxn];
void solve()
{
	sa(n);
	repp(i,1,n)
	{
		sa(val[i]);
	}
	ll res = val[1]-1;
	int maxx=2;
	repp(i,2,n)
	{
		if(val[i]>maxx)
		{
			int k=val[i]/maxx-(val[i]%maxx==0);
			res+=k;
			maxx=max(val[i]%maxx+1,maxx);
		}
		else if(val[i]==maxx)
		{
			maxx++;
		}
	}
	cout<<res<<endl;
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,y;
	cin >> x >> y;
	//ボタン A : ディスプレイの値を 1 増やす。
	//ボタン B : ディスプレイの値の符号を反転する。
	int ans = inf;
	if(x>=0 && y>=0){
		if(y>=x)ans = y-x;
		else {
			ans = 1 + y-(-x);
			ans = min(ans,1+1+abs(abs(y)-abs(x)));
		}
	}else if(y>=0 &&x<0){
		ans = y-x;
		if(abs(x)<=y){
			ans = min(ans,1+y-abs(x));
		}else{
			ans = min(ans,abs(abs(x)-abs(y))+1);
		}
	}else if(x>=0 &&y<0){
		if(abs(y)>=x){
			ans = abs(y)-x + 1;
		}else{
			ans = 1+(y)-(-x);
		}
	}else if(x<0  &&y<0){
		if(y>=x){
			ans = y-x;
		}else{
			ans = min(1+1+(x-y),abs(y)-x+1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define display(v) for (auto x : v) cout << x << ", "
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define endl '\n'
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
 
// DEBUG TEMPLATE by livw
void __print(int x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifdef INCLUDEWHENOFFLINE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


ll calc(ll n)
{
    ll num = 10;
    for (int i = 0; i < n; i++)
        num *= 5;
    return num;
}

int main()
{
    fastio;
    
    ll n;
    cin >> n;
    if (n < 2)
    {
        cout << 0;
        return 0;
    }
    else if (n % 2)
    {
        cout << 0;
        return 0;
    }
    ll cnt = 0;
    ll num = 1;
    for (int i = 1; i <= 18; i++)
    {
        num *= 10;
        cnt += n / num;
    }
    num = 10;
    for (int i = 0; num <= n; i++)
    {
        num *= 5;
        ll cur = num;
        while (cur <= n)
        {
            ll temp = n / cur;
            cnt += temp / 2 + (temp % 2);
            cur *= 10;
        }
    }
    cout << cnt;
    return 0;
}


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

namespace DDCC2020
{
    class C
    {
        static void Main(string[] args)
        {
            //input
            long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long H = input[0];
            long W = input[1];
            long K = input[2];

            long[] countArray = new long[H];
            char[,] s = new char[W, H];
            for (int h = 0; h < H; h++)
            {
                string S = Console.ReadLine();
                long count = 0;
                for (int w = 0; w < W; w++)
                {
                    s[w, h] = S[w];
                    if (S[w] == '#') count++;
                }
                countArray[h] = count;
            }

            long num = 1;
            long[,] res = new long[W, H];
            //行に1個以上のいちごがある場合
            for (int h = 0; h < H; h++)
            {
                bool isFirst = true;
                if (countArray[h] != 0)
                {
                    for (int w = 0; w < W; w++)
                    {
                        if (s[w, h] == '#')
                        {
                            if (!isFirst) { num++; }
                            if (isFirst) { isFirst = false; }
                        }
                        res[w, h] = num;
                    }
                    num++;
                }
            }
            //行にいちごがない場合
            for (int h = 0; h < H; h++)
            {
                if (h == 0 && countArray[h] == 0)
                {
                    for (int h2 = h; h2 < H; h2++)
                    {
                        if (countArray[h2] != 0)
                        {
                            for (int w = 0; w < W; w++)
                            {
                                res[w, h] = res[w, h2];
                            }
                            break;
                        }
                    }
                }

                if (0 < h && countArray[h] == 0)
                {
                    for (int w = 0; w < W; w++)
                    {
                        res[w, h] = res[w, h - 1];
                    }
                }
            }

            //output
            for (int h = 0; h < H; h++)
            {
                for (int w = 0; w < W; w++)
                {
                    Console.Write(res[w, h]);
                    if (w < W - 1) Console.Write(" ");
                }
                Console.WriteLine();
            }
        }
    }
}


Measured memory_bytes: 16480
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			int n = sc.nextInt();
			String c = sc.next();

			//			int red = 0;
			//			int white = 0;
			//
			//			for(int i = 0; i < c.length(); i++) {
			//				if(c.charAt(i) == 'R') {
			//					red++;
			//				}else {
			//					white++;
			//				}
			//			}
			//
			//			//全部をどちらかに塗り替える
			//			if(c.charAt(0) == 'R') {
			//				red--;
			//			}
			//			int nurikae = Math.min(red, white);

			int l = 0;
			int r = n - 1;
			int count = 0;
			while (l < r) {
				if (c.charAt(l) == 'R') {
					l++;
				} else {
					if (c.charAt(r) == 'W') {
						r--;
					} else {
						count++;
						l++;
						r--;
					}
				}

			}
			System.out.println(count);

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

Measured memory_bytes: 40256
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    ll n, k;
    cin >> n >> k;

    ll ans = 0;
    for (ll i = k; i <= n; i++) {
        ans += (n*(n+1))/2 - ((n-i)*(n-i+1))/2 - (i*(i-1))/2 + 1;
        //cout << ans << " ";
        ans %= mod;
    }
    cout << (ans + 1)%mod << "\n";
}



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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  printf("%s\n", s < t ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

    map<lint, lint> mp;
    rep(i, n) mp[a[i]]++;

    lint s = 0;

    for (auto&& p : mp) {
        s += p.second * (p.second - 1) / 2;
    }

    rep(i, n) {
        auto t = s;
        lint v = mp[a[i]];

        t -= v * (v-1) / 2;
        t += (v-1) * (v-2) / 2;

        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define CRLF <<'\n';
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
#define trav(it,v) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;

int main(){
    int n;
    scanf("%d",&n);
    map<int,ll> m;
    rep(i,1,100001)
        m[i] = 0;

    ll sum=0;
    rep(i,0,n){
        int d;
        scanf("%d",&d);
        sum+=d;
        m[d]++;
    }
    int q;
    scanf("%d",&q);
    rep(i,0,q){
        int c,v;
        scanf("%d%d",&c,&v);
        ll count = m[c];
        sum -= count*c;
        sum += count*v;
        m[c] = 0;
        m[v] += count;
        printf("%lld\n",sum);
    }
}


Measured memory_bytes: 10040
def bellman_ford(N, M, edge):
    d = [10 ** 100] * N
    d[0] = 0
    infFlag = False
    for count in range(N):
        for i in range(M):
            if d[edge[i][0]] + edge[i][2] < d[edge[i][1]]:
                d[edge[i][1]] = d[edge[i][0]] + edge[i][2]
                if count == N - 1 and edge[i][1] == N - 1:
                    infFlag = True
    return infFlag, -d[N - 1]


def main():
    N, M = map(int, input().split())
    edge = []
    for i in range(M):
        a, b, c = map(int, input().split())
        edge.append([a - 1, b - 1, -c])
    infFlag, ans = bellman_ford(N, M, edge)
    if infFlag:
        print('inf')
    else:
        print(ans)


if __name__ == '__main__':
    main()

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

int main() {
  static char s[100001];
  int K;
  scanf("%100000s %d", s, &K);
  for(int i = 0; s[i]; ++i) {
    int maxrot = 26-(s[i]-'a');
    if(maxrot==26) maxrot=0;
    int rot;
    if(s[i+1]) {
      rot = maxrot <= K ? maxrot : 0;
    } else {
      rot = K;
    }
    s[i] = (s[i]-'a'+rot)%26+'a';
    K -= rot;
  }
  printf("%s\n", s);
  return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

#define ll long long

int main()
{
 ll int n;

  cin>>n;
   ll int save=n;
 ll int ans=n;
  for(int i=2;i*i<=save;i++)
    if(n%i==0)
      {
	ans*=(i-1);
	ans/=i;
	while(n%i==0)
	  n/=i;
      }
  if(n>1){
    ans*=n-1;
    ans/=n;}
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define MAX 100000
#define MOD 1000000007
using namespace std;
int v[MAX],a[MAX];
bool check(int n)
{
	for(int i=0;i<n;++i)
		if(a[i]^v[i])
			return false;
	return true;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	for(int i=0,x;i<n;++i)
	{
		cin>>x;
		a[x]++;
		++v[abs(n-1-(i<<1))];
	}
	if(!check(n))
		cout<<"0"<<endl;
	else
	{
		n >>= 1;
		long long ans = 1;
		for(int i=1;i<=n;++i)
			ans <<=1, ans %= MOD;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 4392
#include <iostream>
using namespace std;
int main(){
  int count = 0;
  while(1){
    count = 0;
    int n,x;
    cin >> n >> x;
    if(n==0) break;
    for (int i=1;i<=n-2;++i){
      for (int j=i+1;j<=n-1;++j){
        for (int k=j+1;k<=n;++k){
          if (x == i+j+k){
            count += 1;
          }
        }
      }
    }
    cout << count << '\n';

  }


  return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1001001001;

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	int ans = INF;
	for (int i = 0; i <= n - m; i++) {
		int now = 0;
		for (int j = 0; j < m; j++) {
			if (s[i+j] != t[j]) now++;
		}
		ans = min(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int32_t main(){
    int n;
    cin>>n;
    cout<<3*n*n<<endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.*;

// ABC 62-D
// http://abc062.contest.atcoder.jp/tasks/arc074_b

public class Main {
	
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		long N = in.nextLong();
		long A = in.nextLong();
		long B = in.nextLong();
		
		long answer = N * (B - A) + 2 * A - 2 * B + 1;
		if (answer < 0) {
			answer = 0;
		}
		
		System.out.println(answer);
	}
}

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

int main(){
    string s;
    bool appear[26] = {};

    cin >> s;
    for(int i = 0; i < s.length(); i++){
        int index = s[i]-'a';
        if(appear[index]){
            cout << "no" << endl;
            return 0;
        }
        appear[index] = true;
    }

    cout << "yes" << endl;
    return 0;
}

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

int main() {
  string yamada;
  cin >> yamada;
  if (yamada == "A")
    cout << "T" << endl;
  if (yamada == "T")
    cout << "A" << endl;
  if (yamada == "G")
    cout << "C" << endl;
  if (yamada == "C")
    cout << "G" << endl;
}

Measured memory_bytes: 256
function main()
    X,K,D = reads(Int,Int,Int)
    s = sign(X)
    if abs(X)/D >= K
        println((abs(X) - K*D))
    else
        hoge = X÷ D
        amari = X - D*hoge
        f = D/2 >= abs(amari)
        p = f ? 0 : 1
        p = iseven(K - hoge - (f ? 0 : 1)) ? p : 1-p
        println(abs((amari,(D - abs(amari)))[p+1]))
    end
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


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

int main(){
  int r,c;
  cin>>r>>c;
  int t[r+1][c+1];
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++) cin>>t[i][j];
  }for(int i=0;i<=r;i++) t[i][c]=0;
  for(int j=0;j<=c;j++) t[r][j]=0;
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      t[i][c]+=t[i][j];
      t[r][j]+=t[i][j];
      t[r][c]+=t[i][j];
    }
  }for(int i=0;i<=r;i++){
    for(int j=0;j<=c;j++){
     if(j) cout<<" ";
     cout<<t[i][j];
    }cout<<endl;
  }return 0;
}



Measured memory_bytes: 3080
#include <stdio.h>

int main() {
	int N;
	int N2;
	scanf("%d",&N);
	N2=N*100/108;
	if(N2*108/100==N) {
		printf("%d",N2);
		return 0;
	}
	if(((N2+1)*108)/100==N) {
		printf("%d",N2+1);
		return 0;
	}
	if(((N2-1)*108)/100==N) {
		printf("%d",N2-1);
		return 0;
	}
	printf(":(");
	
	
	return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string.h>
#include <vector>
#define ME(x , y) memset(x , y , sizeof(x))
#define SF(n) scanf("%d" , &n)
#define rep(i , n) for(int i = 0 ; i < n ; i ++)
#define INF  0x3f3f3f3f
#define mod 1000000007
#define PI acos(-1)
using namespace std;
typedef long long ll ;
ll fac[100009] , inv[100009];
ll a[100009];

int main()
{
    ll n ;
    scanf("%lld" , &n);
    for(int i = 1 ; i <= n ; i++)
    {
        scanf("%lld" , &a[i]);
    }
    fac[1] = 1 ;
    ll ans = 1 ;
    for(int i = 2 ; i < n ; i++)
    {
        ans = ans * i % mod ;
    }
    inv[1] = inv[0] = 1;
    for(int i = 2 ; i < n ; i++)
    {
        inv[i] = (mod - mod / i) * inv[mod%i] % mod ;
    }
    fac[1] = ans ;
    for(int i = 2 ; i < n ; i++)
    {
        fac[i] = (fac[i-1] + ans * inv[i]) % mod ;
    }
    ll sum = 0 ;
    for(int i = 1 ; i < n ; i++)
    {
        sum = (sum + fac[i]*(a[i+1] - a[i])) % mod ;
    }
    cout << sum << endl;


    return 0;
}


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

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n,m,c,s,g;
int p[20],q[20][55],r[20][55];


int dist[21][100][100];
int cost[20][20010];

int main(void){
	while(1){
		cin >> n >> m >> c >> s >> g;
		if(n==0&&m==0) break;
		s--,g--;
		rep(i,c+1)rep(j,n)rep(k,n) dist[i][j][k]=(j==k)?0:inf;
		rep(i,c)rep(j,20010) cost[i][j]=0;

		rep(i,m){
			int x,y,d,t;
			cin >> x >> y >> d >> t;
			x--,y--;
			dist[t][x][y]=min(dist[t][x][y],d);
			dist[t][y][x]=min(dist[t][y][x],d);
		}

		rep(i,c) cin >> p[i];
		rep(i,c){
			rep(j,p[i]-1) cin >> q[i][j];
			rep(j,p[i]) cin >> r[i][j];
			int cur=1,index=0;
			while(cur<=20000){
				cost[i][cur]=cost[i][cur-1]+r[i][index];
				if(index!=(p[i]-1)&&cur==q[i][index]) index++;
				cur++;
			}
		}

		range(a,1,c+1)rep(k,n)rep(i,n)rep(j,n) dist[a][i][j]=min(dist[a][i][j],dist[a][i][k]+dist[a][k][j]);

		range(a,1,c+1)rep(i,n)rep(j,n)
			if(dist[a][i][j]!=inf)
				dist[0][i][j]=min(dist[0][i][j],cost[a-1][dist[a][i][j]]);

		rep(k,n)rep(i,n)rep(j,n) dist[0][i][j]=min(dist[0][i][j],dist[0][i][k]+dist[0][k][j]);

		if(dist[0][s][g]>=inf)
			cout << -1 << endl;
		else
			cout << dist[0][s][g] << endl;
	}
 	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int K;
    cin >> K;
    set< pair<int, int> > ans;
    for(int i = 1; i <= K; ++i) {
        for(int j = 1; j <= K; ++j) {
            if((i % 2 == 0 && j % 2 == 1) || (i % 2 == 1 && j % 2 == 0)) {
                int a = min(i, j);
                int b = max(i, j);
                ans.insert({a, b});
            }
        }
    }
    printf("%zu\n", ans.size());
    return 0;
}


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

int main() {
  long long n, k, mod=1e9+7;
  cin>>n>>k;
  long long b=1,r=n-k+1;
  int dp[n+1][n+1];
 
  for(int i=0; i<=n; i++){
    dp[i][0]=1;dp[i][i]=1;
    for(int j=1; j<i; j++){
      dp[i][j]=(dp[i-1][j]%mod+dp[i-1][j-1]%mod)%mod;
    }
  }
      
      
  for(long long i=1 ; i<=k;i++ ){
    
    cout<<(dp[n-k+1][i]%mod)*(dp[k-1][i-1]%mod)%mod<<endl;
    
    
  }
}

Measured memory_bytes: 15616
#include <iostream>
using namespace std;
int p,q,a;
int solve(int n,int d,int prod,int sum){
	int cnt=0;
	for(int i=d;prod*i<=a;i++){
		int left=p*(prod*i);
		int right=sum*i+prod;
		if(left<right*q){
			continue;
		}
		if(left==right*q){
			cnt++;
			continue;
		}
		if(n==1){
			continue;
		}
		cnt+=solve(n-1,i,prod*i,right);
	}
	return cnt;
}
int main(){
	int n;
	while(cin>>p>>q>>a>>n,(p||q||a||n)){
		cout<<solve(n,1,1,0)<<endl;
	}
	return 0;
}

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

typedef long long ll;
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
int n, m;
vector<vector<int>> adj;
vector<int> dp;
vector<bool> vis;
void dfs(int u){
    vis[u] = true;
    for(auto& e:adj[u]){
        if(!vis[e]){
            dfs(e);
        }
        dp[u] = max(dp[u], 1 + dp[e]);
    }
}
void solve(){
    cin>>n>>m;
    adj.resize(n);
    dp.resize(n, 0);
    vis.resize(n, false);
    for(int i = 0; i < m; i++){
        int x1, y1;
        cin>>x1>>y1;
        adj[x1 - 1].push_back(y1 - 1);
    }
    for(int i = 0; i < n; i++){
        if(!vis[i]){
            dfs(i);
        }
    }
    cout<<*max_element(dp.begin(), dp.end());
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    // pre();
    while (t--)
        solve();

    return 0;
}

Measured memory_bytes: 10980
#include<iostream>
#include<queue>

int main(){
    using namespace std;
    int n;
    int q;
    cin>>n>>q;
    priority_queue<int> Q[n]={};

    for(int i=0;i<q;i++){
        int inst,t,x;
        cin>>inst>>t;
        switch(inst){
            case 0:{
                cin>>x;
                Q[t].push(x);
                break;
            }
            case 1:{
                if(!Q[t].empty()){
                    cout<<Q[t].top()<<endl;
                }
                break;
            }
            case 2:{
                if(!Q[t].empty()){
                    Q[t].pop();
                }
                break;
            }
        }
    }
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int n; cin >> n;
    if (n == 0) return;

    int cnt = 0;
    reps(i, n - 1) {
      int sum = 0;
      repi(j, i, 100000) {
        sum += j;
        if (sum >= n) break;
      }
      if (sum == n) cnt++;
    }
    cout << cnt << '\n';
  }
}



Measured memory_bytes: 3144
import java.util.*;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char[] s = sc.next().toCharArray();
		int cnt[] = new int[26];
		
		for(char c:s){
			cnt[c-'a']++;
		}
		
		String ans = "None";
		
		for(int i=0;i<26;i++){
			if(cnt[i] == 0){
				ans = "" + (char)('a' + i);
				break;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 26440
N, A = map(int, input().split())
num_base = list(map(int, input().split()))
num_li = [n - A for n in num_base]

import collections as cols
C = cols.Counter([0])

for n in num_li:
  adcols = cols.Counter()
  for idx, count in C.items():
    adcols[n+idx] += count
  C += adcols
print(C[0]-1)

Measured memory_bytes: 3572
def main():
    N=int(input())
    t,x,y=[0]*(N+1),[0]*(N+1),[0]*(N+1)
    for i in range(1,N+1):
        t[i],x[i],y[i]=map(int,input().split())
        dif=((t[i]-t[i-1])-(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])))
        #print(dif)
        if dif < 0 or dif % 2 != 0:
            print("No")
            return
    print("Yes")
    
if __name__=="__main__":
    main()

Measured memory_bytes: 11636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    int n;
    cin >> n;

    string name = "ABD";
    if (n <= 999) {
        name = "ABC";
    }

    cout << name << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

string s;
int segtree[500000*4+1][26],a[500001],fre[26],i;

void makeSegTree(int index,int start,int end)
{
	if(start==end)
	{
		segtree[index][a[start]]++;
		return;	
	}	
	int mid=(start+end)>>1;
	makeSegTree(index<<1,start,mid);
	makeSegTree(index<<1|1,mid+1,end);
	for(i=0;i<26;i++)
		segtree[index][i]=segtree[index<<1][i]+segtree[index<<1|1][i];
}

void update(int index,int start,int end,int i,int pos)
{
	if(start==end)
	{
		segtree[index][a[i]]--;
		a[i]=pos;
		segtree[index][a[i]]++;
		return;
	}
	int mid=(start+end)>>1;
	if(i<=mid)
		update(index<<1,start,mid,i,pos);
	else
		update(index<<1|1,mid+1,end,i,pos);
	for(i=0;i<26;i++)
		segtree[index][i]=segtree[index<<1][i]+segtree[index<<1|1][i];
}

void query(int index,int start,int end,int l,int r)
{
	if(start==l && end==r)
	{
		for(i=0;i<26;i++)
			fre[i]+=segtree[index][i];
		return;
	}
	int mid=(start+end)>>1;
	if(r<=mid)
		query(index<<1,start,mid,l,r);
	else if(l>=mid+1)
		query(index<<1|1,mid+1,end,l,r);
	else
	{
		query(index<<1,start,mid,l,mid);
		query(index<<1|1,mid+1,end,mid+1,r);
	}
}

int main()
{
	fastio;
	int n,i,j,q,l,r,type,ans;
	char ch;
	cin>>n;
	string segtree[n*4];
	string s;
	cin>>s;
	for(i=0;i<n;i++)
		a[i]=s[i]-'a';
	cin>>q;
	makeSegTree(1,0,n-1);
	while(q--)
	{
		cin>>type;
		if(type==1)
		{
			cin>>l>>ch;
			update(1,0,n-1,l-1,ch-'a');
		}
		else
		{
			cin>>l>>r;
			ans=0;
			memset(fre,0,sizeof(fre));
			query(1,0,n-1,l-1,r-1);
			for(i=0;i<26;i++)
				if(fre[i])
					ans++;
			cout<<ans<<"\n";
		}
	}
	return 0;
}


Measured memory_bytes: 174904
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>
#include <map>
using namespace std;

vector<long long> v;

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

   v.resize(n);

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

   sort(v.begin(), v.end(), [&](int a, int b)
   {
      return a > b;
   });

   long long ans = 0;
   int index = 0;
   for (int i = 1; i < n; i++)
   {
      //cout << v[index] << "\n";
      if (i == 1)
      {
         ans += v[index];
         index++;
      }
      else
      {
         ans += v[index];
         if (i & 1)
         {
            index++;
         }
      }
   }
   cout << ans;

   return 0;
}

Measured memory_bytes: 4828
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n,a[1<<17];ll ans,now=1,suf[1<<17];
int main(){
	scanf("%d",&n);
	for(int i=0;i<=n;i++)scanf("%d",a+i);
	for(int i=n;~i;i--)suf[i]=suf[i+1]+a[i];
	for(int i=0;i<=n;i++){
		if(now<a[i])puts("-1"),exit(0);
		ans+=now;
		now-=a[i];
		now=min(now*2,suf[i+1]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5004
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans=0;
long long sort(long long d[],int NumberArrays,int up){
  int tmp;
  for (int i = 0; i < NumberArrays-1; i++) {
    if (up && d[i]<d[i+1]) {
      d[i]=tmp;
      d[i]=d[i+1];
      d[i+1]=tmp;
    }else if (d[i]>d[i+1]) {
      d[i]=tmp;
      d[i]=d[i+1];
      d[i+1]=tmp;
    }
  }
}
int main(int argc, char* argv[]){
	long long int a = 0, b = 0, c = 0,d[10000];
  char f[3];
	scanf("%s",f);
  for (int i = 0; i < 3; i++) {
    if (f[i]=='7') {
      printf("Yes" );
      return 0;
    }
  }
  printf("No");
}


Measured memory_bytes: 1732
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Measured memory_bytes: 13964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC170A()
{
	vi x(5);
	for (int i = 0; i < 5; ++i)
	{
		cin >> x[i];
	}
	for (int i = 0; i < 5; ++i)
	{
		if (x[i] == 0)
		{
			cout << i + 1 << endl;
			return;
		}
	}


}

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


Measured memory_bytes: 3600
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    long long N,K;cin >> N >> K;
    vector<long long> retu(N);
    for(int i = 0;i<N;i++)cin >> retu.at(i);
    //iより前にあるやつはK回転倒する
    vector<long long> tentou_front(N);
    for(int i = 0;i<N;i++){
        for(int j = i+1;j<N;j++){
            if(retu.at(i) > retu.at(j)) tentou_front.at(i)++;
        }
    }
    //iより後ろにあるやつはK-1回転倒する
    vector<long long> tentou_back(N);
    for(int i = 0;i<N;i++){
        for(int j = 0;j<i;j++){
            if(retu.at(i) > retu.at(j)) tentou_back.at(i)++;
        }
    }

    long long ans = 0;
    for(int i = 0;i<N;i++){
        long long plus_front = ((((K+1)*K)/2)%MOD)*tentou_front.at(i);
        long long plus_back = (((K*(K-1))/2)%MOD)*tentou_back.at(i);
        plus_back %= MOD;
        plus_front %= MOD;
        ans += plus_back+plus_front;
        ans %= MOD;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		if (A>=K) {
			System.out.println(K);
		} else if (A+B>=K) {
			System.out.println(A);
		} else {
			System.out.println(A-(K-A-B));
		}
	}

}

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

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

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

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

#define lli long long int
#define mpr make_pair
#define pr pair<lli,lli>
#define pb push_back
#define vl vector<lli>
#define mp map<lli,lli>
#define all(x) x.begin(),x.end()
#define FOR(i,n) for(lli i=0;i<(lli)n;i++)
#define FOR1(i,j,n) for(lli i=j;i<(lli)n;i++)
#define mod 1000000007

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

lli power(lli x,lli n,lli m)
{
	lli res=1;
	while(n>0)
	{
		if(n&1) res=(res*x)%m;
		x=(x*x)%m;
		n=n>>1;
	}
	return res;
}

lli modInverse(lli n,lli  p)
{
	return power(n,p-2,p);
}

lli nCr(lli n,lli r,lli p)
{
	if(r==0)
	return 1;
	lli fac[n+1];
	fac[0]=1;
	for(lli i=1;i<=n;i++)
	fac[i]=fac[i-1]*i%p;
	return ((fac[n]* modInverse(fac[r], p) % p )%p* 
            modInverse(fac[n-r], p) % p) % p; 
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	vl v(5);
	for(lli i=0;i<5;i++)
	cin>>v[i];
	for(lli i=0;i<5;i++)
	{
		if(v[i]==0)
		{
			cout<<i+1<<endl;
			return 0;
		}
	}
	
	
return 0;
}


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

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

  vector<vector<int>> v(N, vector<int>(N, 0));
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--; // 0-indexed

    v.at(a).at(b)++;
    v.at(b).at(a)++;
  }

  for (int i = 0; i < N; i++) {
    int ans = 0;
    for (int num : v.at(i)) {
      if (num > 0) {
        ans += num;
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [0]*(61206)
def calc(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            A[calc(x,y,z)] += 1
for i in range(1,N+1):
    print(A[i])

Measured memory_bytes: 69428
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int n;
    cin >> n;
    ll sum = 0;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    
    vector<ll> ans(n);
    ans[0] = sum;
    for (int i = 0; (2 * i + 1) < n; i++) {
        ans[0] -= 2 * a[2 * i + 1];
    }

    cout << ans[0] << endl;
    rep(i, n - 1) {
        ans[i + 1] = 2 * a[i] - ans[i];
        cout << ans[i + 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mxn 19
#define mod 1000000007
#define ld long double
#define pb push_back
#define inf 1e18
#define fi first
#define se second
typedef long long int ll;
using  namespace std;
int main(void){
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	fast;
	string s,t;
	cin>>s>>t;
	int ans=t.length(),i,j;
	for(i=0;i<=s.length()-t.length();i++){
		string p=s.substr(i,t.length());
		int cr=0;
		for(j=0;j<p.length();j++){
			if(p[j]!=t[j])
			cr++;
		}
		ans=min(ans,cr);
	}
	cout<<ans;
}


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

class Program
{
    static void Main(string[] args)
    {
        var K = sc.ReadInt();
        var ans = 0;
        for (int i = 1; i <= K; i += 2)
        {
            for (int j = 2; j <= K; j += 2)
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 11092
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

A,B,M = inpl()
aa = inpl()
bb = inpl()

ans = min(aa) + min(bb)

for _ in range(M):
    x,y,c = inpl()
    tmp = aa[x-1] + bb[y-1] - c
    ans = min(ans,tmp)


print(ans)


Measured memory_bytes: 19632
#include <iostream>
int main(){
  int A = 0;
  int B = 0;
  int money = 0;
  std::cin >> A >> B;

  if( A >= 13 )
  {
    money = B;
  }
  else if( A <= 12 && A >= 6 )
  {
    money = B / 2;
  }
  else
  {
    money = 0;
  }

  std::cout << money << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int i, j, k, n = 1, x = 1;

		while (n != 0 || x != 0) {
			int count = 0;
			n = scanner.nextInt();
			x = scanner.nextInt();
			if (n == 0 && x == 0) {
				break;
			}
			for (i = 1; i <= n; i++) {
				for (j = 1; j < n; j++) {
					for (k = 1; k < n; k++) {
						if (i > k && j > k && i > j) {
							if (i != j && i != k && j != k) {
								if (i + k + j == x) {
									count = count + 1;
								}
							}
						}
					}
				}
			}
			System.out.println(count);

		}

	}
}



Measured memory_bytes: 26808