akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
    int N, M; cin >> N >> M;
    vector<ll> A(N);
    vector<pair<ll, int> > K;
    rep(i, N){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    rep(i, M){
        int b; 
        ll c;
        cin >> b >> c;
        K.emplace_back(c, b);
    }
    sort(K.begin(), K.end());

    /*rep(i, M){
        cout << "K" << K[i].first << endl;
    }*/

    int count = 0;
    ll ans = 0;
    int a = N-1;
    int k = M-1;
    while(count < N){
        if(k == -1){
            ans += A[a];
            count++;
            a--;
        } else if(A[a] >= K[k].first){
            ans += A[a];
            count++;
            a--;
        } else {
            if(count + K[k].second <= N){
                ans += K[k].first * K[k].second;
                count += K[k].second;
                k--;
            } else {
                int x = N - count;
                ans += K[k].first * x;
                count += x;
                k--;
            }
        }
        //cout << "ans" << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    long long N;
    cin>>N;
    vector <long long> A(N);
    vector <long long> B(N);
    for(int i=0; i<N; i++)
    {
        cin>>A[i];
        B[i]=A[i];
    }

    int max1 = 0, max2 = 0;

    sort(B.begin(),B.end());

    for(int i=0; i<N; i++)
    {
        if(A[i] == B[N-1])
            cout<< B[N-2] <<endl;
        else
            cout<< B[N-1] <<endl;
    }

    return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
	int K, T, m = 0;
	cin >> K >> T;
	for (int i = 0; i < T; ++i) {
		int a;
		cin >> a;
		m = max(m, a);
	}
	int ans = 0;
	if (m > K / 2) {
		int r = K - m;
		int k[10002] = {};
		for (int i = 0; i < r; ++i) {
			k[i * 2 + 1] = 1;
		}
		for (int i = 1; i < K; ++i) {
			ans += k[i - 1] == 0 && k[i] == 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var arr = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        for (var i = 0; i < num; i++) arr[i] -= i + 1;
        Array.Sort(arr);
        var b = num % 2 != 0 ? arr[num / 2]
            : (double)(arr[num / 2 - 1] + arr[num / 2]) / 2;
        var result = 0d;
        var result1 = 0d;
        for (var i = 0; i < num; i++)
        {
            result += Abs(b - arr[i]);
            result1 += Abs(b + 1 - arr[i]);
        }
        WriteLine(Min(result1,result));
    }
}

Measured memory_bytes: 30812
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int a, b, c, x, y, ans = 0;
  cin >> a >> b >> c >> x >> y;

  if(x>y){
    swap(x,y);
    swap(a,b);
  }

  if(a+b>=c*2){
    ans += x * c * 2;
    y -= x;
    x = 0;
  }

  if(b>c*2){
    ans += y * c * 2;
    y = 0; 
  }

  ans += x * a;
  ans += y * b;

  cout << ans;

  return 0;
}


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

int main(){
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (m1 != m2) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
int main()
{
	string s, s1;
	cin >> s >> s1;
	if (s[0] == s1[2] && s[1] == s1[1] && s[2] == s1[0]) cout << "YES";
	else cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
    int n;
    cin>>n;
    set<int> s;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        s.insert(x);
    }
    if((int)s.size()==n)cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 9600
#include<stdio.h>
int n,k,i;
int sum[100000];
int a;
int main(void){
	while(1){
		scanf("%d %d",&n,&k);
		if(n==0 && k==0){
			break;
		}
		/*for(i=0;i<n;i++){
			sum[i]=0;
		}*/
		int temp=0;
		for(i=0;i<n;i++){
			scanf("%d",&a);
			temp+=a;
			sum[i]=temp;
		}
		/*for(i=0;i<n;i++){
			printf("%d\n",sum[i]);
		}*/
		int max=0,j=0;
		for(i=k-1;i<n;i++){
			temp=sum[k-1];
			if(i!=k-1){
				temp=sum[i]-sum[j];
				j++;
			}
			if(max<temp){
				max=temp;
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 1416
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

a, b = na()

if b % a == 0:
    print(a + b)
else:
    print(b - a)

Measured memory_bytes: 3060
def insertion_sort(a, n):

    print(' '.join(map(str, a)))
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j + 1] = a[j]
            j -= 1
        a[j + 1] = v
        print(' '.join(map(str, a)))


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split(' ')))
    insertion_sort(a, n)



Measured memory_bytes: 5604
from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs


def main(inputs):
	L=int(inputs[0][0])
	print(L**3/27)
# 	print((L/3)**3)
	

if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)



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

int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s.substr(i, n - i) == t.substr(0, n - i)) {
            cnt = n - i;
            break;
        }
    }

    cout << n + n - cnt << endl;

    return 0;
}


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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

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

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> b(n - 1);
    for(auto &x : b){
        cin >> x;
    }
    int ans = b[0];
    for(int i = 1; i < n - 1; i++){
        ans += min(b[i], b[i - 1]);
    }
    ans += b[n - 2];
    cout << ans;
    return 0;
}


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

using namespace std;

int main(){
  int cnt = 0;
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  for(int i=0;i<=3000;i++){
    for(int j=0;j<=3000;j++){
      int tmp = n - r*i - g*j;
      if (tmp % b == 0 && 0 <= tmp){
        cnt++;
      }
    }
  }
  cout << cnt << endl;

}

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

using namespace std;

int main()
{
	int N = 1;
	int M = 1;
	int tile[1000];
	int dice[1000];
	int result[10000];
	int place = 0;
	int roops = 0;
	
	for (;;)
	{
		cin >> N >> M;
		if (N != 0 && M != 0)
		{
			roops++;
			result[roops - 1] = 0;
			place = 0;

			for (int a = 0; a < N; a++)
			{
				cin >> tile[a];
			}
			for (int a = 0; a < M; a++)
			{
				cin >> dice[a];
			}
			for (;;)
			{
				result[roops - 1]++;
				place += dice[result[roops - 1] - 1];
				if (place >= N - 1)
				{
					break;
				}
				else
				{
					place += tile[place];
					if (place >= N - 1)
					{
						break;
					}
				}
			}
		}
		else
		{
			break;
		}
	}

	for (int a = 0; a < roops; a++)
	{
		cout << result[a] << endl;
	}

	return 0;
}

Measured memory_bytes: 1168
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; ++i) {
        int l = n - i;
        bool same = true;
        for (int j = i; j < n; ++j) {
            if (s[j] != t[j - i]) {
                same = false;
                break;
            }
        }
        if (same) {
            cout << 2 * n - l << endl;
            return 0;
        }
    }
    cout << 2 * n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,t,a,b,n,c,d,y,temp,m,r,sum,count,k,l,ans;
    t=1;
    // cin>>t;
    while(t--)
    {
        string s1,s2;
        cin>>s1>>s2;
        if(s1>s2)
        cout<<">";
        else if(s1==s2)
        cout<<"=";
        else cout<<"<";
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int> P; 
class Edge
{
	public:
	int to,fee,length,com;//行き先、費用、時間、管理会社
	Edge(int t,int f,int l,int c)
	{
		to=t;fee=f;length=l;com=c;
	}
};

vector<Edge> g[100];
vector<int> pass[256];//1日乗車券の情報
int passcost[256]; //1日乗車券にかかる費用
int dp[1<<8][25][101];
//iに属する会社はただになるパスポートを使って時刻jにkに行く最小費用
int dp2[257][1<<8]; 
//i番目までのパスポートでjの集合の会社をすべて覆う1dayパスポートを買う費用の最小値

//dpを解く
void solvedp(int s,int maxh)
{
	fill(dp[0][0],dp[1<<8][0],1e8-1);
	deque<pair<int,P>> q;
	for(int pp=0;pp<(1<<8);pp++)
	{
		dp[pp][0][s]=0;
		q.push_back(make_pair(s,P(0,0)));
		while(!q.empty())
		{
			auto itr=q[0];q.pop_front();
			P p=itr.second;
			int now=itr.first;
			if(dp[pp][p.second][now]<p.first)
				continue;
			for(int i=0;i<g[now].size();i++)
			{
				Edge e=g[now][i];
				P newp=P(p.first+e.fee,p.second+e.length);
				if(pp&(1<<e.com))
					newp.first-=e.fee;//ただになる
				if(newp.second>maxh)
					continue;
				if(dp[pp][newp.second][e.to]>newp.first)
				{
					q.push_back(make_pair(e.to,newp));
					//cerr<<e.to<<" "<<newp.first<<" "<<newp.second<<endl;
					dp[pp][newp.second][e.to]=newp.first;
				}
			}
		}
	}
}
//dp2を解く
void solvedp2(int p)
{
	fill(dp2[0],dp2[257],1e8-1);
	dp2[0][0]=0; //どこも安くならないのは何も買わない場合
	for(int i=1;i<p+1;i++)
	{
		//i番目のチケットを構築する
		int pp=0; //i番目のチケットが持つ集合
		for(int j=0;j<pass[i-1].size();j++)
			pp|=(1<<pass[i-1][j]);
		for(int j=0;j<(1<<8);j++)
		{
			if(dp2[i-1][j]!=1e8-1)
			{
				dp2[i][j]=min(dp2[i][j],dp2[i-1][j]);
				dp2[i][j|pp]=dp2[i-1][j|pp];
				for(int k=0;k<(1<<8);k++)
				{
					if((pp|k)==(j|pp))
						dp2[i][j|pp]=min(dp2[i][j|pp],dp2[i-1][k]+passcost[i-1]);
				}
			}
		}
	}
	return;
}

int main()
{
	while(1)
	{
		int n,m,h,k;
		cin>>n>>m>>h>>k;
		if(n==0)
			break;
		int s,t;
		for(int i=0;i<256;i++)
			pass[i].clear();
		for(int i=0;i<100;i++)
			g[i].clear();
		for(int i=0;i<m;i++)
		{
			int a,b,c,t,r;
			cin>>a>>b>>c>>t>>r;
			a--;b--;r--;
			g[a].push_back(Edge(b,c,t,r));
			g[b].push_back(Edge(a,c,t,r));
		}
		cin>>s>>t;
		s--;t--;
		int p;
		cin>>p;
		for(int i=0;i<p;i++)
		{
			int l;
			cin>>l>>passcost[i];
			for(int j=0;j<l;j++)
			{
				int c;
				cin>>c;
				c--;
				pass[i].push_back(c);
			}
		}
		//input end
		solvedp(s,h);
		solvedp2(p);
		int ans=1e8-1;
		/* 
		for(int i=0;i<(1<<k);i++)
			cerr<<i<<" "<<dp2[p][i]<<endl;
		*/
		//すべての乗車券の買い方について見る
		for(int i=0;i<(1<<8);i++)
		{
			for(int j=0;j<=h;j++)
				ans=min(dp2[p][i]+dp[i][j][t],ans);
		}
		if(ans==1e8-1)
			ans=-1;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 5936
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {

        int N = NextInt();
        long x = NextLong();
        long[] a = LineLong();
        long[] b = a.ToArray();
        //全部飼う
        long ans = a.Sum();
        for (int k = 0; k < N; k++)
        {
            //k回魔法唱える
            long cost = k * x;
            for (int i = 0; i < N; i++) b[i] = Math.Min(b[i], a[(i - k + N) % N]);
            cost += b.Sum();

            ans = Math.Min(ans, cost);
        }
        Console.WriteLine(ans);
    }

    public static void Main()
    {
        //var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        //Console.SetOut(sw);
        Solve();
        //Console.Out.Flush();
    }
}


public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13544
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
    scanf("%d%d%d",&a,&b,&c);
    if(c>=a&&c<=b)
    {
        printf("Yes\n");
    }else
    {
        printf("No\n");
    }
    return 0;
}


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

int main(){
  long long a,b,c,k;
  cin >> a >> b >> c >> k;
  long long ans = 0;
  if(k <= a) cout << k << endl;
  else if(k <= a + b) cout << a << endl;
  else cout << a - (k - a - b) << endl;
}

Measured memory_bytes: 3644
import bisect

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

Ac = [0]*(N+1)
Bc = [0]*(M+1)
for i in range(1, N+1):
    Ac[i] = Ac[i-1] + A[i-1]
for j in range(1, M+1):
    Bc[j] = Bc[j-1] + B[j-1]

ans = 0
for i in range(N+1):
    n = K - Ac[i]
    if n < 0: break
    tmp = bisect.bisect_right(Bc, n) - 1
    ans = max(ans, i + tmp)
    #print(i, tmp, ans, n, Ac, Bc)
print(ans)

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

const int MOD = 1000000007;

int main() {
  int n; cin>>n;
  string S; cin>>S;
  vector<int> alp(26, 1);
  rep(i, n) alp[(int)(S[i]-'a')]++;
  ll ans=1;
  rep(i, 26) ans=ans*alp[i]%MOD;
  ans--;
  cout<<ans<<endl;
}

Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQUE(c)   sort(ALL((c)));(c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int cnt[101];
int main() {
	int n, q;
	while (cin>>n>>q&& n) {
		REP(i, 101)cnt[i] = 0;
		REP(i, n) {
			int m;
			cin >> m;
			REP(j, m) {
				int d; 
				cin>>d;
				cnt[d]++;
			}
		}
		int maxnum = 0, pos;
		REP(i, 101) {
			if (maxnum < cnt[i]) {
				maxnum = cnt[i];
				pos = i;
			}
		}
		if (maxnum < q)cout << 0 << endl;
		else cout << pos << endl;
	}
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <stack>
#include <cstdio>
#include <deque>

using namespace std;

long long fun(int n){
    long long res = 1;
    for (int i = 1;i <= n; i++){
        res = res*i%1000000007;
    }
    return res;
}

int main(){
    int n,m;
    cin>>n>>m;
    long long result = 0;
    if(abs(n-m)>=2){
        cout<<0<<endl;
    }
    else{
        if (n == m){
            result = (fun(n)*fun(n)%1000000007)*2%1000000007;
        }
        else{
            result = fun(n)*fun(m)%1000000007;
        }
        cout<<result<<endl;
    }



    return 0;
}


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

class Program
{
	static void Main(string[] args)
	{
        string[] input = Console.ReadLine().Split(' ');
        double d = double.Parse(input[0]);
		double t = double.Parse(input[1]);
        double s = double.Parse(input[2]);

        string ans = "";

        if((d/s) <= t){
            ans = "Yes";
        } else {
            ans = "No";
        }

		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 27532
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

string alp = "abcdefghijklmnopqrstuvwxyz";

int times_to_a (char c) {
    return (26 - static_cast<int>(alp.find(c)) );
}

int main() {
    int K;
    string s;
    cin >> s;
    cin >> K;
    
    
    for (int i = 0; i < s.length()-1; i++) {
        if (s[i] == *"a") continue;
        
        int t = times_to_a(s[i]);
        if (t <= K) {
            s.replace(i, 1, "a");
            K -= t;
        }
    }
    K %= 26;
    int t = times_to_a(s[s.length()-1]);
    
    int l;
    if (K < t) {
        l = K + static_cast<int>(alp.find(s[s.length()-1]));
    } else {
        l = K - t;
    }
    char cl = alp[l];
    s.replace(s.length()-1, 1, &cl);
    
    cout << s << endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}

bool isPrime(ll n) {
    ll i = 2;
    while (i*i <= n) {
        if(n%i==0) return false;
        i++;
    }
    return true;
}


int main() {
    ll n; cin >> n;
    vector<ll> primes;
    ll modnum = 1e9+7;

    for(ll i=2; i <= n; i++) {
        if(isPrime(i)) primes.push_back(i);
    }


    ll ans = 1;

    map<ll, ll> mp;
    for(ll i=2; i <= n; i++) {
        ll tmp = i;
        rep(j, primes.size()) {
            while(tmp%primes[j] == 0) {
                tmp /= primes[j] ;
                if(mp.find(primes[j] ) != mp.end()) {
                    mp[primes[j]]++;
                } else {
                    mp[primes[j]] = 1;
                }
            }
        }
    }

    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        ans *= (itr->second + 1);
        ans %= modnum;
    }

    cout << ans%modnum << endl;


    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 







vector<ll> a,p;
ll n,x;
ll calc(ll n,ll x){
     if(n==0){
          if(x>=1)return 1;
          else return 0;
     }
     else if(x<=1+a[n-1]){
          return calc(n-1,x-1);
     }
     else{
          return p[n-1]+1LL+calc(n-1,x-2-a[n-1]);
     }
}
int main()
{
     cin>>n>>x;
    a.push_back(1LL);p.push_back(1LL);
     for(int i=1;i<=n;i++){
          a.push_back(2LL*a[i-1]+3);
          p.push_back(2LL*p[i-1]+1);
     }
     cout<<calc(n,x);
}


























Measured memory_bytes: 3612
#include<stdio.h>
        int main(){
          int a,b,c;
          scanf("%d %d %d",&a,&b,&c);
          if(a==7&&b==5&&c==5||a==5&&b==7&&c==5||a==5&&b==5&&c==7){
            printf("YES\n");
          }else{
            printf("NO\n");
          }
          return 0;
        }

Measured memory_bytes: 128
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    //int n,k,ans=0;
	string s;
	char a[4],b='a',c='a';
	int bb=0,cc=0,dd=0;
	//cin >> n >> k;
	cin >> s;
	b=s[0];
	rep(i,4){
		if(b==s[i]){
			bb++;
		}
		else if(c=='a'){
			c=s[i];
			cc++;
		}
		else if(c==s[i]){
			cc++;
		}
	}

	if(bb==2 && cc==2){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	// if(s[1]==s[0] && s[2]==s[3]){
	// 	cout << "Yes" << endl;
	// }
	// else if(s[1]==s[2] && s[0]==s[3]){
	// 	cout << "Yes" << endl;
	// }
	// else if(s[1]==s[3] &&s[2]==s[0]){
	// 	cout << "Yes" << endl;
	// }
	// else{
	// 	cout << "No" << endl;
	// }

	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        final char[] s = sc.next().toCharArray();
        int ans = 0;
        for (int i = 0; i < n; ) {
            char current = s[i];
            int j;
            for (j = i+1; j < n; j++) {
                if (current != s[j]) {
                    break;
                }
            }
            i = j;
            ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll N,K;
    cin >> N >> K;
    vector<ll> v(N);
    ll ans = 0;
    rep(i, N) cin >> v[i];

    if(N <= K){
        cout << 0 << endl;
        return 0;
    }

    sort(v.begin(), v.end(), greater<int>());
    for (ll i = K; i < N; i++){
        ans += v[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
S = list(input())
mod2 = False
flag = True
for i in S:
    if mod2:
        mod2 = False
        if i == 'R':
            flag = False
            break
    else:
        mod2 = True
        if i == 'L':
            flag = False
            break

print('Yes' if flag else 'No')

Measured memory_bytes: 2940
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			long n = sc.nextLong();
			long m = n;
			long ans = 0;
			long p = 2;
			long c = 1;
			long div;
			
			while(true) {
				div = (long)Math.pow(p, c);
				
				if(n%div == 0) {
					ans++;
					n /= div;
					c++;
					continue;
				}
				
				while(n%p == 0) {
					n /=p;
				}
				
				p++;
				c = 1;
				
				if(p*p>n) {
					break;
				}
			}
			
			if(n!=1) {
				
				ans++;
			}
			
		    System.out.println(ans);
		}
	}


Measured memory_bytes: 35860
program sample
	implicit none
    integer(8)::i,j
    real(8)::a,b,c,d,e,k,sub
    real(8) :: sort(5)
    
    read(*,*) a
    read(*,*) b  
    read(*,*) c    
    read(*,*) d    
    read(*,*) e    
    read(*,*) k 
    
    sort(1) =a
    sort(2) =b
    sort(3)=c
    sort(4)=d
    sort(5)=e
    
    do i=1,5
    	do j=i,5
        	if(sort(i)>sort(j)) then
            	sub=sort(i)
                sort(i)=sort(j)
                sort(j)=sub
            end if
        end do
    end do
    
    if(abs(sort(5)-sort(1))<=k) then
    	write(*,*) 'Yay!'
	else
    	write(*,*) ':('
    end if
    
    stop
end program sample

Measured memory_bytes: 2960
package main

import (
	"fmt"
	"unicode"
)

func main() {
	var n, k int
	var s string
	fmt.Scanf("%d %d", &n, &k)
	fmt.Scanf("%s", &s)
	runes := []rune(s)
	runes[k-1] = unicode.ToLower(runes[k-1])
	fmt.Println(string(runes))
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

N, T = map(int,input().split())
ct=[list(map(int, input().split())) for _ in range(N)]
INF = 100000
ans = INF
for i in range(N):
    if ct[i][1] > T: continue
    ans = min(ans,ct[i][0])
if ans == INF:
    ans="TLE"
print(ans)

Measured memory_bytes: 3060
A, B, C, D = map(int, input().split())

if A < C:
    if C < min(B, D):
        print(min(B, D) - C)
        exit()
elif C < A:
    if A < min(B, D):
        print(min(B, D) - A)
        exit()
else:
    print(min(B, D) - A)
    exit()

print(0)


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

int main(){
  int N,T;
  cin >> N >> T;
  int mi=1e8;
  for(int i=0;i<N;i++){
    int c,t;
    cin >> c >> t;
    if(t<=T){
      if(mi>c){
        mi=c;
      }
    }
  }
  if(mi!=1e8){
    cout << mi << endl;
  }else{
    cout << "TLE" << endl;
  }
  return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n; cin >> n;
    string x; cin >> x;
    vector<ll> ans(n+1, 0), popcount(n+1, 0);
    frep(i, 1, n) {
        rep(j, 20) {
            if(i & (1 << j)) popcount[i]++;
        }
    }

    frep(i, 1, n) {
        ans[i] = ans[i%popcount[i]]+1;
    }

    
    ll bit = 0; // 1の数
    rep(i, n) {
        if(x[i] == '1') bit++;
    }

    // (2^i) % {bit+1, bit-1}を求める
    vector<ll> l(n, 0), s(n, 0);
    ll tmp = 1;
    rep(i, n) {
        l[i] = tmp%(bit+1);
        tmp = (tmp*2)%(bit+1);
    }
    tmp = 1;
    rep(i, n) {
        if(bit-1 == 0) break;
        else {
            s[i] = tmp%(bit-1);
            tmp = (tmp*2)%(bit-1);
        }
    }

    ll lsum = 0, ssum = 0; // 元のxの時の余りの総和
    rep(i, n) {
        if(x[i] == '1') {
            lsum += l[n-1-i];
            ssum += s[n-1-i];
        }
    }

    rep(i, n) {
        tmp = bit;
        if(x[i] == '1') {
            tmp--;
            if(tmp == 0) cout << 0 << endl;
            else cout << ans[(ssum-s[n-1-i])%tmp] + 1 << endl;
        }
        else {
            tmp++;
            cout << ans[(lsum+l[n-1-i])%tmp] + 1 << endl;
        }
        
    }

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 9708
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n;
    cin >> n;
    vector<pair<string, pair<int, int>>> m;
    for (int i = 0; i < n; i++) {
        string s;
        int p;
        cin >> s >> p;

        m.push_back({s, {-p, i + 1}});
    }

    sort(m.begin(), m.end());

    for (auto e : m) {
        cout << e.second.second << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define mset(a,x) memset(a,x,sizeof(a))
#define OUT(x) cout<<(x)<<"\n"
#define SZ(x) (int)(x).size()
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)

ll a, b, c;
set<vector<ll>> S;
ll cnt = 0;
bool found = false;


void dfs(ll a, ll b, ll c) {
    if(S.count({a,b,c})) {
        puts("-1");
        found = true;
        return;
    }

    if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1) return;

    S.insert({a,b,c});
    ++cnt;
    ll aa = b / 2 + c / 2;
    ll bb = a / 2 + c / 2;
    ll cc = a / 2 + b / 2;
    dfs(aa, bb, cc);
}


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

    dfs(a, b, c);
    if(!found) OUT(cnt);

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
 
double minkowski(int* x, int* y, int n, int p) {
    double d = 0.0;
    for (int i = 0; i < n; i++) d += pow(fabs((double)(x[i] - y[i])), p);
    return pow(d, 1.0 / p);
}
 
int minkowski_infinite(int* x, int* y, int n) {
    int max = -1;
    for (int i = 0; i < n; i++) if (max < fabs((double)(x[i] - y[i]))) max = fabs((double)(x[i] - y[i]));
    return max;
}
 
int main(void){
    int n;
    scanf("%d", &n);
 
    int x[100], y[100];
    for (int i = 0; i < n; i++) scanf("%d", &x[i]);
    for (int i = 0; i < n; i++) scanf("%d", &y[i]);
 
    printf("%.5lf\n", minkowski(x, y, n, 1));
    printf("%.5lf\n", minkowski(x, y, n, 2));
    printf("%.5lf\n", minkowski(x, y, n, 3));
    printf("%.5lf\n", (double)minkowski_infinite(x, y, n));
 
    return 0;
}

Measured memory_bytes: 1132
R, G, B, N = list(map(int, input().split()))
ans = 0
for b in range(3001):
    for g in range(3001):
        if (N - b*B - g*G) % R == 0 and (N - b*B - g*G) >= 0:
            #print(b,g)
            ans += 1
print(ans) 


Measured memory_bytes: 40940
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

using lint = long long;

void solve() {
    int n;
    std::cin >> n;

    Graph<> graph(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;
        graph[u].emplace_back(u, v);
        graph[v].emplace_back(v, u);
    }

    std::vector<int> par(n, -1);
    std::vector<lint> paths(n, 0);

    std::queue<int> que;
    que.push(n - 1);
    par[n - 1] = n - 1;

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (auto e : graph[v]) {
            int u = e.dst;
            if (par[u] >= 0) continue;
            par[u] = v;
            paths[u] = (paths[v] | (1LL << u));
            que.push(u);
        }
    }

    int m;
    std::cin >> m;

    std::vector<lint> ss(m);
    for (auto& s : ss) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;
        s = (paths[u] ^ paths[v]);
    }

    lint ans = 0;
    for (int b = 0; b < (1 << m); ++b) {
        int sign = (__builtin_popcount(b) % 2 == 0 ? 1 : -1);

        lint s = 0;
        for (int i = 0; i < m; ++i) {
            if ((b >> i) & 1) s |= ss[i];
        }

        int free = n - 1 - __builtin_popcountll(s);
        ans += sign * (1LL << free);
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;
typedef pair<int, string> PSI;

int n;
map<int, int> mp;
map<int, int>::iterator it;

int main(){
	while (cin >> n&&n){
		int ans = -1;
		mp.clear();
		REP(i, n){
			int num;
			cin >> num;
			it = mp.find(num);
			if (it == mp.end()){
				mp[num] = 1;
			}
			else{
				it->second++;
			}
		}
		for (it = mp.begin(); it != mp.end(); it++){
			if (it->second > n / 2){
				ans = it->first;
			}
		}
		if (ans == -1)cout << "NO COLOR" << endl;
		else cout << ans << endl;
	}
}

Measured memory_bytes: 2732
/* AUTHOR :  SHIVANK JAIN */

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)

using namespace std;

#define ll long long
#define li long int

#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define reprev(i,n,a) for(int i=n;i>=a;i--)
#define endl "\n"

#define vi vector<int>
#define vll vector<ll>
#define vpi vector< pair<int , int> >
#define mapi map<int , int>
#define mapll map<ll ,ll >
#define seti set<int> 

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define sort(v) sort(v.begin() , v.end())

#define BIG 1000000007
int gcd(int a, int b) 
{ // builtin function __gcd(a,b)
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){

     fast;itt;now;
 
//    #ifndef ONLINE_JUDGE
//    // for getting input from input.txt
//    freopen("input.txt", "r", stdin);
//    // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
//    #endif
    
     int n;  cin>>n;
     vi v(n , 0);
     mapi m;
     rep(i,1,n){
     	int p;
     	cin>>p;
     	v[p-1]++; 
	 }
	 rep(i,0,n)
	  cout<<v[i]<<endl;
}

Measured memory_bytes: 3992
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	vector<int> A(3);
	cin >> A[0] >> A[1] >> A[2];
	sort(A.begin(), A.end());
	cout << A[2] * 10 + A[1] + A[0] << endl;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {

    private static int Q;
    private static int N;
    private static int M;
    private static int[] a;
    private static int[] b;
    private static int[] c;
    private static int[] d;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        Q = sc.nextInt();
        a = new int[Q];
        b = new int[Q];
        c = new int[Q];
        d = new int[Q];
        for (int i = 0; i < Q; i++) {
            a[i] = sc.nextInt()-1;
            b[i] = sc.nextInt()-1;
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }

        /*
        if (Q <= 2) {
            int[] A = new int[N];
            A[0] = 1;
            System.out.println(sum);
            return;
        }
        */

        long ans = 0;
        for (int i = 0; i < Q; i++) {
            int[] A = new int[N];
            A[0] = 1;
            long tmp = dfs(1, 1, A);
            ans = Math.max(ans,tmp);
        }
        System.out.println(ans);
    }

    private static long dfs(int pos, int val, int[] A) {
        if (pos == N) {
            return calc(A);
        }

        long max = 0;
        for (int i = val; i <= M; i++) {
            A[pos] = i;
            long tmp = dfs(pos+1, i, A);
            max = Math.max(max,tmp);
        }

        return max;
    }

    private static long calc(int[] A) {
        long ret = 0;
        for (int i = 0; i < Q; i++) {
            if (A[b[i]]-A[a[i]] == c[i]) ret += d[i];
        }
        return ret;
    }

}


Measured memory_bytes: 36852
/* ex3_4 KitamoriFumiya */
#include <stdio.h>

int main(void){
	
	int dividend, divisor, quotient, surplus; // dividend(割られる数), divisor(割る数), quotient(商), surplus(余り)をint型の変数として宣言
	scanf("%d", &dividend); // dividendを入力
	
	divisor = 1; // 割る数の初期値を1にする
	// dividendを1から9までの整数で割る
	while (divisor < 10){
		quotient = dividend / divisor; // 商を求める
		surplus = dividend % divisor; // 余りを求める
		// もし1から9まで順にdividendを割っていた時にdivindendが割り切れ、かつ商が1以上9以下なら途中でループを抜け出す
		if ( 0 < quotient && quotient < 10 && surplus == 0) break;
		divisor++; // 割る数を1ずつ増やしていく
	}
	
	// もし1から9まで順にdividendを割っていた時にdivindendが割り切れ、かつ商が1以上9以下ならdividendを1以上9以下の2つの整数の積で表せるのでYesを出力
	if ( 0 < quotient && quotient < 10 && surplus == 0){
		printf("Yes\n");
	}
	// それ以外はNoを出力
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let (n, d): (usize, i64) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let mut ans = 0;
    for _ in 0..n {
        let (x, y): (i64, i64) = {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            let mut iter = buf.split_whitespace();
            (
                iter.next().unwrap().parse().unwrap(),
                iter.next().unwrap().parse().unwrap(),
            )
        };
    
        if x * x + y * y <= d * d {
            ans += 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2132
inf = 10**9+7
modlist = [1, 10, 9, 12, 3, 4]

S = list(input())
S.reverse()

dp = [[0 for i in range(13)] for j in range(len(S))]
if S[0] == "?":
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(S[0])] = 1

for i in range(1,len(S)):
    for l in range(10):
        if S[i] != "?" and int(S[i]) != l:
            continue
        for j in range(13):
            dp[i][(l*modlist[i%6]+j)%13] += dp[i-1][j]
            dp[i][(l*modlist[i%6]+j)%13] %= inf

ans = dp[len(S)-1][5]
print(ans)

Measured memory_bytes: 70024
// a.c --- Poor
#include <stdio.h>
int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a == b && b != c){ printf("Yes\n"); return 0; }
    if(b == c && c != a){ printf("Yes\n"); return 0; }
    if(c == a && a != b){ printf("Yes\n"); return 0; }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int X;
    cin >> X;
    int N = X / 200;
    if(N == 2){
        cout << 8 << endl;
    }
    if(N == 3){
        cout << 7 << endl;
    }
    if(N == 4){
        cout << 6 << endl;
    }
    if(N == 5){
        cout << 5 << endl;
    }
    if(N == 6){
        cout << 4 << endl;
    }
    if(N == 7){
        cout << 3 << endl;
    }
    if(N == 8){
        cout << 2 << endl;
    }
    if(N == 9){
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();

        long total = 0;
        for (int i = 1; i <= k; i++) {
            for (int j = 1; j <= k; j++) {
                for (int m = 1; m <= k; m++) {
                    total += gcd(gcd(i, j), m);
                }
            }
        }
        System.out.println(total);
    }

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


Measured memory_bytes: 35816
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
signed main(){
    int n;cin>>n;
    vector<int>v(n);rep(i,n)cin>>v[i];
    rep(i,n)rep(j,n)if(i!=j)if(abs(v[i]-v[j])%(n-1)==0)return cout<<v[i]<<" "<<v[j]<<endl,0;
}



Measured memory_bytes: 3124
#include <iostream>

using namespace std;
#define int long long

void reverseStr(string* str)
{
    int n = str->length();
    for (int i = 0; i < n / 2; i++)
        swap(str->at(i), str->at(n - i - 1));
}



signed main(){
    string s;
    int n;
    cin >> s;
    cin >> n;
    bool anterior = false;
    string izda = "", dcha = "";

    for(int i = 0; i < n; i++){
        int op; char c;
        cin >> op;
        if(op == 1)
            if(anterior)
                anterior = false;
            else
                anterior = true;

        else{
            cin >> op;
            cin >> c;

            if(anterior && op == 1) op =2;
            else if(anterior && op ==2) op =1;

            if(op==1) izda = c + izda;
            else dcha+=c;
        }
    }
    s = izda+s+dcha;
    if(anterior) reverseStr(&s);
    cout << s;
}

Measured memory_bytes: 1360
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

#define INF (1LL << 63)
struct edge{
    size_t to;
    size_t weight;
};

vector<size_t> dijkstra(vector<vector<edge>>& Graph, int& startPoint, int& vertexNum){
    vector<size_t> minimumWeight(vertexNum,INF);
    priority_queue<vector<pair<size_t,size_t>>, vector<pair<size_t,size_t>>, greater<pair<size_t,size_t>>> priorityQueue;
    priorityQueue.push({0,startPoint});
    minimumWeight[startPoint] = 0;
    while(!priorityQueue.empty()){
        pair<size_t,size_t> tmp = priorityQueue.top();
        edge Edge;
        Edge.to = tmp.second;
        Edge.weight = tmp.first;
        priorityQueue.pop();
        if(minimumWeight[Edge.to] < Edge.weight) continue;
        for(edge& edge : Graph[Edge.to]){
            if(minimumWeight[edge.to] < minimumWeight[Edge.to] + edge.weight) continue;
            minimumWeight[edge.to] = minimumWeight[Edge.to] + edge.weight;
            priorityQueue.push({minimumWeight[edge.to],edge.to});
        }
    }
    return minimumWeight;
}


int main(){
    int N,M;
    while(cin >> N >> M, N&&M){
        vector<vector<edge>> costGraph(M);
        vector<vector<edge>> timeGraph(M);

        for(int i = 0;i < N; i++){
            size_t a,b,c,t;
            cin >> a >> b >> c >> t;
            a--,b--;

            costGraph[a].push_back({b,c});
            costGraph[b].push_back({a,c});

            timeGraph[a].push_back({b,t});
            timeGraph[b].push_back({a,t});
        }

        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int p,q,r;
            cin >> p >> q >> r;
            p--, q--;
            vector<size_t> res;
            if(r == 0) res = dijkstra(costGraph, p, M);
            else res = dijkstra(timeGraph, p, M);   

            cout << res[q] << endl;        
        }
    }
}


Measured memory_bytes: 3204