akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
	double v;
	double t;
	double y;
	int i,h;
	while(scanf("%lf",&v) != EOF){
		t = v / 9.8;
		y = 4.9 * t * t;
		for(i = 0;;i++){
			h = 5 * i - 5;
			if(h > y){
				printf("%d\n",i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 628
#include <cstdio>
#include <cmath>

int main(){
    int a,b,c,k,ans;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    if(a<b){
        if(b<c)ans = a+b+c*pow(2,k);
        else ans = a+c+b*pow(2,k);
    }else{
        if(a<c)ans = a+b+c*pow(2,k);
        else ans = b+c+a*pow(2,k);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    map<string,int> mp;
    rep(i,0,n)
    {
        string s;
        cin>>s;
        sort(s.B,s.E);
        mp[s]++;
    }
    ll ans=0;
    for(auto z:mp)
    {
        ans+=(ll)z.S*(z.S-1)/2;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 11264
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
 
int main()
{
  int N, M, C;
  cin >> N >> M >> C;
  
  vector<int> B;
  int b;
  for( int i = 0; i < M; i++ ){
    cin >> b;
    B.push_back(b);
  }
  
  int a;
  int sum = 0;
  int cnt = 0;
  
  for( int i = 0; i < N; i++ ){
    for( int j = 0; j < M; j++ ){
      cin >> a;
      sum += a * B[j];
    }
    sum += C;
    if( sum > 0 ){ cnt++; }
    sum = 0;
  }
  
  cout << cnt;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n;
  while(cin>>n, n){
    int allsum = 0;
    vector<int> v(n);
    REP(i, n){
      int sum = 0;
      REP(j, n){
        int tmp;
        cin >> tmp;
        printf("%5d",tmp);
        allsum += tmp; sum += tmp;
        v[j] += tmp;
      }
      printf("%5d\n",sum);
    }
    REP(i, n)
      printf("%5d",v[i]);
    printf("%5d\n",allsum);
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
al = list(map(int, input().split()))

import collections
c = collections.Counter(al)
cc = c.most_common()[0][0]

da = ([i for i, x in enumerate(al) if x ==cc ][0])
db = ([i for i, x in enumerate(al) if x ==cc ][1])

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, n + 2):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

print(n)
for i in range(2,n+2):
    print((cmb(n-1,i,p)+ cmb(n-1,i-1,p)*2 -cmb(da+n-db,i-1,p) + cmb(n-1,i-2,p)) % p)

Measured memory_bytes: 28252
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
n,x,m = ma()
idx = [[] for i in range(m)]
tmp=[]
ans = 0
l=0
r=0
for i in range(m+3):
    x = x%m
    tmp.append(x)
    #print(tmp)
    if idx[x]==[]:
        idx[x].append(i)
    else:
        l = idx[x][0]
        r=i
        break
    ans+=x
    x*=x
    if i==n-1:
        print(ans)
        exit()
#print(l,r)
s =sum(tmp[l:r])
d = r-l
p,q = divmod(n-r,d)
ans+=s*p
for i in range(l,l+q):
    ans+=tmp[i]
print(ans)


Measured memory_bytes: 77468
#include<bits/stdc++.h>
using namespace std;
long long n,a[200010],ans;
long long sum[200010],Hsum[200010];
map<long long,long long>mp;
int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=n;i>1;i--){
		Hsum[i]=Hsum[i+1]+a[i];
		mp[Hsum[i]]++;
	}
	//cout<<"SUM n "<<sum[n]<<"\n";
	for(int i=0;i<n;i++){
		//cout<<"ID "<<i<<" , Wd="<<sum[n]-sum[i]<<"\n";
		//cout<<"NUM="<<mp[sum[n]-sum[i]]<<"\n";
		ans+=mp[sum[n]-sum[i]];
		if(sum[n]-sum[i]==0)ans++;
		if(i<n-1)mp[Hsum[i+2]]--;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 17408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] x = new int[3];
		for(int i = 0;i < 3;++i)
			x[i] = sc.nextInt();
		sc.close();
		
		int count5 = 0;
		int count7 = 0;
		for(int i = 0;i < 3;++i)
			if(x[i] == 5)
				++count5;
			else if(x[i] == 7)
				++count7;
		if(count5 == 2 && count7 == 1)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}


Measured memory_bytes: 21716
x,y,m[10][10],d,h=100;D(v,w){v+=x,w+=y;v<0|v>9|w<0|w>9||(h-=!m[v][w],d=fmax(++m[v][w],d));}R(v,w){D(v,w),D(w,-v),D(-v,-w),D(-w,v);}main(s){for(;~scanf("%d,%d,%d",&x,&y,&s);D(0,0))s>2&&R(0,2),s>1&&R(1,1),R(0,1);x=!printf("%d\n%d\n",h,d);}

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
 
  if (A == B) {
    if (A == C) {
      cout << "No";
    } else {
      cout << "Yes";
    }
  } else {
    if (A == C || B == C) {
      cout << "Yes";
    } else {
      cout << "No";
    }
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
m = int(input())
l = [list(map(int, input().split())) for i in range(m)]
for i in range(m):
    ans = 0
    for j in range(n):
        if j == l[i][0] - 1:
            ans += l[i][1]
        else:
            ans += t[j]
    print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, NN;

  std::cin >> N;

  NN = N * 2;

  for (int i = 1; i * i <= NN; i ++)
    if (NN % i == 0) {
      int j = NN / i;

      if (i + 1 == j) {
        int w = i, h = j;

        std::vector<std::vector<int>> a(h, std::vector<int>(w));

        for (int k = 0, s = 1; k < w; s += w - k - 1, k ++)
          for (int l = k; l < w; l ++)
            a[k][l] = a[l + 1][k] = s + l;

        std::cout << "Yes" << std::endl;

        std::cout << a.size() << std::endl;

        for (const auto& i : a) {
          std::cout << i.size() << ' ';
          for (const auto& j : i)
            std::cout << j << ' ';
          std::cout << std::endl;
        }
        
        return 0;
      }
    }

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


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    n--;
    cout << (ll)((n+k-2)/(k-1)) << endl;
    return 0;
}

Measured memory_bytes: 1024
import bisect
import operator
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
H = list(map(int, sys.stdin.readline().split()))

H = [0] + H + [0]
ans = 0
for h in reversed(range(0, max(H) + 1)):
    yes = False
    for i in range(len(H)):
        if H[i] >= h:
            yes = True
        else:
            if yes:
                ans += 1
            yes = False
print(ans)


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

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

  int maxIndex = 0;
  int max = 0;
  for (int i = 1; i <= N; i++) {
    int count = 0;
    int j = i;
    while (j % 2 == 0) {
      j >>= 1;
      count++;
    }
    if (max <= count) {
      max = count;
      maxIndex = i;
    }
  }
  
  cout << maxIndex << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define matrix vector <vll>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
ll pow(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b&1) res*=a;
		b/=2;
		a*=a;
	}
	return res;
}
int main()
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
  	ll a,  b;
  	cin >> a >> b;
  	ll k = (a+b)/2;
  	if(2*k == a+b) cout << k << "\n";
  	else cout << "IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 256
import io.StdIn._
object Main extends App {
    val Array(n, m) = readLine.split(" ").map(_.toInt)
    val abs = for(count <- 1 to n) yield readLine.split(" ").map(_.toLong)
    val cds = for(count <- 1 to m) yield readLine.split(" ").map(_.toLong)

    for(ab <- abs) {
        val manhattans = cds.map(cd => (ab.head - cd.head).abs + (ab.last - cd.last).abs)
        val min = manhattans.min
        val index = manhattans.indexOf(min)
        println(index+1)
    }
}

Measured memory_bytes: 27440
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int f[111111];
int dis[111111];
int q[111111],hq,tq;
int vis[111111];
int main()
{
	int k=io::F();
	while(k%2==0)k>>=1;
	while(k%5==0)k/=5;
	if(k==1)return puts("1"),0;
	f[0]=1;
	int pf=0;
	for(register int i=1;i<k;++i)
	{
		f[i]=f[i-1]*10%k;
		if(f[i]==1){pf=i;break;}
	}
 	for(hq=1,tq=2,vis[0]=1;hq!=tq;++hq)
	{
		for(register int i=0;i<pf;++i)
		{
			int to=(q[hq]+f[i])%k;
			if(dis[k-to])
				return printf("%d\n",dis[q[hq]]+dis[k-to]+1),0;
			if(!vis[to])q[tq++]=to,dis[to]=dis[q[hq]]+1,vis[to]=1;
		}
	}
	return 0;
}



Measured memory_bytes: 1280
n = int(input())
A = [int(i) for i in input().split()]
B = []

for i in range(1, n + 1):
    B.append(A[i - 1] - i)
    
B.sort()
    
ans = 0
for i in range(1, n + 1):
    ans += abs(A[i - 1] - (B[n // 2] + i))
    
print(ans)

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

namespace ITP2_11_C
{
    public class Program

    {

        public static void Main(string[] args)
        {
            int n = ReadInt();
            List<int> s;

            int partialSet = 0;
            foreach (var x in ReadIntAr().Skip(1)) partialSet |= (1 << x);

            for (int i = 0 ; i < (1 << n) ; i++)
            {
                if ((i | partialSet) == partialSet)
                {
                    s = new List<int>(n);
                    for (int j = 0 ; j < n ; j++)
                    {
                        if ((i >> j & 1) == 1) s.Add(j);
                    }
                    Console.WriteLine("{0}:{1}", i, (s.Count == 0 ? "" : " ") + string.Join(" ", s.Select(x => x.ToString()).ToArray()));
                }
            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 22652
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n;
vector<int> memo(101010, -1);

int rec(int total)
{
    int res = INF;
    if (total == 0)
    {
        return 0;
    }
    if (memo[total] != -1)
    {
        return memo[total];
    }

    for (int i = 1; i <= total; i *= 6)
    {
        res = min(res, rec(total - i) + 1);
    }
    for (int i = 9; i <= total; i *= 9)
    {
        res = min(res, rec(total - i) + 1);
    }
    return memo[total] = res;
}

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

    cin >> n;
    rec(n);
    cout << memo[n] << endl;
}

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

int main() {
    ll N;
    cin >> N;
    vector<P> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(),a.end());
    set<ll> s;
    s.insert(-1);
    s.insert(N);
    ll ans =0;
    for(int i=0;i<N;i++){
        auto itr = s.upper_bound(a[i].second);
        ll right= (*itr-a[i].second);
        --itr;
        ll left= (a[i].second - *itr);
        ans += (right*left)*a[i].first;
        s.insert(a[i].second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15592
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	cin >> N;
	vector<ll> A(N+1, 0);
	rep(i,N)cin >> A[i];
	ll ans = 0;
	rep(i,N){
		ans += A[i]/2;
		A[i] %= 2;
		if(A[i] > 0 && A[i+1] > 0){
			++ans;
			--A[i+1];
		}	
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4052
// C - Rectangle Cutting

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

int main(){
	double W, H, x, y;
	cin >> W >> H >> x >> y;

	float A = W * H / 2.0;

	int multi;
	if (x == W/2.0 && y == H/2.0) multi = 1;
	else multi = 0;

	cout << A << " " << multi << endl;

	return 0;
}

Measured memory_bytes: 256
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


n, k = inl()
print(1 if n % k > 0 else 0)


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

namespace cswork
{

    class Program
    {
        public Program() { }

        Scanner cin;

        void Omame()
        {
            cin = new Scanner();

            int n = cin.nextInt();
            for (int i = 1; i <= 9; i++)
            {
                for(int j=1; j<=9; j++)
                {
                    if(i*j == n)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }


            Console.WriteLine("No");
        }

        static void Main(string[] args)
        {
            new Program().Omame();
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    ll n,k;
    cin>>n>>k;
    vector<ll>a(n), pref(n+1);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        pref[i+1] = mod( pref[i] + a[i], k );
    }

    for(int i=1;i<=n;i++)
    {
        pref[i] = mod( pref[i]-i, k);
    }

    map<ll,ll>fr;
    ll cur = 0;
    ll ans = 0;
    for(int i=n;i>=0;i--)
    {
        ans += fr[pref[i]];

        fr[pref[i]]++;
        cur++;
        while( cur >= k )
        {
            fr[pref[i+k-1]]--;
            cur--;
        }
    }
    cout<<ans,nl;

    return 0;
}

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

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

	bool can = false;
	for (int n = 0; n <= N; ++n) {
		for (int m = 0; m <= M; ++m) {
			int k = n*(M - m) + m*(N - n);
			if (k == K) { can = true; }
		}
	}

	if (can) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
int main(void)
{
	int i,j,H,W;
	while(1)
	{
		scanf("%d %d",&H,&W);
		if(W==0 && H==0)
		break;
		for(i=0;i<H;i++)
		{
			for(j=0;j<W;j++)
			{
				if(i==0||i==H-1||j==0||j==W-1)
				{
				printf("#");
			    }
				else
				{
				printf(".");
			    }
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


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

int main(){
  while(true){
    int n;
    cin>>n;
    if(n==0)break;
    int sequence[n];
    for(int i=0;i<n;i++){
      cin>>sequence[i];
    }
    int ohaziki=32;int now=0;
    while(ohaziki>0){
      ohaziki=ohaziki-(ohaziki-1)%5;
      if(ohaziki<0)ohaziki=0;
      cout<<ohaziki<<endl;
      ohaziki=ohaziki-sequence[now];
      if(ohaziki<0)ohaziki=0;
      cout<<ohaziki<<endl;
      now++;
      if(now>n-1)now=0;
    }
  }
}

Measured memory_bytes: 3000
#include<cstdio>
#include<algorithm>
#define MN 1000001
using namespace std;

const int MOD=1e9+7;
int n,f[MN],m;
inline void M(int &x){while(x>=MOD)x-=MOD;}
int main(){
	int i,j;
	scanf("%d",&n);f[n]=n;m=n-1;
	for (i=n-1;i;i--) f[i]=1LL*(n-1)*(n-1)%MOD,M(f[i]+=f[i+1]),M(f[i]+=m),M(m+=(i+2>n?1:f[i+2])-1);
	printf("%d\n",f[1]);
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define rep(i ,a, n) for (long long int i=a;i<=n;i++)
#define pb  push_back
#define mp make_pair
#define fp first
#define sp second
#define be(v) v.begin(),v.end()
typedef long long ll;
typedef vector<ll> vi ;
typedef vector<pair<ll , ll > >  vpi ;
const int ma1=3e5+5;
string no="NO",yes="YES";
#define MOD 1000000007
int max_char=26;
vector<ll> v;
int main()
{
      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        for(int i=0;i<n;i++)
        cin>>a[i];

        int sum=0;
        ll dp[n];
        dp[0]=0;
        dp[1]=abs(a[0]-a[1]);
        for(int i=2;i<n;i++)
        {
            dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));
        }
        cout<<dp[n-1];

    }
    return 0;
}
















Measured memory_bytes: 5172
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>

using namespace std;

int BubSort(int x[], int n)
{
	int i, j, temp;

	for (i = 0; i < n - 1; i++) {
		for (j = n - 1; j > i; j--) {
			if (x[j - 1] > x[j]) {  /* 前の要素の方が大きかったら */
				temp = x[j];        /* 交換する */
				x[j] = x[j - 1];
				x[j - 1] = temp;
			}
		}
	}
	return 0;
}

int main()
{
	int r, g, b = 0;


	cin >> r>>g >> b;
	
	if ((100 * r + 10 * g + b) % 4 == 0)
	{
		cout<<"YES" << endl;

	}
	else
	{
		cout << "NO" << endl;

	}
	system("pause");
	return 0;
}

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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

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



Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // CODE FESTIVAL 2016 Final B - Exactly N points
  // N問の問題が出題　i番目の問題の配点はi点　ちょうどN点取りたい
  // 解く問題の配点のうち最大値が最小になるようにする
  // 1からNまでの総和N(N+1)/2, 55点を取りたかったら最大値の最小は10
  // 1,3,6,10,15,21,28,36,45,55,66,78,…
  // 1からの和を求めておいて、二分探索かな？
  // Nが小さい場合は、足りない部分を引く（答えとして表示しない）
  int N; cin >> N;
  vector<ll> n(N/2+1+1, 0);
  REP(i, N/2+1){
    n[i+1] = n[i] + (i + 1);
  }
  auto ans = lower_bound(n.begin(), n.end(), N);

  for(int i = 1; i <= ans - n.begin(); i++){
    if(i == *ans - N){
      continue;
    }else{
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 39296
#include <stdio.h>
#define INFTY 1000000001
#define N 500000
void merge(int,int,int);
void mergeSort(int,int);

int A[N],count=0;
int main()
{
  
  int n,i,left,right;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  left=0;
  right=n;
  mergeSort(left,right);
   for(i=0;i<n-1;i++)
    {
      printf("%d ",A[i]);
    }
   printf("%d\n",A[n-1]);
   printf("%d\n",count);
  return 0;
}

void merge(int left,int mid,int right)
{
  int n1=mid-left,n2=right-mid;
  int L[n1],R[n2],i,j,k;
  for(i=0;i<n1;i++)
    {
      L[i]=A[left+i];
    }
  for(i=0;i<n2;i++)
    {
      R[i]=A[mid+i];
    }
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++)
    {
      if(L[i]<=R[j])
	{
	  A[k]=L[i];
	  i=i+1;
	  count++;
	}
      else
	{
	  A[k]=R[j];
	  j=j+1;
	  count++;
	}
    }
}

void mergeSort(int left,int right)
{
  int mid;
  if(left+1<right)
    {
      mid=(left+right)/2;
      mergeSort(left,mid);
      mergeSort(mid,right);
      merge(left,mid,right);
    }
}



Measured memory_bytes: 5684
#include<stdio.h>

#define MAX 100000
 
void swap( int *pa, int *pb )
{
	int t;
	
	t=*pa;
	*pa=*pb;
	*pb=t;
	
	return;
}

int partition( int A[], int p, int r )
{
	int x;
	int i,j;
	
	x=A[r];
	i=p-1;
	for( j=p; j<r; j++ ) {
		if( A[j] <= x ) {
			i++;
			swap( &A[i], &A[j] );
		}
	}
	swap( &A[i+1], &A[r] );
	
	return i+1;
}

int main( void ) 
{	
	int n,i,q;
	int A[MAX+1];
		
    scanf( "%d", &n );
	for( i=0; i<n; i++ ) {
		scanf( "%d", &A[i] );
	}
	q=partition( A, 0, n-1 );
	for( i=0; i<n; i++ ) {
		if( q == i ) {
			printf( "[%d]", A[i] );
		} else {
			printf( "%d", A[i] );
		}
		if( i < n-1 ) {
			printf( " " );
		}
	}
	printf( "\n" );

    return 0;
}

Measured memory_bytes: 992
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n;
    vi v(n);
    REP(i, n) {
        cin >> m;
        if (m % 2 == 0) {
            while (m % 2 == 0) {
                cnt += 1;
                m /= 2;
            }
        }

    }
    cout << cnt << Endl;
}

Measured memory_bytes: 384
#ifdef LOCAL
 #include <P.hpp>
 #include <debugger.hpp>
 #define __int64 __int64_t
#else 
 #include <bits/stdc++.h>
 #define debug(a...) //
 #define __int64 long long int
#endif
using namespace std;

int main()
{
 ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
 __int64 n , m , k;
 cin >> n >> m >> k;
 vector<__int64> s;
 __int64 sum = 0;
 for(int i = 0; i < n; i++) {
  __int64 x;
  cin >> x;
  sum += x;
  s.emplace_back(sum);
 }
 sum = 0;
 __int64 ans = 0;
 ans = upper_bound(s.begin() , s.end() , k) - s.begin();
 debug(ans);
 for(__int64 i = 0; i < m; i++) {
  __int64 y;
  cin >> y;
  if(sum > k) break;
  sum += y;
  if(sum > k) break;
  debug(ans , sum);
  ans = max(ans , i + 1 + (__int64)( upper_bound(s.begin() , s.end() , k - sum) - s.begin()));
 }
 cout << ans << '\n';
 return 0;
}


Measured memory_bytes: 5296
/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
//const ll mod = 998244353;

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define ss(ch) scanf("%s",ch)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(x,y,z) printf("%d %d %d",x,y,z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define plll(x,y,z) printf("%lld %lld %lld",x,y,z)
#define ps(ch) printf("%s",ch)
#define F(i,a,b)      for(int i= a; i <= b; i++)
#define R(i,b,a)      for(int i= b; i >= a; i--)

const int N = 90001;
const int M = 1e5 + 5;

int px[N], py[N];
int ans[N];
int main()
{
  //FASTIO
  /*
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
//*/

  int n, m, D;
  siii(n, m, D);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int x;
      si(x);
      px[x] = i;
      py[x] = j;
    }
  }

  for (int i = D + 1; i <= n * m; i++)
    ans[i] = ans[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
  int q;
  si(q);
  while (q--) {
    int l, r;
    sii(l, r);
    printf("%d\n", ans[r] - ans[l]);
  }
  return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
#include<string.h>

int main(){

  char s[11];
  char t[11];
  scanf("%s",s);
  scanf("%s",t);

  if((strstr(t,s)!=NULL)&&(strstr(t,s)==&t)){
    printf("Yes");
  }else{
    printf("No");
  }


  return 0;
}


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

typedef long long ll;

const int maxn = 100000 + 10;

struct Store {
	int A;
	int B;
};

Store s[maxn];

bool cmp(Store a, Store b)
{
	return a.A < b.A;
}

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> s[i].A >> s[i].B;
	
	sort(s, s + n, cmp);

	ll count = 0;
	int now = 0;

	while (m) {
		while (s[now].B && m) {
			s[now].B--;
			m--;
			count += s[now].A;
		}

		now++;
	}

	cout << count;

	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
    int n;
    long long k;
    cin >> n >> k;
    vector<vector<int>> g(n);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a--;
        g[i].push_back(a);
    }

    vector<long long> d(n, -1LL);
    queue<int> q;
    q.push(0);
    d[0] = 0LL;
    int s = -1;
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto& c : g[v]) {
            if (d[c] != -1) {
                s = c;
                continue;
            }
            d[c] = d[v] + 1LL;
            q.push(c);
        }
    }

    long long mx = -1;
    for (int i = 0; i < n; i++) { mx = max(mx, d[i]); }
    int ans;
    if (k <= d[s]) {
        for (int i = 0; i < n; i++) {
            if (d[i] == k) ans = i + 1;
        }
    } else {
        long long a = (k - d[s]) % (mx - d[s] + 1LL);
        for (int i = 0; i < n; i++) {
            if (d[i] == d[s] + a) ans = i + 1;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15292
N = int(input())
p_list = list(map(int, input().split()))

counter = 0
for pair in zip(p_list, range(1, len(p_list) + 1)):
    if pair[0] - pair[1] != 0:
        counter += 1

if counter == 0 or counter == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

int main() {
  int A, B, C, X, Y, yen = 0;
  cin >> A >> B >> C >> X >> Y;
  if(A >= 2 * C) {
    yen += X * 2 * C;
    Y = max(Y - X, 0);
    X = 0;
  }
  if(B >= 2 * C) {
    yen += Y * 2 * C;
    X = max(X - Y, 0);
    Y = 0;
  }
  if(A + B >= 2 * C) {
    int num = min(X, Y);
    yen += num * 2 * C;
    X -= num;
    Y -= num;
  }
  if(X > 0)
    yen += X * A;
  if(Y > 0)
    yen += Y * B;
  cout << yen << endl;
}

Measured memory_bytes: 256
import string

count = {x: 0 for x in string.ascii_lowercase}
lines = ""

while True:
    try:
        lines += input().lower()
    except EOFError:
        break

for c in lines:
    if 'a' <= c <= 'z':
        count[c] += 1

for key in string.ascii_lowercase:
    print("{0} : {1}".format(key, count[key]))

Measured memory_bytes: 8068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()


int main(){
    string  a, b;
    cin >> a >> b;
    ll n = stoi(a+b);
    ll x = sqrtl(n);
    if(x*x == n){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define N 2001
#define NN 100005
#define LL long long
#define end1 "\n"
#define sp " "
using namespace std;
LL int q,n,m,ar[N][N],pr1[N][N],pr2[N][N],prt[N][N],pryan[N][N],prust[N][N];
void build()
{
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			pr1[i][j]+=pr1[i][j-1]+pr1[i-1][j]-pr1[i-1][j-1];
			if(ar[i][j])
			{
				if(ar[i-1][j])
					pr1[i][j]++,pryan[i][j]++;
				if(ar[i][j-1])
					pr1[i][j]++,prust[i][j]++;
			}
			prust[i][j]+=prust[i][j-1];
			pryan[i][j]+=pryan[i-1][j];
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			prt[i][j]+=prt[i][j-1];
			prt[i][j]+=(prt[i-1][j]-prt[i-1][j-1]);
			if(ar[i][j])
				prt[i][j]++;
		}
}
void build2()
{
	for(int i=1;i<=n;i++)
	 {
		for(int j=1;j<=m;j++) 
		{
			prt[i][j]=prt[i][j-1]+prt[i-1][j]-prt[i-1][j-1]+ar[i][j];
			pr1[i][j]=pr1[i][j-1]+pr1[i-1][j]-pr1[i-1][j-1];
			pr2[i][j]=pr2[i][j-1]+pr2[i-1][j]-pr2[i-1][j-1];
			if(ar[i][j] && ar[i][j-1])
				pr2[i][j]++;
			if(ar[i][j] && ar[i-1][j])
				pr1[i][j]++;
		}
	}
}
void f2(int a,int b,int c,int d)
{
		int t1=pr2[c][d]-pr2[a-1][d]-pr2[c][b]+pr2[a-1][b]+pr1[c][d]-pr1[a][d]-pr1[c][b-1]+pr1[a][b-1];
		int t2=prt[c][d]-prt[a-1][d]-prt[c][b-1]+prt[a-1][b-1];
		cout<<t2-t1<<endl;
}		
void f(int x1,int y1,int x2,int y2)
{
	int sum;
	int t1,t2;
	t1=prt[x2][y2]-prt[x2][y1]-prt[x1][y2]+prt[x1][y1];
	t2=pr1[x2][y2];
	int q,k;
	q=pryan[x2][y1]-pryan[x1][y1];
	k=prust[x1][y2]-prust[x1][y1];
	t2=t2-q-k;
	cout<<t1<<sp<<t2<<endl;
}
char s[N][N];
int main()
{
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	cin>>n>>m>>q;
	for(int i=1;i<=n;i++)
		cin>>s[i]+1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		ar[i][j]=s[i][j]-'0';
	int x1,x2,y1,y2;
	build2();
	
	//~ cout<<endl;
	//~ for(int i=1;i<=n;i++)
	//~ {
		//~ for(int j=1;j<=m;j++)
			//~ cout<<pr1[i][j]<<sp;
		//~ cout<<endl;
	//~ }	
	
	//~ cout<<endl;	
	
	//~ for(int i=1;i<=n;i++)
	//~ {
		//~ for(int j=1;j<=m;j++)
			//~ cout<<prust[i][j]<<sp;
		//~ cout<<endl;
	//~ }
	
	//~ cout<<endl;	
	
	//~ for(int i=1;i<=n;i++)
	//~ {
		//~ for(int j=1;j<=m;j++)
			//~ cout<<pryan[i][j]<<sp;
		//~ cout<<endl;
	//~ }
	
	//~ cout<<endl;	
	
	for(int i=1;i<=q;i++)
		cin>>x1>>y1>>x2>>y2,f2(x1,y1,x2,y2);
			
}	


Measured memory_bytes: 131968
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)

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

    vector<int> h(N);
    rep(i, 0, N) cin >> h[i];

    vector<int> dp(N, 10000);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    rep(i, 2, N) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
long long K, C[8];
char p[10]="FESTIVAL";
int main(){
    int i, j, k;
    scanf("%lld",&K);
    for(i=0;i<=10 && K;i++){
        if(i==0){
            for(j=0;j<7;j++){
                C[j]=1;
                printf("%c",p[j]);
            }
        }
        else{
            for(j=6;j>=1;j--){
                C[j]+=C[j-1];
                printf("%c",p[j]);
            }
            for(j=0;C[0]!=C[1];j++){
                C[0]++;
                printf("%c",p[0]);
            }
        }
        long long tp = K/C[6];
        if(i!=10){
            for(j=0;j<tp%2;j++)printf("L");
            K -= C[6]*(tp%2);
        }
        else{
            for(j=0;j<tp%100;j++){
                printf("L");
            }
            K -= C[6]*(tp%100);
        }
    }
    if(!K)return 0;
    for(i=1;i<=6 && K;i++){
        for(j=6;j>=i;j--){
            C[j] += C[j-1]*99;
            for(k=0;k<99;k++)printf("%c",p[j]);
        }
        long long tp = K/C[6];
        if(i!=6){
            for(j=0;j<tp%100;j++)printf("L");
            K-=C[6]*(tp%100);
        }
        else{
            for(j=0;j<tp;j++)printf("L");
            return 0;
        }
    }
}

Measured memory_bytes: 128
//                      Aman Raj  - AmanRaj1608
#include<bits/stdc++.h>
using namespace std;
#define ll                        long long
#define vi                        vector<int>
#define pb                        emplace_back
#define rep(i,a,b)                for(int i = a; i<b; ++i)
#define rrep(i,a,b)               for(int i = a; i>=b; --i)
#define p(a)                      cout << a << "\n";
#define p2(a,b)                   cout << a << " " << b << "\n";
#define fast_io                   ios_base::sync_with_stdio(false);cin.tie(NULL);
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://

int32_t main() {
	fast_io;
    ll tt = 1;
	// cin >> tt;
    while(tt--) {
		int n;	cin >> n;
		vi a(n),b(n),c(n);
		rep(i,0,n)	cin >> a[i] >> b[i] >> c[i];

		int dp[n][3];
		// Base Cases
		dp[0][0] = a[0];  dp[0][1] = b[0];  dp[0][2] = c[0];
		rep(i,1,n) {
			dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
			dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
			dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
		}
		cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
    }
    return 0;
}
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
long long a[200001],b[200001];
int main()
{
	a[0]=0;
	long long n,m,k;
	cin>>n>>m>>k;
	int T=n;
	long long t=1,l=1,cnt1=0,cnt2=0;
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]+=a[i-1];
		if(a[i]>k)
			T=i-1;
	}
	for(int i=1;i<=m;i++)
	{
		cin>>b[i];
		b[i]+=b[i-1];
	}
	int place=m;
	for(int i=0;i<=T;i++)
	{
		long long k2=k-a[i]; 
		for(int j=place;j>=0;j--)
		{
			//cout<<"i:"<<i<<" j:"<<j<<" place:"<<place<<" k2:"<<k2<<" ans:"<<ans<<endl;
			if(b[j]<=k2)
			{
				ans=max((long long)i+j,ans),place=j;
				break;
			}
		}
	} 
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6760
def unification(S: str) -> int:
    c0 = sum([int(c) for c in S])
    c1 = sum([1 - int(c) for c in S])

    return min(c0, c1) * 2


if __name__ == "__main__":
    S = input()
    answer = unification(S)
    print(answer)


Measured memory_bytes: 3956
#include<bits/stdc++.h>
    using namespace std;
    int main(){
      char str[4];
      cin>>str;
      if(str[0]==str[1]&&str[1]==str[2]||str[1]==str[2]&&str[2]==str[3]||str[0]==str[1]&&str[1]==str[2]&&str[2]==str[3])cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }

Measured memory_bytes: 256
/*
	*	Created By: 'Present_Sir'
	*	Created On: Thursday 27 August 2020 02:26:52 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define lgt(s) ((int)s.length())
#define int long long
using namespace std;

class Solver{
    public:
        void test(){
            //int t; cin>>t; for(int i=1; i<=t; ++i)
            {
                //cout<<"Case #"<<i<<": ";
                this->solve();
            }
        }
        void solve(){
            int ar[5];
            for(int i=0; i<5; ++i){
                cin>>ar[i];
                if(ar[i] == 0){
                    cout<<i+1<<endl;
                    return;
                }
            }
        }
};


int32_t main(){
    IOS;
    Solver S;
    S.test();
    return 0;
}



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

typedef long long LL;

int main(){
	LL n, t;
	int k;
	scanf("%lld%lld", &n, &t);

	LL tle = 1000000000 / t + 1;
	LL tm = 0;
	while(scanf(" n^%d+", &k) == 1){
		LL s = 1;
		for(int i = 0; i < k; ++i){
			s = min(s * n, tle);
		}
		tm = min(tm + s, tle);
	}

	if(tm < tle){
		printf("%lld\n", tm * t);
	}
	else{
		puts("TLE");
	}
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] In = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int a = In[0];
            int b = In[1];
            if (b % a == 0) b += a;
            else b -= a;
            Console.WriteLine(b);
        }
    }
}


Measured memory_bytes: 28276
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    //NO_TLE
    LL n;
    cin>>n;
    cout<<n*(n-1)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); 
        int ans = 0;
		int [] in = new int [n];
        for(int i=0;i<n;i++){in[i] = sc.nextInt();}
        Arrays.sort(in);
        for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
        int small = j;
        int big = n;
        int point = (small+big)/2;
        int size = point-small;               
        while(big-small>1){size = Math.max(size/2,1);
                         if(in[i]+in[j]>in[point]){small=point;point+=size;}
                         else{big=point;point-=size;}                
                        }
        ans+=small-j;
        }                              
                              }         
        System.out.println(ans);
	}
}

Measured memory_bytes: 27408
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

ll inf = 1000000000000000;
vector<vector<ll>> dp;
int n;
vector<ll> a,s;

ll rec(int l = 0, int r = n) {
  if ((r - l) <= 1) return 0;
  if ((r - l) == 2) {
    return a[l] + a[l+1];
  }

  if (dp[l][r] != inf) return dp[l][r];
  for (int i = l+1; i <= r-1; i++) {
    chmin(dp[l][r], rec(l,i) + rec(i,r) + s[r] - s[l]);
  }

  return dp[l][r];
}

int main() {
  cin >> n;
  a.resize(n);
  rep(i,0,n) cin >> a[i];
  s.resize(n+1);
  rep(i,0,n) {
    s[i+1] = s[i] + a[i];
  }
  dp.assign(n+2,vector<ll>(n+2,inf));
  cout << rec() << endl;
  return 0;
}


Measured memory_bytes: 4920