akhauriyash/Code-Regression huggingface dataset:
using System;
    using System.Collections.Generic;
    using System.Linq;
 
    class Program
    {
        static void Main(string[] args)
        {
            var line = System.Console.ReadLine();
            var data = line.Split(new char[] { ' ' });
            int H = Convert.ToInt32(data[0]);
            int N = Convert.ToInt32(data[1]);

            int[] A = new int[N];
            int[] B = new int[N];
            for (int i = 0; i < N; i++)
            {
                line = Console.ReadLine();
                data = line.Split(new char[] { ' ' });
                A[i] = Convert.ToInt32(data[0]);
                B[i] = Convert.ToInt32(data[1]);
            }
             double[] dp = new double[H + 1];
            for (int i = 0; i < dp.Length; i++)
            {
                dp[i] = double.PositiveInfinity;
            }
            dp[0] = 0; // 最初の配列のみ0

            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < H; j++)
                {
                    int nj = Math.Min(j + A[i], H);
                    dp[nj] = Math.Min(dp[nj], dp[j] + B[i]);
                }
            }
            Console.WriteLine(dp[H]);
        }
    }

Measured memory_bytes: 11260
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>

#define MAX_NUM (500000)

static void MaxHeapify(int heap[], int size, int index) {
    int l = index * 2;
    int r = index * 2 + 1;
    int largest;

    if ( l <= size && heap[l] > heap[index] ) {
        largest = l;
    } else {
        largest = index;
    }
    if ( r <= size && heap[r] > heap[largest] ) {
        largest = r;
    }

    if ( largest != index ) {
        int t;

        t = heap[index];
        heap[index] = heap[largest];
        heap[largest] = t;

        MaxHeapify(heap, size, largest);
    }

    return;
}

static void BuildMaxHeap(int heap[], int size) {
    int i;
    for ( i = size / 2; i > 0; i-- ) {
        MaxHeapify(heap, size, i);
    }

    return;
}

int main(int argc, char* argv[]) {
    int n;
    int i;
    int heap[MAX_NUM + 1];

    scanf("%d\n", &n);
    for ( i = 1; i <= n; i++ ) {
        int d;
        scanf("%d", &d);
        heap[i] = d;
    }

    BuildMaxHeap(heap, n);

    for ( i = 1; i <= n; i++ ) {
        printf(" %d", heap[i]);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 3704
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] tmp = scanner.nextLine().split(" ");
		int n  = Integer.parseInt(tmp[0]);
		int x  = Integer.parseInt(tmp[1]);
		long a = 0;

		String[] temp = scanner.nextLine().split(" ");

		a = Math.abs(x -   Long.parseLong(temp[0]));

		for(int i = 1; i < n; i++) {

			a = gcd(a,  Math.abs(Long.parseLong(temp[i]) -   Long.parseLong(temp[i - 1])));

		}
		System.out.println(a);
	}

	public static long gcd(long x, long y) {

		if(x % y == 0) {

			return y;

		}else {

			return gcd(y, x % y);

		}

	}

}


Measured memory_bytes: 62648
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

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

ll memo[1000010];

ll fib(ll x){
  if(x == 0) return 1;
  else if(x <= 2) return x;
  else if(memo[x] != 0) return memo[x];
  return memo[x] = fib(x-2) + fib(x-1);
}

int main()
{
  string s;
  cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl; 
  return 0;
}

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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

string s;


signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>s;
    int Avis,Zvis;
    rep(i,0,s.size()){
        if(s[i]=='A'){
            Avis=i;
            break;
        }
    }
    rrep(i,0,s.size()){
        if(s[i]=='Z'){
            Zvis=i;
            break;
        }
    }
    cout<<Zvis-Avis+1<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 720
#include <stdio.h>

int main(void){
  int A, B;
  char S[20] = {};
  int count = 0;//'-'の個数
  int i, j, k;
  scanf("%d %d %s", &A, &B, S);
  for(i = 0; i < A; i++){
    if(S[i] == '-'){
      printf("No\n");
      return 0;
    }
  }
  if(S[A] != '-'){
    printf("No\n");
    return 0;
  }
  for(i = A + 1; i < A + B + 1; i++){
    if(S[i] == '-'){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
N,A,B = map(int,input().split())
S  = input()
t,k = 0,0
for i in range(N):
    if S[i]=="a":
        if t < A+B:
            print("Yes")
            t +=1
        else:
            print("No")
    elif S[i]=="b":
        if t < A+B and k <B:
            print("Yes")
            t += 1
            k += 1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 53080
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
A = list()
B = list()
for i in range(M):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)

class UnionFind():
    def __init__(self, n):
        self.parents = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            # 経路圧縮
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)

        if root_x != root_y:
            if self.rank[root_x] > self.rank[root_y]:
                self.parents[root_y] = root_x
                self.size[root_x] += self.size[root_y]
            else:
                self.parents[root_x] = root_y
                self.size[root_y] += self.size[root_x]
                if self.rank[root_x] == self.rank[root_y]:
                    self.rank[root_y] += 1

unionfind = UnionFind(N)
for i in range(M):
  unionfind.union(A[i]-1, B[i]-1)
count_list = [0]*N
for i in range(N):
  count_list[unionfind.find(i)] += 1
print(max(count_list))

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

namespace ConsoleApplication1
{
    class Program
    {
        static int[] preorder, parent, lowest;
        static bool[] visited;
        static int timer;

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int V = int.Parse(input[0]);
            int E = int.Parse(input[1]);

            Dictionary<int, List<int>> G = new Dictionary<int, List<int>>();
            for (int i = 0; i < V; i++) G.Add(i, new List<int>());

            preorder = new int[V];
            parent = new int[V];
            lowest = new int[V];
            visited = new bool[V];

            for (int i = 0; i < E; i++)
            {
                input = Console.ReadLine().Split(' ');
                int s = int.Parse(input[0]);
                int t = int.Parse(input[1]);

                G[s].Add(t);
                G[t].Add(s);
            }

            ArtPoints(G);
        }

        static void ArtPoints(Dictionary<int, List<int>> G)
        {
            timer = 1;

            DFS(G, 0, -1);

            int len = G.Count;
            int[] result = new int[len];
            for (int i = 1; i < len; i++)
            {
                int p = parent[i];

                if (preorder[p] <= lowest[i]) result[p]++;
            }
            result[0]--;

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < len; i++)
            {
                if (result[i] > 0) sb.AppendLine(i.ToString());
            }
            Console.Write(sb);
        }

        static void DFS(Dictionary<int, List<int>> G, int current, int prev)
        {
            preorder[current] = timer;
            lowest[current] = timer;
            timer++;

            visited[current] = true;

            int len = G[current].Count;
            for (int i = 0; i < len; i++)
            {
                int next = G[current][i];

                if (!visited[next])
                {
                    parent[next] = current;

                    DFS(G, next, current);

                    lowest[current] = Math.Min(lowest[current], lowest[next]);
                }
                else if (next != prev)
                {
                    lowest[current] = Math.Min(lowest[current], preorder[next]);
                }
            }
        }
    }
}

Measured memory_bytes: 13156
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using o_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) find_by_order(i)
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);


/*======================================================================*/
void solve(){
    int n;
    cin >> n;
    vi v(n+1, 0);
    for(int i = 1; i*i <= n; i++){
        for(int j = 1; j*j <= n; j++){
            for(int k = 1; k*k <= n; k++){
                if((i+j+k)*(i+j+k) - i*j - i*k - j*k <= n)v[(i+j+k)*(i+j+k) - i*j - i*k - j*k ]++;
            }
        }
    }
    rep(i, 1, n+1)cout << v[i] << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

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

const int INF = int(1e9) + 200;

const int MAXN = 1.1e5;
int N;
int L[MAXN];
int R[MAXN];

int Lpref[MAXN];
int Lsuff[MAXN];
int Rpref[MAXN];
int Rsuff[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> L[i] >> R[i];
	}
	int GL = *max_element(L, L + N);
	int GR = *min_element(R, R + N);

	Lpref[0] = Lsuff[N] = -200;
	Rpref[0] = Rsuff[N] = INF;
	for (int i = 0; i < N; i++) {
		Lpref[i+1] = max(Lpref[i], L[i]);
		Rpref[i+1] = min(Rpref[i], R[i]);
	}
	for (int i = N; i > 0; i--) {
		Lsuff[i-1] = max(Lsuff[i], L[i-1]);
		Rsuff[i-1] = min(Rsuff[i], R[i-1]);
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int cnd = (R[i] - L[i] + 1) + max(0, min(Rpref[i], Rsuff[i+1]) - max(Lpref[i], Lsuff[i+1]) + 1);
		ans = max(ans, cnd);
	}

	vector<pair<int, int>> vec;
	for (int i = 0; i < N; i++) {
		vec.emplace_back(L[i], R[i]);
	}
	sort(vec.begin(), vec.end());
	for (int i = N-1; i > 0; i--) {
		vec[i-1].second = min(vec[i-1].second, vec[i].second);
	}
	for (int i = 0; i+1 < N; i++) {
		ans = max(ans, max(0, GR - vec[i].first + 1) + max(0, vec[i+1].second - GL + 1));
	}

	cout << ans << '\n';
	return 0;
}

// consider global min and global max
// same side, in which case other side might as well be a single range
// if one side is empty, the other might as well be a single range too
// opposite sides, in which case we


Measured memory_bytes: 3832
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
typedef long long ll;
#include <cmath>

int main(int argc, char *argv[])
{
	int n;
	cin>>n;
	vector<int> x(n);
	int s=0;

	for (int i=0;i<n;i++)
	{
		cin>>x[i];
		s+=x[i];

	}
	//sort(x.begin(),x.end());
	int m=s/n;
	
	int r1=0,r2=0;
	for (int i=0;i<n;i++)
	{
		r1+=(m-x[i])*(m-x[i]);
		r2+=(m+1-x[i])*(m+1-x[i]);
	}
	if(r2<r1) r1=r2;
	cout<<r1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n;
    cin>>n;
    vector<double> v(n);
    double res=0;
    rep(i,n){
        cin>>v.at(i);
    }
    sort(v.begin(),v.end());
    res = v.at(0);
    for(int i=1;i<n;i++){
        res = (res+v.at(i))/2;
    }
    printf("%lf\n",res);
    return 0;
}


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

int p[N] = {};
void init(){
	for(int i = 0; i < N; ++i){
		p[i] = 1;
	}
	p[0] = p[1] = 0;
	for(int i = 2; i < sqrt(N); ++i){
		if(!p[i]) continue;
		for(int j = 2; i*j < N; ++j){
			p[i*j] = 0;
		}
	}
}


int main(void){
	int a,d,n;
	init();
	while(true){
		cin >> a >> d >> n;
		if(!a&&!d&&!n) break;
		int cnt = 0;
		int i = 0;
		while(true){
			if(p[a+d*i])cnt++;
			if(cnt==n)break;
			i++;
		}
		cout << a+d*i << endl;
	}
	return 0;
}


Measured memory_bytes: 6908
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string newName;
  cin >> newName;
  int resultCnt = 0;
  for(int n = 0; n < N; ++n) {
    string oldName;
    cin >> oldName;
    bool wordLoopEnd = false;
    for(int istart = 0; (istart <= oldName.size() - newName.size()) && !wordLoopEnd; ++istart) {
      for(int dchr = 1; dchr < oldName.size() && !wordLoopEnd; ++dchr) {
        stringstream ss;
        for(int ichr = 0; ichr < newName.size(); ++ichr) {
          int index = istart + ichr * dchr;
          if(oldName.size() > index) {
            ss << oldName[index];
          } else {
            break;
          }
        }
        // cout << ss.str() << endl;
        if(ss.str() == newName) {
          ++resultCnt;
          wordLoopEnd = true;
          // cout << "OK!" << endl;
        }
      }
    }
  }
  cout << resultCnt << endl;
  return 0;
}

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

typedef pair<int,int> P;

int h,w,s,all;
int u[35][35] = {0};
int f[35][35] = {0};
// メモ化, DP
P dp[35][35][35][35];

// [x1,x2] && [y1,y2] の領域の総和を計算する.
int sum(int x1, int y1, int x2, int y2){
	x2++; y2++;
	return f[y2-1][x2-1] - f[y2-1][x1-1] - f[y1-1][x2-1] + f[y1-1][x1-1];
}

// 初期化.
void init(){
	for(int i=0 ; i < 35 ; i++ ){
		for(int j=0 ; j < 35 ; j++ ){
			for(int k=0 ; k < 35 ; k++ ){
				for(int l=0 ; l < 35 ; l++ ){
					dp[i][j][k][l].first = dp[i][j][k][l].second = 0;
				}
			}
		}
	}
}

// メモ化再帰, P.first := 最大グループ数, P.second := 最大予備力.
P dfs(int lx, int ly, int rx, int ry){
	if( dp[lx][ly][rx][ry].first != 0 ) return dp[lx][ly][rx][ry];
	
	P res = P( 1 , s - (all - sum(lx,ly,rx,ry)) );
	
	// 水平に分割
	for(int y=ly ; y < ry ; y++ ){
		if( all - s > sum(lx,ly,rx,y) ) continue;
		if( all - s > sum(lx,y+1,rx,ry) ) continue;
		P a = dfs( lx , ly  , rx , y );
		P b = dfs( lx , y+1 , rx , ry );
		P now = P( a.first + b.first , min(a.second,b.second) );
		res = max( res , now );
	}
	
	// 垂直に分割
	for(int x=lx ; x < rx ; x++ ){
		if( all - s > sum(lx,ly,x,ry) ) continue;
		if( all - s > sum(x+1,ly,rx,ry) ) continue;
		P a = dfs(lx,ly,x,ry);
		P b = dfs(x+1,ly,rx,ry);
		P now = P( a.first + b.first , min(a.second,b.second) );
		res = max( res , now );
	}
	return dp[lx][ly][rx][ry] = res;
}

int main(){
	while( cin >> h >> w >> s, h || w || s ){
		//入力 + 累積和化
		for(int y = 1 ; y <= h ; y++ ){
			for(int x = 1 ; x <= w ; x++ ){
				cin >> u[y][x];
				f[y][x] = u[y][x] + f[y][x-1];
			}
		}
		for(int y = 1 ; y <= h ; y++ ){
			for(int x = 1 ; x <= w ; x++ ){
				f[y][x] += f[y-1][x];
			}
		}
		init();
		all = sum(1,1,w,h);
		P ans = dfs( 1 , 1 , w , h );
		cout << ans.first << " " << ans.second << endl;
	}
}

Measured memory_bytes: 12000
package main

import (
	"fmt"
)

func main() {
	var W, H, x, y, r int
	fmt.Scan(&W)
	fmt.Scan(&H)
	fmt.Scan(&x)
	fmt.Scan(&y)
	fmt.Scan(&r)

	if (r <= x && r <= y) && (x <= W-r && y <= H-r) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1148
import math
import sys
from itertools import permutations
input = sys.stdin.readline

N=int(input())
ans=0
cur=0
for i in range(1,N+1):
    cur+=i
    ans+=cur
# print(ans)
for i in range(N-1):
    u,v=map(int,input().split())
    U=min(u,v)
    V=max(u,v)
    x=U*(N-V+1)
    ans-=x
    # print("x",x)

print(ans)


Measured memory_bytes: 68224
x = int(input())
resA = 0
resB = 0
for a in range(500):
  for b in range(-500,500):
    A = a**5
    B = b**5
    N= A-B
    if A-B==x:
      resA = a
      resB = b
      break
    else:
      pass
  if A-B==x:
    break
print(resA,resB)

Measured memory_bytes: 9196
#include <stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    int i = 1;
    do{
        int x = i;
        if( x % 3 == 0){
            printf(" %d", i);
            continue;
        }
        do{
            if( x % 10 == 3){
                printf(" %d", i);
                break;
            }
            x /= 10;
        }while( x );
    }while( ++i <= n);
    printf("\n");
}

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

bool chk(const int x) {
    int div = 0;
    for (int i = 1; i <= x; ++i) div += 0 == x%i;
    return div == 8;
};

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    assert(chk(105) == true);
    int n; cin >> n;
    int res = 0;
    for (int i = 1; i <= n; i += 2) res += chk(i);
    cout << res;
    return 0;
}

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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            int shift = int.Parse(Console.ReadLine());
            string str = Console.ReadLine();
            string retstr = string.Empty;
            List<string> comp = new List<string> { "A", "B", "C", "D", "E", "F", "G"
            , "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
            foreach (var s in str)
            {
                for (int i = 0; i < comp.Count; i++)
                {
                    if (comp[i].CompareTo(s.ToString()) == 0)
                    {
                        if (i + shift >= 26)
                        {
                            retstr += comp[i + shift - 26];
                        }
                        else { retstr += comp[i + shift]; }
                        break;
                    }
                }
            }
            Console.WriteLine(retstr);
            Console.ReadLine();
        }



    }
}

Measured memory_bytes: 37200
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n;
    cin>>n;
    int a[n];
    vector<int> idx(n+1);
    rep(i,n){
        cin>>a[i];
        idx[a[i]]=i;
    }
    ll ans=0;
    multiset<int> used;
    /*番兵
    ↓を入れないとlower_boundの結果がused.begin(),used.end()
    になることがあり、そのときbeginの一個前、endとendの後ろとか
    参照できないからこれを入れると最高に都合がよい。
    これを入れなくてもbegin,endが出てきたら場合分けでもいける。
     */
    used.insert(-1);
    used.insert(-1);
    used.insert(n);
    used.insert(n);
    for(ll i=n;i;i--){
        auto pre=used.lower_bound(idx[i]);
        --pre;
        auto nxt=pre;++nxt;
        ans+=(*pre-*prev(pre)) * (*nxt-idx[i]) * i;
        ans+=(idx[i]-*pre) * (*next(nxt)-*nxt) * i;
        used.insert(idx[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    while(cin>>n){
            if(n<1000){cout<<1000-n<<endl; continue;}
            int t=(n+1000-1)/1000;
            cout<<(t*1000)%n<<endl;

    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(void){
	// int mountains;
	std::vector<int> mountains;
	for (int i = 0; i < 10; i ++) {
		int temp;
		cin >> temp;
		mountains.push_back(temp);
	}

	sort(mountains.begin(),mountains.end(), greater<int>());
	for (int i = 0; i < 3; i ++) {
		cout << mountains.at(i) << endl;
	}

	return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

//attrは10で初期化！
int main()
{
    int n;
    cin >> n;
    ll m;
    cin >> m;
    if (m == 0)
    {
        cout << -1 << endl;
        return 0;
    }
    map<int, vector<int>> g1, g2;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g1[a].push_back(b);
    }
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    map<pair<int, int>, bool> visited;
    deque<int> que;
    vector<int> attr(n, 10);
    vector<int> v2;

    que.push_back(s);
    int ans = 0;
    map<pair<deque<int>, int>, bool> state;
    while (true)
    {
        deque<int> next;

        next.clear();
        while (!que.empty())
        {
            int now = que.back();
            que.pop_back();
            for (auto x : g1[now])
            {
                if (visited[{x, ans % 3}] == true)
                    continue;
                //cerr << x << " ";
                next.push_back(x);
                visited[{x, ans % 3}] = true;
            }
        }
        //cerr << endl;
        que = next;

        ans++;
        if (visited[{t, (ans - 1) % 3}] == true && ans % 3 == 0)
        {
            cout << ans / 3 << endl;
            return 0;
        }
        else if (state[{que, ans % 3}] == true)
        {
            cout << -1 << endl;
            return 0;
        }
        visited[{t, (ans - 1) % 3}] = false;
        state[{que, ans % 3}] = true;
    }
}


Measured memory_bytes: 250752
using System;
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var ret = Console.ReadLine().Split(' ').Select(int.Parse).OrderByDescending(x => x).Take(r[1]).Sum();
            Console.WriteLine(ret);
        }

    }
}

Measured memory_bytes: 13396
n = int(input())
a = list(map(int,input().split()))
ans = [0] * n
for i in  range((n + 1) // 2):
    ans[n - i - 1] = a[n - i - 1]
for i in range(n // 2):
    m = n // 2
    s = 0
    for j in range(n // (m - i) - 1):
        s += ans[(m - i) * (2 + j) - 1]
    if s % 2 != a[m - i - 1]:
        ans[m - i - 1] = 1

anss = []
for i in range(n):
    if ans[i] == 1:
        anss.append(str(i + 1))
print(len(anss))
print(' '.join(anss))

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

int main(void) {
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    set<char> st;
    st.insert(a[i]);
    st.insert(b[i]);
    st.insert(c[i]);
    cnt += (int)st.size() - 1;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll ans=0,n,i,j;
	cin>>n;
	string a,b,c;
	cin>>a>>b>>c;
	for(i=0;i<n;i++){
		set<ll>s;
		s.insert(a[i]);
		s.insert(b[i]);
		s.insert(c[i]);
		if(s.size()==2)ans++;
		else
		if(s.size()==3)ans+=2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import math
A=list(map(int, input().split()))
b=str(A[0])+str(A[1])
c=int(b)
#print(round(math.sqrt(int(b)),10))
#c=round(math.sqrt(int(b)),10)
d=0
for i in range(10000):
    if i*i==c:
        print('Yes')
        d=1
if d==0:
    print('No')

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; 2*i+1 <= n; i++)
    {
        int count = 0;
        for(int j = 1; j <= 2*i+1; j++)
        {
            if((2*i+1) % j == 0) count++;
        }
        if(count == 8) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"
 
using namespace std;
 
typedef long long ll;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
    
 #define sz(x) (int)(x).size()
 #define mp make_pair
 #define pb push_back
 #define all(x) x.begin(), x.end()
 
 #define PI 3.14159265358979323846264338327950L
const int MOD = 1000000007;
 
int main() 
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    string s;
    cin>>s;

    if(s[s.size()-1] == 's') s+="es";
    else s+='s';

    cout<<s;
}


Measured memory_bytes: 3660
import sys
sys.setrecursionlimit(10**9)
INF = 10**18


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    ans = 0
    v=list(map(int,input().split()))
    c=list(map(int,input().split()))
    for i in range(N):
        ans += max(0, v[i]-c[i])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

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

	n := scanInt()
	l := scanInt()
	a := scanInts(n)

	index := -1

	for i := 0; i < n-1; i++ {
		if a[i]+a[i+1] >= l {
			index = i
			break
		}
	}

	if index == -1 {
		fmt.Println("Impossible")
		return
	}

	fmt.Println("Possible")

	for i := 0; i < index; i++ {
		fmt.Fprintln(wr, i+1)
	}

	for i := 0; i < n-2-index; i++ {
		fmt.Fprintln(wr, n-1-i)
	}

	fmt.Fprintln(wr, index+1)
	wr.Flush()
}


Measured memory_bytes: 4480
#include <iostream>

using namespace std;

int main()
{
	int x, y, tmp;

	while (true)
	{
		cin >> x >> y;
		if (x == 0 && y == 0)
			break;

		if (x > y) cout << y << " " << x << endl;
		else cout << x << " " << y << endl;
	}
}

Measured memory_bytes: 3056
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

ll p[100005] = {};
ll pi[100005] = {};
ll sum[100005] = {};
int main(int, const char**)
{
    ll n, x, m;
    cin >> n >> x >> m;
    ll t = x;
    ll index = 1;
    while(p[t] == 0)
    {
        Print(t);
        if(t == 0)
        {
            break;
        }
        p[t] = t * t % m;
        Print(p[t]);
        pi[t] = index;
        Print(pi[t]);
        sum[index] = sum[index - 1] + t;
        index++;
        t = p[t];
    }

    auto loopCount = index - pi[t];
    auto headCount = index - 1 - loopCount;
    Print(headCount);
    Print(loopCount);
    Print(t);
    Print(index);
    Print(pi[t]);
    Print(sum[index - 1]);
    Print(sum[pi[t] - 1]);
    auto loopSum = sum[index - 1] - sum[pi[t] - 1];
    Print(loopSum);

    if(t == 0)
    {
        auto ti = min(index - 1, n);
        cout << sum[ti] << endl;
        return 0;
    }

    if(n <= headCount)
    {
        cout << sum[n] << endl;
        return 0;
    }

    auto rest = n - headCount;
    Print(rest);
    auto lc = rest / loopCount;
    Print(lc);
    auto lm = rest % loopCount;
    Print(lm);
    auto ms = sum[headCount + lm] - sum[headCount];
    Print(ms);
    auto ans = lc * loopSum + ms + sum[headCount];
    cout << ans << endl;    

    return 0;
}


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

int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

constexpr int INF = 1e9+7;
constexpr ll INFL = 9*1e18;

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

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

int inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
template<typename T>inline void print(T&& x){cout<<setprecision(32)<<x<<endl;}


// TODO: write
int main() {
  int n;cin>>n;
  print(!n);
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N; std::cin >> N;
  std::vector<ll> a(N); rep(i,N) std::cin >> a[i];
  ll S = 0; rep(i,N) S ^= a[i];
  rep(i,N) {
    std::cout << (S^a[i]) << " ";
  }
  std::cout << std::endl;
  return 0;
}



Measured memory_bytes: 4748
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+10;
const int MAX2=2e5+4;
const int MAAX=2e18;
const int MOD=1e9+7;
int dp[2][MAX],w,n;
int v[105],we[105];
int fun(int idx,int val)
{
    if(idx==n)
    {
        return 0;
    }
    int &ret=dp[idx][val];
    if(ret!=-1)
    {
        return ret;
    }

    return ret=min(we[idx]+fun(idx+1,val-v[idx]),fun(idx+1,val));
}
in main()
{

 cin>>n>>w;
 int s=0;
 for(int i=1;i<=n;i++)
 {
     cin>>we[i]>>v[i];
     s+=v[i];
 }
 for(int i=0;i<=s;i++)
    dp[0][i]=INT_MAX,dp[1][i]=INT_MAX;
 for(int i=0;i<=n;i++) dp[i][0]=0;
 int ans=0;
 for(int i=1;i<=n;i++)
 {
     for(int j=0;j<=s;j++)
     {
         dp[i&1][j]=dp[(i-1)&1][j];
         if(j-v[i]>=0)
         dp[i&1][j]=min(dp[i&1][j],we[i]+dp[(i-1)&1][j-v[i]]);
         if(dp[i&1][j]<=w)
         {
             ans=max(j,ans);
         }
     }
 }

 cout<<ans<<endl;
 return 0;
}


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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

double dp[310][310][310];
ll n;

double rec(ll i,ll j,ll k){
	//1この皿がi枚、2この皿がj枚、３この皿がk枚
	if(dp[i][j][k]>=0.0) return dp[i][j][k];
	double ret=0.0;
	if(i>0) ret+=rec(i-1,j,k)*i;//1この皿を引いた場合
	if(j>0) ret+=rec(i+1,j-1,k)*j;//2この皿を引いた場合
	if(k>0) ret+=rec(i,j+1,k-1)*k;//３この皿を引いた場合
	ret+=n;//(n/i+j+k)、n枚ある皿から(i+j+k)枚の皿をえらぶ期待値（確率の逆数）
	ret/=(double)(i+j+k);
	dp[i][j][k]=ret;
	return ret;
}

void solve(){
	cin>>n;

	ll a[3]={0,0,0};
	REP(i,n){
		ll aa;
		cin>>aa;
		a[aa-1]++;
	}

	memset(dp,-1.0,sizeof(dp));
	dp[0][0][0]=0.0;
	cout<<fixed<<setprecision(10)<<rec(a[0],a[1],a[2])<<en;
	
}

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

    solve();
    return 0;
}

Measured memory_bytes: 233088
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f3f3f3f3fLL
#define rep(i,a,b) for(register ll i=(a);i<=(b);i++)
#define dep(i,a,b) for(register ll i=(a);i>=(b);i--)
using namespace std;
const int maxn=310+5;
const int maxm=5000+5;
//const double pi=acos(-1.0);
//const double eps=1e-9;
const ll mo=1e9+7;
int n,m,k;
ll a[maxn];
ll ans,tmp,cnt;
ll dp[maxm][maxm];
char s[maxn];
ll po[maxm];
ll power(ll a,ll n)
{
    ll sum=1;
    while(n)
    {
        if(n&1) sum=sum*a%mo;
        n>>=1;
        a=a*a%mo;
    }
    return sum;
}
int main()
{
    dp[0][0]=1;
    rep(i,0,5000)
    {
        rep(j,0,i)
        {
            dp[i+1][j+1]=(dp[i+1][j+1]+2*dp[i][j])%mo;
            dp[i+1][max(j-1,0LL)]=(dp[i+1][max(j-1,0LL)]+dp[i][j])%mo;
        }
    }
    po[0]=1;
    rep(i,1,5000) po[i]=po[i-1]*2%mo;
    rep(i,1,5000) po[i]=power(po[i],mo-2);
    while(scanf("%d%s",&m,s)!=EOF)
    {
        n=strlen(s);
        printf("%lld\n",dp[m][n]*po[n]%mo);
    }
    return 0;
}


Measured memory_bytes: 194048
#include<iostream>
#include<vector>
using namespace std;
int main(void){
	int n,k,s;

	vector<vector<vector<int > > > a(21,vector<vector<int> >(11,vector<int>(156,0)));
	vector<vector<int> > b(21,vector<int>(2,0));
	for(int i=1;i<21;i++){
		b[i][1]=i;
	}
	int sum=0;
	for(int i=0;i<1024*1024;i++){
		int l=i;
		sum=0;
		int m=0;
		int count=0;
		bool flag=true;
		for(int j=1;j<21;j++){
			if(l%2==1){
				sum+=b[j][1];
				m=max(m,j);
				count++;
				if(count>10||sum>155){
					flag=false;
					break;
				}
			}
			l/=2;
		}
		if(flag){
			for(int j=m;j<21;j++){
			a[j][count][sum]++;
			}
		}
	}
	while(1){
		cin>>n>>k>>s;
		if(n==0)break;
		cout<<a[n][k][s]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3240
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
ans=0
for i in range(1,n+1):
    num=n//i
    ans+=(num*(i+num*i))//2
print(ans)

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

using namespace std;

typedef long long  ll;
typedef vector<ll> VL;
typedef pair<ll,ll> PLL;
#define pb push_back
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=998244353;


void solve()
{
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	VL p(a),q(b),r(c);
	fr(i,0,a)
		cin>>p[i];
	fr(i,0,b)
		cin>>q[i];
	fr(i,0,c)
		cin>>r[i];
	sort(ALL(p),greater<ll>());
	sort(ALL(q),greater<ll>());
	sort(ALL(r),greater<ll>());
	priority_queue<PLL> qq;
	fr(i,0,x)
	{
		qq.push({p[i],0});
	}
	fr(i,0,y)
	{
		qq.push({q[i],1});
	}
	fr(i,0,c)
	{
		qq.push({r[i],-1});

	}
	ll tot=0,cx=0,cy=0,ans=0;
	while(!qq.empty()&&tot<x+y)
	{
		PLL f=qq.top();
		if(f.S==0)
		{
			if(cx<x)
			{
				tot++;
				cx++;
				ans+=f.F;
			}

		}
		else if(f.S==1)
		{
			if(cy<y)
			{
				cy++;
				tot++;
				ans+=f.F;
			}
		}
		else
		{
			tot++;
			ans+=f.F;
		}
		qq.pop();
	}
	cout<<ans<<endl;
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
		solve();
	}
	return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  int ans=0;
  for(int i=0;i<3;i++) {
    if(s.at(i)==t.at(i)) {
      ans+=1;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw`(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

const ll MAX = MOD;

void solve(){
  int H,W; cin>>H>>W;
  
  map<int,int> mp;
  multiset<int> ms;

  REP(i,W){
    mp[i] = i;
    ms.insert(0);
  }
  
  REP(i,H){
    int a,b; cin>>a>>b;
    --a;
    auto it = mp.lower_bound(a);
    int max_r = -1;
    while(it != mp.end() && it->first <= b){
      chmax(max_r,it->second);
      int temp = it->first - it->second;
      ms.erase(ms.find(temp));
      it = mp.erase(it);
    }
    if(max_r != -1 && b < W){
      ms.insert(b-max_r);
      mp[b] = max_r;
    }
    int ans = -1;
    if(ms.size()>0){
      ans = *ms.begin() + (i+1);
    }
    cout << ans << "\n";
  }
  return;
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

Measured memory_bytes: 22372
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  vector<vector<pii>> G(N);
  vector<pii> E(N - 1);
  vector<int> color(N - 1, -1);
  int kinds = 0;
  rep(i, 0, N - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back({b, i});
    G[b].push_back({a, i});
    E[i] = {a, b};
  }
  rep(i, 0, N) { chmax(kinds, sz(G[i])); }

  auto dfs = [&](auto fun, int v, int p, int shift) -> void {
    int c = shift;
    for (pii e : G[v]) {
      if (e.first == p) continue;
      fun(fun, e.first, v, (c + 1) % kinds);
      color[e.second] = c;
      c++;
      c %= kinds;
    }
  };
  dfs(dfs, 0, -1, 0);

  rep(i, 0, N) {
    set<int> c;
    for (pii e : G[i]) {
      c.insert(color[e.second]);
    }
    assert(sz(c) == sz(G[i]));
  }

  cout << kinds << endl;
  for (int c : color) cout << c + 1 << endl;
  return (0 ^ _ ^ 0);
}



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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  string ans = "No";
  if (a == b && b != c) ans = "Yes";
  if (a == c && a != b) ans = "Yes";
  if (b == c && a != b) ans = "Yes";
  cout << ans << endl;
}


Measured memory_bytes: 256