akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#define ll long long
int n, k;
int main()
{
    scanf("%d %d", &n, &k);
    if(k & 1) {
        ll tmp = n / k;
        printf("%lld\n", tmp * tmp * tmp);
    }
    else {
        ll tmp1 = n / k, tmp2 = tmp1;
        if(n % k >= k / 2) tmp2++;
        printf("%lld\n", tmp1 * tmp1 * tmp1 + tmp2 * tmp2 * tmp2);
    }
    return 0;
}

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

int main() {
  int H, W;

  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0) break;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i % 2 == j % 2)
          cout << '#';
        else
          cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	string s;
	cin >> s;
	if (!cin) return false;

	int cont = 0;
	for (int i = 0; i < s.size() / 2; ++i) {
		if (s[i] != s[s.size() - 1 - i]) ++cont;
	}
	cout << cont << '\n';

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a<b){
        System.out.println("a < b");
        }else if(a>b){
        System.out.println("a > b");
        }else if(a==b){
        System.out.println("a == b");
        }
    }
}

Measured memory_bytes: 26196
import java.util.*;
import java.io.*;
import java.util.stream.*;

public class Main{
	private static BufferedReader in;
	private static BufferedWriter out;
	
	public static void main(String[] args) throws IOException {
		open();

		StringTokenizer st;
		StringBuilder sb;
	
		st=new StringTokenizer(readString());
		long n=Long.parseLong(st.nextToken());
		long a=Long.parseLong(st.nextToken());
		long b=Long.parseLong(st.nextToken());
		long nro=(n/(a+b))*a+Math.min(n%(a+b), a);
		out.write(nro+"\n");		
		
		close();
	}
	
	private static int[] readInts() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	}
	private static int readInt() throws IOException {
		return Integer.parseInt(in.readLine());
	}
	private static long[] readLongs() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
	}
	private static long readLong() throws IOException {
		return Long.parseLong(in.readLine());
	}
	private static double[] readDoubles() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToDouble(Double::parseDouble).toArray();
	}
	private static double readDouble() throws IOException {
		return Double.parseDouble(in.readLine());
	}
	private static String readString() throws IOException {
		return in.readLine();
	}
	private static int setBit(int S, int j) {
		return S | (1 << j);
	}
	private static int isOn(int S, int j) {
		return S & (1 << j);
	}
	private static int clearBit(int S, int j) {
		return S & ~(1 << j);
	}
	private static int toggleBit(int S, int j) {
		return S ^ (1 << j);
	}
	private static int lowBit(int S) {
		return S & (-S);
	}
	private static int setAll(int n) {
		return (1 << n) - 1;
	}
	private static int modulo(int S, int N) {
		return ((S) & (N - 1));
	} // returns S % N, where N is a power of 2
	private static boolean isPowerOfTwo(int S) {
		return (S & (S - 1)) == 0 ? true : false;
	}
	private static int nearestPowerOfTwo(int S) {
		return ((int) Math.pow(2.0, (int) ((Math.log((double) S) / Math.log(2.0)) + 0.5)));
	}
	private static int turnOffLastBit(int S) {
		return ((S) & (S - 1));
	}
	private static int turnOnLastZero(int S) {
		return ((S) | (S + 1));
	}
	private static int turnOffLastConsecutiveBits(int S) {
		return ((S) & (S + 1));
	}
	private static int turnOnLastConsecutiveZeroes(int S) {
		return ((S) | (S - 1));
	}
	private static void open() {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new BufferedWriter(new OutputStreamWriter((System.out)));
	}
	private static void close() throws IOException {
		out.flush();
		out.close();
		in.close();
	}
}

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

/*============================ DEBUGGING =============================*/

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

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

/*============================= DEFINES ==============================*/

#define eps 1e-9
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define set(x,k) memset(x,k,sizeof x)

/*============================== TYPEDEFS ============================*/

typedef long long ll;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<bool> vb;
typedef queue<int> qi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
/*============================ START FROM HERE =======================*/

int main(){
	FIO
	
	int n;cin>>n;cout<<n*n*n;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N], k;
int32_t main(){_

   cin>>n>>k;

   int ans = 0;

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

   cout<<ans;
   

   return 0;
}

Measured memory_bytes: 1024
/*
 Templatka c++ Kacper Fis																							   																											   //
*/

#include <iostream>
#include <cstdio>
#include <limits>
#include <cstdlib>
#include <utility>
#include <iterator>
#include <bitset>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <time.h>
#include <iomanip>
#include <sstream>
#include <bits/stdc++.h>

using namespace std;

const int INF = 1000000001;
const float PI = 3.14;
typedef long long LL;

typedef vector<int> vi;
typedef list<int> li;
typedef queue<int> qi;
typedef pair<int,int> ii;
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra

list<int>::iterator it;
list<int>::iterator it1;
vector<int>::iterator it2;
vector<int>::iterator it3;
set<int>::iterator it4;
map<string, int>::iterator it5;
vector<ii>::iterator iter;

#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair(x, y)
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////



///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{ios_base::sync_with_stdio(false); cin.tie(NULL);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z << endl;





	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<bitset>
using namespace std;
int n,m,ans,x[100010],y[100010];
bool die[500];
bitset<500> a[500];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
        scanf("%d%d",&x[i],&y[i]);
    for(int i=1;i<=n;i++)
    {
        a[i][i]=1;
        for(int j=m;j;j--)
            if(a[i][x[j]] && a[i][y[j]])
            {
                die[i]=1;
                break;
            }
            else
                if(a[i][x[j]])
                    a[i][y[j]]=1;
                else
                    if(a[i][y[j]])
                        a[i][x[j]]=1;
    }
    for(int i=1;i<n;i++)
        if(!die[i])
            for(int j=i+1;j<=n;j++)
                if(!die[j] && (a[i]&a[j]).none())
                    ++ans;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int a[3], b[3];

  map<int, int> m;
  for (int i = 0; i < 3; i++) {
    cin >> a[i] >> b[i];
    m[a[i]]++;
    m[b[i]]++;
  }

  int mx = 0;
  for (auto& p : m) {
    mx = max(p.second, mx);
  }

  cout << (mx >= 3 ? "NO" : "YES") << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,i,p;
    cin>>n>>m;
    if(n>=m)
    p=m;
    else
    p=n;
    if(p==n){
        for(i=0;i<m;i++)
        cout<<n;
    }else
{
    for(i=0;i<n;i++)
    cout<<m;
}


    return 0;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc = new Scanner(System.in);
		String s=sc.nextLine();
		String p=sc.nextLine();
		s=s+s;
		
		if(s.indexOf(p)==-1)System.out.println("No");
		else System.out.println("Yes");
	}

}

Measured memory_bytes: 26212
#include <iostream>
#include <string>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main (){
    int N, M, A, B;
    cin >> N >> M;
    Graph G(N);

    for(int i=0; i < M;++i){
        cin >> A >> B;
        G[A-1].push_back(B);
        G[B-1].push_back(A);
        //cout << i << endl;
    }

    //cout << "heyyy" << endl;
    vector<int> dist(N, -1); // 全頂点-->未訪問
    queue<int> que;
    cout << "Yes" << endl;
    dist[0]=1;
    que.push(1);

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

        for (int n:G[arrow-1]){
            if(dist[n-1] != -1){
                continue;
            }
            dist[n-1] = arrow;
            que.push(n);
        }
    }

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

        cout << dist[i] << endl;

    }
    return 0;
}

Measured memory_bytes: 10264
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    T=LI()
    V=LI()
    T_sum = sum(T)

    #初期化
    max_V = [inf]*(2*T_sum+1)
    now = 0
    for i,(t,v) in enumerate(zip(T,V)):
        max_V[now] = min(max_V[now], v)
        for dt in range(2*t):
            now += 1
            max_V[now] = min(max_V[now], v)
    max_V[0] = 0
    max_V[-1] = 0


    #前から
    for i in range(2*T_sum):
        max_V[i+1] = min(max_V[i+1], max_V[i]+0.5)

    for i in range(2*T_sum)[::-1]:
        max_V[i] = min(max_V[i], max_V[i+1]+0.5)

    #計算部分
    ans = 0
    for i in range(2*T_sum):
        ans += (max_V[i]+max_V[i+1])/2

    ans /= 2
    print(ans)
            

if __name__ == '__main__':
    main()

Measured memory_bytes: 67052
W,H,N = (int(i) for i in input().split())

l = [list(map(int, input().split())) for i in range(N)] 

x_max = max([i[0] if i[2] == 1 else 0 for i in l])
x_min = min([i[0] if i[2] == 2 else W for i in l])
y_max = max([i[1] if i[2] == 3 else 0 for i in l])
y_min = min([i[1] if i[2] == 4 else H for i in l])

x = min(x_max+(W-x_min),W)
y = min(y_max+(H-y_min),H)

print(W*H - x*H - y*W + x*y)


Measured memory_bytes: 3064
#include<cassert>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#define inver(a) power(a,mod-2)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;
const int mod=998244353;
const int maxm=200+50;
const int maxn=8000+50; 
const int maxlog=20;
const int maxnode=maxn<<2;
int n,m;
int a[maxnode];
int b[maxnode];
int fac[maxn];
int fac_inv[maxn];
int f[maxm][maxn];
inline int add(int x)
{
	return x>=mod?x-mod:x;
}
inline int dec(int x)
{
	return x<0?x+mod:x;
} 
ll power(ll x,ll y)
{
	ll re=1;
	while(y)
	{
		if(y&1) re=re*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return re;
}
ll C(int x,int y)
{
	return (ll)fac[x]*fac_inv[y]%mod*fac_inv[x-y]%mod;
}
void init(int n)
{
	fac[0]=1;
	for(int i=1;i<=n;++i)
	{
		fac[i]=(ll)fac[i-1]*i%mod;
	}
	fac_inv[n]=inver(fac[n]);
	for(int i=n;i>=1;--i)
	{
		fac_inv[i-1]=(ll)fac_inv[i]*i%mod;
	}
}
namespace pol
{
	const int g=3;
	vector<int> w[2][maxlog];
	void init()
	{
		int g_inv=inver(g);
		for(int i=1,s=0;i<maxnode;i<<=1,++s)
		{
			ll w0=power(g,(mod-1)/(i<<1));
			ll w1=power(g_inv,(mod-1)/(i<<1));
			w[0][s].push_back(1);
			w[1][s].push_back(1);
			for(int k=1;k<i;++k)
			{
				w[0][s].push_back(w[0][s][k-1]*w0%mod);
				w[1][s].push_back(w[1][s][k-1]*w1%mod);
			}
		}
	}
	void FFT(int *a,int n,int f)
	{
		int d=f==-1;
		for(int i=0,j=0;i<n;++i)
		{
			if(i<j) swap(a[i],a[j]);
			for(int l=n>>1;(j^=l)<l;l>>=1);
		}
		for(int i=1,s=0;i<n;i<<=1,++s)
		{
			for(int j=0,p=i<<1;j<n;j+=p)
			{
				int *u=a+j;
				int *v=a+j+i;
				for(int k=0;k<i;++k,++u,++v)
				{
					int x=*u;
					int y=(ll)*v*w[d][s][k]%mod;
					*u=add(x+y);
					*v=dec(x-y);
				}
			}
		}
		if(f==-1)
		{
			int r=inver(n);
			for(int i=0;i<n;++i)
			{
				a[i]=(ll)a[i]*r%mod;
			}
		}
	}
}
int solve()
{
	for(int i=0;i<=n;++i)
	{
		f[1][i]=1;
	}
	init(n+2);
	pol::init();
	for(int i=1;i<=n;++i)
	{
		b[i]=fac_inv[i+2];
	}
	int deg=1;
	while(deg<=n*2) deg<<=1;
	pol::FFT(b,deg,1);
	for(int k=1;k<m;++k)
	{
		memset(a,0,sizeof(a));
		for(int i=0;i<=n;++i)
		{
			a[i]=(ll)f[k][i]*fac_inv[i]%mod;
			f[k+1][i]=f[k][i]*(C(i+1,2)+1)%mod;
		}
		pol::FFT(a,deg,1);
		for(int i=0;i<deg;++i)
		{
			a[i]=(ll)a[i]*b[i]%mod;
		}
		pol::FFT(a,deg,-1);
		for(int i=0;i<=n;++i)
		{
			f[k+1][i]=(f[k+1][i]+(ll)a[i]*fac[i+2])%mod;
		}
	}
	int an=0;
	for(int i=0;i<=n;++i)
	{
		an=(an+f[m][i]*C(n,i))%mod;
	}
	return an;
}
int main()
{
	scanf("%d%d",&n,&m);
	printf("%d\n",solve());
	return 0;
} 

Measured memory_bytes: 7168
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int N;
int C[500] = {};
int S[500] = {};
int F[500] = {};

int solve(int i, int t) {
    int time = S[i];
    while (true) {
        if (time >= t)
            return time;
        time += F[i];
    }
}

int main() {
    cin >> N;
    for (int i = 0; i < N - 1; ++i) cin >> C[i] >> S[i] >> F[i];

    for (int i = 0; i < N - 1; ++i) {
        int t = S[i] + C[i];
        for (int j = i + 1; j < N - 1; ++j)
            t = solve(j, t) + C[j];
        cout << t << endl;
    }

    // 町N
    cout << 0 << endl;
}


Measured memory_bytes: 256
import math
a,b,c,d = map(int, input().split())
 
#cとdの最大公約数を求める
first = [c,d%c]
first.sort()
if d%c==0:
  cd = c
elif first[0]==1:
  cd = 1
else:
  while first[0]>=2:
    first[1] = first[1]%first[0]
    first.sort()
    if first[0]==0:
      cd = first[1]
    elif first[0]==1:
      cd = 1
lcm = c*d//cd
 
#1.7＊10^17みたいなノリだから、intにするとまずいのでは
zen = b-a+1
if a%c==0:
  c_num = b//c - a//c + 1
else:
  c_num = b//c - a//c
  
if a%d==0:
  d_num = b//d - a//d + 1
else:
  d_num = b//d - a//d
  
if a%lcm==0:
  lcm_num = b//lcm - a//lcm + 1
else:
  lcm_num = b//lcm - a//lcm

ans = zen - c_num - d_num + lcm_num
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 500002;

int n, Q, tr[26][maxn];
string s;

int lowbit(int x) {
    return x & (-x);
}

void update(int c, int v, int x) {
    while (x <= n) {
        tr[c][x] += v;
        x += lowbit(x);
    }
}

int getsum(int c, int x) {
    int sum = 0;
    while (x > 0) {
        sum += tr[c][x];
        x -= lowbit(x);
    }
    return sum;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    cin >> n;
    cin >> s;
    cin >> Q;

    // cout << s <<  " Q:" << Q << endl;

    for (int i = 0; i < n; ++i) {
        update(s[i]-'a', 1, i+1);
    }

    int op, pos, l, r;
    string c;

    // vector<int> res;

    for (int i = 0; i < Q; ++i) {
        cin >> op;
        if (op == 1) {
            cin >> pos >> c;
            // printf("pos: %d %s\n", pos, c.c_str());
            if (s[pos-1] != c[0]) {
                update(s[pos-1]-'a', -1, pos);
                update(c[0]-'a', 1, pos);
                s[pos-1] = c[0];
            }
        } else {
            cin >> l >> r;
            //  printf("l: %d %d\n", l, r);
            int cnt = 0;
            for (int j = 0; j < 26; ++j)
                if (getsum(j, r) - getsum(j, l-1) > 0)
                    ++cnt;

            cout << cnt << endl;
            // res.push_back(cnt);
        }
    }

    // for (int i = 0; i < res.size(); ++i)
    // cout << res[i] << endl;

	return 0;
}

Measured memory_bytes: 51740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll k;
    cin>>k;
    ll sum=0;
    for(int i=1;i<=k;i++)
        for(int j=1;j<=k;j++)
        for(int l=1;l<=k;l++)
        sum+=(__gcd(i,__gcd(j,l)));
    cout<<sum;
}



Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func solve(a, b, c int) int {
	if a%2 == 1 || b%2 == 1 || c%2 == 1 {
		return 0
	}
	if a == b && a == c {
		return -1
	}

	ret := 0
	for a%2 == 0 && b%2 == 0 && c%2 == 0 {
		preA := a
		preB := b
		preC := c
		a = (preB + preC) / 2
		b = (preA + preC) / 2
		c = (preA + preB) / 2
		ret++
	}

	return ret
}

func main() {
	a, _ := strconv.Atoi(input())
	b, _ := strconv.Atoi(input())
	c, _ := strconv.Atoi(input())

	fmt.Println(solve(a, b, c))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cast static_cast
#define ll long long int
#define v vector
#define vi vector< int >
#define vpi vector< pair< int,int > >
using namespace std;
ll modF=1e7;

void solve(){
	int n;
	cin>>n;
	int dp[n+1][3];
	int h[3];
	cin>>h[0]>>h[1]>>h[2];
	dp[1][0]=h[0];
	dp[1][1]=h[1];
	dp[1][2]=h[2];
	for(int i=2;i<=n;i++){
		cin>>h[0]>>h[1]>>h[2];
		for(int j=0;j<3;j++){
			int max=0;
			for(int k=0;k<3;k++){
				if(j!=k){
					if(dp[i-1][k]>max){
						max=dp[i-1][k];
					}
				}
			}
			max+=h[j];
			dp[i][j]=max;
		}
	}
	int max=0;
	for(int i=0;i<3;i++){
		if(dp[n][i]>max){
			max=dp[n][i];
		}
	}
	cout<<max<<"\n";
}

int main(){
	boost_io;
	solve();
	return 0;
}

Measured memory_bytes: 4804
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
//#include<unordered_map>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl;
#define wa() cout<<"No"<<endl;
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;};
//
const int maxm=1e5+5;


signed main(){
    string s;
    cin>>s;
    int q=re;
    int f=0;
    while(q--){
        int d=re;
        if(d==1){//rev
            f^=1;
        }else{
            int t=re;
            char d;cin>>d;
            if(t==1){//begin
                if(f==0)s.insert(s.begin(),d);
                else s.insert(s.end(),d);
            }else{
                if(f==0)s.insert(s.end(),d);
                else s.insert(s.begin(),d);
            }
        }
    }
    if(f)reverse(s.begin(),s.end());
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 900
class union_find():
    
    def __init__(self,n):
        self.n=n
        self.root=[-1]*(n+1)
        self.rank=[0]*(n+1)

    def find_root(self,x):
        if self.root[x]<0:
            return x
        else:
            self.root[x]=self.find_root(self.root[x])
            return self.root[x]

    def unite(self,x,y):
        x=self.find_root(x)
        y=self.find_root(y)
        

        if x==y:
            return 
        elif self.rank[x]>self.rank[y]:
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y

            if self.rank[x]==self.rank[y]:
                self.rank[y]+=1


N,M = map(int,input().split())
g = union_find(N)
group = 0
for i in range(M):
  A,B= map(int,input().split())
  g.unite(A,B)

for j in g.root:
  if j < 0:
    group += 1

print(group - 2)
  

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

int main()
{
	string ss;
	cin>>ss;
	if(ss=="SUN")
		cout<<7;
	else if(ss=="MON")
		cout<<6;
	else if(ss=="TUE")
		cout<<5;
	else if(ss=="WED")
		cout<<4;
	else if(ss=="THU")
		cout<<3;
	else if(ss=="FRI")
		cout<<2;
	else
		cout<<1;

	return 0;
}



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

using namespace std;

int a, b;
int ans;

int main()
{
    scanf("%d%d", &a, &b);
    if(a >= 13) printf("%d", b);
    else if(a >= 6) printf("%d", b / 2);\
    else printf("0");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int paper[10][10];
  int x,y,q,i,j,count;
  int px,py;
  int max=0;
  int xplus[] = {0,0,-1,1,-1,-1,1,1,0,0,-2,2};
  int yplus[] = {-1,1,0,0,-1,1,-1,1,-2,2,0,0};

  for(j=0;j<10;j++){
    for(i=0;i<10;i++){
      paper[i][j]=0;
    }
  }

  while(scanf("%d,%d,%d",&x,&y,&q)!=EOF){
    paper[y][x]++;
    for(i=0;i<q*4;i++){
      px=x+xplus[i];
      py=y+yplus[i];
      if(px>=0&&px<10&&py>=0&&py<10){
	paper[py][px]++;
      }
    }
  }
  for(j=0;j<10;j++){
    for(i=0;i<10;i++){
      if(paper[j][i]==0){
	count++;
      }
      if(paper[j][i]>max){
	max=paper[j][i];
      }
    }
  }

  printf("%d\n",count);
  printf("%d\n",max);


  return 0;
}

Measured memory_bytes: 600
n = int(input())
s = input()
s = s.split(" ")
count = 0
for i in range(n):
    s[i] = int(s[i])
for i in range(n):
    minj = i
    for j in range(i+1,n):
        if s[j] < s[minj]:
            minj = j
    if i!= minj:
        v = s[i]
        s[i] = s[minj]
        s[minj] = v
        count += 1
for i in range(n-1):
    print(s[i],end = " ")
print(s[n-1])
print(count)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl;
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<endl;
#define pi M_PI
int main()
{
	fastio();
	int n;cin>>n;
	ll a[n+1],b[n];
	loop(i,0,n+1)
	{
		cin>>a[i];
	}
	loop(i,0,n)
	{
		cin>>b[i];
	}
	ll ans=0;
	int i=0,j=0;
	ll temp;
	while(i!=n)
	{
		if(b[i]>=a[j])
		{
			ans+=a[j];
			temp = b[i]-a[j];
			// cout<<"temp "<<temp<<endl;
			ans+=min(temp,a[j+1]);
			a[j+1]=max(a[j+1]-(b[i]-a[j]),(ll)0);
			i++;
			j++;
			// cout<<ans<<endl;
		}
		else
		{
			ans+=b[i];
			i++;
			j++;
		}
	}
	cout<<ans;
	return 0;
}	

Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))

if N % 2 == 0:
    dp = [[(-1)*10**15]*2 for _ in range(N)]
    dp[0][0] = A[0]
    dp[0][1] = 0
    dp[1][0] = A[0] + A[1]
    dp[1][1] = max(A[0], A[1])
    for i in range(N-2):
        dp[i+2][0] = max(dp[i+2][0], dp[i][0] + A[i+2])
        dp[i+2][1] = max(dp[i+2][1], dp[i][1] + A[i+2])
        dp[i+1][1] = max(dp[i+1][1], dp[i][0])
    dp[N-1][1] = max(dp[N-1][1], dp[N-2][0])
    print(dp[N-1][1])
else:
    dp = [[(-1)*10**15]*3 for _ in range(N)]
    dp[0][0] = A[0]
    dp[0][1] = 0
    dp[0][2] = 0
    dp[1][0] = A[0] + A[1]
    dp[1][1] = max(A[0], A[1])
    dp[1][2] = 0
    for i in range(N-2):
        dp[i+2][0] = max(dp[i+2][0], dp[i][0] + A[i+2])
        dp[i+2][1] = max(dp[i+2][1], dp[i][1] + A[i+2])
        dp[i+1][1] = max(dp[i+1][1], dp[i][0])
        dp[i+1][2] = max(dp[i+1][2], dp[i][1])
        dp[i+2][2] = max(dp[i+2][2], dp[i][2] + A[i+2], dp[i][0])
    dp[N-1][1] = max(dp[N-1][1], dp[N-2][0])
    dp[N-1][2] = max(dp[N-1][2], dp[N-2][1])
    print(dp[N-1][2])


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

string N;

int main() {
  cin >> N;

  int k = 0;
  for (int i = 0; i < N.size(); i++) {
    k += (N[i] - '0');
  }
  cout << (k % 9 == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <cmath>

using namespace std;

int mod_num_counter[2030];

int main()
{
    //fill(mod_num_counter,mod_num_counter+2030,0);

    long long a, b, n;
    cin >> a >> b >> n;

    long long x = n >= b ? b - 1: n;

    long long ans = a*x/b - a*(x/b);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1,n-1):
  a = p[i-1:i+2]
  if a[0] < a[1] < a[2] or a[0] > a[1] > a[2]:
    count += 1
print(count)

Measured memory_bytes: 3064
/* 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 n,i,j,k,ans=0;
	cin>>n;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++)
			for(k=1;k<=n;k++)
				ans+=(__gcd(i,__gcd(j,k)));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3652
unittest
{
	assert( [ "5", "6 9 4 2 11" ].parse.expand.solve == "11 6" );
	assert( [ "2", "100 0" ].parse.expand.solve == "100 0" );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	as.sort();
	
	auto n = as[ $ - 1 ];
	as.popBack;
	auto c = n * 0.5L;
	auto r = long.max;
	foreach( a; as )
	{
		if( ( c - a ).abs < ( c - r ).abs ) r = a;
	}
	return format( "%s %s", n, r );
}


Measured memory_bytes: 6568
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double area = Math.PI * r*r;
        double length = 2 * Math.PI * r;
        System.out.printf("%f %f", area ,length);
        sc.close();

    }
}


Measured memory_bytes: 28372
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}
ll NN, MA, MB;
ll ans = 1000000;
vector<long long> a(50 - 1 + 1);
vector<long long> c(50 - 1 + 1);
vector<long long> b(50 - 1 + 1);

void dfs(int n, ll aa, ll bb, ll cc) {
  if (cc >= ans)
    return;

  if (n == NN) {
    if (aa + bb == 0)
      return;
    double f = MA / (double)MB;
    double _f = aa / (double)bb;
    if (f == _f) {
      ans = min(ans, cc);
    }
    return;
  }

  ll ccc = cc + c[n];
  ll aaa = aa + a[n];
  ll bbb = bb + b[n];

  dfs(n + 1, aa, bb, cc);
  dfs(n + 1, aaa, bbb, ccc);
}

void solve(long long N, long long M_a, long long M_b, vector<long long> a,
           vector<long long> b, vector<long long> c) {
  NN = N;
  MA = M_a;
  MB = M_b;

  dfs(0, 0, 0, 0);

  if (ans == 1000000)
    ans = -1;

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long M_a;
  long long M_b;
  long long N;
  cin >> N;
  cin >> M_a;
  cin >> M_b;
  for (int i = 0; i <= N - 1; i++) {
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
  }
  solve(N, M_a, M_b, a, b, c);
  return 0;
}


Measured memory_bytes: 256
var
 n,a,b,i,k,s,x:longint;
begin
 readln(n,a,b);
 for i:=1 to n do
  begin
   k:=i;
   x:=0;
   while k<>0 do
    begin
     x:=x+k mod 10;
     k:=k div 10;
    end;
   if (x>=a) and (x<=b) then s:=s+i;
  end;
 write(s);
end.

Measured memory_bytes: 128
#include <iostream>
#include <map>

std::map<long long, long long> prime_fact(long long n) {
	std::map<long long, long long> ret;
	for (long long i = 2; i * i <= n; i++) {
		if (n % i) continue;
		long long cnt = 0;
		while (n % i == 0) {
			n /= i;
			cnt++;
		}
		ret[i] = cnt;
	}
	if (n > 1) ret[n] = 1;
	return ret;
}

int main() {
	long long n;
	std::cin >> n;
	std::map<long long, long long> mp = prime_fact(n);
	std::cout << n << ':';
	for (auto &i : mp) {
		while (i.second--) {
			std::cout << ' ' << i.first;
		}
	}std::cout << std::endl;
}


Measured memory_bytes: 3104
using System;

namespace ALDS111A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] ans = new int[n, n];
            string outs;
            for (int i = 0; i < n; ++i) 
            {
                for (int j = 0; j < n; ++j) 
                    ans[i, j] = 0;

                string s = Console.ReadLine();
                string[] nums = s.Split(' ');
                int k = int.Parse(nums[1]);
                for (int v = 0; v < k; ++v) 
                {
                    ans[i, int.Parse(nums[v + 2]) - 1] = 1;
                }
            }
            for (int i = 0; i < n; ++i) 
            {
                outs = ans[i, 0].ToString();
                for (int j = 1; j < n; ++j)
                {
                    outs += " " + ans[i, j].ToString();
                }
                Console.WriteLine(outs);
            }
        }
    }
}

Measured memory_bytes: 6156
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  cout << endl
#define con continue

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss>b.ss;
    return (a.ff < b.ff); 
} 

//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////

void solve(){

    ll n ;
    cin>>n;

    map<string,ll> m;
    loop(i,0,n){
        string a;
        cin>>a;
        m[a]++;
    }

    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"];

    return;
}
 
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
       // cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

Measured memory_bytes: 3688
#include <algorithm>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
  int N;
  cin >> N;
  map<string, int> m;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    m[s]++;
  }
  int maxv = 0;
  for (auto p : m) {
    maxv = max(maxv, p.second);
  }
  for (auto p : m) {
    if (p.second == maxv) cout << p.first << endl;
  }

  return 0;
}

Measured memory_bytes: 25216
import math
def main():
    a, b, c = (float(a) for a in input().split())
    s = a * b * math.sin(math.radians(c)) * 0.5
    l = a + b + math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(c)))
    h = b * math.sin(math.radians(c))
    print(s)
    print(l)
    print(h)


main()



Measured memory_bytes: 5704
N = int(input())
MOD = 10 ** 9 + 7
memo = [{} for i in range(N + 1)]

def ok(last4):
	for i in range(4):
		t = list(last4)
		if i >= 1:
			tmp = t[i]
			t[i] = t[i - 1]
			t[i - 1] = tmp
		if ''.join(t).count('AGC') >= 1:
			return False
	return True
			
def AGC(n, last3):
	if last3 in memo[n]:
		return memo[n][last3]
	if n == N:
		return 1
	ret = 0
	for c in 'AGCT':
		if ok(last3 + c):
			ret = (ret + AGC(n + 1, last3[1:] + c)) % MOD
		memo[n][last3] = ret
	return ret
	
print(AGC(0, 'TTT'))


Measured memory_bytes: 48988
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a != c){
      print("Yes");
    } else if(a == c && a != b){
      print("Yes");
    } else if(b == c && a != b){
      print("Yes");
    } else {
      print("No");
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 1000005
const ll MOD = 1000000007;

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

	ll n;
	cin>>n;
	ll a[n],b[n];
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	if(n&1)
		cout<< b[n/2]-a[n/2] + 1 <<endl;
	else{
		ll v1 = a[n/2] + a[n/2 - 1];
		ll v2 = b[n/2] + b[n/2 - 1];
		cout<< v2+1-v1 <<endl;
	}
}

Measured memory_bytes: 6784
n, m, l = map(int, input().split())

A = [0] * n
B = [0] * m

for i in range(n):
    A[i] = list(map(int, input().split()))

for i in range(m):
    B[i] = list(map(int, input().split()))


for i in range(n):
    list = []
    for j in range(l):
        o = 0
        for k in range(m):
            o += A[i][k] * B[k][j]
        list.append(o)
    c = map(str, list)
    d = ' '.join(c)
    print(d)



Measured memory_bytes: 6304
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

const int ML=400100;

int tplb,nx[ML],vv[ML],top[ML];

void ins(int u,int v)
{
	int np=tplb++;
	
	vv[np]=v; nx[np]=top[u]; top[u]=np;
}

int d[ML];

void dfs(int u,int fa)
{
	for (int kb=top[u]; ~kb; kb=nx[kb])
	{
		int v=vv[kb];
		
		if (v==fa) continue;
		
		d[v]+=d[u]; dfs(v,u);
	}
}

int main()
{
	int n,q; scanf("%d%d",&n,&q);
	
	for (int i=1; i<=n; i++) top[i]=-1;
	
	for (int i=1; i<n; i++)
	{
		int u,v; scanf("%d%d",&u,&v);
		
		ins(u,v); ins(v,u);
	}
	
	for ( ; q; q--)
	{
		int p,dd; scanf("%d%d",&p,&dd);
		
		d[p]+=dd;
	}
	
	dfs(1,0);
	
	for (int i=1; i<=n; i++) printf("%d ",d[i]);
	
	return 0;
}

Measured memory_bytes: 17280
import scala.io.StdIn
/**
  * AOJ
  */

sealed trait Side

object Up extends Side
object North extends Side
object East extends Side
object West extends Side
object South extends Side
object Under extends Side

object Main {

  def main(args: Array[String]): Unit = {

    val diceMap = List(Up,North,East,West,South,Under).zip(StdIn.readLine().split(" ").map(_.toInt)).toMap
    val cmdList = StdIn.readLine().toCharArray
    println(cmdList.foldLeft(diceMap){(x,y) => getNextStatus(y,x)}(Up))
  }

  def getNextStatus(cmd:Char,dice:Map[Side,Int]): Map[Side,Int] = {
    cmd match {
      case 'E' => Map(Up -> dice(West),North -> dice(North),East -> dice(Up),West -> dice(Under),South -> dice(South),Under -> dice(East))
      case 'N' => Map(Up -> dice(North),North -> dice(Under),East -> dice(East),West -> dice(West),South -> dice(Up),Under -> dice(South))
      case 'S' => Map(Up -> dice(South),North -> dice(Up),East -> dice(East),West -> dice(West),South -> dice(Under),Under -> dice(North))
      case 'W' => Map(Up -> dice(East),North -> dice(North),East -> dice(Under),West -> dice(Up),South -> dice(South),Under -> dice(West))
    }
  }
}

Measured memory_bytes: 44212
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

using lint = long long;
using ldouble = long double;

bool solve() {
    int N, M;
    cin >> N >> M;
    if (N == 0) return false;

    vector<int> A(N);
    for (auto &a : A) cin >> a;

    int ans = -1;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            if (A[i] + A[j] <= M) {
                ans = max(ans, A[i] + A[j]);
            }
        }
    }
    if (ans < 0) {
        cout << "NONE" << endl;
    } else {
        cout << ans << endl;
    }
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}



Measured memory_bytes: 3104
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
N=II()
A=LI()
Sum=sum(A)
Q=II()
cnt={}
queries=[]
for i in range(Q):
  b,c=MI()
  queries.append((b,c))
for a in A:
  if a not in cnt:
    cnt[a]=0
  cnt[a]+=1
#print(cnt)   
for b,c in queries:
  if b in cnt:
    Sum-=cnt[b]*b
    Sum+=cnt[b]*c
    if c not in cnt:
      cnt[c]=0
    cnt[c]+=cnt[b]
    cnt[b]=0
  print(Sum) 
  

Measured memory_bytes: 97932
import sys
sys.setrecursionlimit(10**7)

N = int(input())
h = list(map(int, input().split()))

dp = [-1] * N

# 足場 i から 足場 N - 1 まで移動するときのコストの最小値
def rec(i):
    if dp[i] >= 0:
        return dp[i]
    
    res = -1
    if i == N - 1:
        res = 0
    elif i == N - 2:
        res = rec(i + 1) + abs(h[i + 1] - h[i])
    else:
        res =  min(rec(i + 1) + abs(h[i + 1] - h[i]), rec(i + 2) + abs(h[i + 2] - h[i]))
    
    dp[i] = res
    return dp[i]

print(rec(0))

Measured memory_bytes: 100992
#include <iostream>

using namespace std;
long long a[200010],b[200010],c[200010],cnt = 0;
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(i=0;i<n;i++){
		cin >> b[i];
	}
	int k = 0;
	while(k<300){
		k++;
		for(i=0;i<n;i++){
			int l = i - 1,r = i + 1;
			if(l<0) l += n;
			if(r>=n) r -= n;
			long long x = b[l] + b[r];
			if(b[i]%x>=a[i]){
				c[i] = b[i]%(b[l] + b[r]);
				cnt += b[i]/(b[l] + b[r]);
			}else{
				if(b[i] < a[i]){
					cout << -1 << endl;
					return 0;
				}
				if((b[i] - a[i])%(b[l] + b[r])==0){
					c[i] = a[i];
					cnt += (b[i] - a[i])/(b[l] + b[r]);
				}
			}
		}
		bool flag = true;
		for(i=0;i<n;i++){
			b[i] = c[i];
			if(a[i]!=b[i]){
				flag = false;
			}
		}
		if(flag){
			cout << cnt << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
	int x,y;
	int n[13]={0,1,2,1,3,1,3,1,1,3,1,3,1};
	scanf("%d%d",&x,&y);
	if(n[x]==n[y])	printf("Yes\n");
	else	printf("No\n");
	return 0;
}

Measured memory_bytes: 128