akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class mainClass
{
	static Scanner sc;
	public static void Main(string[] args)
	{
		sc = new Scanner();
		pre();
		while (solve()) {}
	}
	static List<int> n = new List<int>();
	static void pre()
	{
		for (int i = 0; i < (1 << 16); i++)
		{
			int sq = (int)Math.Sqrt(i);
			if (sq * sq == i) n.Add(i);
		}
		n.Reverse();
		return;
	}
	static bool solve()
	{
		int N = sc.nextInt();
		if (N == 0) return false;
		int cnt = 0;
		for (int i = 0; i < n.Count; i++)
		{
			if (N - n[i] > n[i] + n[i] + n[i]) continue;
			if (N - n[i] < 0) continue;
			for (int j = i; j < n.Count; j++)
			{
				if (N - n[i] - n[j] < 0) continue;
				if (N - n[i] - n[j] > n[j] + n[j]) continue;
				for (int k = j; k < n.Count; k++)
				{
					if (N - n[i] - n[j] - n[k] < 0) continue;
					if (N - n[i] - n[j] - n[k] > n[k]) continue;
					for (int l = k; l < n.Count; l++)
					{
						if (N - n[i] - n[j] - n[k] - n[l] == 0) cnt++;
					}
				}
			}
		}
		Console.WriteLine(cnt);
		return true;
	}
}

public class Scanner
{
	public Scanner() { }
	public string next()
	{
		return Console.ReadLine();
	}
	public int nextInt()
	{
		return int.Parse(next());
	}
	public double nextDouble()
	{
		return double.Parse(next());
	}
	public long nextLong()
	{
		return long.Parse(next());
	}
	public string[] nextArray()
	{
		return next().Split(' ');
	}
	public int[] nextIntArray()
	{
		return Array.ConvertAll(nextArray(), e => int.Parse(e));
	}
	public long[] nextLongArray()
	{
		return Array.ConvertAll(nextArray(), e => long.Parse(e));
	}
	public double[] nextDoubleArray()
	{
		return Array.ConvertAll(nextArray(), e => double.Parse(e));
	}
}

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

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

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  vector<LL> wareru(0);

  FOR(i,1,1000001){
    if(i*i>N){
      break;
    }
    
    if(N%i==0){
      if(i!=1){
      wareru.push_back(i);
      }
      if(i!=N/i){
        wareru.push_back(N/i);
      }
    }
  }


  LL ans = 0;

  REP(i,wareru.size()){
    auto x = wareru[i];
    LL nowN = N;
    while (true)
    {
      if (nowN % x == 0)
      {
        nowN /= x;
      }
      else
      {
        if((nowN-1)%x==0){
          ans++;
        }
        break;
      }

      if(nowN == 1){
        ans++;
        break;
      }
    }
  }

  N--;

  FOR(i,1,1000001){
    if(i*i>N){
      break;
    }
    if(N%i==0){
      if(i!=1){
        ans++;
      }
      if(i!=N/i){
        ans++;
      }
    }

  }

  cout << ans << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Console;

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var c = Cin();
            switch (c)
            {
                case "A":Cout("T");break;
                case "T":Cout("A");break;
                case "C":Cout("G");break;
                case "G":Cout("C");break;
            }
            Cin();
        }


        static int GCD(int a, int b)
        {
            if (a < b) { swap(ref a, ref b); }
            if (a % b == 0) { return b; }
            else { return GCD(b, a % b); }
        }

        static void swap<T>(ref T a, ref T b)
        {
            T t = a;
            a = b;
            b = t;
        }

        static readonly int MOD10E9 = 10000007;
        static bool isInt(double d) { return (int)d == d; }
        static string Cin() { return ReadLine(); }
        static string[] CinAr() { return ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); }
        static long CinL() { return S2L(Cin()); }
        static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); }
        static double CinD() { return S2D(Cin()); }
        static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static long S2L(string s) { return long.Parse(s); }
        static double S2D(string s) { return double.Parse(s); }
        static void Cout(object s) { WriteLine(s); }
        static int[] yakusuu(int n)
        {
            if (n == 1) { return new int[] { 1 }; }
            HashSet<int> res = new HashSet<int>();
            for (int i = 1; i < Math.Ceiling(n / 2.0); i++)
            {
                if (n % i == 0)
                {
                    res.Add(i);
                    res.Add(n / i);
                }
            }
            return res.ToArray();
        }
        static void CoutAr<Type>(IEnumerable<Type> types)
        {
            string text = string.Join(" ", types);
            WriteLine(text);
        }

        public static long nCr(int n, int r)
        {
            // naive: return Factorial(n) / (Factorial(r) * Factorial(n - r));
            return nPr(n, r) / Factorial(r);
        }

        public static long nPr(int n, int r)
        {
            // naive: return Factorial(n) / Factorial(n - r);
            return FactorialDivision(n, n - r);
        }

        private static long FactorialDivision(int topFactorial, int divisorFactorial)
        {
            long result = 1;
            for (int i = topFactorial; i > divisorFactorial; i--)
                result *= i;
            return result;
        }

        private static long Factorial(int i)
        {
            if (i <= 1)
                return 1;
            return i * Factorial(i - 1);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;

string dice[8];
bool use[8];
string cube[8];

char trans(char a){
  if('a'<=a && a<='z')return a-32;
  else return a+32;
}

bool rec(int times){
  if(times == 8)return true;
  for(int i=0;i<8;i++){
    if(!use[i]){
      bool f = true;
      char ex;
      if(times%2){
	bool f2 = false;
	ex = trans(cube[times-1][5]);
	for(int j=0;j<6;j++)
	  if(dice[i][j]==ex)f2 = true;
	f &= f2;
      }

      if(times%4>=2){
	bool f2 = false;
	ex = trans(cube[times-2][3]);
	for(int j=0;j<6;j++)
	  if(dice[i][j]==ex)f2 = true;
	f &= f2;
      }
      if(times>=4){
	bool f2 = false;
	ex = trans(cube[times-4][4]);
	for(int j=0;j<6;j++)
	  if(dice[i][j]==ex)f2 = true;
	f &= f2;
      }
      if(f){
	use[i] = true;
	string tmp = dice[i];
	for(int j=0;j<6;j++){
	  if(j){
	    swap(tmp[0],tmp[1]);
	    swap(tmp[1],tmp[5]);
	    swap(tmp[5],tmp[4]);
	  }
	  for(int k=0;k<4;k++){
	    if(k && j&1){
	      swap(tmp[3],tmp[4]);
	      swap(tmp[4],tmp[2]);
	      swap(tmp[2],tmp[1]);
	    }else if(k){
	      swap(tmp[1],tmp[2]);
	      swap(tmp[2],tmp[4]);
	      swap(tmp[4],tmp[3]);
	    }
	    //if(!i && !times)cout << tmp << endl;
	    f = true;
	    if(times%2){
	      if(trans(tmp[0])!=cube[times-1][5])f = false;
	    }
	    if(times%4>=2){
	      if(trans(tmp[2])!=cube[times-2][3])f = false;
	      }
	    if(times>=4){
		if(trans(tmp[1])!=cube[times-4][4])f = false;
	    }
	    if(f){
	      cube[times] = tmp;
	      if(rec(times+1))return true;
	    }
	  }
	}
	use[i] = false;
      }
    }
  }

  return false;
}

int main(){
  for(;;){
    cin >> dice[0];
    if(dice[0] == "0")break;
    for(int i=1;i<8;i++)cin >> dice[i];
    for(int i=0;i<8;i++)use[i] = false;

    if(rec(0))cout << "YES\n";
    else cout << "NO\n";
    //for(int i=0;i<8;i++)cout << cube[i] << endl;
  }
}

Measured memory_bytes: 900
#include <stdio.h>

int main()
{
	int a,b,c,t,i,n;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(a<b){
			if(b<c){
				t=a;a=c;c=t;
			}
			else{
				t=a;a=b;b=t;
			}
		}else if(a<c){
				t=a;a=c;c=t;
		}
		
		if(a*a==b*b+c*c){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    int k;
    cin >> s >> k;
    char ans='1';
    for(int i=0; i<k && i<s.length(); i++) {
        if(s[i]!='1') {
            ans = s[i];
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

vi to[200005];
vi ans;

void dfs(int v, int p = -1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
  return;
}

int main () {
  int N, Q; cin >> N >> Q;
  REP(i,N-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    to[a].PB(b);
    to[b].PB(a);
  }

  ans.resize(N);
  REP(i,Q) {
    int p, x; cin >> p >> x;
    --p;
    ans[p] += x;
  }

  dfs(0);
  REP(i,N) {
    cout << ans[i] << endl;
  }
  
  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = (1<<29);
const int INFF = 0x7fffffff;
const ll LINF = (1ll<<60);
const ll LINFF = 0x7fffffffffffffff;
const long double PI = 3.14159265359;

#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define prec(x) cout << fixed << setprecision(x)
#define sz(x) (int)x.size()
#define _log2(x) 31-__builtin_clz(x)

#define hash sodnf9843bsd
#define right iadjfof23n3okd
#define pqueue priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define len length
#define endl '\n'

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll a, ll b){return uniform_int_distribution<ll>(a, b)(rng);}


vector<int> tgi[300005] = {};
int cntj[300005] = {};
vector<pair<int, int>>tg;

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

    int n, m;cin>>n>>m;
    int k;cin>>k;

    _fi(k){
        int a, b;cin>>a>>b;
        tgi[a].pb(i);
        cntj[b]++;
        tg.pb({a, b});
    }

    int besti = 0;
    int bestx = 0;
    int besty = 0;
    for(int i = 1;i <= 300000;i++){
        int x = sz(tgi[i]);
        int y = 0;
        for(int id:tgi[i]) y = max(y, cntj[tg[id].second]);

        if (x > bestx || (x == bestx && y < besty)){
            besti = i;
            bestx = x;
            besty = y;
        }
    }

    for(int id:tgi[besti]) cntj[tg[id].second]--;

    int ans = 0;
    for(int j = 1;j <= 300000;j++) ans = max(ans, cntj[j]);
    ans += bestx;

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 23776
s = input()
n = len(s)

s_wo_x = s.replace("x", "")
if s_wo_x != s_wo_x[::-1]:
    print(-1)
else:
    num_x = []
    cnt = 0
    for i in range(n):
        if s[i] == "x":
            cnt += 1
        else:
            num_x.append(cnt)
            cnt = 0
    num_x.append(cnt)

    ans = 0
    N = len(num_x)
    for i in range(N // 2):
        if num_x[i] == num_x[N - i - 1]:
            continue
        else:
            ans += abs(num_x[i] - num_x[N - i - 1])

    if N % 2 == 1:
        if num_x[N // 2] % 2 > 1 and num_x[N // 2] % 2 == 0:
            ans += 1
    print(ans)


Measured memory_bytes: 3964
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define FFOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>

int gcd(int a, int b) {return b?gcd(b,a%b):a;}

signed main(){
	
	int n,k;cin>>n>>k;
	
	int dai,kou;
	
	
	rep(i,n)
	{
		int a;cin>>a;
		
		if(i==0)
		{
			dai = a;
			kou = a;
			continue;
		}
		
		dai = max(dai,a);
		kou = gcd(kou,a);
	}
	
	cout << ((k<=dai && k%kou==0)?"POSSIBLE":"IMPOSSIBLE") << endl;

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val array = readLine()!!.split(" ").map(String::toInt).toMutableList()
    var x = array[0]
    var y = array[1]
    val newArray = mutableListOf<Int>()

    var count = 1
    while (count != 0) {
        count = x % y
        if (count == 0) newArray.add(y) else newArray.add(count)
        x = y
        y = count
    }
    println(newArray.last())
}


Measured memory_bytes: 32068
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
   
   set<ll> st;
   ll ans = 0;
   rep(n)
   {
       if(st.empty() || (*st.begin() > arr[i]))
            ans++;
       st.insert(arr[i]);        
   }
   
   cout<<ans;
        
   
   return 0;        
}  
   

Measured memory_bytes: 11264
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  vector<int> V;
  int N = 3;
  rep(i, N) {
    int v;
    cin >> v;
    V.push_back(v);
  }
  sort(V.begin(), V.end());
  cout << 10 * V[2] + V[1] + V[0] << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scan = new Scanner(System.in);
        
        int dantaicount = scan.nextInt();
        
        int sekistart,sekiend;
        int ninzu = 0;
        
        for (int count = 0 ; count < dantaicount ; count++){
            sekistart = scan.nextInt();
            sekiend = scan.nextInt();
            
            ninzu = ninzu + sekiend - sekistart + 1;
            
        }
 
        System.out.println(ninzu);
        
    }
}

Measured memory_bytes: 25800
dp = Array.new(100001,0.0)
dp[1] = 1
for i in 2..100000
    p = 1.0
    w = 0.5
    k = 1
    while k<i && p>1e-13
        dp[i] += (p*(1-w))*(k+dp[[0,i-k-1].max])
        p *= w
        w /= 2
        k += 1
    end
    dp[i] += i*p
end
while true
    n = gets.to_i
    if n == 0
        break
    end
    puts dp[n]
end

Measured memory_bytes: 6896
/*input
10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
bool comp(pair<string,pii> a,pair<string,pii> b){
	if(a.f == b.f){
		return a.s.f>b.s.f;
	}
	return a.f<b.f;
}
signed main() {
	IOS;
	int n;
	cin>>n;
	pair<string,pii> a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i].f>>a[i].s.f;
		a[i].s.s=i;
	}
	sort(a+1,a+n+1,comp);
	for(int i=1;i<=n;i++){
		cout << a[i].s.s << endl;

	}
return 0;
}


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

const int N = 1e5 + 7, INF = 0x3f3f3f3f;

int dp[N][3];

int main() {
        int n; cin >> n;
        for(int i = 1; i <= n; i++) {
                cin >> dp[i][0] >> dp[i][1] >> dp[i][2];
                dp[i][0] += max(dp[i - 1][1], dp[i - 1][2]);
                dp[i][1] += max(dp[i - 1][0], dp[i - 1][2]);
                dp[i][2] += max(dp[i - 1][0], dp[i - 1][1]);
        }

        cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;

}


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

int main(){
	string S,A;
	cin >> S;
	for(int i=0; i<S.size(); i++){
		if(S[i]=='0'){
			A += "0";
		} else if(S[i]=='1'){
			A += "1";
		} else if(S[i]=='B'){
			if(A.size()>0){
				A.erase(A.size()-1);
			}
		}
	}
	cout << A << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        for (int k = i + 1; k < n; k++)
        {
            sum += d[i] * d[k];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 1000005
ll arr[MAX];
void init()
{
    for(int i=1;i<MAX;i++){
        for(int j=i;j<MAX;j+=i) arr[j]++;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    init();
    ll n; cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=(arr[n-i]);
    }
    cout<<ans<<endl;
}

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

int main()
{
    string T;
    cin >> T;

    if (T[0] == '?')
    {
        if (T[1] == 'D')
        {
            T[0] = 'P';
        }
        else if (T[1] == '?')
        {
            T[0] = 'P';
            T[1] = 'D';
        }
        else
        {
            T[0] = 'D';
        }
    }

    for (int i = 1; i < T.length(); i++)
    {
        if (T[i] == '?')
        {
            if (T[i - 1] == 'P')
            {
                T[i] = 'D';
            }
            else if (T[i + 1] == 'D')
            {
                T[i] = 'P';
            }
            else if (T[i + 1] == '?')
            {
                T[i] = 'P';
                T[i + 1] = 'D';
            }
            else
            {
                T[i] = 'D';
            }
        }
    }

    cout << T << endl;
}

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

using namespace std;

int cnt, m;
int G[100]={1};

void insertionSort(int *A, int n, int g){
  for(int i=g;i<n;i++){
    int v=A[i];
    int j=i-g;

    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }

    A[j+g]=v;
  }
}

void shellSort(int *A, int n){
  cnt=0;

  for(int i=1;i<100;i++){
    G[i]=3*G[i-1]+1;
    if(G[i]>n){
      m=i;
      break;
    }
  }

  for(int i=0;i<m;i++){
    insertionSort(A, n, G[m-i-1]);
  }
}

int main(){

  int n, a[1000000];

  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];

  shellSort(a, n);

  cout<<m<<endl;

  for(int i=0;i<m;i++){
    cout<<(i?" ":"");
    cout<<G[m-i-1];
  }
  cout<<endl;

  cout<<cnt<<endl;

  for(int i=0;i<n;i++) cout<<a[i]<<endl;

  return 0;
}




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

int main()
{
	int a;
	int b;

	while (cin >> a >> b)
	{
		int n = a + b;

		if (n / 10 == 0)
		{
			cout << 1 << endl;
		}
		else if (n / 10 >= 1 && n / 10 <= 9)
		{
			cout << 2 << endl;
		}
		else if (n / 10 >= 10 && n / 10 <= 99)
		{
			cout << 3 << endl;
		}
		else if (n / 10 >= 100 && n / 10 <= 999)
		{
			cout << 4 << endl;
		}
		else if (n / 10 >= 1000 && n / 10 <= 9999)
		{
			cout << 5 << endl;
		}
		else if (n / 10 >= 10000 && n / 10 <= 99999)
		{
			cout << 6 << endl;
		}
		else if (n / 10 >= 100000 && n / 10 <= 999999)
		{
			cout << 7 << endl;
		}
	}
}



Measured memory_bytes: 3004
n = gets.chomp.to_i
s = []
n.times do |i|
  s[i] = gets.chomp.split("").sort.join
end

s.sort!

ans = 0
ptr = 0
n.times do |i|
  if s[ptr] != s[i]
    len = (i-1) - ptr
    ans += ((len+1)*len)/2
    ptr = i
  end
end
len = (n-1) - ptr
ans += ((len+1)*len)/2

puts(ans)

Measured memory_bytes: 27624
S = input()
op_cnt = len(S)-1
sum = 0
for i in range(2**op_cnt):
    op = [""] * op_cnt
    for j in range(op_cnt):
        if ((i>>j) & 1):
            op[j] = "+"
    formula = ""
    for p_n, p_o in zip(S, op + [""]):
        formula += (p_n + p_o)
    sum += eval(formula)
#    print(formula)
print(sum)


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

int main()
{
	int n[50],i = 0, inp = 0, out[50]={0}, a = 0, b = 0, c = 0, d = 0;

	//??\???
	while( cin >> inp){
		if(inp >= 1 && inp <= 50){
	  		n[i] = inp;
			i++;
	  }
	}

	//??????
	for(int j = 0;j < i;j++){

		//?§£
		for(a = 0;a <= 9;a++){
			if(n[j] == (a + b +c +d) && (b <= 9 || c <= 9 || d <= 9)){
				out[j]++;
				//cout << a << " " << b << " "  << c << " "  << d << endl;
			}

			for(b = 0;b <= 9;b++){
				if(n[j] == (a + b +c +d) && (c <= 9 || d <= 9)){
					out[j]++;
					//cout << a << " " << b << " "  << c << " "  << d << endl;
				}

				for(c = 0;c <= 9;c++){
					if(n[j] == (a + b +c +d) && (d <= 9)){
						out[j]++;
						//cout << a << " " << b << " "  << c << " "  << d << endl;
					}

					for(d = 0;d <= 9;d++){
						if(n[j] == (a + b +c +d)){
							out[j]++;
							//cout << a << " " << b << " "  << c << " "  << d << endl;
						}
					}
				}
			}
		}

		cout << out[j] << endl;
	}	

	return 0;
}

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

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans;
    if (k%2 == 0) ans = a - b;
    else ans = b - a;
    if (abs(b - a) >= K) cout << "Unfair" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = [list(map(int,input().split())) for i in range(M)]

def calc(lis):
	T2 = T.copy()
	T2[lis[0]-1] = lis[1]
	return sum(T2)

for i in range(M):
	print(calc(P[i]))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    string ans="NG";
    /*
    if(b-a > k) ans = "OK";
    else if(k == 1)ans = "OK";
    else if(b % k == 0 || a % k == 0)ans = "OK";
    else if(b / k != a / k) ans = "OK";
    else ans = "NO";
    */
   rng(i,a,b+1){
       if(i%k==0){
           ans = "OK";
           break;
       }
   }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

int main()
{   
    int n;
    cin >> n;
    vi a(n+1, -1);
    rep(i, n) cin >> a[i+1];

    vi b(n+1);
    for(int i = n; i >= 1; i--) {
        int sum = 0;
        for(int j = i+i; j <= n; j+=i) {
            sum ^= b[j];
        }
        b[i] = sum^a[i];
    }
    vi ans;
    for(int i = 1; i <= n; i++) {
        if(b[i]) ans.push_back(i);
    }

    cout << ans.size() << endl;
    for(auto x : ans) cout << x << endl;

    return 0;
}


Measured memory_bytes: 5204
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

vector<int>ve[120000];

int main(){
//	ios::sync_with_stdio(false);
//	cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	int x,y;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		if(x>k) continue;
		int tt=k-x+1;
		ve[tt].push_back(y);
	}
	
	priority_queue<int>q;
	int ans=0;
	for(int i=k;i>=1;i--){
		for(int j=0;j<ve[i].size();j++) q.push(ve[i][j]);
		if(!q.empty()){
			ans+=q.top();
			q.pop();	
		}
	}
	cout<<ans<<"\n";
	
	return 0;
} 

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int x;
    cin>>x;
    cout<<((x>=30)?"Yes":"No")<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<long>a(3*n);
  for(int i=0; i<3*n; i++)cin >> a[i];
  priority_queue<long>leftq, rightq;
  vector<long>lefts(n+1), rights(n+1);
  for(int i=0; i<n; i++)leftq.push(-a[i]);
  lefts[0]=accumulate(a.begin(), a.begin()+n, 0L);
  for(int i=1; i<=n; i++){
    if(-leftq.top()<a[n+i-1]){
      lefts[i]=lefts[i-1]-(-leftq.top())+a[n+i-1];
      leftq.pop();
      leftq.push(-a[n+i-1]);
    }
    else lefts[i]=lefts[i-1];
  }
  for(int i=2*n; i<3*n; i++)rightq.push(a[i]);
  rights[0]=accumulate(a.begin()+2*n, a.begin()+3*n, 0L);
  for(int i=1; i<=n; i++){
    if(rightq.top()>a[2*n-i]){
      rights[i]=rights[i-1]-rightq.top()+a[2*n-i];
      rightq.pop();
      rightq.push(a[2*n-i]);
    }
    else rights[i]=rights[i-1];
  }
  long ret=lefts[0]-rights[n];
  for(int i=0; i<=n; i++){
    ret = max(ret, lefts[i]-rights[n-i]);
  }
  for(int i=0; i<=n; i++){
    cerr << lefts[i] << ' ' << rights[n-i] << endl;
  }
  cout << ret;
  return 0;
}


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

template <typename _tp> inline void read(_tp&x){
	char ch=getchar(),ob=0;x=0;
	while(ch!='-'&&!isdigit(ch))ch=getchar();if(ch=='-')ob=1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();if(ob)x=-x;
}

const int N = 203, M = 10001003;
bool ispri[M], vs[N];
int a[N], tot;
int n, Ans;

void input() {
	read(n);
	int x, y; read(x);
	a[tot = 1] = x;
	for(int i=2;i<=n;++i) {
		read(y);
		if(x+1 != y) a[++tot] = x+1, a[++tot] = y;
		x = y;
	}
	a[++tot] = ++x;
	
	for(int i=2;i<=x;++i) ispri[i] = true;
	for(int i=2;i<=x;++i) if(ispri[i])
		for(int j=i+i;j<=x;j+=i) ispri[j] = false;
	ispri[2] = false;
}

namespace Part1 {
	struct Edge {int v, w, nxt;} e[N*N];
	int head[N], cur[N];
	int q[N], he, ta, dis[N];
	int s, t, _;
	
	inline void add(int x, int y) {
		e[++_].v = y, e[_].w = 1, e[_].nxt = head[x], head[x] = _;
		e[++_].v = x, e[_].w = 0, e[_].nxt = head[y], head[y] = _;
	}
	
	void init() {
		s = tot + 1, t = s + 1, _ = 1;
		for(int i=1;i<=t;++i) head[i] = 0;
	}
	
	bool bfs() {
		for(int i=1;i<=t;++i) dis[i] = -1;
		dis[q[he = ta = 1] = s] = 0;
		while(he <= ta) {
			int x = q[he++];
			for(int i=head[x];i;i=e[i].nxt)
				if(e[i].w and -1 == dis[e[i].v]) {
					dis[q[++ta] = e[i].v] = dis[x] + 1;
					if(e[i].v == t) return true;
				}
		}
		return false;
	}
	
	int dfs(int x, int flw) {
		if(x == t or !flw) return flw;
		int res = 0, tmp;
		for(int&i=cur[x];i;i=e[i].nxt)
			if(e[i].w and dis[e[i].v] == dis[x] + 1)
			if(tmp = dfs(e[i].v, e[i].w)) {
				e[i].w -= tmp, e[i^1].w += tmp, res += tmp;
				if(res == flw) return res;
			}
		if(!res) dis[x] = -1;
		return res;
	}
	
	int Dinic() {
		const int oo = 1e9;
		int res = 0;
		while(bfs()) {
			for(int i=1;i<=t;++i) cur[i] = head[i];
			res += dfs(s, +oo);
		}
		return res;
	}

	void work() {
		init();
		for(int i=1;i<=tot;++i)
			if(a[i]&1) add(s, i);
	
		for(int i=1;i<=tot;++i) if(a[i]&1)
		for(int j=1;j<=tot;++j) if(~a[j]&1)
			if(ispri[abs(a[i] - a[j])]) add(i, j);
		
		for(int i=1;i<=tot;++i)
			if(~a[i]&1) add(i, t);
	
		Ans += Dinic();
		for(int i=head[s];i;i=e[i].nxt)
			if(!e[i].w) vs[e[i].v] = true;
		for(int i=head[t];i;i=e[i].nxt)
			if(e[i].w) vs[e[i].v] = true;
	}
}

void Part23() {
	int ct[2] = {0, 0};
	for(int i=1;i<=tot;++i)
		if(!vs[i]) ++ct[a[i]&1];
	Ans += ct[0] ^ (ct[0] & 1);
	Ans += ct[1] ^ (ct[1] & 1);
	Ans += (ct[0] & ct[1] & 1) * 3;
}

int main() {
	input();
	
	Part1::work();
	Part23();
	
	printf("%d\n", Ans);
	return 0;
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 1e5 + 5;
int arr[MAX];
int n;

int find_best(int pivot) {
	int best = -1;

	auto it = lower_bound(arr + 1, arr + n + 1, pivot);
	auto prev_it = it - 1;
	if(it == (arr + n)) {
		best = *(--it);
	}
	else if(it == (arr + 1)) {
		best = *it;
	}
	else if(abs(*it - pivot) < abs(*prev_it - pivot)) {
		best = *it;
	}
	else {
		best = *prev_it;
	}

	return best;
}

int main() {
	scanf("%d", &n);

	fori(i, 1, n + 1) {
		scanf("%d", arr + i);
	}

	sort(arr + 1, arr + n + 1);

	int other = -1;

	if(arr[n] % 2 == 0) {
		other = find_best(arr[n] / 2);
	}
	else {
		int a = find_best(arr[n] / 2);
		int b = find_best(arr[n] / 2 + 1);

		if(abs(a - arr[n] / 2) < abs(b - (arr[n] / 2 + 1))) {
			other = a;
		}
		else {
			other = b;
		}
	}

	printf("%d %d\n", arr[n], other);

	return 0;
}


Measured memory_bytes: 640
def main():
  import sys
  import collections
  n,k,q=map(int,input().split())
  a=[int(e) for e in sys.stdin]
  point=[k-q]*n
  
  for person,getPoint in collections.Counter(a).items():
    point[person-1]+=getPoint
  
  for res in point:
    print("Yes" if res>0 else "No")
    
  
if __name__=="__main__":
  main()

Measured memory_bytes: 13164
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
ll a[100010], b[100010];

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

    ll ans = 0;
    ll add = 0;
    repr(i, n) {
        ll m = (a[i] + add) % b[i];
        if (m == 0) continue;
        add += b[i] - m;
        ans += b[i] - m;
    }
    cout << ans << endl;
}


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

int main(){
	int a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0) cout << "Zero" << '\n';
	else if (a > 0) cout << "Positive" << '\n';
	else if ((b - a + 1) % 2 == 0) cout << "Positive" << '\n';
	else cout << "Negative" << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<utility>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long int ll;
int main(void) {
	string str,ans;
	cin >> str;
	for (int i = 0; i < str.length(); i++) {
		if (str[i] == 'B') {
			if(!ans.empty())
				ans.erase(ans.end() - 1);
		}
		else ans.push_back(str[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    s = "abcdefghijklmnopqrstuvwxyz"
    ans = ""
    while True:
        d = n % 26
        ans += s[d - 1]
        if n <= 26:
            break
        n = (n // 26)
        if d == 0:
            n -= 1
    print(ans[::-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
import collections
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = ZZ()
    cnt = collections.Counter(A)
    cc = 0
    for key in cnt.keys():
        if cnt[key]%2 == 0: cc += 1
    num_ele = len(set(A))
    print(num_ele if cc%2 == 0 else num_ele-1)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 21084
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
S = np.frombuffer(readline().rstrip(),'S1')
Q = int(readline())
query = map(int,read().split())

isD = S == b'D'
isM = S == b'M'
isC = S == b'C'

cumD = isD.cumsum(dtype=np.int64)
cumM = isM.cumsum(dtype=np.int64)

def F(K):
    """
    ・Cごとに数える。
    ・そのためには(i-K,i] 内のDMの個数を調べる（負インデックスには関係ない文字があると思っておく）
    ・区間内のDの個数、Mの個数が取得できれば、差分が取得できるので最後に累積和
    """
    # (i-K,i]内のDの個数、Mの個数
    D = cumD.copy(); D[K:] -= cumD[:-K]
    M = cumM.copy(); M[K:] -= cumM[:-K]
    # 最後がMのとき、Dの個数分増える
    DM = isM * D
    # 左端のDを捨てるとき、Mの個数分減る
    DM[K:] -= isD[:-K] * M[K-1:-1]
    np.cumsum(DM,out=DM)
    # Cごとに集計
    return DM[isC].sum()

print('\n'.join(str(F(K)) for K in query))


Measured memory_bytes: 63300
// 2014/08/01 Tazoe

#include <iostream>
#include <cmath>
using namespace std;

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

		if(n==0)
			break;

		double s[1000];
		double sum = 0.0;
		for(int i=0; i<n; i++){
			cin >> s[i];

			sum += s[i];
		}

		double m = sum/(double)n;

		double sum2 = 0.0;
		for(int i=0; i<n; i++){
			sum2 += (s[i]-m)*(s[i]-m);
		}

		double a = sqrt(sum2/(double)n);

		cout.precision(8);
		cout << fixed << a << endl;
	}

	return 0;
}

Measured memory_bytes: 1292
#include <stdio.h>

int main()
{
    long long n, a, cnt = 0;
    scanf("%lld", &n);
    for(long long i = 0; i < n; i++)
    {
        scanf("%lld", &a);
        while(a % 2 == 0) {
                a = a / 2;
                cnt++;}
    }
    printf("%lld", cnt);
}


Measured memory_bytes: 128
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

a,v = imap()
b,w = imap()
t = iinput()

flag = abs(a-b) <= (v-w)*t
ans = "YES" if flag else "NO"
print(ans)


Measured memory_bytes: 37772
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    bool ans = false;
    for (int i = 1; i <= 9; ++i)
    {
        for (int j = 1; j <= 9; ++j)
        {
            if (i * j == n) ans = true;
        }
    }

    cout << (ans ? "Yes\n" : "No\n");
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int x = 0;
		int y = 0;
		for (int i=0; i<n; i++) {
			String s1 = stdIn.next();
			String s2 = stdIn.next();
			if(s1.compareTo(s2) > 0){
				x += 3;
			}else if (s1.compareTo(s2) < 0) {
				y += 3;
			}else {
				x ++;
				y ++;
			}
		}
		System.out.println(x+" "+y);
	}
}

Measured memory_bytes: 20832
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    #define see(x) cout<<#x<<" = "<<x<<endl
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (ll x,ll n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    int main()
    {   
         IOS;
         ll n,m,i,j,k;
         string s;
         cin>>n;
         cin>>s;
         for(i=0;i<s.length();i++)
         {
           int c=s[i]-'A';
           c+=n;
           c%=26;
           s[i]=c+'A';
         }
         cout<<s;
         
         cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
    }

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

using namespace std;

int main()
{
	long long n;
	cin >> n;
	int num_of_letters = 1;
	long long first = 1;
	long long temp_size = 26;
	while (n > first + temp_size - 1)
	{
		num_of_letters++;
		first += temp_size;
		temp_size *= 26;
	}
	n -= first;
	string res(num_of_letters, 'a');
	int pos = res.size() - 1;
	while (n > 0)
	{
		res[pos--] = (n % 26) + 'a';
		n /= 26;
	}
	cout << res << endl;
}

Measured memory_bytes: 3560
#include <stdio.h>
#include <stdlib.h>

#define STUDENT_MAX 10001  /* 生徒数最大値 + 1 */
#define TIME_RANGE  721    /* 時間範囲(1260 - 540 + 1) */
#define TIME_IDX_SHIFT 540

int Login_sts[STUDENT_MAX][TIME_RANGE];
volatile int Login_cnt[STUDENT_MAX];
int Login_time[STUDENT_MAX];

int main(void){
	int N; /* PC数 */
	int M; /* 生徒数 */
	int r; /* 記録数 */
	int t; /* 時刻 */
	int n; /* PC */
	int m; /* 生徒 */
	int s; /* login/logout */
	int q; /* 質問数 */
	int t_s; /* 範囲(開始) */
	int t_e; /* 範囲(終了) */

	int i,j,ans;

	while(1){
		scanf("%d %d",&N,&M);
		if((N == 0) && (M == 0))break;
		/* Init */
		for(i = 0;i < STUDENT_MAX;i++){
			for(j = 0;j < TIME_RANGE;j++){
				Login_sts[i][j] = 0;
				Login_cnt[i] = 0;
			}
		}
		/* Input */
		scanf("%d",&r);
		for(i = 0;i < r; i++){
			scanf("%d %d %d %d",&t,&n,&m,&s);
			if(s == 1){ /* login */
				if(Login_cnt[m] == 0){
					Login_time[m] = t;
				}
				Login_cnt[m]++;
			}else{  /* logout */
				Login_cnt[m]--;
				if(Login_cnt[m] == 0){
					for(j = (Login_time[m] - TIME_IDX_SHIFT);j < (t- TIME_IDX_SHIFT);j++){
						 Login_sts[m][j] = 1;
					}
				}
			}
		}

		/* Output */
		scanf("%d",&q);
		for(i = 0;i < q; i++){
			ans = 0;
			scanf("%d %d %d",&t_s,&t_e,&m);
			for(j = (t_s - TIME_IDX_SHIFT);j < (t_e - TIME_IDX_SHIFT);j++){
				ans += Login_sts[m][j];
			}
			printf("%d\n",ans);
		}
	}


	return 0;
}



Measured memory_bytes: 29980
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define GET_BIT(n, i) (((n) & (1LL << ((i)-1))) >> ((i)-1)) // i start from 1
#define SET_BIT(n, i) ((n) | (1LL << ((i)-1)))
#define CLR_BIT(n, i) ((n) & ~(1LL << ((i)-1)))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
void myInit();
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int MOD = 1000000007;
const int N = 3e5, M = N;
//=========TQR==============
vi g[N];

int main() {
	myInit();
	FIO;
	string s;
	int i, sum = 0;
	cin >> s;
	fo(i, s.length()) {
		sum += (s[i] - '0');
	}
	if (sum % 9 == 0)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

void myInit() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int mpow(int base, int exp) {
	base %= MOD;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % MOD;
		base = ((ll)base * base) % MOD;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		g[u - 1].pb(v - 1);
		g[v - 1].pb(u - 1);
	}
}

void dfs(int u, int par) {
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10752
import bisect

a, b, q = map(int, input().split())
s = []
for i in range(a):
    s.append(int(input()))
s.sort()
t = []
for i in range(b):
    t.append(int(input()))
t.sort()

for i in range(q):
    x = int(input())
    temp_s = bisect.bisect(s, x)
    temp_t = bisect.bisect(t, x)
    temp = float("inf")
    if temp_s == 0:
        num = (s[0],)
    elif temp_s == a:
        num = (s[a - 1],)
    else:
        num = (s[temp_s - 1], s[temp_s])
    for j in num:
        temp2 = bisect.bisect(t, j)
        if temp2 == 0:
            num2 = (t[0],)
        elif temp2 == b:
            num2 = (t[b - 1],)
        else:
            num2 = (t[temp2 - 1], t[temp2])
        for k in num2:
            temp = min(temp, abs(x - j) + abs(j - k))
    if temp_t == 0:
        num = (t[0],)
    elif temp_t == b:
        num = (t[b - 1],)
    else:
        num = (t[temp_t - 1], t[temp_t])
    for j in num:
        temp2 = bisect.bisect(s, j)
        if temp2 == 0:
            num2 = (s[0],)
        elif temp2 == a:
            num2 = (s[a - 1],)
        else:
            num2 = (s[temp2 - 1], s[temp2])
        for k in num2:
            temp = min(temp, abs(x - j) + abs(j - k))
    print(temp)

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  int N, K; cin >> N >> K;
  if ((N-1)*(N-2)/2<K) { cout << -1 << endl; return 0; }
  int M = N*(N-1)/2 - K;
  cout << M << endl;
  for (int i=2; i<=N; i++) cout << 1 << " " << i << endl;
  M -= N-1;
  for (int i=2; i<=N; i++) for (int j=i+1; j<=N; j++){
    if (M==0) break;
    cout << i << " " << j << endl;
    M--;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++)
    {
        long long temp;
        cin >> temp;
        a[i] = temp - i - 1;
    }
    sort(a.begin(), a.end());
    long long b;
    if (n % 2 == 0)
    {
        b = a[n / 2 - 1];
    }
    else
    {
        b = a[(n + 1) / 2 - 1];
    }

    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += abs(a[i] - b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  string ans ="Sunny";
  if(s == "Sunny")ans = "Cloudy";
  else if(s == "Cloudy")ans = "Rainy";
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
n, a, b = gets.strip.split.map(&:to_i)

# 各桁の和を求める
def digit_sum n
    sum = 0
    while n > 0 do
        sum += n % 10
        n /= 10
    end
    sum
end

ans = (1..n)
        .map { |i| [i, digit_sum(i)] }
        .select { |d| a <= d[1] && d[1] <= b }
        .inject(0) { |sum, d| sum + d[0] }

puts ans

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define REP(i,n) for(ll i = 0; i < (n); i++)

ll n;
const ll mod = 1e9 + 7;

struct Matrix {
	vector<vector<ll>> a = vector<vector<ll>>(n, vector<ll>(n));
	Matrix operator *(const Matrix& other) {
		Matrix product;
		//vector<vector<long long>> tmp(n, vector<long long>(n));
		REP(i, n)REP(j, n)REP(k, n) {
			product.a[i][k] = (product.a[i][k] + a[i][j] * other.a[j][k]) % mod;
		}
		return product;
	}
};
Matrix expo_power(Matrix a, ll k) {
	Matrix product;
	REP(i, n) product.a[i][i] = 1;
	while (k > 0) {
		if (k % 2) {
			product = product * a;
		}
		a = a * a;
		k /= 2;
	}
	return product;
}
ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}

int main() {
#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
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll m, k;
	cin >> n  >> k;
	Matrix adj;
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < n; j++)
			cin >> adj.a[i][j];
	}
	Matrix prod = expo_power(adj, k);
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < n; j++)
			ans = (ans + prod.a[i][j]) % mod;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3684