akhauriyash/Code-Regression huggingface dataset:
using System;

namespace AtCoder_20190218
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string str1 = Console.ReadLine();
            int[] An = new int[int.Parse(str)];

            string[] ss = str1.Split(' ');
            bool isContinue = true;
            int count = 0;
            for (int i = 0; i < An.Length; i++)
            {
                An[i] = int.Parse(ss[i]);
            }

                while (isContinue)
            {
                for (int i = 0; i < An.Length; i++)
                {
                    if (An[i] % 2 == 0)
                    {
                        An[i] = An[i] / 2;
                    }
                    else
                    {
                        isContinue = false;
                        count--;
                        break;
                    }
                }
                count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    while (true) {
        val h = sc.nextInt()
        val w = sc.nextInt()
        if (h == 0 && w == 0) break

        for (i1 in 1..h) {
            for (i2 in 1..w) {
                print(if ((i1 + i2) % 2 == 0) "#" else ".")
            }
            println()
        }
        println()
    }
}


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

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    cin >> A.at(i);
  }

  // x日目に、株の売却が終了した時点の所持金の最大値
  vector<ll> dp(N + 1, 0);
  // 1日目の所持金の最大値
  dp.at(1) = 1000;
  for (int i = 2; i <= N; i++) {
    // 最初に、株の売買をしないパターンをセット
    dp.at(i) = dp.at(i - 1);

    // * j日目 (1日目, 2日目, ... , i-1日) に現金で最大限に株を購入し、
    //   それをi日目に売った際の所持金をシミュレーションする
    //
    // * 何もしない場合 (前日と同じ金額を保持する場合) と比較して、
    //   手持ちの金額が最大化するケースをi日目の所持金 dp.at(i) とする
    //
    // * i = N となる最終日は、j = 1 〜 N-1 日目のそれぞれについて、
    //   以下のケースを計算し、所持金が最大化するケースを採用する
    //   * j日に取りうる最大の所持金を保持している状態
    //   * j日に最大限に株を購入し、i = N日に売却する
    //
    for (int j = 1; j <= i - 1; j++) {
      ll V = dp.at(j) / A.at(j);
      ll W = dp.at(j) + (A.at(i) - A.at(j)) * V;

      dp.at(i) = max(dp.at(i), W);
    }
  }

  cout << dp.at(N) << endl;
  return 0;
}

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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  long long ans = 1e18;
  for (int p = 0; p <= 100; ++p) {
    long long cur = 0;
    for (int i = 0; i < n; ++i) {
      cur += (x[i] - p) * (x[i] - p);
    }
    ans = min(ans, cur);
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
	int x, h;
	double S;
	while(1){
		scanf("%d", &x );
		scanf("%d", &h );
		if( !x && !h )	break;
		double b = sqrt( x*x/4.0 + h*h );
		S = x*x + 2*b*x;
		printf("%.6f\n", S);
	}
	return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

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

int main(){
    CININIT;
    ll N,L;cin>>N>>L;
    vector<ll> a(N);
    rep(i,N) cin>>a[i];

    int t=-1;
    for(int i=0;i<N-1;i++){
        int sum = a[i] + a[i+1];
        if(sum>=L){
            t=i;
            break;
        }
    }

    if(t==-1){
        cout << "Impossible" << endl;
        return 0;
    }

    cout << "Possible" << endl;

    for(int i=0;i<t;i++){
        cout << i+1 << endl;
    }
    for(int i=N-2;i>t;i--){
        cout << i+1 << endl;
    }
    cout << t+1 << endl;
}


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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	int rectNum = 0;
	int rhomNum = 0;
	int a;
	int b;
	int c;
	while( scanf("%d,%d,%d", &a, &b, &c) != EOF )
	{
		if( a == b )
		{
			rhomNum++;
		}
		if( a * a + b * b == c * c )
		{
			rectNum++;
		}
	}
	printf("%d\n%d\n", rectNum, rhomNum);
	return (0);
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI v(n);
	rep(i, n) cin >>v[i];
	
	map<int, int> me, mo;
	rep(i, n){
		if(i%2) mo[v[i]]++;
		else me[v[i]]++;
	}
	multimap<int, int> ye, yo;
	for(auto x: me) ye.insert(pii(-x.second, x.first));
	for(auto x: mo) yo.insert(pii(-x.second, x.first));
	
	auto ite = ye.begin(), ito = yo.begin();
	int ans = min(n + ite->first, n + ito->first);
	for(int i=0; ite !=ye.end() && i<4; ite++, i++){
		ito = yo.begin();
		for(int j=0; ito !=yo.end() && j<4; ito++, j++){
			if(ite->second == ito->second) continue;
			int ct = n +ite->first + ito->first;
			
			//dbg(i,j,ct, ans);
			ans = min(ans, ct);
		}
	} 
	cout << ans <<"\n";

	return 0;
}


Measured memory_bytes: 9984
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] Line = S.Split(' ');
            int A = int.Parse(Line[0]);
            int B = int.Parse(Line[1]);

            if(A - B * 2 < 0)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine(A - B * 2);
            }

        }
    }
}

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

int main() {
    int d, g;
    cin >> d >> g;

    vector<int> p(d), c(d);

    for (int i = 0; i < d; i++) {
        cin >> p.at(i);
        cin >> c.at(i);
    }
    int answer = 1001;

    for (int bit = 0; bit < (1 << d); bit ++) {
        int total = 0;
        int count = 0;
        for (int i = 0; i < d; i++) {
            if (bit & (1 << i)) {
                total += (i + 1) * 100 * p.at(i) + c.at(i);
                count += p.at(i);
            }
        }
        if (total < g) {
            int maxUnused = -1;
            for (int i = d - 1; i >= 0; i--) {
                if (!(bit & (1 << i))){
                    maxUnused = i;
                    break;
                }
            }
            if(maxUnused >= 0) {
                for (int i = 0; i < p.at(maxUnused); i++) {
                    total += (maxUnused + 1) * 100;
                    count ++;
                    if (total >= g) break;
                }
            }
        }
        if (total >= g) answer = min(answer, count);
    }
    cout << answer << endl;


    return 0;
}

Measured memory_bytes: 3628
s=list(map(int,input().split()))

oklist=[]

def keta(x):
    ketalist=[]
    for j in range(len(x)):
        ketalist.append(int(x[j]))
    return(sum(ketalist))
        
    

for i in range(s[0]+1):
    check=keta(str(i))
    if(s[1]<=check and check<=s[2]):
        oklist.append(i)     
sum_=sum(oklist)
print(sum_)

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

int main(){
    string S;
    cin >> S;
    int Ans=0, p=0, L;
    L=S.size();
    while( p < L-2){
        if(S.at(p)!=S.at(p+1)){
            ++Ans;
            p+=1;
        }else{
            ++Ans;
            ++Ans;
            p+=3;
        }        
    }
    if(p==L-2){
        if(S.at(L-2)==S.at(L-1)){
            ++Ans;
        }else{
            ++Ans;
            ++Ans;
        }
    }else if(p==L-1){
        ++Ans;
    }
    
    cout << Ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
  #define ll long long
int counter(ll n)
{
    int cnt = 0 ;
    while(n)
    {
        n/=10;
        cnt++;
    }
    return cnt ;
}

int main()
{
  ll n,m;
  cin >> n ;
  int mn = INT_MAX;
  for(ll i=1; i*i<=n; i++)
  {
      if(n%i==0)
      {
          int mx = 0;
          int x = counter(i);
          int y = counter(n/i);
          mx = max(x,y);
          mn = min(mn,mx);
      }
  }

  cout << mn << endl;
}


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

const int MOD = 1e9 + 7;

long long fact(long long x)
{
	long long ans = 1;
	for (int i = 1; i <= x; i++)
	{
		ans *= i;
		ans %= MOD;
	}

	return ans;
}

long long power(long long n, long long k)
{
	if (k == 0)
		return 1;
	else if (k % 2)
		return ((n % MOD) * (power(n, k - 1) % MOD)) % MOD;
	else
	{
		long long half = power(n, k / 2);
		return ((half % MOD) * (half % MOD)) % MOD;
	}
}

int main()
{
	long long p, q, x, y;
	scanf("%lld %lld", &p, &q);
	x = (2 * p - q) / 3, y = (2 * q - p) / 3;
	if (x < 0 || y < 0 || (p + q) % 3)
	{
		printf("0");
		return 0;
	}
	x = x + y;

	long long a = fact(x);
	long long b = 1LL * fact(x - y) * fact(y);
	b = power(b, MOD - 2);

	printf("%lld", a * b % MOD);
}

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

//i番目の数を変えるとする
int gcd(int x, int y) {
    return x ? gcd(y%x, x) : y;
}

int main() {
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    vector<int> left(N);
    left[0] = a[0];
    for (int i = 1; i < N; i++) {
        left[i] = gcd(a[i], left[i-1]);
    }
    vector<int> right(N);
    right[N-1] = a[N-1];
    for (int i = N-2; i >= 0; i--) {
        right[i] = gcd(a[i], right[i+1]);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int val;
        if (i == 0) val = right[1];
        else if (i == N-1) val = left[N-2];
        else val = gcd(left[i-1], right[i+1]);
        ans = max(ans, val);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=100005;
//i_am_noob
int n;
string str;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> str;
	if(sz(str)<=n) print1(str);
	else{
		print1(str.substr(0,n)+"...");
	}
	return 0;
}

Measured memory_bytes: 3652
N,T = map(int,input().split())
list_t = list(map(int,input().split()))

counter=0
last_pushed=0
for t in list_t:
  if t<=last_pushed+T:
    # print("t",t)
    # print("last_pushed+T",last_pushed+T)
    #水がまだ出ている状態なら
    counter+=(t-last_pushed)
    last_pushed=t
    #最後に押した時間を変えて終了
  elif t>last_pushed+T:
    #水が止まっている状態なら
    counter+=T
    last_pushed=t

print(counter+T)    
  

Measured memory_bytes: 26836
def main():
    ABC = list(map(int, input().split()))
    A, B, C = ABC[0], ABC[1], ABC[2]
    if A < C:
        if C < B:
            print('Yes')
        else:
            print('No')
    if A > C:
        if C > B:
            print('Yes')
        else:
            print('No')
main()

Measured memory_bytes: 3060
N, M, Q = map(int, input().split())
train = [[0 for _ in range(N + 1)]for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    train[L][R] += 1
# print(train)

cumsum = [[0 for _ in range(N + 1)]for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, N + 1):
        cumsum[i][j] = cumsum[i][j - 1] + train[i][j]
# print(cumsum)

for _ in range(Q):
    p, q = map(int, input().split())
    tmp = 0
    for i in range(p, q + 1):
        tmp += cumsum[i][q] - cumsum[i][p - 1]
    print(tmp)


Measured memory_bytes: 80180
#include <bits/stdc++.h>
#define prt_cs                  printf("Case %lld: ",cs)
#define sqr(x)                  (x)*(x)
#define ms(a,b)                 memset(a, b, sizeof(a))
#define db                      double
#define ll                      long long int
#define MOD                     100000007
#define PI                      2*acos(0.0)
#define pii                     pair< int, int >
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
#define gcd(a, b)               __gcd(a, b)
#define lcm(a, b)               (((a)*(b))/gcd(a,b))
#define MAX                     100005

using namespace std;

ll a[MAX][3];

ll dp[MAX][4];

ll solve(int idx,int n,int last)
{
    if(idx==n)
    {
        return 0;
    }
    if(dp[idx][last]!=-1)return dp[idx][last];
    ll ans=0;
    for(int i=0;i<3;i++)
    {
        if(i==last)continue;
        ans=max(ans,a[idx][i]+solve(idx+1,n,i));
    }
    return dp[idx][last]=ans;
}

int main()
{
//    READ;
//    WRITE;
    ms(dp,-1);
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            scanf("%lld",&a[i][j]);
        }
    }
    ll ans=solve(0,n,3);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 13568
class Cube:
    def __init__(self, x, y, z, s):
        self.x, self.y, self.z = x, y, z
        self.s = s

    def is_in_cube(self, x, y, z):
        return self.x <= x <= self.x + self.s and self.y <= y <= self.y + self.s and self.z <= z <= self.z + self.s

    def intersect(self, C):
        dxyz = [(0, 0, 0),
                (C.s, 0, 0), (0, C.s, 0), (0, 0, C.s),
                (C.s, C.s, 0), (C.s, 0, C.s), (0, C.s, C.s),
                (C.s, C.s, C.s)]
        for dx1, dy1, dz1 in dxyz:
            nx1, ny1, nz1 = C.x + dx1, C.y + dy1, C.z + dz1
            if self.is_in_cube(nx1, ny1, nz1):
                for dx2, dy2, dz2 in dxyz:
                    nx2, ny2, nz2 = self.x + dx2, self.y + dy2, self.z + dz2
                    if C.is_in_cube(nx2, ny2, nz2):
                        a, b, c = abs(nx1 - nx2), abs(ny1 - ny2), abs(nz1 - nz2)
                        if a * b * c == 0:
                            continue
                        # print(a, b, c, end=':')
                        return 2 * (a * b + b * c + c * a)
        return 0


edges = list()
inters = dict()


def calc_overlap(vs):
    ret = sum(inters.get((vs[i], vs[i + 1]), 0) for i in range(len(vs) - 1))
    if len(vs) > 2:
        ret += inters.get((vs[-1], vs[0]), 0)
    return ret


def dfs(v, par, vs, res):
    if res == 0:
        return calc_overlap(vs)

    ret = -1

    for e in edges[v]:
        if e != par:
            vs.append(e)
            ret = max(ret, dfs(e, v, vs, res - 1))
            vs.pop()
    return ret


while True:
    N, K, S = map(int, input().split())
    # print((N, K, S))
    if not (N | K | S):
        break
    cubes = []
    for _ in range(N):
        x, y, z = map(int, input().split())
        cubes.append(Cube(x, y, z, S))
    # cubes = [Cube(*map(int, input().split()), S) for _ in range(N)]
    edges = [[] for _ in range(N)]
    inters = dict()
    for i in range(N):
        for j in range(i + 1, N):
            sur = cubes[i].intersect(cubes[j])
            if sur > 0:
                # print(i, j, cubes[i].intersect(cubes[j]))
                inters[i, j] = inters[j, i] = sur
                edges[i].append(j)
                edges[j].append(i)
    # print(edges, inters)

    ans = -1
    for i in range(N):
        ans = max(ans, dfs(i, -1, [i], K - 1))

    print(-1 if ans == -1 else S * S * 6 * K - ans)

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


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

	vector<ll> v(n);
	unordered_set<ll> s;
	for(auto& e : v) {
		cin >> e;
		s.insert(e);
	}
	sort(v.begin(), v.end());

	int ans = 0;
	for(int i=0;i<n;i++) {
		for(int j=i+1;j<n;j++) {
			int cnt = 2;
			ll nv = v[j] + (v[j] - v[i]);
			while(s.count(nv) > 0) {
				cnt++;
				nv += (v[j] - v[i]);
			}
			ans = max(ans, cnt);
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll a[200000];
int main() {
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    sort(a, a+n, greater<ll>());
    priority_queue<ll> pq;
    ll ans=0;
    pq.push(a[0]);
    for(int i=1;i<n;++i){
        ans += pq.top();
        pq.pop();
        pq.push(a[i]);
        pq.push(a[i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6928
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}


long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}

class Point{
public:
	long long x;
	long long y;
};
long long N,M;
vector<long long>X(100006,0);
bool isOK(long long time){
	long right=0;
	for(int i=0;i<M;i++){
		if(right>=X[i]-1){
			//go right
			right=X[i]+time;
		}else{
			if(right < X[i]-time-2)return false;
			right=max(X[i],X[i]+(time-(2*(X[i]-right)-1)));
		}
		//cout<<right<<endl;
	}
	if(right<N-1)return false;
	return true;
	
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long Q,H,S,D;
	cin>>Q>>H>>S>>D;
	long long N;
	cin>>N;
	
	S=min(S,min(4*Q,2*H));
	
	if(2*S<=D){
		cout<<S*N<<endl;
	}else{
		if(N%2==1){
			cout<<(N/2)*D+S<<endl;
		}else cout<<(N/2)*D<<endl;
	}
}


Measured memory_bytes: 1024
let n = stdin.ReadLine() |> int
let h = stdin.ReadLine().Split() |> Array.map int64

Array.scan (fun (h1,c1,h2,c2) t -> (h2,c2,t,Array.min [|c1+(abs (t-h1));c2+(abs (t-h2))|])) (h.[0],0L,h.[1],(abs (h.[1]-h.[0]))) h.[2..n-1]
|> ((fun x -> x.[n-2]) >> (fun (_,_,_,c2) -> c2))
|> stdout.WriteLine

Measured memory_bytes: 50508
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int Mod=1e9+7;
int qpow(int x,int y){
	int res=1;
	for (;y;y>>=1,x=1LL*x*x%Mod)
		if (y&1) res=1LL*res*x%Mod;
	return res;
}
int S[210][210];
int fac[210];

int n,m,k;
struct Edge{
	int to,nxt;
}edge[210];
int cnt=1,last[55];
inline void addedge(int x,int y){
	edge[++cnt]=(Edge){y,last[x]},last[x]=cnt;
	edge[++cnt]=(Edge){x,last[y]},last[y]=cnt;
}
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int dfn[55],low[55];
int stk[55],top; int col,siz[55],tot[55],c[55];  //siz edgetot
void tarjan(int x){
	dfn[x]=low[x]=++*dfn; stk[++top]=x;
	for (int i=last[x],v;i;i=edge[i].nxt)
		if (!dfn[v=edge[i].to]){
			int t=top; tarjan(v);
			low[x]=min(low[x],low[v]);
			if (low[v]>=dfn[x]){
				col++; stk[++top]=x; siz[col]=top-t;
				for (int j=t+1;j<=top;j++) c[stk[j]]=col;
				for (int j=t+1;j<=top;j++){
					int xx=stk[j];
					for (int e=last[xx];e;e=edge[e].nxt){
						int yy=edge[e].to;
						if (c[yy]==col) tot[col]++;
					}
				}
				tot[col]>>=1;
				top=t;
			}
		}
		else low[x]=min(low[x],dfn[v]);
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	S[0][0]=1;
	for (int i=1;i<=m;i++)
		for (int j=1;j<=i;j++)
			S[i][j]=(1LL*S[i-1][j]*(i-1)+S[i-1][j-1])%Mod;
	fac[0]=1; for (int i=1;i<=m;i++) fac[i]=1LL*fac[i-1]*i%Mod;
	for (int i=1;i<=m;i++){
		int x,y; scanf("%d%d",&x,&y);
		addedge(x,y);
	}
	for (int i=1;i<=n;i++) if (!dfn[i]) tarjan(i);
	int ans=1,sum=1,nodetot=0;
	for (int i=1;i<=col;i++){
		if (siz[i]==2){nodetot++;continue;}
		if (tot[i]==siz[i]){
			int subans=0;
			for (int j=0;j<tot[i];j++) subans=(subans+qpow(k,gcd(j,tot[i])))%Mod;
			ans=1LL*ans*subans%Mod;
			sum=1LL*sum*tot[i]%Mod;
			continue;
		}
		int subans=0;
		for (int j=1;j<=tot[i];j++) subans=(subans+1LL*qpow(k,j)*S[tot[i]][j])%Mod;
		ans=1LL*ans*subans%Mod;
		sum=1LL*sum*fac[tot[i]]%Mod;
	}
	ans=1LL*ans*qpow(k,nodetot)%Mod;
	ans=1LL*ans*qpow(sum,Mod-2)%Mod;
	printf("%d\n",(ans+Mod)%Mod);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    vector<int> A(N);
    int minv = 101, maxv = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        minv = min(minv, A[i]);
        maxv = max(maxv, A[i]);
    }

    int ans = 1<<30;
    for(int i=minv; i<=maxv; i++){
        int tmp = 0;
        for(int j=0; j<N; j++){
            tmp += (A[j] - i) * (A[j] - i);
        }
        ans = min(tmp, ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
std::set<unsigned int> all;
unsigned int func(unsigned int s, unsigned int ind = 1) {
    all.insert(s);
    unsigned int nxt = (s & 1) ? ((s * 3) + 1) :  (s / 2);
    ind += 1;
    if (all.find(nxt) != all.cend()) return ind;    
    return func(nxt , ind);
}

int main() {
    unsigned int s;
    cin >> s;
    cout << func(s) << endl;

    return 0;
}


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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


long long floor_sum(long long n, long long m, long long a, long long b) {
    long long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

signed main() {
	int t;
	cin >> t;
	while (t--) {
		int n, m, a, b;
		cin >> n >> m >> a >> b;
		cout << floor_sum(n, m, a, b) << endl;
	}
}

Measured memory_bytes: 3628
import bisect

nums = [0, 0] + [1 for i in range(10**5-2)]
x = []

for i in range(2, 10**5):
    if nums[i]:
        for l in range(i*2, 10**5, i):
            nums[l] = 0
        if nums[(i+1)//2]:
            x.append(i)

Q = int(input())
for i in range(Q):
    l, r = list(map(int, input().split()))
    l_ = bisect.bisect_left(x, l)
    r_ = bisect.bisect_right(x, r)
    print(r_-l_)

Measured memory_bytes: 4632
#include <iostream>
#include <cstdio>
#define N 300005
using namespace std;

typedef long long ll;
ll M = 998244353;
ll n, a, b, k, s, fac[N]{1, 1}, inv[N]{1, 1}, fin[N]{1, 1};

ll f(ll p, ll q) {
	return fac[p] * fin[p - q] % M * fin[q] % M;
}

int main()
{
	ll i, j;
	cin >> n >> a >> b >> k;
	for (i = 2; i <= n; i++) fac[i] = fac[i - 1] * i % M;
	for (i = 2; i <= n; i++) inv[i] = inv[M % i] * (M - M / i) % M;
	for (i = 2; i <= n; i++) fin[i] = fin[i - 1] * inv[i] % M;
	for (i = 0; a * i <= k && i <= n; i++) {
		j = (k - a * i) / b;
		if (a * i + b * j != k || j > n) continue;
		s = (s + f(n, i) * f(n, j)) % M;
	}
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 7296
#include <queue>
#include <string>
#include <iostream>
using namespace std;
int main() {
	string cmd; // while ????????´??§??????????????????????????°???????????¨??????
	priority_queue<int> Q;
	int value;

	while (cin >> cmd && cmd != "end") {
		if (cmd == "insert") {
			cin >> value;
			Q.push(value);
		
		} else if (cmd == "extract") {
			cout << Q.top() << endl;
			Q.pop();
		}
	}
}

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

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

struct Task {
	string name = "";
	int time = 0;
};

// FILO
class Queue {
public:

	Queue(int size) : array_(size), head_(0), tail_(0), size_(size) {};

	// キューの末尾に代入
	void enqueue(Task v) {
		array_[tail_] = v;
		tail_ = ++tail_ % size_;
	}

	// キューから出す
	Task dequeue() {
		const auto t = array_[head_];
		head_ = ++head_ % size_;
		return t;
	}

private:
	vector<Task> array_;
	int head_;
	int tail_;
	int size_;
};

int main() {
	int n, q;
	cin >> n >> q;
	
	Queue queue(n + 1);
	rep(i, n) {
		string name; int time;
		cin >> name >> time;
		queue.enqueue({ name, time });
	}

	int count = 0;
	int total_time = 0;

	while (count != n) {
		auto task = queue.dequeue();



		if (task.time - q <= 0) {
			cout << task.name << " " << total_time + task.time << endl;

			total_time += task.time;
			count++;
		}
		else {
			task.time -= q;
			total_time += q;
			queue.enqueue(task);
		}
	}


	return 0;
}


Measured memory_bytes: 5908
n = int(input())
mod = 10 ** 9 + 7

if n < 3:
  print(0)
  exit()
  
elif n < 6:
  print(1)
  exit()

memo = [0, 0, 0, 1, 1, 1]

for i in range(6, n+1):
  j = 3
  tmp = 1
  while i - j >= 3:
    tmp = (tmp + memo[i-j]) % mod
    j += 1
  memo.append(tmp)
print(memo[-1])

Measured memory_bytes: 64360
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include<math.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	bool ans = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= i; j++) {
			if (i * j == n)ans = 1;
		}
	}
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3572
def read_plus_1():
    return(int(input())+1)


a = read_plus_1()
b = read_plus_1()
c = read_plus_1()
x = int(input())

count = 0
for i in range(0, a):
    if i * 500 > x:
        continue
    for j in range(0, b):
        if i * 500 + j * 100 > x:
            continue
        for k in range(0, c):
            if i * 500 + j * 100 + k * 50 == x:
                count += 1
                break
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int N=200005,mod=1e9+7;
int n,a[N],b[N];
int Fac[N],Inv[N];
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1)
			ans=1LL*ans*x%mod;
	return ans;
}
int sum[4002][4002],_0=2001;
int C(int n,int m){
	if (m<0||m>n)
		return 0;
	return 1LL*Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
int add(int a,int b){
	a+=b;
	if (a>=mod)
		a-=mod;
	return a;
}
int del(int a,int b){
	a-=b;
	if (a<0)
		a+=mod;
	return a;
}
int main(){
	Fac[0]=1;
	for (int i=1;i<N;i++)
		Fac[i]=1LL*Fac[i-1]*i%mod;
	Inv[N-1]=Pow(Fac[N-1],mod-2);
	for (int i=N-1;i>=1;i--)
		Inv[i-1]=1LL*Inv[i]*i%mod;
	scanf("%d",&n);
	memset(sum,0,sizeof sum);
	for (int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		sum[-a[i]+_0][-b[i]+_0]++;
	}
	for (int i=1;i<4002;i++)
		for (int j=1;j<4002;j++)
			sum[i][j]=add(sum[i][j],add(sum[i-1][j],sum[i][j-1]));
	int ans=0;
	for (int i=1;i<=n;i++){
		ans=add(ans,sum[a[i]+_0][b[i]+_0]);
		ans=del(ans,C(a[i]+a[i]+b[i]+b[i],b[i]+b[i]));
	}
	ans=1LL*ans*Pow(2,mod-2)%mod;
	printf("%d",ans);
	return 0;
}

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

int main() {
  string S, m;
  cin >> S;
  int N = S.size();
  int count = 0;
  for (int i = 0; i < N; i++) {
    string f = S.substr(i,1);
    if (m == f) {
      m = S.substr(i,2);
      i += 1;
      if (i != N) count += 1;
    }
    else{
      m = f;
      count += 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 644
<?php
$inputNum = trim(fgets(STDIN));

for ($i = 1; $i <= $inputNum; $i++) {
    $num = $i;
    if ($num % 3 == 0) {
        $conditionMatchedNum[] = $i;
        continue;
    }
    while ($num) {
        if ($num % 10 == 3) {
            $conditionMatchedNum[] = $i;
            break;
        }
        $num = floor($num / 10);
    }
}
 
echo ' '.implode(' ', $conditionMatchedNum), PHP_EOL;

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int half;
    if(n % 2 == 0){
        half = n/2;
    }else{
        half = n/2 + 1;
    }
    
    double ans = 0.0;

    ans = (double)half/(double)n;

    cout << ans << endl;
}

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

int s[100005];

int main()
{
   	int a,b;
   	cin >> a >> b;
	/*for(int i = 0; i < n; i++){
		cin >> s[i];
	}*/
	if((a+b)%2==0)
	{
		cout << (a+b)/2;
	}   	
	else cout << "IMPOSSIBLE" << endl;
   	
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

const inf = 1000000000

var N, A, B, C int
var L []int

func main() {
	fmt.Scan(&N, &A, &B, &C)
	L = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&L[i])
	}

	ans := dfs(0, 0, 0, 0)

	fmt.Println(ans)
}

func dfs(dep, aLen, bLen, cLen int) int {
	if dep == N {
		if aLen == 0 || bLen == 0 || cLen == 0 {
			return inf
		}
		return abs(A-aLen) + abs(B-bLen) + abs(C-cLen) - 30
	}
	cost0 := dfs(dep+1, aLen, bLen, cLen)
	cost1 := dfs(dep+1, aLen+L[dep], bLen, cLen) + 10
	cost2 := dfs(dep+1, aLen, bLen+L[dep], cLen) + 10
	cost3 := dfs(dep+1, aLen, bLen, cLen+L[dep]) + 10
	return min(cost0, cost1, cost2, cost3)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(a ...int) (x int) {
	x = a[0]
	for _, i := range a {
		if i < x {
			x = i
		}
	}
	return
}


Measured memory_bytes: 512
def solve(n, d):
    for i in range(n - 2):
        if all(len(d[i + k]) == 1 for k in range(3)):
            return True
    return False


def main():
    n = int(input())
    d = [set(map(int, input().split())) for _ in range(n)]
    print("Yes" if solve(n, d) else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	int r,s,p;cin >> r >> s >> p;
	string t;cin >> t;
	ll ans = 0;
	rep(i,k){
		bool flg = true;
		for(int j = i; j < n; j += k){
			if(j < k){
				if(t.at(j) == 'r') ans += p;
				else if(t.at(j) == 's') ans += r;
				else ans += s;
				flg = false;
			}
			else{
				if(flg){
					if(t.at(j) == 'r') ans += p;
					else if(t.at(j) == 's') ans += r;
					else ans += s;
					flg = false;
				}
				else{
					if(t.at(j) == t.at(j - k)){
						flg = true;
					}
					else{
						if(t.at(j) == 'r') ans += p;
						else if(t.at(j) == 's') ans += r;
						else ans += s;
					}
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
inline int read(){char c = getchar();int x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x)&(-x)
const int N = 1e6 + 5;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const int mod = 998244353;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //    freopen("input.txt","r",stdin);
    //    freopen("output.txt","w",stdout);
    ll n,Max = 0,sum = 0;
    cin >> n;
    ll arr[n+5];
    for(int i = 0;i < n;i++) cin >> arr[i];
    Max = arr[0];
    for(int i = 1;i < n;i++)
    {
        if(arr[i] < Max)
            sum += (Max-arr[i]);
        Max = max(Max,arr[i]);
    }
    cout << sum << endl;
}


Measured memory_bytes: 5168
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using order_statistics_tree = tree<T,null_type,less_equal<T>,rb_tree_tag,
  tree_order_statistics_node_update>;
 #define all(x) (x).begin(),(x).end()

vector<int> u, v, dest;
signed main(){
    int n;
    cin >> n;
    u.resize(n); v.resize(n); dest.resize(n);
    for(auto& i: u) cin >> i;
    for(auto& i: v) cin >> i;
    int ans = 0;
    if(n&1){
        for(auto j: v)ans^=j;
        for(auto j: u)ans^=j;
    }
    sort(all(v));
    for(int i = 28, t = (1<<29)-1; i >=0; i--, t>>=1){
        auto it = upper_bound(all(v), t);
        for(auto&j: v)j&=t;
        merge(v.begin(), it, it, v.end(), dest.begin());
        copy(all(dest), v.begin());
        int cnt = 0;
        for(auto j: u)cnt^=v.end()-upper_bound(all(v), t^j&t);
        ans^=(cnt&1)<<i+1;
    }
    cout << ans <<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
char s[201010]={0};
int main()
{
    int a[111]={0};
    int n;
    int sum=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
    }
    int t=1000000;
    int num=0;
    for(int i=0;i<n;i++){
        num+=a[i];
        t=min(t,max(2*num-sum,sum-2*num));
        //cout << t;

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


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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

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

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); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int d[100001];

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

    int n;
    cin >> n;
    rep(i, n) cin >> d[i];
    int res = 0, cnt = 1;
    sort(d, d + n);
    rep(i, n) {
    	if(d[i] == d[i + 1]) {
    		++cnt;
    	}
    	else {
    		if(cnt % 2 == 1) ++res;
    		cnt = 1;
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())
Alst = list(map(int, input().split()))
Alst.sort()
ans = 1
rec = True
for i in range(N):
    ans = ans * Alst[i]
    if ans > 10**18:
        rec = False
        break

if rec:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 21648
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long K=sc.nextLong();
		long A=sc.nextLong();
		long B=sc.nextLong();

		if(A>=B) {
			System.out.println((K+1));		//ビスケットを交換しないでそのままため続けたほうが良い
			//最初に1枚持っている
			System.exit(0);
		}
		else if(A<B) {	//交換したほうがお得なとき
			long res=K-(A-1);
			long ans=(B-A)*((res)/2);
			if(res%2==0) {
				ans+=A;
			}
			else {
				ans+=A+1;
			}
			ans=Math.max(ans,K+1);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	string s,t; cin>>s>>t;
	int l = s.length();
	int c = 0;
	forn(i,l)
	{
		if(s[i]!=t[i]) c++;
	}
	cout<<c;
	return 0;
}


Measured memory_bytes: 3800
#include <cstdio>
#include <iostream>
using namespace std;
int a,b;
int main()
{
    scanf("%d%d",&a,&b);
    if(a%3==0||b%3==0||(a+b)%3==0) printf("Possible\n");
    else printf("Impossible\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int A,a,b,c,d;
  	cin >> A;
  	if ((A/10)%111 == 0 || (A%1000)%111 == 0 ) {
  		cout << "Yes" << endl;
  	}else{
  		cout << "No" << endl;
	}
}

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

bool sort_pair( std::pair< int, int > origin, std::pair< int, int > another )
{
    return origin.first < another.first;
}


int main()
{
    int64_t a,b;
    b = 0;
    std::cin>> a;

    std::vector< int64_t > dam( a );
    std::vector< int64_t > mountain( a );

    for( int i = 0; i < a; i++ )
    {
        std::cin>> dam[i];
        b += dam[i];
    }

    mountain[0] = b;
    bool finish = true;
    
    for( int i = 1; i < a; i+=2 )
    {
        mountain[0] -= dam[i] * 2;
    }
        
    dam[0] -= mountain[0] / 2;
    dam[a-1] -= mountain[0] / 2;

    for( int i = 1; i < a; i++ )
    {
        mountain[i] = std::min( dam[i], dam[i-1] ) * 2;
        dam[i] -= mountain[i] / 2;
        dam[i-1] -= mountain[i] / 2;
    }
    
    for( int i = 0; i < a; i++ )
    {
        std::cout<< mountain[i] << " ";
        //std::cout<< dam[i] << " ";
    }

}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
string s,st,ss;
int f[3005][3005];
char b[3005][3005];
string truyvet(int x, int y){
    if(x==0||y==0){
        return "";
    }
    if(b[x][y]=='c'){
        return truyvet(x-1,y-1)+s[x-1];
    }
    else
    if(b[x][y]=='l'){
        return truyvet(x-1,y);
    }
    else{
        return truyvet(x,y-1);
    }
}
int main(){
    cin >> s >> st;
    for(int i=0;i<s.size();++i){
        for(int j=0;j<st.size();++j){
            if(s[i]==st[j]){
                f[i+1][j+1]=f[i][j]+1;
                b[i+1][j+1]='c';
            }
            else{
                if(f[i][j+1]>f[i+1][j]){
                    f[i+1][j+1]=f[i][j+1];
                    b[i+1][j+1]='l';
                }
                else
                {
                    f[i+1][j+1]=f[i+1][j];
                    b[i+1][j+1]='q';
                }
            }
        }
    }
    cout << truyvet(s.size(),st.size());
    return 0;
}

Measured memory_bytes: 44672
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;



int main() {
	string s;
	cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3624
a, b, c = map(str, input().split())
s1 = ord(a[0])
s2 = ord(b[0])
s3 = ord(c[0])

c1 = chr(s1)
c2 = chr(s2)
c3 = chr(s3)
print(c1 + c2 + c3)

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

using namespace std;

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

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N; cin >> N;
    cout << (N+1)/2 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	lli n,k,temp,index;
	cin>>n>>k;
	lli a[n],i,j;
	fr(i,n)
	{
		cin>>a[i];
	}
	vector<lli>v,w;
	v.pb(1);
	j=0;
	while(v.size()!=n+1)
	{
		v.pb(a[j]);
		j=a[j]-1;
	}
	map<lli,lli>m;
	fr(i,v.size())
	{
		if(m[v[i]]==0)
			m[v[i]]=1;
		else
		{
			temp=v[i];
			index=i;
			break;
		}
	}
	fr(i,v.size())
	{
		if(v[i]==temp)
		{
			break;
		}
	}
	//cout<<temp;
	if(k<i)
	{
		cout<<v[k];
		return 0;
	}
	else
	{
		k-=i;
	}
	for(j=i;j<index;j++)
		w.pb(v[j]);
	cout<<w[k%w.size()];
	return 0;
}

Measured memory_bytes: 19444