akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
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<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d;
    cin >> d;
    vector<int> c(26);
    for(int i=0; i<26; i++) cin >> c[i];
    vector<vector<int>> G(d,vector<int> (26));
    for(int i=0; i<d; i++){
        for(int j=0; j<26; j++){
            cin >> G[i][j];
        }
    }
    vector<int> t(d);
    for(int i=0; i<d; i++){
        int id=-1;
        int mx=-1;
        for(int j=0; j<26; j++){
            if(chmax(mx,G[i][j])){
                id = j;
            }
        }
    }
    // for(int i=0; i<d; i++){
    //     t[i] = rand() % 26;
    // }
    // ll sum = 0;
    // for(int k=0; k<10000; k++){
    //     int a = rand() % d;
    //     int b = rand() % 26;
    //     int pre = t[a];
    //     t[a] = b;
    //     vector<ll> now(26,0);
    //     vector<int> last(26,0);
    //     for(int i=0; i<d; i++){
    //         last[t[i]] = i+1;
    //         now[t[i]] += G[i][t[i]];
    //         for(int j=0; j<26; j++){
    //             now[t[i]] -= c[j] * (i+1 - last[j]);
    //         }
    //     }
    //     ll s = 0;
    //     for(int j=0; j<26; j++){
    //         s += now[j];
    //     }
    //     if(s > sum){
    //         sum = s;
    //     }else{
    //         t[a] = pre;
    //     }
    // }
    for(int i=0; i<d; i++){
        cout << t[i]+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3712
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val s = nextLong()
    var r = Math.sqrt(s.toDouble()).toLong()

    if (r * r == s) {
        println("0 0 $r 0 0 $r")
        return
    }

    val diff = ((r+1) * (r+1)) - s 
    println("0 0 ${r+1} 1 $diff ${r+1}")
}

fun next() = readLine()!!
fun nextLong() = next().toLong()

fun println(value : Any) {
    pw.println(value)
}

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

int main() {
  int N, R, T;
  cin >> N >> R >> T;
  vector<int> P(N);
  for(auto& p: P) cin >> p;
  vector<int> current(N, 1);
  vector<int> full(R), empty(R);
  int ans = 0;
  for(int t = 1; t <= T; ++t) {
    for(int i = 0; i < N; ++i) {
      current[i] = (current[i] + P[i]) % R;
      --full[current[i]];
      if(t != 1) ++empty[current[i]];
    }
    for(int r = 0; r < R; ++r) {
      if(full[r] < 0) {
        ans += -full[r];
        full[r] = 0;
      }
      full[r] += empty[r];
      empty[r] = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long long LL;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

typedef unsigned long long HASH;

class RollingHash {
public:
	static const ULL HMOD = (1ULL << 61) - 1;
	static const ULL MASK30 = (1ULL << 30) - 1;
	static const ULL MASK31 = (1ULL << 31) - 1;
	static ULL base;
	static const ULL POS = HMOD * ((1ULL << 3) - 1);
	static vector<ULL> powmemo;
	vector<HASH> hash;   //部分列[0,n)のハッシュを持つ
	RollingHash(vector<LL>& S) {
		if (base == 0) {
			random_device rnd;
			mt19937 mt(rnd());
			uniform_int_distribution<ULL> rand(129, HMOD - 1);
			RollingHash::base = rand(mt);
			powmemo.resize(500000, 1);
			for (LL n = 1; n < 500000; n++) {
				powmemo[n] = mod(Mul(powmemo[n - 1], base));
			}
		}
		hash.resize(S.size() + 1);
		hash[0] = 0;
		for (ll n = 1; n <= S.size(); n++) {
			hash[n] = mod(Mul(hash[n - 1], base) + S[n - 1]);
		}
	}
	//部分列[a,b)のハッシュ
	HASH get(LL a, LL b) {
		return mod(hash[b] + POS - Mul(hash[a], powmemo[b - a]));
	}
	//部分列配列への保存なしに変換
	HASH conv(vector<LL>& S) {
		HASH ans = 0;
		for (ll n = 0; n < S.size(); n++) {
			ans = mod(Mul(ans, base) + S[n]);
		}
		return ans;
	}
	static HASH Mul(HASH a, HASH b) {
		HASH au = a >> 31;
		HASH ad = a & MASK31;
		HASH bu = b >> 31;
		HASH bd = b & MASK31;
		HASH midd = au * bd + ad * bu;
		HASH midu = midd >> 30;
		midd = midd & MASK30;
		return ((au * bu) << 1) + ad * bd + (midd << 31) + midu;
	}
	static HASH mod(HASH val) {
		val = (val & HMOD) + (val >> 61);
		if (val >= HMOD)val -= HMOD;
		return val;
	}
};
ULL RollingHash::base = 0;
vector<ULL> RollingHash::powmemo = vector<ULL>();

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N;
	string S;
	cin >> N >> S;
	vector<LL> VS(N);
	for (ll n = 0; n < N; n++) {
		VS[n] = S[n] - 'a';
	}
	ll ans = 0;
	RollingHash rh(VS);
	for (ll i = 0; i < N; i++) {
		for (ll j = i + 1; j < N; j++) {
			ll s = 0, e = min(j - i, N - j) + 1;
			while (e - s > 1) {
				ll m = (e + s) / 2;
				HASH ha = rh.get(i, i + m);
				HASH hb = rh.get(j, j + m);
				if (ha == hb)s = m;
				else e = m;
			}
			ans = max(ans, s);
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 4224
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();

		int a1 = 0;
		int a2 = 0;
		int a3 = 0;
		a1 = a + b;
		a2 = a * b;
		a3 = a - b;
		
		
		if(a1 > a2){
			if(a1 > a3){
				System.out.println(a1);
			}else{
				System.out.println(a3);
			}
		}else {
			if(a2 > a3){
				System.out.println(a2);
			}else{
				System.out.println(a3);
			}
		}
	}
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
    ll res = 1LL; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1LL)  
            res = (res*x) % p;
        y = y>>1LL; 
        x = (x*x) % p;  
    }  
    return res;  
}  

int main(){
	IO
	ll x, k, d;
	cin >> x >> k >> d;

	ll req = abs(x)/d;
	if(req > k) {
		if(x < 0) 
			cout << abs(x + k*d) << endl;
		else 
			cout << abs(x - k*d) << endl;
	}
	else {
		if(x < 0) 
			x+=req*d;
		else 
			x-=req*d;
		k-=req;

		if(k%2LL) {
			if(x < 0) x+=d;
			else x-=d;
		}
		cout << abs(x) << endl;
	}
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


template<int um> class UF {
	public:
	vector<int> par,rank,cnt;
	UF() {par=rank=vector<int>(um,0); cnt=vector<int>(um,1); for(int i=0;i<um;i++) par[i]=i;}
	void reinit() {int i; FOR(i,um) rank[i]=0,cnt[i]=1,par[i]=i;}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int count(int x) { return cnt[operator[](x)];}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		cnt[y]=cnt[x]=cnt[x]+cnt[y];
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};

int N;
ll X[202020];
vector<pair<int,ll>> E[202020];

UF<202020> uf;
pair<ll,ll> dp[202020][3];

void dfs(int cur,int pre) {
	dp[cur][0]={X[cur],uf[cur]};
	dp[cur][1]=dp[cur][2]={1LL<<60, -1};
	
	int i;
	FORR(e,E[cur]) if(e.first!=pre) {
		dfs(e.first,cur);
		FOR(i,2) {
			dp[cur][2]={dp[e.first][i].first+e.second,dp[e.first][i].second};
			sort(dp[cur],dp[cur]+3);
			if(dp[cur][0].second==dp[cur][1].second) dp[cur][1]=dp[cur][2];
		}
	}
	
}

void dfs2(int cur,int pre,ll d0,ll c0,ll d1,ll c1) {
	
	int i;
	FOR(i,2) {
		dp[cur][2]={(i==0)?d0:d1, (i==0)?c0:c1};
		sort(dp[cur],dp[cur]+3);
		if(dp[cur][0].second==dp[cur][1].second) dp[cur][1]=dp[cur][2];
	}
	FORR(e,E[cur]) if(e.first!=pre) dfs2(e.first,cur,dp[cur][0].first+e.second,dp[cur][0].second,dp[cur][1].first+e.second,dp[cur][1].second);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>X[i];
	FOR(i,N-1) {
		cin>>x>>y>>j;
		E[x-1].push_back({y-1,j});
		E[y-1].push_back({x-1,j});
	}
	ll ret=0;
	while(uf.count(0)<N) {
		dfs(0,-1);
		dfs2(0,-1,dp[0][0].first,dp[0][0].second,dp[0][1].first,dp[0][1].second);
		
		vector<pair<ll,pair<int,int>>> V;
		FOR(i,N) dp[i][2]={1LL<<60,-1};
		FOR(i,N) {
			j=0;
			if(uf[i]==dp[i][j].second) j++;
			dp[i][0].first+=X[i];
			dp[i][1].first+=X[i];
			dp[uf[i]][2]=min(dp[uf[i]][2],dp[i][j]);
		}
		
		FOR(i,N) if(i==uf[i]) {
			if(uf[dp[i][2].second]!=uf[i]) {
				ret+=dp[i][2].first;
				uf(dp[i][2].second,i);
			}
		}
	
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 53888
n, s = map(int, input().split())
a = [int(x) for x in input().split()]
mod = 998244353

dp = [[0 for _ in range(s+1)] for __ in range(n+1)]

dp[0][0] = 1

for i in range(n):
    for j in range(s+1):
        dp[i+1][j] += dp[i][j]
        if j-a[i] == 0:
            dp[i+1][j] += i+1
        elif j-a[i] >= 0:
            dp[i+1][j] += dp[i][j-a[i]]
        dp[i+1][j] %= mod

ans = 0

for i in range(n+1):
    ans += dp[i][s]
    ans %= mod

print(ans)


Measured memory_bytes: 120284
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int N; cin >> N;
  vector<vector<pair<int, int>>> G(N);
  REP(i, N - 1) {
    int a, b;
    cin >> a >> b; a--; b--;
    G.at(a).push_back(make_pair(b, i));
    G.at(b).push_back(make_pair(a, i));
  }
  int max_deg = 0;
  REP(i, N) {
    max_deg = max((int)G.at(i).size(), max_deg);
  }
  // cout << max_deg << endl;

  vector<int> color(N - 1);

  vector<bool> seen(N, false);
  queue<pair<int, int>> todo;

  todo.push(make_pair(0, -1));
  seen[0] = true;
  while (!todo.empty()) {
    int here = todo.front().first;
    // cout << here << endl;
    int edge = todo.front().second;
    todo.pop();

    int color_num = 0;
    for (pair<int, int> pr: G.at(here)) {
      if (seen.at(pr.first) == false) { 
      seen.at(pr.first) = true;
      todo.push(pr);

      if (edge >= 0 && color_num == color.at(edge)) color_num++;
      color.at(pr.second) = color_num;
      color_num++;
      }
    }
  }

  cout << max_deg << endl;
  REP(i, N - 1) {
    cout << color.at(i) + 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 7040
import java.util.*;

//update 2019/12/13

public class Main{

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int[] a = new int[6];
    for(int i=0;i<6;i++){
      a[i] = nextInt();
    }

    String result = "Yay!";

    for(int i=0;i<6;i++){
      for(int j=i+1;j<6;j++){
        if((a[j]-a[i])>a[5]){
          result = ":(";
        }
      }
    }

    System.out.println(result);

/*
    for(int i=0;i<n;i++){

    }
*/

  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char aaa){
    return aaa - 48;
  }

  public static int maxInt(int[] a,int lng){
    int max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static int minInt(int[] a,int lng){
    int min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

  public static long maxLong(long[] a,int lng){
    long max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static long minLong(long[] a,int lng){
    long min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

}


Measured memory_bytes: 23764
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>
using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4]={0,-1,0,1};
static const int dy[4]={1,0,-1,0};
static const char dir[4]={'r','u','l','d'};
int MDT[N2][N2];

struct Puzzle {int f[N2],space,MD;};

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz){
  int sum=0;
  for(int i=0;i<N2;i++){
    if(pz.f[i]==N2) continue;
    sum+=MDT[i][pz.f[i]-1];
  }
  return sum;
}

bool isSolved(){
  for(int i=0;i<N2;i++) if(state.f[i]!=i+1) return false;
  return true;
}


bool dfs(int depth,int prev){
  if(state.MD==0) return true;
  if(depth+state.MD>limit) return false;

  int sx=state.space/N;
  int sy=state.space%N;
  Puzzle tmp;

  for(int r=0;r<4;r++){
    int tx=sx+dx[r];
    int ty=sy+dy[r];
    if(tx<0||ty<0||tx>=N||ty>=N) continue;
    if(max(prev,r)-min(prev,r)==2) continue;
    tmp=state;
    state.MD-=MDT[tx*N+ty][state.f[tx*N+ty]-1];
    state.MD+=MDT[sx*N+sy][state.f[tx*N+ty]-1];
    swap(state.f[tx*N+ty],state.f[sx*N+sy]);
    state.space=tx*N+ty;
    if(dfs(depth+1,r)){
      path[depth]=r;
      return true;
    }
    state=tmp;
  }

  return false;
}


string ite(Puzzle in){
  in.MD=getAllMD(in);

  for(limit=in.MD;limit<=LIMIT;limit++){
    state=in;
    if(dfs(0,-100)){
      string ans="";
      for(int i=0;i<limit;i++) ans+=dir[path[i]];
      return ans;
    }
  }


  return "unsolvable";
}


int main(){
  for(int i=0;i<N2;i++)
    for(int j=0;j<N2;j++)
      MDT[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
  Puzzle in;
  for(int i=0;i<N2;i++){
    cin >> in.f[i];
    if(in.f[i]==0){
      in.f[i]=N2;
      in.space=i;
    }
  }
  string ans=ite(in);
  cout << ans.size() << endl;

  return 0;
}




Measured memory_bytes: 3160
# 貪欲法で解く貪欲法とは次の状態の値を最適にすることだけを考えること
n = int(input())
k = int(input())
shown = 1
def manA(x):
  return 2 * x

def manB(x):
  return k + x

for _ in range(n):
  shown = min(manA(shown),manB(shown))

print(shown)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=1e9;
const int mod=1e9+7;
int main(void)
{
    int ans=0;
    int m,n;
    cin >> m >> n;
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            int d1=j%10;
            int d2=j/10;
            if(d1*d2==i && d1>=2 && d2>=2) 
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{

  int n,k ;
  cin >> n >> k ;
  int ans = 0 ;
  
  while(n>0){
    ans++ ;
    n/=k ;
  }
  
  cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

struct UnionFind{
    int n;
    vector<int> Parent;
    vector<int> sizes;
    UnionFind(int _n):n(_n),Parent(_n),sizes(_n,1){ rep(i,n)Parent[i]=i; }
    //find the root of x
    int root(int x){
        if(x!=Parent[x]){
        Parent[x] = root(Parent[x]);
        }
        return Parent[x];
    }
    //merge x and y
    void unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        Parent[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x,int y){ return root(x) == root(y); }
    int size(int x){ return sizes[root(x)]; }
    int group_num(){
        set<int> s;
        for(int i = 0; i < n; ++i){
            s.insert(root(i));
        }
        return int(s.size());
    }
};
int main() {
    int N, Q;
    cin >> N >> Q;
    UnionFind T(N);
    while(Q--){
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0)T.unite(u, v);
        else cout << T.same(u, v) << endl;
    }
}


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

int main() {
    int N; cin >> N;
    for(int i = 1; i < 10; ++i) {
        if(N % i == 0 && N / i < 10) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 256
using System;

namespace C___Slimes
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int Slimes = 1;
            for (int i = 0; i < S.Length-1; i++)
            {
                if(S[i] != S[i+1])
                {
                    Slimes += 1;
                }
            }
            Console.WriteLine(Slimes);
        }
    }
}


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



int main() {
    int a,b,x;
    cin>>a>>b>>x;

    if(x>=a) {
        x -= a;
        if (x > b) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
    }else{
        cout<<"NO"<<endl;
    }


}


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

int main(){
    cout.precision(17);
    cout.setf(ios_base::fixed, ios_base::floatfield);

    int N;
    cin >> N;

    vector<pair<int64_t,int64_t>> info[4];
    map<char, int> idx;
    idx['R'] = 0; idx['L'] = 1; idx['U'] = 2; idx['D'] = 3;

    int64_t x, y;
    char d;
    vector<double> cand;
    int64_t xmax[4], xmin[4], ymax[4], ymin[4];
    for(int i=0;i<4;i++){
        xmax[i] = ymax[i] = -1e15;
        xmin[i] = ymin[i] = 1e15;
    }
    for(int i=0;i<N;i++){
        cin >> x >> y >> d;
        info[idx[d]].emplace_back(x, y);
        xmax[idx[d]] = max(xmax[idx[d]], x);
        xmin[idx[d]] = min(xmin[idx[d]], x);
        ymax[idx[d]] = max(ymax[idx[d]], y);
        ymin[idx[d]] = min(ymin[idx[d]], y);
    }

    cand.push_back(0.0);

    cand.push_back(0.5*(xmax[idx['L']]-xmax[idx['R']]));
    cand.push_back(xmax[idx['L']]-xmax[idx['U']]);
    cand.push_back(xmax[idx['L']]-xmax[idx['D']]);
    cand.push_back(-xmax[idx['R']]+xmax[idx['U']]);
    cand.push_back(-xmax[idx['R']]+xmax[idx['D']]);

    cand.push_back(0.5*(xmin[idx['L']]-xmin[idx['R']]));
    cand.push_back(xmin[idx['L']]-xmin[idx['U']]);
    cand.push_back(xmin[idx['L']]-xmin[idx['D']]);
    cand.push_back(-xmin[idx['R']]+xmin[idx['U']]);
    cand.push_back(-xmin[idx['R']]+xmin[idx['D']]);

    cand.push_back(0.5*(ymax[idx['D']]-ymax[idx['U']]));
    cand.push_back(ymax[idx['D']]-ymax[idx['L']]);
    cand.push_back(ymax[idx['D']]-ymax[idx['R']]);
    cand.push_back(-ymax[idx['U']]+ymax[idx['L']]);
    cand.push_back(-ymax[idx['U']]+ymax[idx['R']]);

    cand.push_back(0.5*(ymin[idx['D']]-ymin[idx['U']]));
    cand.push_back(ymin[idx['D']]-ymin[idx['L']]);
    cand.push_back(ymin[idx['D']]-ymin[idx['R']]);
    cand.push_back(-ymin[idx['U']]+ymin[idx['L']]);
    cand.push_back(-ymin[idx['U']]+ymin[idx['R']]);

    double ans = 1e18;
    for(auto t: cand){
        if(t>1e14) continue;
        if(t < 0) t*= -1;
        double l=1e15, r=-1e15, u=-1e15, d=1e15;
        for(auto pos: info[idx['L']]){
            l = min(l, pos.first-t);
            r = max(r, pos.first-t);
            u = max(u, pos.second+0.0);
            d = min(d, pos.second+0.0);
        }
        for(auto pos: info[idx['R']]){
            l = min(l, pos.first+t);
            r = max(r, pos.first+t);
            u = max(u, pos.second+0.0);
            d = min(d, pos.second+0.0);
        }
        for(auto pos: info[idx['U']]){
            l = min(l, pos.first+0.0);
            r = max(r, pos.first+0.0);
            u = max(u, pos.second+t);
            d = min(d, pos.second+t);
        }
        for(auto pos: info[idx['D']]){
            l = min(l, pos.first+0.0);
            r = max(r, pos.first+0.0);
            u = max(u, pos.second-t);
            d = min(d, pos.second-t);
        }

        ans = min(ans, (r-l)*(u-d));
    }

    cout << ans << endl;

    
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> vec(100);
  for (int m = 0; m < W + 1; m++) {
  cout << "#";
  }
  cout << "#" << endl;
  for (int a = 0; a < H; a++) {
  cout << "#";
    for (int i = 0; i < W; i++) {
      cin >> vec.at(i);
      cout << vec.at(i);
    }
  cout << "#" << endl;
  }
  for (int n = 0; n < W + 1; n++) {
  cout << "#";
  }
  cout << "#" << endl;

}



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


int main() {
  string S;
  cin>>S;
  int N=S.size();
  
  int sumz=0;
  int sumn=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='0') sumz++;
    else sumn++;
  }
  cout<<2*min(sumz,sumn)<<endl;
  
}

Measured memory_bytes: 3744
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    string S;
    cin >> S;
    int ans=0;
    int cmp=0;
    rep(i,3){
        if(S[i]=='R') cmp++;
        else cmp=0;
        ans=max(ans,cmp);
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int N, A, B;

void init()
{
	cin >> N >> A >> B;
}

void solve()
{
	int a = 0, b = 0;
	rep(i, N) {
		char c;
		cin >> c;
		if (c == 'a') {
			a++;
			PRINT(a + min(b, B) <= A + B);
		}
		if (c == 'b') {
			b++;
			PRINT(a + b <= A + B && b <= B);
		}
		if (c == 'c') {
			PRINT(0);
		}
	}

}



Measured memory_bytes: 640
#include<iostream>
using namespace std;
unsigned long xor_x=88172645463325252ULL;
unsigned long rng()
{
	xor_x^=xor_x<<7;
	return xor_x^=xor_x>>9;
}
int D;
int c[26],s[365][26];
int t[365],now;
int anst[365],ans;
void calc()
{
	int lst[26];
	for(int i=0;i<26;i++)lst[i]=-1;
	now=0;
	for(int i=0;i<D;i++)
	{
		now+=s[i][t[i]];
		lst[t[i]]=i;
		for(int j=0;j<26;j++)now-=c[j]*(i-lst[j]);
	}
}
int change(int d,int q)
{
	int ret=0;
	ret-=s[d][t[d]];
	ret+=s[d][q];
	{
		int r=d+1;
		while(r<D&&t[r]!=t[d])r++;
		int l=d-1;
		while(l>=0&&t[l]!=t[d])l--;
		ret-=c[t[d]]*(r-d)*(d-l);
	}
	{
		int r=d+1;
		while(r<D&&t[r]!=q)r++;
		int l=d-1;
		while(l>=0&&t[l]!=q)l--;
		ret+=c[q]*(r-d)*(d-l);
	}
	return ret;
}
main()
{
	cin>>D;
	for(int i=0;i<26;i++)cin>>c[i];
	for(int i=0;i<D;i++)for(int j=0;j<26;j++)cin>>s[i][j];
	for(int i=0;i<D;i++)
	{
		anst[i]=t[i]=rng()%26;
	}
	calc();
	ans=now;
	for(int tm=0;tm<3000;tm++)
	{
		while(true)
		{
			int d=rng()%D,q=rng()%26;
			int ret=change(d,q);
			if(rng()%2000>tm||ret>=0)
			{
				now+=ret;
				t[d]=q;
				break;
			}
		}
		for(int k=0;k<3000;k++)
		{
			int d1=rng()%(D-1)+1,d2=rng()%d1;
			int pt1=t[d1],pt2=t[d2];
			int diff=0;
			diff+=change(d1,pt2);
			t[d1]=pt2;
			diff+=change(d2,pt1);
			t[d2]=pt1;
			if(rng()%2000>tm||diff>=0)
			{
				now+=diff;
			}
			else
			{
				t[d1]=pt1;
				t[d2]=pt2;
			}
		}
		if(ans<=now)
		{
			ans=now;
			for(int i=0;i<D;i++)anst[i]=t[i];
		}
		else if(rng()%2000<tm)
		{
			now=ans;
			for(int i=0;i<D;i++)t[i]=anst[i];
		}
	}
	for(int i=0;i<D;i++)cout<<anst[i]+1<<endl;
	cerr<<ans<<endl;
}


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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

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

    cout << (a + b) % 24 << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;


typedef long long LL;
const int SIZE = 10;
typedef set<int> SI;
int n;
string s;
int a_num;
int m;
int T[SIZE];
bool C[SIZE];
int d_sum;

int to_int( char c ) {
    if ( c == '*' ) return 0;
    return c - '0';
}

int get_b( bool f, int t ) {
    int nt = 2 * t;
    if ( ! f ) return t;
    return nt >= 10 ? nt/10%10 + nt%10 : nt;
}

bool input() {
    if ( ! ( cin >> n && n ) ) return false;
    cin >> s;
    a_num = count( s.begin(), s.end(), '*' );
    d_sum = 0;
    for ( int i = 0; i < n; ++ i ) {
        d_sum += get_b(i%2==1,to_int(s[n-i-1]));
    }
    for ( int i = 0, j = 0; i < n && j < a_num; ++ i ) {
        if ( s[n-i-1] == '*' ) {
            C[j++] = ( i % 2 == 1 );
        }
    }
    
    cin >> m;
    SI T_;
    for ( int i = 0; i < m; ++ i ) {
        int t;
        cin >> t;
        T_.insert(t);
    }
    m = T_.size();
    int ti = 0;
    for ( SI::iterator it_i = T_.begin(); it_i != T_.end(); ++ it_i ) {
        T[ti++] = *it_i;
    }
    return true;
}

LL solve() {
    LL dp[20][20][20];
    fill( (LL*)dp, (LL*)dp+20*20*20, 0 );
    dp[0][0][d_sum%10] = 1;
    for ( int i = 0; i < a_num; ++ i ) {
        for ( int j = 0; j < m; ++ j ) {
            for ( int k = 0; k < 10; ++ k ) {
                if ( dp[i][j][k] == 0 ) continue;
                for ( int nj = 0; nj < m; ++ nj ) {
                    int nk = ( k + get_b( C[i], T[nj] ) ) % 10;
                    dp[i+1][nj][nk] += dp[i][j][k];
                }
            }
        }
    }
    LL res = 0;
    for ( int i = 0; i < m; ++ i ) {
        res += dp[a_num][i][0];
    }
    return res;
}

int main() {
    while ( input() ) cout << solve() << endl;
    return 0;
}

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

int main(){
    int a,b,c,x;
    int sum=0;
    cin>>a>>b>>c>>x;

    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                if(500*i+100*j+50*k==x){sum++;}
            }
        }
    }


cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define newline putchar('\n')
#define leave_space putchar(' ')
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
const int MAXN = 1e5 + 10;
vector<pii> add[32];
int now[MAXN], ans[MAXN];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n, c;
	cin >> n >> c;
	rep (i, 1, n) {
		int x, y, z;
		cin >> x >> y >> z;
		add[z].pb(pii(x, y));
	}
	int res = 0;
	rep (i, 1, c) {
		memset(now, 0, sizeof(now));
		for (auto pr : add[i]) {
			++now[pr.fst - 1];
			--now[pr.sed];
		}
		rep (j, 1, MAXN - 10) {
			now[j] += now[j - 1];
		}
		rep (j, 0, MAXN - 10) {
			ans[j] += bool(now[j]);
			res = max(res, ans[j]);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long W = sc.nextLong();
		long H = sc.nextLong();
		long x = sc.nextLong();
		long y = sc.nextLong();
		sc.close();
		// 結果出力
		System.out.println(
			W * H * 0.5 + " " + 
			((x * 2) == W && (y * 2) == H ? "1" : "0"));
	}
}


Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B,C;
  cin>>A>>B>>C;
  
  vector<int>vec={A,B,C};
  sort(vec.begin(),vec.end());
  
  if(vec.at(0)==vec.at(1)){
    cout<<vec.at(2)<<endl;
  }
  else if(vec.at(1)==vec.at(2)){
    cout<<vec.at(0)<<endl;
  }
}

    
  


Measured memory_bytes: 256
import itertools
n = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))
n = list(range(1,n+1))

flag = 0
for i, p in enumerate(itertools.permutations(n), start=1):
    if p == P:
        a = i
        flag += 1
    if p == Q:
        b = i
        flag += 1
    if flag == 2:
        break
print(abs(a-b))

Measured memory_bytes: 3188
#include <stdio.h>
#define MAX 10000
#define NIL -1

typedef struct kk {
    int parent;
    int left;
    int right;
} Node;

Node T[MAX];
int n,D[MAX],H[MAX];

void setdepth(int u,int d)
{
    if(u == NIL) return;
    D[u] = d;
    setdepth(T[u].left,d+1);
    setdepth(T[u].right,d+1);
}

int setheight(int u)
{
    int h1 = 0,h2 = 0;
    if(T[u].left != NIL) h1 = setheight(T[u].left) + 1;
    if(T[u].right != NIL) h2 = setheight(T[u].right) + 1;
    
    return H[u] = (h1 > h2 ? h1 : h2);
}

int getsibling(int u)
{
    if(T[u].parent == NIL) return NIL;
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
    if(T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;
    return NIL;
}

void print(int u)
{
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getsibling(u));
    int deg = 0;
    if(T[u].left != NIL) deg++;
    if(T[u].right != NIL) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);
    
    if(T[u].parent == NIL) printf("root\n");
    else if(T[u].left == NIL && T[u].right == NIL) printf("leaf\n");
    else printf("internal node\n");
}

int main()
{
    int v,l,r,root = 0,i;
    scanf("%d",&n);
    for(i = 0;i < n;i++) T[i].parent = NIL;
    
    for(i = 0;i < n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].left = l;
        T[v].right = r;
        if(l != NIL) T[l].parent = v;
        if(r != NIL) T[r].parent = v;
    }
    
    for(i = 0;i < n;i++) if(T[i].parent == NIL) root = i;
    
    setdepth(root,0);
    setheight(root);
    
    for(i = 0;i < n;i++) print(i);
    
    return 0;
}





Measured memory_bytes: 2148
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
typedef int64_t Int;
typedef uint64_t uInt;
const double pi = M_PI;
 
int main() {
    Int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
 
    Int ans = INT64_MAX, count = max(x, y);
 
    for (Int i = 0; i < count + 1; i++) {
        ans = min(ans, 2 * c * i + a * max((Int)0, x - i) + b * max((Int)0, y - i));
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int n=in();
    printf("AB%c\n",'C'+(n>=1000));
    return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
MOD = pow(10, 9) + 7

yakusu = [0]
ans = 0
for i in range(K):
    n = i + 1

    yaku = 0
    if n > 1:
        for j in range(1, int(n**0.5)+1):
            if n % j == 0:
                yaku += j - yakusu[j]
                if j != n//j and j != 1:
                    yaku += n//j - yakusu[n//j]
    yakusu.append(yaku)

    ans += pow((K//n), N, MOD) * (n - yaku)
    ans %= MOD

print(ans)


Measured memory_bytes: 79748
def decrypt(str, a, b)
  table = ('a'..'z').to_a
  stack = []
  for i in 0...str.size
    s = str[i]
    if s =~ /[a-z]/
      n = (a * table.index(s) + b) % 26
      stack << table[n]
    else
      stack << s
    end
  end
  stack.join
end

n = gets.chomp.to_i

n.times do
  encrypted = gets.chomp
  a = 1
  found = false
  until found
    if a.gcd(26) == 1
      for b in 0..25
        decrypted = decrypt(encrypted, a, b)
        if decrypted =~ /\b(this|that)\b/
          found = true
          break
        end
      end
    end
    a += 1
  end

  puts decrypted
end

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

string z;
int res = 0;
void licz(int a,int b){
  if(a+1 >= b)return;
  if(z[a] == z[b-1]){
    licz(a+1,b-1);
  }else{
    if(z[a] == 'x'){
      res ++;
      licz(a+1,b);
    }else if(z[b-1] == 'x'){
      res ++;
      licz(a, b-1);
    }else{
      cout << "-1\n";
      exit(0);
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> z;
  licz(0,SZ(z));
  cout << res << "\n";
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
   int r;
   cin >> r;
   if(r < 1200){
       cout << "ABC" << endl;
   } else if(1200 <= r && r < 2800){
       cout << "ARC" << endl;
       }else{
       cout << "AGC" << endl;
   }


}

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

int main() {
  ll h,n;
  cin >> h >> n;
  vector<int>a(n);
  rep(i,n) cin >>a[i];
  ll sum = 0;
  rep(i,n) sum+=a[i];
  if(sum>=h) cout <<"Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

int main(void){
    ll N, K; cin >> N >> K;
    
    ll ans = 0;
    for(ll i = K; i <= N + 1; i++){
        ll L = i * (i - 1) / 2;
        ll R = N * (N + 1) / 2 - (N - i) * (N - i + 1) / 2 ;
        ans += R - L + 1;
        ans %= MOD;
    }
    cout << ans << endl;
}


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

map<string,int> M;

int str2int(string S){
    if(M.find(S)==M.end()){
        int n = M.size();
        M[S]=n;
    }
    return M[S];
}

int E[200][200];//[a][b]=a to b

int main(){
    int N;
    while(cin>>N,N){
        fill(E[0],E[200],10000);
        M.clear();
        for(int i=0;i<N;i++){
            string S;
            cin>>S;
            for(int c=0;c<S.size();c++){
                if(S[c]=='-'){
                    string S1=S.substr(0,c);
                    string S2=S.substr(c+1,S.size()-c-1);
                    int i1=str2int(S1);
                    int i2=str2int(S2);
                    E[i1][i2]=1;
                    break;
                }
            }
        }
        int m = M.size();
        cout<<m<<endl;
        for(int i=0;i<m;i++){
            for(int j=0;j<m;j++){
                if(E[i][j]==1||E[j][i]==1) continue;
                //cond1
                bool b=false;
                for(int k=0;k<m;k++){
                    if(k==i||k==j) continue;
                    if((E[i][k]==1||E[k][i]==1)&&(E[j][k]==1||E[k][j]==1)){
                        b=true;
                        break;
                    }
                }
                //cond2,3
                for(int k=0;k<m;k++){
                    if(k==i||k==j) continue;
                    if((E[k][i]==1&&E[j][k]==1)||(E[i][k]==1&&E[k][j]==1)){
                        b=false;
                        break;
                    }
                }
                if(b) E[i][j]=E[j][i]=0;
            }
        }
        //WF
        for(int i=0;i<m;i++) E[i][i]=0;
        for(int k=0;k<m;k++){
            for(int i=0;i<m;i++){
                for(int j=0;j<m;j++){
                    E[i][j]=min(E[i][j],E[i][k]+E[k][j]);
                }
            }
        }
        int Q;
        cin>>Q;
        for(int i=0;i<Q;i++){
            string S;
            cin>>S;
            for(int c=0;c<S.size();c++){
                if(S[c]=='-'){
                    string S1=S.substr(0,c);
                    string S2=S.substr(c+1,S.size()-c-1);
                    int i1=str2int(S1);
                    int i2=str2int(S2);
                    if(i1>=m||i2>=m||E[i1][i2]%2==0){
                        cout<<"NO"<<endl;
                    }else{
                        cout<<"YES"<<endl;
                    }
                    break;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3280
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long

int main(void)
{
    char s[200002];
    char t[200002];
    int i, count = 0;
    scanf("%s", s);
    scanf("%s", t);
    for (i = 0; i < strlen(s); i++)
    {
        if (s[i] != t[i])
            count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 2064
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main() {

	int A,B;
	cin>>A>>B;
	cout<<(A-1)*(B-1)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

main(void)
{
	int n,a,i;

	long long int max = -1000000;
	long long int min = 1000000;
	long long int sum =0;
	a=0;
	scanf("%d",&n);
	for(a = 1;a <= n;a++){
		scanf("%d",&i);
		if (i < min) min = i;
		if (i > max) max = i;
		sum +=i;
	}
	printf("%lld %lld %lld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	ll n, d, count=0;
	cin>>n>>d;
	for(ll i=0;i<n;i++){
		ll p,q;
		cin>>p>>q;
		double dis;
		dis = sqrt(pow(p,2)+pow(q,2));
		if(dis<=d){
			count++;
		}
	}
	cout<<count<<endl;

}


Measured memory_bytes: 3696