akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define pb push_back
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = 1; i <= n; ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
using namespace std;
typedef vector<int> vi;

const int MX = 100005;
const int INF = 1001001001;

int w, h, n;
int ans;

void f(int a, int b) {
  if (a < w && b < w && a == b) ans++;
  a -= w; b -= w-2;
  if (a <= 0 || b <= 0) return;
  if (a <= h-2 && b <= h-2 && a == b) ans++;
  a -= h-1; b -= h-3;
  if (a <= 0 || b <= 0) return;
  if (a == b) ans++;
}

int main() {
  scanf("%d%d",&w,&h);
  scanf("%d",&n);
  int a = 1, b = 1;
  rep(i,n) {
    int p;
    scanf("%d",&p);
    if (p) b++; else a++;
    f(a,b);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3244
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
    char word[150];
    int cnt=0;
    while(~scanf("%s",word)){
        int N=0,Long=strlen(word),L,i;
        //if(Long%2==1)N=1;
        L=Long-1;
        for(i=0;i<Long/2;i++){
            if(word[i]!=word[L])break;
            L--;
        }
        if(i==Long/2)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main() {
    int32_t n, x;

    while (cin >> n >> x) {
        if (n == 0 && x == 0) {
            break;
        }

        int32_t count = 0;

        for (int32_t i = 1; i <= n - 2; i++) {
            for (int32_t j = i + 1; j <= n - 1; j++) {
                for (int32_t k = j + 1; k <= n; k++) {
                    if (i + j + k == x) {
                        count++;
                    }
                }
            }
        }

        cout << count << endl;
    }

    return 0;
}

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

using namespace std;

int N;
long long int A[1000*1000+1];

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

	long long int sumHeight = 0; // 最長の踏み台

	for (int i = 1; i < N;i++) {
		if (A[i-1] > A[i]){
			// 踏み台の高さをsumに足す
			int box = A[i - 1] - A[i];
			sumHeight += box;

			// 同じ高さに合わせる
			A[i] += box;
		}
	}

	cout << sumHeight << endl;
}

Measured memory_bytes: 5200
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		String reString = "No";
		
		
		if(a <= b) {
			if(a < c && c < b) {
				reString = "Yes";
			}
		} else {
			if(b < c && c < a) {
				reString = "Yes";
			}
		}
		System.out.println(reString);
	}
}

Measured memory_bytes: 23124
import heapq

class edge:
    def __init__(self,to,cap,cost,rev):
        self.to = to
        self.cap = cap
        self.cost = cost
        self.rev = rev

class min_cost_flow:
    INF = 52**60
    def __init__(self, n):
        self.V = n
        self.G = [[] for _ in range(n)]
        self.h = [0 for _ in range(n)]
        self.dist = [0 for _ in range(n)]

    def add_edge(self, f, t, cap, cost):
        self.G[f].append(edge(t,cap,cost,len(self.G[t])))
        self.G[t].append(edge(f,0,-cost,len(self.G[f])-1))

    def min_cost_flow(self, s, t, f):
        prevv = [0 for _ in range(self.V)]
        preve = [0 for _ in range(self.V)]

        res = 0
        self.h = [0 for _ in range(self.V)]
        while f > 0:
            pq = []
            self.dist = [min_cost_flow.INF for _ in range(self.V)]
            self.dist[s] = 0
            # dijkstra
            heapq.heappush(pq,(0,s))
            while len(pq) != 0:
                p = heapq.heappop(pq)
                v = p[1]
                if p[0] > self.dist[v]:
                    continue
                for i in range(len(self.G[v])):
                    e = self.G[v][i]
                    if e.cap>0 and self.dist[e.to]>self.dist[v]+e.cost+self.h[v]-self.h[e.to]:
                        self.dist[e.to] =  self.dist[v]+e.cost+self.h[v]-self.h[e.to]
                        prevv[e.to] = v
                        preve[e.to] = i
                        heapq.heappush(pq,(self.dist[e.to],e.to))

            if self.dist[t] == min_cost_flow.INF:
                return -1

            for i in range(self.V):
                self.h[i] += self.dist[i]

            d = f
            v = t
            while v != s:
                d = min(d,self.G[prevv[v]][preve[v]].cap)
                v = prevv[v]
            f -= d
            res += d*self.h[t]

            v = t
            while v != s:
                self.G[prevv[v]][preve[v]].cap -= d
                self.G[v][self.G[prevv[v]][preve[v]].rev].cap += d
                v = prevv[v]

        return res

    def solve(self,s,t,n,d):
        f = self.min_cost_flow(s,t,n)
        ans = []
        for i in range(n):
            for j in range(len(self.G[n+i])):
                if self.G[n+i][j].cap>0:
                    cost = -self.G[n+i][j].cost
                    ans.append(d[cost])
                    break
        ans.sort()
        return ''.join(ans)

def main():
    n = int(input())
    s = []
    for _ in range(n):
        s.append(input())

    flow = min_cost_flow(2*n+2)
    S,T = 2*n,2*n+1
    X = 52**52

    for i in range(n):
        flow.add_edge(S,i,1,0)
        flow.add_edge(n+i,T,1,0)

    d = {}
    for i in range(n):
        for j in range(n):
            cost = X
            if 'A'<=s[i][j]<='Z':
                cost -= 52**(51-(ord(s[i][j])-ord(('A'))))
            else:
                cost -= 52**(25-(ord(s[i][j])-ord(('a'))))
            flow.add_edge(i,n+j,1,cost)
            d[cost] = s[i][j]

    print(flow.solve(S,T,n,d))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9536
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int sum = 0;
			for(int i=0;i<10;i++)sum+=sc.nextInt();
			System.out.println(sum);
		}
	}	
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

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

void solution() {
  int a, b, c;
  cin >> c >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % c == 0) {
      cout << "OK" << endl;
      return;
    }
  }
  cout << "NG" << endl;
}

int32_t main() {
  DESYNC;
  solution();
}


Measured memory_bytes: 3692
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> A = {a, b, c};
  sort(A.begin(), A.end());
  if (A[0] == 5 && A[1] == 5 && A[2] == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;

using ll = long long;
using ipair = pair<ll,int>;
using pairv = vector<ipair>;

void PrimeFactorization(ll n, pairv& ans)
{
    if (n == 1) return;
    ll org_n = n;
    ll max_prime = (ll)(sqrt(double(n)));
    ll prime = 2;
    vector<int> sieve(max_prime + 9);

    bool is_n_prime = true; // 入力した数が素数かどうか
    bool do_while = true;
    int count = 0;
    while(1){
        if (prime > max_prime) break;
        for (ll i = prime; i <= max_prime; i += prime) 
            sieve[i] = 1;
        if (!do_while) break;
        while(1){ // primeで割り切れなくなるまで繰り返し
            if (n % prime == 0){
                is_n_prime = false;
                n /= prime; ++count;
                if (n == 1) { do_while = false; break; } // n == 1 なら外側のwhileから抜ける
            } else break; // 割り切れなかったら内側のwhileから抜ける
        }
        if (!do_while) break;
        if (count) ans.push_back(ipair(prime,count));
        count = 0; ++prime;
        for (ll i = prime; sieve[i]; ++i) if (i > max_prime) { do_while = false; break; }
        if (!do_while) break;
    }
    if (count) ans.push_back(ipair(prime,count));
    if (is_n_prime) ans.push_back(ipair(n,1));   

    ll check = 1;
    for (auto a: ans){
        for(int i = 0; i < a.second; ++i) check *= a.first;
    }
    if (check != org_n){
        ll d = org_n / check; ans.push_back(ipair(d,1));
    } 
}

int main()
{
    ll n; cin >> n;
    pairv pv;
    PrimeFactorization(n,pv);
    ll ans = 0;
    for (auto p : pv)
        for (int dec = 1, remain = p.second; dec <= remain; remain -= dec++, ++ans);
    cout << ans << endl;

    return 0; 
}

Measured memory_bytes: 7224
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, c, i, g;
    
     scanf("%d%d%d", &a, &b, &c);
    g=0;
    for (g=a; g<=b; g++) {
        if (c % g == 0) {
            i++;
        }
    }
    printf("%d\n", i);
    return 0;
}



Measured memory_bytes: 2100
N, K = map(int, input().split())

MOD = 10 ** 9 + 7
count = [0] * (N + 1)
for i in range(1, N + 1):
    count[i] += count[i - 1] + i
    count[i] %= MOD

ans = 1
for k in range(K, N + 1):
    ans += count[-1] - count[-k - 1] - count[k - 1] + 1
    ans %= MOD
print(ans)


Measured memory_bytes: 66376
from fractions import gcd

a,b,c,d = [int(i) for i in input().split()]

def count_num(num):
  a_1 = num//c
  a_2 = num//d
  a_3 = num//(c * d // gcd(c, d))
  return num - (a_1 + a_2 - a_3)

print(int(count_num(b) - count_num(a-1)))


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

const ll maxs = 1e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

ll a,b,n;

ll get(ll x){
    ll v = a*x/b;
    v -= (a*floor(x/b));
    return v;
}

void solve(){
    cin >> a >> b >> n;
    if(b <= n){
        cout << get(b-1) << endl;
        return;
    }
    else{
        cout << get(n) << endl;
    }
    // ll l=0,r=n;
    // ll res=0;
    // while(l<=r){
    //     ll mid  = (l+r)/2;
    //     if( get(res) < get(mid) ){
    //         res = mid;
    //         l = mid+1;
    //     }
    //     else r = mid-1;
    // }
    // cout << get(res) << endl;
}

int main(){
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long[] a = sc.LongArray();

        long money = 1000;
        long stock = 0;

        for (int i = 0; i < n - 1; i++)
        {
            if (a[i] < a[i + 1])
            {
                stock += money / a[i];
                money = money % a[i];
            }
            else if (a[i] > a[i + 1])
            {
                money += stock * a[i];
                stock = 0;
            }
        }

        long answer = money + stock * a[n - 1];

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28076
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#define ll long long
#define pb push_back
using namespace std;
const int N=110000;
vector<int> P[N];
int n;
int main()
{
	cin>>n;
	ll k=1;
	for(;k<=n+1;k++)
	{
		if(k*(k-1)!=2ll*n) continue;
		int tot=0;
		for(int i=1;i<=k;i++)
			for(int j=i+1;j<=k;j++)
				P[i].pb(++tot),P[j].pb(tot);
		printf("Yes\n%lld\n",k);
		for(int i=1;i<=k;i++)
		{
			int l=P[i].size();
			printf("%d ",l);
			for(int j=0;j<l;j++) printf("%d ",P[i][j]);
			puts("");
		}
		return 0;
	}
	return puts("No"),0;
}


Measured memory_bytes: 4864
#include <stdio.h>    
#include <math.h>
#define _CRT_SEVURE_NO_WARNINGS
int main()
{
	int a, b;
	int left[4];
	int right[4];
	int i;
	for (i = 0; i < 4; i++){
		left[i] = right[i] = 0;
	}
	while (scanf("%d.%d", &a,&b)!=EOF){
		if (a == 0){
			if (b >= 6) left[1]++;
			else if (b <= 1) left[3]++;
			else left[2]++;
		}
		else if(a == 1){
			if (b>=1) left[0]++;
			else left[1]++;
		}
		else left[0]++;
		scanf("%d.%d", &a, &b);
		if (a == 0){
			if (b >= 6) right[1]++;
			else if (b <= 1) right[3]++;
			else right[2]++;
		}
		else if (a == 1){
			if (b >= 1) right[0]++;
			else right[1]++;
		}
		else right[0]++;
	}
	for (i = 0; i < 4; i++){
		printf("%d %d\n", left[i], right[i]);
	}
	return 0;
}

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

using namespace std;

int main(void)
{
  int n;
  
  cin >> n;
  
  int a[n];
  int b = 0;
  
  for(int loop = 0; loop < n; loop ++ ) {
    cin >> a[loop];
    if( a[loop] != (loop + 1) ) b ++;
  }
  
  switch( b ) {
    case 0:
    case 2:
      cout << "YES" << endl;
      break;
    default:
      cout << "NO" << endl;
      break;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <stack>
#include <vector>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <set>
#include <limits>
#include <numeric>
#include <array>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int wMax;
	cin >> wMax;
	vector<int> weights(n);
	vector<int> values(n);
	long long res = 0;

	for (int i = 0; i < n; ++i)
	{
		cin >> weights[i];
		cin >> values[i];
	}

	int totalvalue = accumulate(values.begin(), values.end(), 0);
	vector<long long> prev(totalvalue + 1, numeric_limits<int>::max());
	prev[0] = 0;
	vector<long long> cur(totalvalue + 1, numeric_limits<int>::max());

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j <= totalvalue; ++j)
		{
			cur[j] = prev[j];
			if (j - values[i] >= 0)
			{
				cur[j] = min(cur[j], weights[i] + prev[j - values[i]]);
			}
		}
		prev = cur;
	}

	for (long long i = 0; i <= totalvalue; ++i)
	{
		if (cur[i] <= wMax) res = max(res, i);
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1792
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(int argc,char** argv){
	string s;
	cin>>s;
	if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi")cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	ls := make([]int, n)
	lm := make(map[int]int)
	for i := range ls {
		fmt.Scan(&ls[i])
		lm[ls[i]]++
	}
	ks := make([]int, 0)
	for k := range lm {
		ks = append(ks, k)
	}
	sort.Ints(ks)

	if n < 3 {
		fmt.Println(0)
		return
	}

	count := 0
	for i := 0; i < len(ks)-2; i++ {
		for j := i + 1; j < len(ks)-1; j++ {
			for k := j + 1; k < len(ks); k++ {
				if ks[i]+ks[j] > ks[k] {
					count += lm[ks[i]] * lm[ks[j]] * lm[ks[k]]
				}
			}
		}
	}
	fmt.Println(count)

}


Measured memory_bytes: 1864
n = int(input())
b = list(map(int,input().split()))
for i in range(n):
	if b[i] > i+1:
		print(-1)
		exit()

ansl = []
while len(b) != 0:
	tmp = 0
	for i in range(len(b)):
		targ = i+1-b[i]
		if targ == 0:
			tmp = i
	ansl.append(str(b[tmp]))
	b.pop(tmp)

ansl.reverse()
print("\n".join(ansl))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	while(true)
{
	int c=0;
	int n,x;
	cin >> n >> x;
	if(n==0&&x==0)return 0;
	for(int i = 1;i<=n;++i)
	{
		for(int j = i+1;j<=n;j++)
		{
			for(int k=j+1;k<=n;k++)
			{
				if(i+j+k==x)c++;
			}
		}
	}
	cout<<c<<endl;
	
}
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int H, W;
  cin >> H >> W;
  char c[H][W];
  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < W; j++) {
      c[i][j] = s[j];
    }
  }
  int t[H][W];
  memset(t, -1, sizeof(t));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (c[i][j] == 'c') t[i][j] = 0;
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 1; j < W; j++) {
      if (t[i][j - 1] != -1) {
        if (t[i][j] == -1) t[i][j] = t[i][j - 1] + 1;
        else t[i][j] = min(t[i][j], t[i][j - 1] + 1);
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (j == 0) cout << t[i][j];
      else cout << " " << t[i][j];
    }
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    set<int> ss[26];
    rep(i, n) {
        int x = s[i] - 'a';
        ss[x].emplace(i);
    }
    
    int q;
    cin >> q;
    while (q--) {
        int k;
        cin >> k;
        if (k == 1) {
            int a; char c;
            cin >> a >> c;
            --a;
            ss[s[a] - 'a'].erase(a);
            ss[c - 'a'].emplace(a);
            s[a] = c;
        } else {
            int l, r;
            cin >> l >> r;
            --l; --r;
            
            int ans = 0;
            rep(i, 26) {
                auto it = ss[i].lower_bound(l);
                if (it == ss[i].end()) continue;
                if (*it <= r) ++ans;
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 27236
def frog1(a,n):
  dp=[0]*(n)
  dp[0]=0
  dp[1]=abs(a[1]-a[0])
  for i in range(2,n):
    dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]))
  return dp[-1]
 
def main():
  n=int(input())
  a=list(map(int,input().split()))
  print(frog1(a,n))
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 13928
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		long Matrix_A[][] = new long[n][m];
		long Matrix_B[][] = new long[m][l];
		long Matrix_C[][] = new long[n][l];
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < l; j++) {
				Matrix_C[i][j] = 0;
			}
		}
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				Matrix_A[i][j] = scan.nextLong();
			}
		}
		
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < l; j++) {
				Matrix_B[i][j] = scan.nextLong();
			}
		}
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				for(int k = 0; k < l; k++) {
					Matrix_C[i][k] += Matrix_A[i][j] * Matrix_B[j][k]; 
				}
			}
		}
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < l; j++) {
				if( j == l - 1) {
					System.out.println(Matrix_C[i][j]);
				}else {
					System.out.print(Matrix_C[i][j] + " ");
				}
			}
		}
		
		
	}
}



Measured memory_bytes: 53396
#include <stdio.h>
#include <math.h>
int main(void){
	long long int N, i, p, sum = 1;
	int  power=1;

	scanf("%lld", &N);

	for(i=1; i<=N; i++){
		power = (power*i)%1000000007;		
	}
	p = power % 1000000007;

	printf("%lld\n", p);

	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

char s[MAXN];
int cnt0[MAXN], cnt1[MAXN];

void solve(){
	int n;
	scanf("%d%s", &n, &s[1]);
	REPN(i, 1, n) {
		cnt0[i] = cnt0[i - 1];
		cnt1[i] = cnt1[i - 1];
		if (s[i] == '.') {
			cnt0[i]++;
		} else {
			cnt1[i]++;
		}
	}
	int ans = n;
	REPN(i, 0, n) {
		ans = min(ans, cnt1[i] + cnt0[n] - cnt0[i]);
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    ll N, K;
    cin>>N>>K;
    vector<ll> D(K);
    vector<bool> S(N, false);
    rep(i, K){
        ll d;
        cin>>d;
        vector<ll> A(d);
        rep(j, d){
            cin>>A[j];
            A[j]--;
            S[A[j]]=true;
        }
    }
    ll Ans=0;
    rep(i, N){
        if(!(S[i]))Ans++;
    }
    cout<<Ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#define mt make_tuple
#define ll long long
#define ld long double
#define eb emplace_back
#define fi first
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin >> vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define min(a,b) (a>b?b:a) 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626
 
using namespace std;
 using namespace __gnu_pbds;
 template <typename T>
 using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 
//----------------------------------------------------------------------------------------------------------------------
  
void swap(int & a, int & b){
    auto temp = a;
    a = b;
    b = temp;
}
 
const ll MOD = 1e9 + 7;
 
ll inf = 1LL*1e11;
 
void no(){
    cout <<"NO" << endl;exit(0);
}
void yes(){
    cout <<"YES" << endl; exit(0);
}

void solve(){
   string s; 
   cin >> s;
   if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
   else cout << "No";
}       
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--) solve();
    return 0;
} 


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	long long A, B;
	cin >> A >> B;

	long long X = A * B;

	//swap
	if (B > A){
		int tmp = A;
		A = B;
		B = tmp;
	}

	//euclid
	long long R = A % B;
	while (R > 0) {
		A = B;
		B = R;
		R = A % B;
	}

	printf("%lld\n", X / B);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solveA()
{
  long long a,b,tem;
  cin>>a>>b;
  tem=(a+b);
  if(tem%2==0)
  {
    cout<<tem/2<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
}
void solveB()
{
  int n,i,j,count;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  j=1;
  count=0;
  for(i=0;i<n;i++)
  {
    if(ar[i]!=j)
    {
      count++;
    }
    if(count>2)
    {
      cout<<"NO"<<endl;
      return;
    }
    j++;
  }
  cout<<"YES"<<endl;
}
void solveC()
{
  int a,b,x,y;
  cin>>a>>b;
  x=max(a,b);
  y=min(a,b);
  if((x-y)>=2)
  {
    cout<<2*x-1<<endl;
  }
  else
  {
    cout<<x+y<<endl;
  }
}
void solveD()
{
  int n,i,j;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  int count=n;
  for(i=n-1;i>=0;i--)
  {
    for(j=i-1;j>=0;j--)
    {
      if(ar[i]<ar[j])
      {
        count--;
        break;
      }
    }
  }
  cout<<count<<endl;
}
void solveE()
{
  int h,w,x,y,H,W;
  cin>>H>>W;
  cin>>h>>w;
  x=h*W;
  y=(H-h)*w;
  cout<<(H*W)-(x+y)<<endl;
}
void solveF()
{
  int n,m,c,i,j;
  cin>>n>>m>>c;
  int b[m];
  int ar[n][m];
  for(i=0;i<m;i++)
  {
    cin>>b[i];
  }
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      cin>>ar[i][j];
    }
  }
  int count=0;
  int sum;
  for(i=0;i<n;i++)
  {
    sum=0;
    for(j=0;j<m;j++)
    {
      sum=sum+ar[i][j]*b[j];
    }
    if((sum+c)>0)
    {
      count++;
    }
  }
  cout<<count<<endl;
}
void solveG()
{
  int a,b,c,tem;
  cin>>a>>b>>c;
  tem=b/a;
  if(tem>c)cout<<c<<endl;
  else cout<<tem<<endl;
}
void solveH()
{
  int a,b,c,tem,i;
  cin>>a>>b>>c;
  tem=min(a,b);
  vector<int>vec;
  for(i=1;i<=tem;i++)
  {
    if(a%i==0&&b%i==0)
    {
      vec.push_back(i);
    }
  }
  cout<<vec[vec.size()-c]<<endl;
}
void solveI()
{
  double t,x;
  cin>>t>>x;
  cout<<fixed<<setprecision(10)<<t/x<<endl;
}
void solveJ()
{
  int n,i;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  sort(ar,ar+n);
  int sum=0;
  for(i=0;i<n-1;i++)
  {
    sum=sum+ar[i];
  }
  if(ar[n-1]<sum)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
void solveK()
{
  int A,B,x,y;
  cin>>A>>B;
  x=max((A+B),(A-B));
  y=max(x,A*B);
  cout<<y<<endl;
}
int main()
{
  // solveA();
  //solveB();
  // solveC();
  // solveD();
// solveE();
 //solveF();
// solveG();
//solveH();
//solveI();
//solveJ();
solveK();
  return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
#include<iostream>
using namespace std;
template<typename T> void in(T &x) {
    char ch = getchar();
    bool flag = 0;
    while(ch > '9' || ch < '0') flag |= (ch == '-'), ch = getchar();
    x = ch - '0';
    ch = getchar();
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    if(flag) x = -x;
    return ;
}

int n, m;
bool vis[100005];
int sum[100005];
int main() {
    in(n);
    in(m);
    int ans = 0;
    vis[1] = 1;
    for(int i = 1; i <= n; i++)
        sum[i] = 1;
    for(int u, v, i = 1; i <= m; i++) {
        in(u);
        in(v);
        if(sum[u]==0) continue;
        if(vis[u] && sum[u]) {
            sum[u]--;
            sum[v]++;
            vis[v] = 1;
            if(sum[u] == 0) vis[u] = 0;
        } else {
            sum[u]--;
            sum[v]++;
        }
    }
    for(int i = 1; i <= n; i++)
        if(sum[i] && vis[i]) ans++;
    printf("%d", ans);
}

Measured memory_bytes: 768
#include <stdio.h>

int main(){
  char c,lc,str;
  int i,j,A[26]={0};

  while(scanf("%c", &str) != EOF){
    for(j=0,c='a',lc='A';j<26;j++,c++,lc++){
      if((int)str>=97&&(int)str<=122){
	if(c==str)A[(int)c-97]++;
      }else if((int)str>=65&&(int)str<=90){
	if(lc==str)A[(int)lc-65]++;
      }
    }
  }
  for(i=0,c='a';i<26;i++,c++){
    printf("%c : %d\n",c,A[i]);
  }
  return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
 
int main() {
  string s;
  cin >> s;

  bool a = false;
  bool b = false;

  rep(i, 3) {
    if (s.substr(i, 1) == "A") {
      a = true;
    } else {
      b = true;
    }
  }
  if (a && b) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

namespace ABC101_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NK[0];
            var K = NK[1];
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var c = 0;
            var p = 0;
            while (p < N-1)
            {
                p += K - 1;
                c++;
            }
            Console.WriteLine(c);
        }
    }
}


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

void print(string str, int a, int b){
  cout << str.substr(a, b-a+1) << endl;
}

string reverse(string str, int a, int b){
  string part = str.substr(a, b-a+1);
  reverse(part.begin(), part.end());
  return str.substr(0, a) + part + str.substr(b+1, str.size());
}

string replace(string str, int a, int b, string p){
  return str.replace(a, b-a+1, p);
}

int main(){
  string str;
  int q;
  cin >> str >> q;
  for(int i=0; i<q; i++){
    int a, b;
    string inst, p;
    cin >> inst >> a >> b;
    if(inst == "print") print(str, a, b);
    else if(inst == "reverse") str = reverse(str, a, b);
    else if(inst == "replace"){
      cin >> p;
      str = replace(str, a, b, p);
    }
  }
  return 0;
}


Measured memory_bytes: 3208
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  long long n;
  cin >> n;
  string ans;
  n--;
  while (n >= 0) {
    ans += (n % 26) + 'a';
    n /= 26;
    n--;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n;
   string ans = "No";
   cin >> n;
   for (int i = 0; i <= n; i += 4)
      if ((n - i) % 7 == 0)
         ans = "Yes";
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main() 
{
  ll X; cin>>X;
  if(X>=30) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3648
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i] = a[i];
	}
	sort(a,a+n);
	int l=a[n-1];
	int sl = a[n-2];
	for(int i=0;i<n;i++){
		if(b[i]!=l){
			cout<<l<<endl;
		}
		else {
			cout<<sl<<endl;
		}
	}
	
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 3200
def correct(m, s):
	if m == "J":
		return s[-1] + s[:len(s)-1]
	elif m == "C":
		return s[1:] + s[0]
	elif m == "E":
		length = len(s)
		if length % 2 == 0:
			return s[length / 2:] + s[:length / 2]
		else :
			return s[(length+1) / 2:] + s[(length-1) / 2] + s[:(length-1) / 2]
	elif m == "A":
		return s[::-1]
	elif m == "P":
		cor = ""
		for si in s:
			if si.isdigit():
				cor += str(9 if int(si) == 0 else int(si) - 1)
			else :
				cor += si
		return cor
	else :
		cor = ""
		for si in s:
			if si.isdigit():
				cor += str(0 if int(si) == 9 else int(si) + 1)
			else :
				cor += si
		return cor

n = int(raw_input())
for i in range(n):
	messengers = raw_input()
	order_correct = messengers[::-1]
	cor = raw_input()
	for m in order_correct:
		cor = correct(m, cor)
	print cor

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

class Solution
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var anwer = new StringBuilder();
        for (int i = 0; i < n; i++)
        {
            var q = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var score = q[0] * q[1] - 1;
            var r = (long)(Math.Sqrt(score)) + 1;
            while (r > 0 && r * r > score)
            {
                r--;
            }

            long count = r * 2 - q.Distinct().Count(qq => qq <= r);
            if (r != 0 && score / r == r)
            {
                count--;
            }
            anwer.AppendLine(count.ToString());
        }

        Console.Write(anwer.ToString());
    }
}

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

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

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

        vector<int> g;
        for (int i = 1; i < K+1; ++i) {
                for (int j = 1; j < K+1; ++j) {
                        g.push_back(gcd(i, j));
                }
        }
        long long ans = 0;
        for (int i = 0; i < g.size(); ++i) {
                for (int j = 1; j < K+1; ++j) {
                        ans += gcd(g[i], j);
                }
        }
        cout << ans << endl;



}


Measured memory_bytes: 3728
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    ll num = gcd(a[0],a[1]);
    for(ll i=1;i<n;i++) num = gcd(a[i],num);
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> a(3);
  REP(i, 3) cin >> a[i];

  vector<int> b(3);
  REP(i, 3) cin >> b[i];

  auto f = [&](int N, vector<int> &a, vector<int> &b){
    vector<int> dp(N+1, -INF);
    dp[0] = 0;
    REP(i, N) REP(j, 3){
      chmax(dp[i+1], dp[i]);
      if(i+a[j] <= N) chmax(dp[i+a[j]], dp[i]+b[j]-a[j]);
    }
    return dp[N]+N;
  };

  int ans = f(N, a, b);
  cout << f(ans, b, a) << "\n";

  return 0;
}

Measured memory_bytes: 198500
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Greedy Takahashi
            var line = ReadLine();
            var A = line[0];
            var B = line[1];
            var K = line[2];

            if (A >= K)
            {
                Console.WriteLine("{0} {1}", A - K, B);
            }
            else if (A + B > K)
            {
                Console.WriteLine("{0} {1}", 0, B - (K - A));
            }
            else
            {
                Console.WriteLine("0 0");
            }
        }

        static List<long> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => long.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
/* author   : mpily :-()
title : Competing.cpp
time :Tue Aug 27 09:33:36 2019

*/
#include<bits/stdc++.h>
using namespace std;
vector<int>letters[26];

int getAns(string s, string t){
	int indexs = 0;
	int indext = 0;
	int rounds = 0;
	int prev = indext;
	while(indext < t.size()){
		if(s[indexs%s.size()] == t[indext]){
			indext+=1;
			indexs+=1;
		}
		else {
			indexs+=1;
		}
		if(indexs && !(indexs%s.size())){
			 if(indext == prev)return -1;
			 else prev = indext;			
		}
	}
	return indexs;
}
int main(){
	string s,t;
	cin>>s>>t;
//	cout<<getAns(s,t)<<"\n";
	int count = 1;
	for(auto & a : s){
		letters[a-'a'].push_back(count);
		count+=1;
	}
	long long letterscount = 0;
	bool can = 1;
	int prev = 0;
	for(auto & a : t){
		if(!(letters[a-'a'].size())){
			can = 0;
			break;
		}
		else{
			bool did = 0;/*
			for(auto & b : letters[a-'a']){
				if(b > prev){
					letterscount+=(b-prev);
					prev = b;
					did = 1;
					break;
				}
			}*/
			if(prev >= letters[a-'a'][letters[a-'a'].size()-1]) did = 0;
			else{
				did = 1;
				int max  = letters[a-'a'].size()-1;
				int min = 0;
				int mid = (max+min)/2;
				while(max > min){
					if(letters[a-'a'][mid] < prev){
						min = mid+1;
						mid = (max+min)/2;
					}
					else if(letters[a-'a'][mid] == prev){
						mid = mid+1;max = mid;min = mid;
					}
					else{
						max = mid;
						mid = (min + max)/2;
					}
				}
				letterscount+=(letters[a-'a'][mid]-prev);
				prev = letters[a-'a'][mid];
				
			}
			if(did)continue;
			else{
				letterscount+= s.size()-prev;
				letterscount+= letters[a-'a'][0];
				prev = letters[a-'a'][0];
			}
		}
	}
	if(can)cout<<letterscount<<"\n";
	else cout<<-1<<"\n";
	return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  string date;
  cin >> date;
  if (date > "2019/04/30") cout << "TBD" << endl;
  else cout << "Heisei" << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int h,w,n;
    cin >>h >> w >> n;
    if(h<w)
        swap(h,w);
    int ans;
    ans=n/h;
    if(n%h)
        ans++;
    cout << ans<<endl;
    return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;

struct tp
{
	ll five=0, two=0;
} a[200010];
bool cmp(tp a, tp b)
{
	return a.five<b.five;
}
char st[30];
int main()
{
	ll n, m, i, j, k;

	scanf("%lld", &n);
	ll cnt=0;
	for(i=0; i<n; i++) 
	{
		double x;
		scanf(" %s", st);
		double v=num;
		ll y=0;
		ll sz=strlen(st), pos=sz;
		for(j=0; j<sz; j++)
		{
			if(st[j]=='.') 
				{
					pos=j;
					break;
				}
		}
		ll base=1;
		for(j=pos-1; j>=0; j--)
		{
			y+=(st[j]-'0')*base*num;
			base*=10;
		}
		base=10;
		for(j=pos+1; j<sz; j++)
		{
			y+=(st[j]-'0')*(num/base);
			base*=10;
		}
		//cout<<y<<endl;
		if(y==0) 
			{
				cnt++;
				continue;
			}
		while(y%5==0) a[i].five++, y/=5;
		while(y%2==0) a[i].two++, y/=2;
		//cout<<a[i].five<<" "<<a[i].two<<endl;
	}
	sort(a, a+n, cmp);
	ordered_set <pair <ll, ll> > st;
	ll fake=1, res=0;
	for(i=0, j=n-1; i<n; i++)
	{
		for( ;j>=0; j--)
		{
			if(a[i].five+a[j].five<18) break;
			st.insert({a[j].two, fake++});
		}
		ll x=st.order_of_key({18LL-a[i].two, 0LL});
		res+=st.size()-x;
		//cout<<res<<endl;
		if(a[i].five*2LL>=18LL && a[i].two*2LL>=18LL) 
			{
				res--;
			}
	}

	res=res/2 + (cnt*(cnt-1))/2;

	printf("%lld\n", res);








	return 0;
}

Measured memory_bytes: 19368