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

using namespace std;

typedef long long ll;

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

    int n;
    cin >> n;

    vector<ll> data(1 << n);
    for(int i = 0; i < (1 << n); ++i)
        cin >> data[i];

    ll f, s, best = 0;
    for(int msk = 1; msk < (1 << n); ++msk){
        f = 0, s = -1;
        for(int sub = msk; sub > 0; sub = msk & (sub - 1)){
            if(data[sub] > data[f]){
                s = f;
                f = sub;
                continue;
            }
            if(s == -1 || (sub != f && data[sub] > data[s]))
                s = sub;
        }
        best = max(best, data[f] + data[s]);
        cout << best << "\n";
    }

    return 0;
}//RUL0

Measured memory_bytes: 5120
# coding-utf8 #

n = int(input())

li = list(map(int, input().split()))

count = 0
result = 0
flag = True

while flag:
  for index, num in enumerate(li):
    if num % 2 == 0:
      count += 1
      li[index] = num / 2

  if count == n:
    count = 0
    result += 1
  else:
    flag = False

print(result)

Measured memory_bytes: 38768
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define ll long long
using namespace std;
const int LIM = 3e5+3;
int cost[LIM+3], d[LIM+3];
ll INF = 1e18;
ll Ans = 0;

void solve(int l,int r)
{
  if(l >= r)return;
  int mid = (l+r)/2;
  vector<pair<int,ll> > V,W;
  int mx = 0; ll cur = 0;
  for(int i = mid+1;i<=r;i++)
  {
    cur += cost[i];
    if(abs(d[i]-d[i-1]) > mx)
      mx = abs(d[i]-d[i-1]), V.push_back(mp(mx,cur));
    else 
      V[V.size()-1].S = min(V.back().S, cur);
  }
  for(int i = 1; i<V.size();i++)
    V[i].S = min(V[i].S, V[i-1].S);
  mx = 0, cur = cost[mid];
  W.push_back(mp(0,cur));
  for(int i = mid-1;i>=l;i--)
  {
    cur += cost[i];
    if(abs(d[i+1]-d[i]) > mx)
      mx = abs(d[i+1]-d[i]), W.push_back(mp(mx,cur));
    else 
      W[W.size()-1].S = min(W.back().S, cur);
    int ind = upper_bound(V.begin(), V.end(), mp(mx,0ll))-V.begin();
    ind--;
    if(ind < 0)continue;
    Ans = min(Ans, cur+1ll*mx*mx+V[ind].S); 
  }
  for(int i = 1; i<W.size();i++)
    W[i].S = min(W[i].S, W[i-1].S);
  mx = 0, cur = 0;
  for(int i = mid+1;i<=r;i++)
  {
    cur += cost[i];
    mx = max(mx,abs(d[i]-d[i-1]));
    int ind = upper_bound(W.begin(), W.end(), mp(mx,0ll))-W.begin();
    ind--;
    if(ind < 0)continue;
    Ans = min(Ans, cur+1ll*mx*mx+W[ind].S); 
  }
  solve(l, mid);
  solve(mid+1,r);
}
int arr[LIM+3];
int h[LIM+3];
int main(){
    ll Sum = 0;
    int n;cin >> n;
    for(int i = 0;i<n+1;i++)
      cin >> arr[i],Sum += arr[i];
    for(int i = 0;i<n;i++)
      cin >> h[i];
    for(int i = 0;i<n;i++)
    {
      if(arr[i] > h[i])arr[i]-=h[i], h[i] = 0;
      else h[i] -= arr[i], arr[i] = 0;
      if(arr[i+1] > h[i])arr[i+1]-=h[i], h[i] = 0;
      else arr[i+1] = 0;
    }
    ll Ans = 0;
    for(int i = 0;i<n+1;i++)
      Ans+=arr[i];
    cout << Sum-Ans << endl;
}

Measured memory_bytes: 1024
a, b, c, d  = map(int, input().split())

def divide(n):
    return (b // n) - ((a-1) // n)

def gcd(a,b):
    if ( b==0 ):
        return a
    else:
        return (gcd(b, a%b))

def lcm(x, y):
    return (x * y) // gcd(x, y)

ans = b - a + 1

ans -= divide(c)

ans -= divide(d)

ans += divide(lcm(c,d))

print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Integer> list = new ArrayList<Integer>();
		while(scan.hasNext()){
			int d = scan.nextInt();
			int n600 = 600;
			int ans = 0;
			for(int x = d; x < n600; x += d){
				ans += d * ((x * x));
			}
			list.add(ans);
		}

		for(int n : list){
			System.out.printf("%d\n", n);
		}
	}
}

Measured memory_bytes: 25980
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(n,m);
    cout << ((n==m)? "Yes":"No") << nn;
    return 0;
}

Measured memory_bytes: 256
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]


s = input().split('T')
x,y = ai()

xx,yy = [],[]
c = 0
for i in range(len(s)):
    if i%2:
        yy.append(len(s[i]))
    else:
        xx.append(len(s[i]))

anx = set()
for i in range(len(xx)):
    if i == 0:
        anx = {xx[i]}
    else:
        aanx = set()
        for j in anx:
            aanx.add(j+xx[i])
            aanx.add(j-xx[i])
        anx = aanx
any = {0}
for i in range(len(yy)):
    aany = set()
    for j in any:
        aany.add(j+yy[i])
        aany.add(j-yy[i])
    any = aany

if x in anx and y in any:
    print('Yes')
else:
    print('No')


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

#define sz(o) ((int)o.size())
#define all(o) o.begin(), o.end()
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define repr(i, a, b) for(int i = (a); i >= (b); i--)

typedef long long int ll;
typedef vector<ll> vll;
typedef vector<int> vi;


void solve(int testcase) {
    priority_queue<ll> pq;
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    pq.push(a);
    pq.push(b);
    pq.push(c);
    rep(i, 1, k){
        ll n = pq.top();
        pq.pop();
        pq.push(2*n);
    }
    ll s = 0;
    while(!pq.empty()){
        s += pq.top();
        pq.pop();
    }
    cout << s;
}

int main(){
    #ifdef VPAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << setprecision(2);
    clock_t b = clock();
    int t = 1;
    //cin >> t;
    rep(tt, 1, t) solve(tt);
    clock_t e = clock();
    cerr << (double(e - b) / CLOCKS_PER_SEC) << " sec";
    return 0;
}

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

using namespace std;

const int INF = 10000000;

int solve(vector<vector<int>> &dists)
{
    const int v = dists.size();

    vector<vector<int>> dp(1 << v, vector<int>(v, INF));
    dp[1][0] = 0;

    const int all = (1 << v) - 1;

    for (int S = 1; S <= all; S++)
    {
        for (int s = 0; s < v; s++) {
            if ((S & (1 << s)) != 0) {
                for (int e = 0; e < v; e++) {
                    if (dists[s][e] != INF && (~S & (1 << e)) != 0) {
                        const int nS = S | (1 << e);
                        if (nS == all) {
                            dp[nS][e] = min(dp[nS][e], dp[S][s] + dists[s][e] + dists[e][0]);
                        } else {
                            dp[nS][e] = min(dp[nS][e], dp[S][s] + dists[s][e]);
                        }
                    }
                }
            }
        }
    }

    int ans = INF;
    for (int i = 0; i < v; i++) {
        ans = min(ans, dp[all][i]);
    }
    return ans == INF ? -1 : ans;
}

int main()
{
    int v, e;
    cin >> v >> e;
    
    vector<vector<int>> dists(v, vector<int>(v, INF));
    for (int i = 0; i < e; i++) {
        int s, e, d;
        cin >> s >> e >> d;
        dists[s][e] = d;
    }

    cout << solve(dists) << endl;

    return 0;
}


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

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var k = int.Parse(line[1]);
            if (n == 0 && k == 0) break;
            var a = new int[n];
            for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim());
            var max1 = getMax(a, n, k);
            var ans = getAns(a, n, k, max1);
            if (ans == -1) Console.WriteLine("NO GAME");
            else Console.WriteLine(ans - max1);
        }
    }
    static int getAns(int[] a, int n, int k, int max1)
    {
        var ans = max1;
        var ok = false;
        for (int i = 0; i < n - 1; i++)
            for (int j = i + 1; j < n; j++)
            {
                swap(a, i, j);
                var t = getMax(a, n, k);
                swap(a, i, j);
                if (t > ans) { ans = t; ok = true; }
                else if (t == ans) ok = true;
            }
        return ok ? ans : -1;
    }
    static void swap(int[] a, int x, int y)
    {
        var w = a[x];
        a[x] = a[y];
        a[y] = w;
    }
    static int getMax(int[] a, int n, int k)
    {
        var ans = 0;
        for (int i = 0; i <= n - k; i++)
        {
            var t = 1;
            for (int j = 0; j < k; j++)
                t *= a[i + j];
            ans = Max(ans, t);
        }
        return ans;
    }
}



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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

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);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, m;
  cin >> n >> m;

  vector<ll> a(m);

  rep(i, m) {
    cin >> a[i];
  }

  vector<ll> dp(n + 10);

  dp[0] = 1;
  if (m == 0 || a[0] != 1) {
    dp[1] = 1;
  }

  auto itr = a.begin();
  for (ll i = 2; i <= n; i++) {
    while (itr != a.end() && *itr < i) {
      itr++;
    }
    //段が壊れていなかったら
    if (itr == a.end() || *itr != i) {
      dp[i] = dp[i - 2] + dp[i - 1];
      dp[i] %= mod;
    }
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,lis[111][111]={},d[111]={},f[111],t=1;

void dfs(int now){
  d[now]=t++;
  for(int i=1;i<=n;i++)
    if(lis[now][i]&&d[i]==0)dfs(i);
  f[now]=t++;
}

int main(){
  cin>>n;
  for(int c=0;c<n;c++){
    int u,k,v;
    cin>>u>>k;
    for(int i=0;i<k;i++){
      cin>>v;
      lis[u][v]=1;
    }
  }
  for(int i=1;i<=n;i++)if(d[i]==0)dfs(i);
  for(int i=1;i<=n;i++)cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;  
  
  return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
map<pii, ll> cnt;
int main() {
  IOS;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long double y;
    cin >> y;
    ll x = llround(y * 1e9);
    int cnt2 = 0, cnt5 = 0;
    while (x % 2 == 0)
      x /= 2, cnt2++;
    while (x % 5 == 0)
      x /= 5, cnt5++;
    cnt[{cnt2, cnt5}]++;
  }
  ll ans = 0;
  for (auto i : cnt) {
    for (auto j : cnt) {
      if (i.ff.ff + j.ff.ff >= 18 && i.ff.ss + j.ff.ss >= 18) {
        if (i < j)
          ans += i.ss * j.ss;
        else if (i == j)
          ans += i.ss * (i.ss - 1) / 2;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3816
#include <iostream>

using namespace std;

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

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

public class Remainder
{
    static Dictionary<long,long> ans;
   
    static public void Main()
    {
        //var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        //var N = NK[0];
        //var K = NK[1];
        var H = long.Parse(Console.ReadLine());
    
        ans = new Dictionary<long,long>();
        ans.Add(1,1);
        Solve(H);
      
        Console.WriteLine(ans[H]);

    }
  
    static long Solve(long num){
      if(ans.ContainsKey(num)){
        return ans[num];
      }else{
        
        var tmp = Solve(num/2)*2+1;
        ans.Add(num,tmp);
        return ans[num];
      }
    }

}


Measured memory_bytes: 13268
fun main(args: Array<String>) {
    val (n, k) = readListInt()
    var p = readListInt().toMutableList().sorted()
    var count =  0
    for (i in 0 until k) {
        count += p[i]
    }
    println(count)



}

private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readListString() = read().split(" ")

private fun readListInt() = readListString().map { it.toInt() }

private fun readListLong() = readListString().map { it.toLong() }

private fun readListDouble() = readListString().map { it.toDouble() }

private fun readMatrixString(n: Int): List<List<String>> {
    val matrix = mutableListOf<List<String>>()
    for (i in 0 until n) {
        val list = readListString()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixInt(n: Int): List<List<Int>> {
    val matrix = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        val list = readListInt()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixDouble(n: Int): List<List<Double>> {
    val matrix = mutableListOf<List<Double>>()
    for (i in 0 until n) {
        val list = readListDouble()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixLong(n: Int): List<List<Long>> {
    val matrix = mutableListOf<List<Long>>()
    for (i in 0 until n) {
        val list = readListLong()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 40704
#include <bits/stdc++.h>
#define Phuong ios_base::sync_with_stdio(0); cin.tie(0);
#define mpp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<int,int> pii;

/// problem's variable




///--------------------


int main()
{
    Phuong;
    int n,k;
    cin >> k >> n;
    int first;
    int last;
    int maxx=0;
    int head=0;
    for(int i=0; i<n; ++i)
    {
        if (i==0)
        {
            cin >> head;
            first = head;
        }else
        if (i==n-1)
        {
            cin >> last;
            maxx=max(maxx,last-head);
        } else
        {
            int u;
            cin >> u;
            maxx=max(maxx,u-head);
            head=u;
        }
    }
    maxx=max(maxx,k-last+first);
    cout << k-maxx;
    return 0;
}


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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
//typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c,d;
  cin >> a >> b >> c >> c >> d;

  cout << max(a / 2 * 2 + b + c / 2 * 2 + d / 2 * 2,
              (a > 0 && c > 0 && d > 0 ? (a - 1) / 2 * 2 + b + (c - 1) / 2 * 2 + (d - 1) / 2 * 2 + 3 : 0LL)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define BUF_S 18000000
#define N 100010
#define in I()
using namespace std;
typedef long long ll;
int n,a[N];
ll ans1,ans2,now;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		now+=a[i];
		if(i&1){
			if(now>=0)ans1+=now+1,now=-1;
		}else{
			if(now<=0)ans1+=-now+1,now=1;
		}
	}
	now=0;
	for(int i=1;i<=n;i++){
		now+=a[i];
		if(!(i&1)){
			if(now>=0)ans2+=now+1,now=-1;
		}else{
			if(now<=0)ans2+=-now+1,now=1;
		}
	}
	cout<<min(ans1,ans2);
	return 0;
}

Measured memory_bytes: 640
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long 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 * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	string a,b,c;
	cin >> a >> b >> c;
	cout << "A" << b[0] << "C" << rt;
	please AC;
}

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

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W);

		W = in.readLine();
		String[] D = W.split(" ");
		int[] d = new int[N];
		for(int i=0;i<N;i++){
			d[i] = Integer.parseInt(D[i]);
		}
		long ans =0;
		for(int i=0;i<N;i++){
			for(int k=i+1;k<N;k++){
				ans += d[i]*d[k];
			}
		}

		System.out.println(ans);

	}
}


Measured memory_bytes: 21204
#![allow(non_snake_case, unused_macros, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Main
fn main(){
    input!{
        S: String,
    }
    if S.len()==2{
        println!("{}", S);
    }else{
        println!("{}", S.chars().rev().collect::<String>());
    }
}



Measured memory_bytes: 4352
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;


int n, m;
string s;

int main() {
	cin >> n;
	VI h(n);
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	int now = h[0]-1;
	for (int i = 1; i < n; i++)
	{
		if (h[i] >= now + 1) {
			now = h[i] - 1;
		}
		else if (h[i] == now) {
			continue;
		}else { cout << "No" << endl;return 0; }
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main(){
    int N, i, j, k, max_sales, sales, open;
    cin >> N;

    bool F[N][10], J[10];
    int P[N][11], match_num[N];

    for (i=0; i<N; i++) {
        for (j=0; j<10; j++) {
            cin >> F[i][j];
        }
    }
    for (i=0; i<N; i++) {
        for (j=0; j<11; j++) {
            cin >> P[i][j];
        }
    }

    for (k=1; k<1024; k++) {
        open = k;
        for (i=0; i<10; i++) {
            J[i] = open %2;
            open /= 2;    
        }

        sales = 0;
        for (i=0; i<N; i++) {
            match_num[i] = 0;
            for (j=0; j<10; j++) {
                match_num[i] += J[j] * F[i][j];
            }
            sales += P[i][match_num[i]];
        }
        if (k==1) max_sales = sales;
        else max_sales = max(max_sales, sales);
    }

    cout << max_sales << endl;

    return 0;
}


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

using namespace std;
using ll = long long int;

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

    unordered_map<string, int> m;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        m[s]++;
    }

    auto Print = [&m](const string &s)
    {
        cout << s << " x " << m[s] << endl;
    };

    Print("AC");
    Print("WA");
    Print("TLE");
    Print("RE");
}

Measured memory_bytes: 3604
n = int(input())
l = list(map(int,input().split()))
a = [0 for i in range(10**6)]
b = [0 for i in range(10**6)]
a_i = 0
b_i = 0
i = 0
for e in l:
    if i%2 == 0:
        a[e]+=1
        if(a[a_i]<=a[e]):
            a_i=e
    else:
        b[e]+=1
        if(b[b_i]<=b[e]):
            b_i=e
    i+=1
a.sort()
a.reverse()
b.sort()
b.reverse()
if a_i != b_i:
    print(n-a[0]-b[0])
else:
    print(n-max(a[0]+b[1],a[1]+b[0]))


Measured memory_bytes: 25580
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC171
{
    class C
    {
        static void Main(string[] args)
        {
            //var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            //var p = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
            // var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = long.Parse(Console.ReadLine());
            char[] C = new char[26];
            C[0] = 'z';

            for (int i = 0; i < 25; i++)
            {
                C[i + 1] = (char)('a' + i);
            }
            //Console.WriteLine(string.Join(" ", C));

            string ans = "";
            //ans += C[N % 26];
            //long tempN = N / 26;
            long tempN = N;
            while (tempN > 0)
            {
                ans += C[tempN % 26];
                if(tempN % 26 == 0) tempN = tempN / 26 - 1;
                else tempN /= 26;
            }
            Console.WriteLine(string.Concat(ans.Reverse()));

        }
    }
}


Measured memory_bytes: 28260
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<ll> a, x;

int main()
{
    int n;
    ll sum_all = 0ll, sum_odd = 0ll;
    cin>>n;
    a.resize(n); x.resize(n);
    REP(i,n) {
        cin>>a[i];
        if (i > 0 && i % 2 == 1)
            sum_odd += a[i];
        sum_all += a[i];
    }
    x[0] = sum_all - sum_odd * 2;
    FOR(i,1,n) {
        x[i] = a[i-1] * 2 - x[i-1];
    }

    REPALL(i,x) cout<<x[i]<<" ";
    putchar('\n');

    return 0;
}


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

using namespace std;
int main() {
    int c[3][3];

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    for (int a1 = 0; a1 <= 100; a1++) {
        int b1 = c[0][0] - a1;
        int b2 = c[0][1] - a1;
        int b3 = c[0][2] - a1;

        int a2 = c[1][0] - b1;
        if ( (a2 == c[1][1] - b2) && (a2 == c[1][2] - b3) ) {
            int a3 = c[2][0] - b1;
            if (a3 == c[2][1] - b2 && a3 == c[2][2] - b3) {
                cout << "Yes" << endl;
                return 0;
            }
        }

    }

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



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


#define rep(i,n) for(int i = 0; i < n; i++)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second

using namespace std;
using ll = long long;
using pll = pair<long, long>;

//取る順番はどうでもいい(どの順にとっても距離の最小は右端+左端+min(右端+左端)
vector<pll> ls;
vector<pll> rs;

int main(void){
    ll n, c, x, v;
    vector<pll> xv;
    cin >> n >> c;
    rep(i,n){
        cin >> x >> v;
        xv.push_back(pll(x, v));
    }

    sort(all(xv));
    ls.push_back(xv[0]);

    for(int i = 1; i < n; ++i){
        ls.push_back(pll(xv[i].X, ls.back().Y + xv[i].Y));
    }

    reverse(all(xv));
    rs.push_back(xv[0]);
    rs[0].X=c-rs[0].X;

    for(int i = 1; i < n; ++i){
        rs.push_back(pll(c-xv[i].X, rs.back().Y + xv[i].Y));
    }
    ll ans = 0;
    vector<ll> sls, srs;
    sls.push_back(0);
    srs.push_back(0);
    rep(i, n){
        ll t = ls[i].Y-ls[i].X-ls[i].X;
        if(t > sls.back()){
            sls.push_back(t);
        }else{
            sls.push_back(sls.back());
        }
    }
    rep(i, n){
        ll t = rs[i].Y-rs[i].X-rs[i].X;
        if(t > srs.back()){
            srs.push_back(t);
        }else{
            srs.push_back(srs.back());
        }
    }


    rep(i, n){
        ans = max(ans, ls[i].Y - ls[i].X + srs[n-i-1]);
        ans = max(ans, rs[i].Y - rs[i].X + sls[n-i-1]);
    }

    cout << ans << endl;

    return 0;
}



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

int n, m;
vector<int> g[100001];
int queries[100000][3];
int color[100001];
bool visit[100001][11];
int nowcolor;
 
void recur(int u, int d) {
  if (visit[u][d]) return;
  visit[u][d] = true;
  if (d == 0) {
    color[u] = nowcolor;
    return;
  }
  recur(u, d - 1);
  for (int v : g[u]) {
    recur(v, d - 1);
  }
}
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    cin >> queries[i][0] >> queries[i][1] >> queries[i][2];
    --queries[i][0];
  }
  for (int i = q - 1; i >= 0; --i) {
    nowcolor = queries[i][2];
    recur(queries[i][0], queries[i][1]);
  }
  for (int i = 0; i < n; ++i) {
    cout << color[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 9208
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
dp=[0]*(n+1)
dp[0]=1

af = [0]*(n+1)
for ai in a:
  af[ai]+=1

if 1 in a:
  dp[1]=0
else:
  dp[1]=1

  
for i in range(2,n+1):
  dp[i]=dp[i-2]+dp[i-1]
  if af[i]==1:    
    dp[i]=0

print(dp[-1]%1000000007)    

Measured memory_bytes: 460788
#include <bits/stdc++.h>
using namespace std;
const int DIM = 2e5 + 7;
vector <int> l[DIM];
bool viz[DIM];
int p[DIM];
void bfs(int x)
{
   viz[x] = true;

   queue <int> c;

   c.push(x);
   while(!c.empty())
   {
       int nod = c.front();
       c.pop();

       for(int i = 0; i < l[nod].size(); i++)
       {
           int vec = l[nod][i];

           if(viz[vec] == false)
           {
               viz[vec] = true;
               p[vec] = nod;
               c.push(vec);
           }
       }
   }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i=1; i<=m; i++)
    {
        int x, y;
        cin >> x >> y;
        l[x].push_back(y);
        l[y].push_back(x);
    }
    bfs(1);
    for(int i=2; i<=n; i++)
        if(p[i] == 0)
        {
            cout <<"No";
            return 0;
        }
    cout<<"Yes"<<'\n';
    for(int i=2; i<=n; i++)
        cout << p[i] <<'\n';
    return 0;
}

Measured memory_bytes: 13056
#1 insertionSort(A, N) // N個の要素を含む0-オリジンの配列A
#2   for i が 1 から N-1 まで
#3     v = A[i]
#4     j = i - 1
#5     while j >= 0 かつ A[j] > v
#6       A[j+1] = A[j]
#7       j--
#8     A[j+1] = v
def insertionSort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j-=1
        A[j+1] = v
        print(*A)

N = int(input())
A = list(map(int, input().split()))
print(*A)
insertionSort(A, N)



Measured memory_bytes: 5976
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if (a<=8 && b<=8) printf("Yay!\n");
    else printf(":(\n");
    return 0;
}


Measured memory_bytes: 128
l,r = map(int,input().split())
if r - l > 2019:
    print(0)
else:
    x = min(r%2019,l%2019)
    y = max(r%2019,l%2019)
    ans = 10**18
    for i in range(x,y):
        for j in range(i+1,y+1):
            ans = min(ans, (i*j)%2019)
    print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main()
{
    char o[10000],e[10000];
    char sum[100000];
    int i,j,k,p,l,u;
    while(gets(o)&&gets(e))
    {
        k=strlen(o);
        p=strlen(e);
        u=0;
        for(i=0; i<=k; i++)
        {
            sum[u]=o[i];
            u=u+2;
        }
        u=1;
        for(i=0; i<=p; i++)
        {
            sum[u]=e[i];
            u=u+2;
        }
        l=strlen(sum);
        for(i=0; i<l; i++)
        {
            printf("%c",sum[i]);
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 3123456
int n,m,t,x[SZ];
char ch,B[1<<20],*S=B,*T=B;
#define getc() (S==T&&(T=(S=B)+fread(B,1,1<<20,stdin),S==T)?0:*S++)
#define isd(c) (c>='0'&&c<='9')
int aa,bb;int F(){
	int x; scanf("%d",&x); return x;
    while(ch=getc(),!isd(ch)&&ch!='-');ch=='-'?aa=bb=0:(aa=ch-'0',bb=1);
    while(ch=getc(),isd(ch))aa=aa*10+ch-'0';return bb?aa:-aa;
}
#define gi F()
#define BUFSIZE 5000000
namespace fob {char b[BUFSIZE]={},*f=b,*g=b+BUFSIZE-2;}
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
struct foce {~foce() {pob; fflush(stdout);}} _foce;
namespace ib {char b[100];}
inline void pll(ll x)
{
    if(x==0) {pc(48); return;}
    //if(x<0) {pc('-'); x=-x;} //如果有负数就加上 
    char *s=ib::b;
    while(x) *(++s)=x%10, x/=10;
    while(s!=ib::b) pc((*(s--))+48);
}
ll qf[SZ],f[SZ];
int main()
{
	n=gi,m=gi,t=gi;
	for(int i=1;i<=n;i++) x[i]=gi;
	int p=0; f[0]=0; qf[0]=-2LL*x[1];
	for(int i=1;i<=n;i++)
	{
		while(t<=2*(x[i]-x[p+1])&&p<i) ++p;
		ll c=1e18;
		if(p<i)
			c=min(c,f[p]+max(t,2*(x[i]-x[p+1])));
		if(p) c=min(c,qf[p-1]+2*x[i]);
		f[i]=c;
		qf[i]=min(qf[i-1],f[i]-2LL*x[i+1]);
	}
	printf("%lld\n",f[n]+m);
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    int a1=pow(a,2);
    int a2=pow(a,3);

    cout<<a+a1+a2<<endl;
}




Measured memory_bytes: 4036
from collections import deque

if __name__ == '__main__':
    s = input()
    d = deque()
    l = deque()

    for i, c in enumerate(s):
        if c == "\\":
            d.append(i)
        if c == "/":
            if len(d) == 0:
                continue

            j = d.pop()

            s = i - j
            while len(l) > 0:
                _j, _i, _s = l.pop()
                if j < _j:
                    s += _s
                else:
                    l.append((_j, _i, _s))
                    break

            l.append((j, i, s))

    # sum all areas
    ans = str(len(l))
    sum_area = 0
    for j, i, s in l:
        ans += " " + str(s)
        sum_area += s

    # print answer
    print(sum_area)
    print(ans)

Measured memory_bytes: 8336
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,l,r,left=1,right=100000,flag=0;
    cin>>n>>m;
    for (int i=0;i<m;i++) {
        cin>>l>>r;
        if (l>right||r<left) {
            flag=1;
            break;
        }
        if (l>=left&&l<=right) {
            left=l;
        }
        if (r<=right&&left<=r) {
            right=r;
        }
    }
    if (flag==0) {
        cout<<right-left+1<<endl;
    } else {
        cout<<0<<endl;
    }
}


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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;

typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

string s[7] = {"thu", "fri", "sat", "sun", "mon", "tue", "wed"};

signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x;
    cin >> x;
    cout << s[x % 7] << "\n";
	return 0;
}



Measured memory_bytes: 3252
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<typename T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vvll A(2,vll(N));
    for(ll i=0;i<2;i++)for(ll j=0;j<N;j++)cin>>A[i][j];
    
    vvll dp(N,vll(2));
    for(ll i=0;i<N;i++){
        if(i==0)dp[i][0]=A[0][i];
        else {
            dp[i][0]=dp[i-1][0]+A[0][i];
        }
    }
    
    for(ll i=0;i<N;i++){
        if(i==0)dp[i][1]=dp[i][0]+A[1][i];
        else{
            if(dp[i-1][1]>dp[i][0])dp[i][1]=dp[i-1][1]+A[1][i];
            else dp[i][1]=dp[i][0]+A[1][i];
        }
    }
    cout<<dp[N-1][1]<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define mod 1000000007LL
 
ll f[4010][2010],n,m,k,len;
 
inline ll rd()
{
    ll x=0;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar());
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x;
}
 
int main()
{
    n=rd();m=rd();k=rd();len=(n+m-1)/(k-1);
    for (ll i=1;i<k;i++) f[1][i]=1LL;
    for (ll i=2;i<=len;i++) for (ll j=0;j<=m;j++) for (ll kk=0;kk<min(k,j+1);kk++)
        f[i][j]=(f[i][j]+f[i-1][j-kk])%mod;
    ll ans=0;
    for (int i=1;i<=len;i++) for (int j=m;j>0;j-=k-1) if ((k-1)*i+1-j<=n) ans=(ans+f[i][j])%mod;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 62976
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

type Work struct {
	Date, Money int
}

type PriorityQueue []Work

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	if pq[i].Money != pq[j].Money {
		return pq[i].Money > pq[j].Money
	} else {
		return pq[i].Date < pq[j].Date
	}
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PriorityQueue) Push(x interface{}) {
	item := x.(Work)
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

func main() {
	sc.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()
	wm := make(map[int][]Work)
	for i := 0; i < n; i++ {
		a, b := nextInt(), nextInt()
		wm[a] = append(wm[a], Work{a, b})
	}

	var w PriorityQueue
	heap.Init(&w)

	res := 0
	for i := 1; i <= m; i++ {
		if ws, ok := wm[i]; ok {
			for _, work := range ws {
				heap.Push(&w, work)
			}
		}

		if w.Len() != 0 {
			x := heap.Pop(&w).(Work)
			res += x.Money
		}
	}

	fmt.Println(res)
}

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

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=n-1;i>=m;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;

bool paircmp(pair<int, int> a, pair<int, int> b) {
	return a.second > b.second;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n, m,ans=0;
		cin >> n >> m;
		if (!n) break;
		vector<pair<int, int>> v(n);
		REP(i, n) {
			int a, b;
			cin >> a >> b;
			v[i] = { a,b };
		}
		sort(ALL(v), paircmp);
		REP(i, n) {
			int a = min(m, v[i].first);
			m -= a;
			v[i].first -= a;
			ans += v[i].first*v[i].second;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3136
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 2e9;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = a * c;
	ans = max(ans, a * d);
	ans = max(ans, b * d);
	ans = max(ans, b * c );
	cout << ans << '\n';
	
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


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

int main()
{
    string a,b;
    int num;
    cin >> a >> b;
    num = stoi(a+b);
    for(int i=0; i<1000; i++){
        if(i*i == num){
            cout << "Yes" << endl;
            return 0;
        }
        if(i*i>num){
            break;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

using namespace std;

#define PB push_back
#define MP make_pair

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

const int MOD = 1e9+7;
const int INF = 1e9;
const int MAX_N = 100;

int N, A;
int sum[2][MAX_N+1];

int main() {
  cin >> N;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N+1; j++) {
      sum[i][j] = 0;
    }
  }

  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A;
      if (j==0) sum[i][j+1] = A;
      else sum[i][j+1] += sum[i][j] + A;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, (sum[0][i+1] - sum[0][0]) + (sum[1][N] - sum[1][i]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
# 045_a
a = int(input())  # 上底の長さ
b = int(input())  # 下底の長さ
h = int(input())  # 高さ

if (1 <= a & a <= 100) & (1 <= b & b <= 100) & (1 <= h & h <= 100):
    if (h % 2 == 0):
        s = int((a + b) * h / 2)
        print(s)

Measured memory_bytes: 8968
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
using namespace std;

using int64 = long long;
using int128 = __int128;

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

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

  int K;
  cin >> K;

  vector<int64> A(K);
  repeat (i, K) {
    cin >> A[i];
  }

  int64 x = 2, y = 2;
  for (int i = K - 1; i >= 0; i--) {
    // [x, y]における最小のA[i]の倍数
    int64 nx = ((x + A[i] - 1) / A[i]) * A[i],
          ny = (y / A[i]) * A[i] + A[i] - 1;
    if (nx > y or nx > ny) {
      cout << -1 << endl;
      return 0;
    }
    x = nx;
    y = ny;
  }
  cout << x << " " << y << endl;

  return 0;
}



Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))
mode = 0
money = 1000
kabu = 0
for i in range(N):
  if i == 0:
    if A[i+1] > A[i]:
      kabu += 1000//A[i]
      money -= kabu*A[i]
      mode = 1
    else:
      continue
  elif i == N-1:
    money += kabu*A[i]
  else:
    if mode == 1:
      if A[i] >= A[i-1]:
        if A[i] > A[i+1]:
          money += kabu*A[i]
          kabu = 0
          mode = 0
        else:
          continue
    else:
      if A[i] < A[i+1]:
        kabu += money//A[i]
        money -= kabu*A[i]
        mode = 1
      else:
        continue
print(money)

Measured memory_bytes: 9136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  vector<string> a;
  int begin = 0;
  for(int i = 0;i < s.size();i++){
    if(s[i] == 'A'){}
    else if(s[i] == 'B' && s[i + 1] == 'C')i++;
    else{
      a.push_back(s.substr(begin,i - begin));
      begin = i + 1;
    }
  }
  //cout << 1 << endl;
  //cout << begin << endl;
  if(s.size() - 1 > begin)a.push_back(s.substr(begin,s.size() - begin + 1));
  ll res = 0;
  //cout << a[0].size() << endl;
  //cout << 2 << endl;
  //cout << a[1] << endl;
  for(int i = 0;i < a.size();i++){
    ll count = 0;
    string sub;
    sub = a[i];
    //cout << "sub " << sub << endl;
    for(int j = sub.size() - 1;j >= 0;j--){
      //cout << sub[j] << endl;
      if(sub[j] == 'C'){
        count++;
        j--;
      }
      if(sub[j] == 'A')res += count;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3448