akhauriyash/Code-Regression huggingface dataset:
import math
n,m=map(int,input().split())
if abs(n-m)>1:
    print('0')
else:
    if n==m:
       ans1=math.factorial(n)%(10**9+7)
       ans2=math.factorial(n)%(10**9+7)
       print(ans1*ans2*2%(10**9+7))
    else:
       ans1=math.factorial(n)
       ans2=math.factorial(m)
       print(ans1*ans2%(10**9+7))


Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define fio() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MOD 1000000007
#define lli long long int
#define ld long double
#define pb push_back
using namespace std;

int main()
{
    fio();
    ld n,k;
    cin>>n>>k;
    cout<<(int)(ceil((n-1)/(k-1)));
    cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";

}

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

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	int c[m];
	for (int i = 0; i < m; ++i) cin>>c[i];
	int dp[n+5];
	for (int i = 0; i < n+5; ++i) dp[i]=100000000;
	dp[0]=0;
	for (int i = 0; i < n+5; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			if(i+c[j]<=n) dp[i+c[j]]=min(dp[i+c[j]],dp[i]+1);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}



Measured memory_bytes: 3288
var
	L,R,ans,tmp,M,i,j:Longint;
begin
	read(L,R);
	M:=2019;
	ans:=M;
	if L+2017<=R then begin
		writeln(0);
		exit;
	end;
	for i:=L to R do begin
		for j:=1 to 50 do begin
			if i+j>R then break;
			tmp:=i mod M*(i+j)mod M;
			if ans>tmp then ans:=tmp;
		end;
	end;
	writeln(ans);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}
  // assign: 総とっかえ
  void init(int n) { par.assign(n, -1); }

  int root(int x) {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }

  bool issame(int x, int y) { return root(x) == root(y); }

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;

    // xにyをmerge
    if (par[x] > par[y]) swap(x, y);  // merge technique
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x) { return -par[root(x)]; }
};

int main(){
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.merge(a, b);
    }
    set<int> r;
    rep(i, n){
        r.insert(uf.root(i));
    }
    cout << r.size() - 1 << endl;
    return 0;
}

Measured memory_bytes: 7600
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
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);

    string S; cin >> S;
    int n = S.size();

    const string keyence = "keyence";

    bool isOK = false;
    int index = 0;

    for(int i = 0; i < n; i++){
        string first = "";
        for(int j = 0; j < i; j++){
            first += S[j];
        }
        for (int j = i; j < n; j++){
            string second = ""; 
            for(int k = 0; k < n-i; k++){
                if (j+k >= n) break;
                second += S[j+k];
            }
            if (keyence == (first+second)){
                isOK = true;
            }
        }
    }


    if(isOK) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main(){

  int angle;
  int pic[10][10];
  int kaisu=0;
  int num;
  int n;
  int x,y;

  while(1){

    angle=1;
    x = y = 0;
    num=1;
    cin >> n;
    if(n==0)
      break;

    kaisu++;

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

      pic[x][y]=num;

      if(angle == 0){
	if(y==n-1){
	  x++;
	  angle = 1;
	}
	else if(x==0){
	  y++;
	  angle = 1;
	}
	else{
	  x--;
	  y++;
	}
      }////////////////////////

      else{
	if(x==n-1){
	  y++;
	  angle = 0;
	}
	else if(y==0){
	  x++;
	  angle = 0;
	}
	else{
	  x++;
	  y--;
	}
      }/////////////////////////////

      num++;

    }

    cout << "Case " << kaisu << ':' << endl;

    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
	printf(" %2d",pic[j][i]);
      }
      cout << endl;
    }


  }


  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>

int kMod = 1e9+7;

void print_all(const std::vector<int>& v)
{
  for (int x : v) {
    std::cout << x << '\n';
  }
}

int main()
{
  int n, m;
  std::cin >> n >> m;
  std::vector<bool> is_broken(n, false);
  for (int i = 0; i < m; i++) {
    int broken_index;
    std::cin >> broken_index;
    is_broken.at(broken_index-1) = true;
  }
  std::vector<int> patterns(n, 0);
  if (is_broken.at(0)) {
    patterns.at(0) = 0;
  } else {
    patterns.at(0) = 1;
  }
  if (n <= 1) {
    std::cout << patterns.at(0) << '\n';
    return 0;
  }
  if (is_broken.at(1)) {
    patterns.at(1) = 0;
  } else {
    patterns.at(1) = patterns.at(0) + 1;
  }
  for (int i = 2; i < n; i++) {
    if (is_broken.at(i)) {
      patterns.at(i) = 0;
    } else {
      patterns.at(i) = (patterns.at(i-1) + patterns.at(i-2)) % kMod;
    }
  }
  std::cout << patterns.back() << '\n';
  //print_all(patterns);
  return 0;
}


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

const int mod = 1000000007;

int N;
bool a[21][21];
int dp[1 << 21];

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

    dp[0] = 1;
    for(int S = 0; S < 1 << N; S++) {
        int i = __builtin_popcount(S);
        for(int j = 0; j < N; j++) {
            if(S >> j & 1 && a[i - 1][j] == 1) {
                dp[S] += dp[S ^ 1 << j];
                if(dp[S] >= mod) dp[S] -= mod;
            }
        }
    }

    cout << dp[(1 << N) - 1] << endl;
}

Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

int main(){
	int k,x;
	cin>>k>>x;
	vector<int> ans(2*k-1);

	rep(i,2*k-1){
		ans[i]=x-abs(k-1)+i;
	}

	rep(i,2*k-1) cout<<ans[i]<<" ";
}

Measured memory_bytes: 256
from itertools import combinations
import bisect
n = int(input())
*A, = map(int, input().split())
q = int(input())
*M, = map(int, input().split())
S = set()
for i in range(1, n + 1):
    for c in combinations(A, i):
        S.add(sum(c))
for m in M:
    if m in S:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 5736
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    for(int i = 0; i < n; i++){
        cout << s.at(i) << t.at(i);
    }
    cout << endl;
    return 0;
}


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

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

	int res = 0;
	stack<char> stk;
	for(int i = 0; i < s.length(); i++){
		if(stk.empty()) stk.push(s[i]);
		else if(stk.top()!=s[i]){
			stk.pop();
			res++;
		}
	    else stk.push(s[i]);
	}

	cout<<2*res;
}

Measured memory_bytes: 512
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <cmath>
#include <limits.h>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a, ll b){return b? gcd(b, a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  ll x[N];
  ull ret[N]; //折り返し地点
  bool hasPositive = false;
  bool hasNegative = false;
  bool hasZero = false;
  int changed = -1;
  for(int i = 0; i < N; i++){
    cin>>x[i];
    if(x[i] > 0 && changed < 0){
      changed = i;
    }
    if(x[i] > 0){
      hasPositive = true;
    }else if (x[i] < 0){
      hasNegative = true;
    }else{
      hasZero = true;
    }
  }
  ull ans = 0;
  bool ansDetermined = false;
  if(hasPositive == false){
    ans = -x[N-K];
    ansDetermined = true;
  }else if(hasNegative == false){
    ans = x[K-1];
    ansDetermined = true;
  }

  if(hasZero){
    bool afterZero = false;
    for(int i = 0; i < N;i++){
      if(x[i] == 0){
        afterZero = true;
      }
      if(afterZero){
        x[i-1] = x[i];
      }
    }
    N = N-1;
    K = K-1;
    changed--;
    if(K==0){
      ans = 0;
      ansDetermined = true;
    }
  }

  if(!ansDetermined){
    for(int i = 0; i < N; i++){
      if(x[i] < 0){
        if(i+K-1 < N){
          ret[i] = -2*x[i] + x[i+K-1];
        }else{
          ret[i] = ULLONG_MAX;
        }
      }else if (x[i] > 0){
        if(i-K+1 >=0){
          ret[i] = x[i] + x[i] - x[i-K+1];
        }else{
          ret[i] = ULLONG_MAX;
        }
      }
    }
    ull min = ULLONG_MAX;
    for(int i = 0; i < N; i++){
      if(min > ret[i]){
        min = ret[i];
      }
    }
    ans = min;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = int_fast64_t;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,b,c;
    cin >> a >> b >> c;
    if (a > b) swap(a,b);
    if (b > c) swap(c,b);
    if (a > b) swap(a,b);
    cout << c * 10 + a + b << endl;
}

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

Measured memory_bytes: 256
s="URDL";d={i:[]for i in s}
_,*a=map(str.split,open(0))
for*z,u in a:d[u]+=[*map(int,z)],
I=N=9e9;P,M="x+y,","x-y,"
for*F,S in(2,0,"x,y,"),(3,1,"y,x,"),(0,1,P+M),(3,2,P+M),(3,0,M+P),(2,1,M+P):
 n=p=-I
 for x,y,r in sorted(eval(f"(({S}Q)for Q,P in enumerate(F)for x,y in d[s[P]])")):
  if r:n,p=x,y
  elif x==n:N=min(N,y-p)
print(["SAFE",N*5][N<I])

Measured memory_bytes: 129900
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        sc.close();

        int cnt = 0;

        for (int i=0; i<S.length(); i++) {
            if (S.substring(i,i+1).equals(T.substring(i,i+1)))
                cnt++;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
 
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; }
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const ll maxv=105;
int dist[maxv][maxv];
int n;
void warshallfloyd(){
  for(int k = 0; k < n; k++)
    for(int i = 0; i < n; i ++)
      for(int j = 0; j < n; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
 
 
signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll m; cin>>n>>m;
  rep(i,n) rep(j,n) dist[i][j]=INF;
  vector<tuple<ll,ll,ll>> es;
  rep(i,m){
    ll a,b,c; cin>>a>>b>>c;
    a--,b--;
    es.emplace_back(a,b,c);
    dist[a][b]=dist[b][a]=c;
  }
  
  warshallfloyd();
  
  ll ans=0;
  rep(i,m){
    ll a,b,c;
    tie(a,b,c)=es[i];
    if(dist[a][b]<c) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
let n = read_int ()
let i, d = ref 1, ref 1
let rec f n = if n <= 9 then 1 else 1 + f (n / 10)
let _ =
  while !i * !i < n do if n mod !i = 0 then d := !i; incr i done;
  Printf.printf "%d\n" @@ if !i * !i = n then f !i else f @@ n / !d

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		S[i] = (S[i] - 'A' + N) % 26 + 'A';
	}
	cout << S << endl;
}


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

int main() {
  int A,B,C,D;

  cin >> A >> B >> C>> D;
  
  if (A+B>C+D) {
    cout <<"Left"<< endl;
  }
  else if (A+B<C+D){
    cout << "Right" << endl;
  }
   else{
     cout << "Balanced" << endl;
   }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static int gcd (int x, int y) {
        if (y == 0) return x;
        return gcd(y, x % y);
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int x = scanner.nextInt(), y = scanner.nextInt();
        System.out.println(gcd(x, y));
    }
}



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

int main(){
  long long N; cin >> N;
  vector<long long> A(N);
  long long ans = 0;
  for (int i=0; i<N; i++) {
    cin >> A[i];
    ans += abs(A[i]);
  }
  sort(A.begin(), A.end());
  if (A[0]*A[N-1]<0){
    cout << ans << endl;
    for (int i=1; i<N; i++){
      if (A[i]*A[N-1]>0){
        for (int j=i; j<N-1; j++){
          cout << A[0] << ' ' << A[j] << endl;
          A[0] -= A[j];
        }
        cout << A[N-1] << ' ' << A[0] << endl;
        return 0;
      }
      cout << A[N-1] << ' ' << A[i] << endl;
      A[N-1] -= A[i];
    }
  }
  else if (A[0]==0&&A[N-1]==0){
    cout << ans << endl;
    for (int i=0; i<N-1; i++){
      cout << 0 << ' ' << 0 << endl;
    }
    return 0;
  }
  else if (A[0]>=0){
    ans -= A[0]*2;
    cout << ans << endl;
    cout << A[0] << ' ' << A[N-1] << endl;
    A[0] -= A[N-1];
    A.erase(A.begin()+N-1);
    N--;
    if (A[0]==0&&N>1){
      if (N==2){
        cout <<A[N-1] << ' ' << A[0] << endl;
        A[0] -= A[N-1];
        A.erase(A.begin()+N-1);
        N--;
      }
      else {
        cout <<A[0] << ' ' << A[N-1] << endl;
        A[0] -= A[N-1];
        A.erase(A.begin()+N-1);
        N--;
      }
    }
    for (int i=1; i<N; i++){
      if (A[i]*A[N-1]>0){
        for (int j=i; j<N-1; j++){
          cout << A[0] << ' ' << A[j] << endl;
          A[0] -= A[j];
        }
        cout << A[N-1] << ' ' << A[0] << endl;
        return 0;
      }
      cout << A[N-1] << ' ' << A[i] << endl;
      A[N-1] -= A[i];
    }
  }
  else {
    ans += A[N-1]*2;
    cout << ans << endl;
    cout << A[N-1] << ' ' << A[0] << endl;
    A[N-1] -= A[0];
    A.erase(A.begin());
    N--;
    if (A[N-1]==0&&N>1){
      if (N==2){
        cout <<A[0] << ' ' << A[N-1] << endl;
        A[N-1] -= A[0];
        A.erase(A.begin());
        N--;
      }
      else{
         cout <<A[N-1] << ' ' << A[0] << endl;
         A[N-1] -= A[0];
         A.erase(A.begin());
         N--;
       }
      }
    for (int i=1; i<N; i++){
      if (A[i]*A[N-1]>0){
        for (int j=i; j<N-1; j++){
          cout << A[0] << ' ' << A[j] << endl;
          A[0] -= A[j];
        }
        cout << A[N-1] << ' ' << A[0] << endl;
        return 0;
      }
      cout << A[N-1] << ' ' << A[i] << endl;
      A[N-1] -= A[i];
    }
  }
}


Measured memory_bytes: 2688
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }
    static class Task{
        public void solve(Scanner sc, PrintWriter out){
            String S = nstr(sc);
            String T = nstr(sc);
            List<String> SList = new ArrayList<>();

            for(int i = 0; i < S.length(); i++){
                String x = String.valueOf(S.charAt(i));
                SList.add(x);
            }
            List<String> TList = new ArrayList<>();
            for(int i = 0; i < T.length(); i++){
                String x = String.valueOf(T.charAt(i));
                TList.add(x);
            }

            for (int i=0; i<SList.size(); i++){
                String tmp = SList.get(SList.size()-1);
                SList.remove(SList.size()-1);
                SList.add(0, tmp);
                if (SList.equals(TList)){
                    out.println("Yes");
                    return;
                }
            }
            out.println("No");

        }
    }

    static int nint(Scanner sc){
        return Integer.parseInt(sc.next());
    }
    static long nlong(Scanner sc){
        return Long.parseLong(sc.next());
    }
    static double ndouble(Scanner sc){
        return Double.parseDouble(sc.next());
    }
    static float nfloat(Scanner sc){
        return Float.parseFloat(sc.next());
    }
    static String nstr(Scanner sc){
        return  String.valueOf(sc.next());
    }
    static long[] longLine(Scanner sc, int size){
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }
    static int[] intLine(Scanner sc, int size){
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }
    static String[] strLine(Scanner sc, int size){
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }
}

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

const int MOD = (int)1e9+7;

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

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

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

	cout << lcm(A,B) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    bool c1 = A==B;
    bool c2 = B==C;
    bool c3 = C==A;
    if(c1) cout << C << endl;
    else if(c2) cout << A << endl;
    else if(c3) cout << B << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int sleep() {
	int j=0;
	for(int i=1; i<=2000001; i++) j++;
	return j;
}
struct data {
	int sum=0;
	int red=0;
} s[100005];
int main() {
	ios::sync_with_stdio(false);
	int n,m,i;
	scanf("%d%d",&n,&m);
	s[1].sum=s[1].red=1;
	for(i=2; i<=n; i++) s[i].sum=1;
	int x,y,ans=0;
	while(m--) {
		scanf("%d%d",&x,&y);
		if(s[x].red==1&&s[x].sum==1) {
			s[y].red=1;
			s[x].sum=s[x].red=0;
			s[y].sum++;
		} else if(s[x].red==0&&s[x].sum!=0) {
			s[y].sum++;
			s[x].sum--;
		} else if(s[x].red==1&&s[x].sum>1) {
			s[x].sum--;
			s[y].red=1;
			s[y].sum++;
		}
	}
	for(i=1; i<=n; i++) {
		if(s[i].red==1) ans++;
	}
	printf("%d\n",ans);
	sleep();
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
#define PI acos(-1)
using namespace std;
int def[10][7]={
  {0,1,1,1,1,1,1},
  {0,0,0,0,1,1,0},
  {1,0,1,1,0,1,1},
  {1,0,0,1,1,1,1},
  {1,1,0,0,1,1,0},
  {1,1,0,1,1,0,1},
  {1,1,1,1,1,0,1},
  {0,1,0,0,1,1,1},
  {1,1,1,1,1,1,1},
  {1,1,0,1,1,1,1}
};
int main(){
  int n;
  while(cin>>n,n+1){
    int in;
    cin>>in;
    int now[7]={0};
    rep(i,7){
      now[i]=def[in][i];
      cout<<def[in][i];
    }
    cout<<endl;
    rep(i,n-1){
      cin>>in;
      rep(j,7){
	if(now[j]==def[in][j])cout<<0;
	else cout<<1;
	now[j]=def[in][j];
      }
      cout<<endl;
    }
  }


}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
char s[51][51];
int cnt = 0;
int h, w;
int main()
{
    cin >> h >> w;
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> s[j][i];
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cnt = 0;
            if (s[j][i] == '#')
            {
                cout << "#";
            }
            else
            {
                for (int x = -1; x <= 1; x++)
                {
                    for (int y = -1; y <= 1; y++)
                    {
                        int X = j + x;
                        int Y = i + y;
                        if (0 <= X && X < w && 0 <= Y && Y < h)
                        {
                            if (s[X][Y] == '#')
                            {
                                cnt++;
                            }
                        }
                    }
                }
                cout << cnt;
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
int main(){
    
  int a,b,c;
  int tmp;
  
  scanf("%d %d %d",&a,&b,&c);
  
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
 
 if(a>c){
    tmp=a;
    a=c;
    c=tmp;
  }
 
  if(b>c){
    tmp=b;
    b=c;
    c=tmp;
  }
 
  printf("%d %d %d\n",a,b,c);
   
  return 0;
}


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

const ll MOD=1000000007;

int main(){
    int N,M;
    cin>>N>>M;
    vector<int>X(M);
    rep(i,M){
        cin>>X.at(i);
    }
    if(N>=M){
        cout<<0<<endl;
    }
    else{
        sort(X.begin(),X.end());
        vector<int>SA(M-1);
        for(int i=0;i<M-1;i++){
            SA.at(i)=X.at(i+1)-X.at(i);
        }
        sort(SA.begin(),SA.end());
        int sum=0;
        for(int i=0;i<M-N;i++){
            sum=sum+SA.at(i);
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("Sample.txt")
    N = Scanner.string()
    K = Scanner.int()
    M = len(N)
    dp = [[[0 for _ in range(2)] for _ in range(4)] for _ in range(M + 1)]
    dp[0][0][0] = 1
    for i in range(M):
        for j in range(4):
            for k in range(2):
                nd = int(N[i])
                for d in range(10):
                    ni = i + 1
                    nj = j
                    nk = k
                    if d != 0:
                        nj += 1
                    if nj > K:
                        continue
                    if k == 0:
                        if d < nd:
                            nk = 1
                        if d > nd:
                            continue
                    dp[ni][nj][nk] += dp[i][j][k]
    ans = dp[M][K][0] + dp[M][K][1]
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 40940
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int n, l;
  string s[110];
  cin >> n >> l;
  REP(i, n)
      cin >> s[i];
    sort(s, s + n);
REP(i,n){
  cout << s[i];
}
printf("\n");

return 0;
}

Measured memory_bytes: 764
n,x,m=map(int,input().split())
p=[0]*(m+1)
a=x
t=0
s=0
for i in range(2*m):
    if p[a]==1:
        p[a]=2
        break
    else:
        p[a]=1
        a=a**2%m
a=x
S=0
for i in range(2*m):
    if p[a]==1:
        s+=1
        S+=a
        a=a**2%m
    else:
        s+=1
        S+=a
        break
T=0
A=0
for i in range(2*m):
    a=a**2%m
    t+=1
    T+=a
    if p[a]==2:
        A=a
        break


a=x
if n<=s:
    ans=0
    for i in range(n):
        ans+=a
        a=a**2%m
    print(ans)
else:
    ans=S
    a=A
    n-=s
    ans+=(n//t)*T
    n=n%t
    for i in range(n):
        a=a**2%m
        ans+=a
    print(ans)



Measured memory_bytes: 66824
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll H, W;
	std::cin >> H >> W;
	vector<vll> a(H, vll(W, 0));

	ll sum = 0;
	ll ll_input;
	queue < pair<pair<ll, ll>, pair<ll, ll>>> q;
	rep(i, 0, H) {
		rep(j, 0, W) {
			std::cin >> ll_input;
			a[i][j] += ll_input;
			if (i == H - 1 && j == W - 1) {
				break;
			}
			if (a[i][j] & 1) {
				if (i < H - 1) {
					q.push({ {i,j},{i + 1,j} });
					a[i + 1][j] ++;
				}
				else {
					q.push({ {i,j},{i,j + 1} });
					a[i][j + 1] ++;
				}
				a[i][j]--;
			}
		}
	}
	std::cout << q.size() << endl;
	while (!q.empty()) {
		std::cout << q.front().first.first+1 << " " << q.front().first.second+1 << " " << q.front().second.first+1 << " " << q.front().second.second+1 << endl;
		q.pop();
	}


	return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include<algorithm>
#include<string>
using namespace std;
const int maxn =1e5+10;
long long gcd(long long x,long long y)
{
    if(y==0)return x;
    return gcd(y,x%y);
}
int main()
{
    long long x,y;
    cin >> x >> y;
    long long g=gcd(x,y);
    long long ans=0;
    for(long long i=2;i<= g / i; i++)
    {
        if(g%i==0)
        {
            ans++;
            while(g%i==0) g/=i;
        }
    }
    if(g>1) ans++;
    cout << ans +1 <<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        for(int i=0; i<s.length(); i+=2){
            System.out.print(s.charAt(i));
        }
        System.out.println("");
    }
}

Measured memory_bytes: 30124
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
using namespace std;

using ll=long long int;

int main() {

	int v[6];
	for (int i = 0; i < 6; i++) cin >> v[i];


	if (v[4] - v[0] <= v[5])cout << "Yay!" << endl;
	else cout << ":(" << endl;

	return 0;
}





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

int main() {
  string w;
  cin >> w;
  map<char,int> mp;
  
  for (int i = 0; i < w.size(); i++){
    cin >> w.at(i);
    mp[w.at(i)]++;
  }
  
  string ans = "Yes";
  int mx = 0;
  for (auto p : mp) mx = max ( mx, p.second);
  for (auto p : mp){
    if(p.second % 2 == 1) {
      ans = "No";
      break;
    }
 }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int w, h, x, y;
  cin >> w >> h >> x >> y;

  float max;
  int answer = 0;
  
  max = 0.5 * w * h;
  if(2*x==w && 2*y==h){
    answer = 1;
  }
  
  cout << max << " " << answer << endl;
  return 0;
}

Measured memory_bytes: 256
use strict;
use warnings;
 
chomp(my $nab = <>);
my($n, $a, $b) = split / /, $nab;
 
my $ans = 0;
 
for (my $i=1; $i <= $n; $i++){
	my $sum = 0;
	my @num = split //, $i;;
    foreach (@num) {$sum += $_;}
    if ($sum >= $a && $sum <= $b) {
    $ans += $i;
    }
}
 
print $ans . "\n";

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n;
  while(cin >> n, n) {
    int m[n], a[n], b[n];
    REP(i,n) {
      cin >> m[i] >> a[i] >> b[i];
    }
    bool f = false;
    REP(i,n) {
      int tmp = 0;
      REP(j,n) {
        if (a[j] < b[i] && b[i] <= b[j])
          tmp += m[j];
      }
      //   cout << b[i] << " " <<tmp << endl;
      if (tmp > 150) {
        f = 1;
        break;
      }
    }
    if (f)
      cout << "NG" << endl;
    else
      cout << "OK" << endl;
  }
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, m, k;
    cin >> n >> m >> k;

    vector<pair<int, int> > v(n);
    for(int i=0; i<n; ++i)
        cin >> v[i].first;
    for(int i=0; i<n; ++i)
        cin >> v[i].second;
    sort(v.rbegin(), v.rend());

    int ans = 0;
    for(int j=0; j<(1<<n); ++j){
        bitset<15> bs(j);
        if(k < bs.count())
            continue;

        int rest = m;
        int cnt = 0;
        for(int i=0; i<n; ++i){
            if(bs[i]){
                int x = min(rest, v[i].second);
                cnt += v[i].first * x;
                rest -= x;
            }
        }
        ans = max(ans, cnt + rest);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3096
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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


Measured memory_bytes: 3556
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int total = 0;
    ArrayList<Integer> list = new ArrayList<Integer>();
    for (int i = 0; i < N; i++) {
      list.add(sc.nextInt());
    }
    Collections.sort(list, Collections.reverseOrder());
    for (int i = 0; i < K; i++) {
      total += list.get(i);
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 21844
// Problem : C - Forbidden List
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define mk make_pair
#define fast                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x) (int)x.size()
#define mem(a, val) memset(a, val, sizeof(a))
#define deci(x) cout << fixed << setprecision(x);
#define bitcount(x) __builtin_popcountll(x)

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

const long long int mod = 1e9 + 7;
const long double EPS = 1e-12;
const int N = 1e5 + 20;

ll vis[300];

void solve() {
  ll x, n;
  cin >> x >> n;
  ll temp;
  ll ans = 1e18, dif = 1e18;
  rep(i, 0, n) {
    cin >> temp;
    vis[temp] = 1;
  }
  rep(i, 0, 200) {
    if (vis[i]) continue;
    ll temp = i;
    ll ndif = abs(temp - x);

    if (ndif < dif) {
      dif = ndif;
      ans = temp;
    } else if (ndif == dif) {
      ans = min(ans, temp);
    }
  }
  cout << ans;
}
int main() {
  fast;
  ll t;
  t = 1;

  // cin>>t;

  while (t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> a(h,vector<char> (w,'-'));
    int sh = 0;
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
            if(a[i][j]=='#'){
                sh++;
            }
        }
    }
    if(sh==h+w-1){
        cout<<"Possible"<<endl;
    }
    else{
        cout<<"Impossible"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(void) {
	int n, a, i, j, x = 1;
	cin >> n;
	a = (int)sqrt(8 * n + 1);
	if (a * a != 8 * n + 1) {
		printf("No\n");
		return 0;
	}
	a >>= 1;
	printf("Yes\n%d\n", a + 1);
	vector<vector<int>> d(a + 1, vector<int>(a));
	for (i = 0; i < a; i++) {
		for (j = i; j < a; j++) {
			d[i][j] = x;
			d[j + 1][i] = x++;
		}
	}
	for (i = 0; i <= a; i++) {
		printf("%d ", a);
		for (j = 0; j < a; j++) {
			printf("%d ", d[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        String[] days = new String[]{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
        int nextSat = -1;
        for(int i = 0; i < days.length; i++) {
            if (S.equals(days[i])) {
                nextSat = S.equals(days[0]) ? days.length : days.length - i;
            }
        }
        System.out.println(nextSat);
    }

}


Measured memory_bytes: 21844
#include <stdio.h>
int main(void){
    int a;
    int h,m,s;
    scanf("%d",&a);
    h=a/3600;
    m=(a-h*3600)/60;
    s=a-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

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

int main(){
    int n;
    while (cin>>n,n){
        map<string, int>items;
        for (int i = 0; i < n; i++){
            string str;
            int a;
            cin >> str >> a;
            items[str]= a;
        }
        int renkinn;
        cin >> renkinn;
        for (int i = 0; i < renkinn; i++){
            string item;
            int sum = 0, a;
            cin >> item >> a;
            for (int j = 0; j < a; j++){
                string b;
                cin >> b;
                sum += items[b];
            }
            if (sum < items[item])items[item] = sum;
        }
        string ans;
        cin >> ans;
        cout << items[ans] << endl;
    }
    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> l(n);
  REP(i, n) cin >> l[i];
  ll ans = 0;
  sort(ALL(l));
  REP(i, n - 2) FOR(j, i + 1, n - 1) FOR(k, j + 1, n) {
    if (l[i] + l[j] > l[k]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll A,B;
    cin >> A >> B;
    print(max({A + B, A - B, A * B}));

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[4][4];
int main()
{
	cin>>a[1][1]>>a[1][2]>>a[2][2];
	int s=a[2][2]*3;
	a[1][3]=s-a[1][1]-a[1][2];
	a[3][2]=s-a[1][2]-a[2][2];
	a[3][3]=s-a[1][1]-a[2][2];
	a[2][3]=s-a[1][3]-a[3][3];
	a[2][1]=s-a[2][2]-a[2][3];
	a[3][1]=s-a[3][2]-a[3][3];
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int main()
{
    int n, k;
    cin>>n>>k;
    cout<<int(log(n)/log(k)+1)<<endl;
}


Measured memory_bytes: 640
n = gets.chomp.to_i
ab = []
n.times do
  ab.push gets.split.map(&:to_i)
end
count = 0
ab.reverse_each do |e|
  a = e.first
  b = e.last
  mod = (count + a) % b
  count += b - mod if mod > 0
end
puts count


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

int main(){
  int k, s;
  cin >> k >> s;

  int count = 0;

  for(int x = 0; x <= k; x++){
    for(int y = 0; y <= k; y++){
      int z = s - x - y;
      if(0 <= z && z <= k){
        count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    priority_queue<ll, vector<ll>, greater<>> q0;
    priority_queue<ll> q1;
    vector<ll> v_mid(N);

    ll s0 = 0, s1 = 0;
    REP(i, N) {
        ll a; cin >> a;
        q0.push(a);
        s0 += a;
    }

    REP(i, N) {
        ll a; cin >> a;
        v_mid[i] = a;
    }

    REP(i, N) {
        ll a; cin >> a;
        q1.push(a);
        s1 += a;
    }

    ll ans = s0 - s1;

    vector<ll> v0(N+1);
    v0[0] = s0;
    REP(i, N) {
        q0.push(v_mid[i]);
        ll a = q0.top(); q0.pop();
        s0 -= (a - v_mid[i]);
        v0[i+1] = s0;
    }

    vector<ll> v1(N+1);
    v1[N] = s1;
    REP(i, N) {
        q1.push(v_mid[N-i-1]);
        ll a = q1.top(); q1.pop();
        s1 -= (a - v_mid[N-i-1]);
        v1[N-i-1] = s1;
    }

    REP(i, N+1) if (v0[i] - v1[i] > ans) ans = v0[i] - v1[i];

    cout << ans << endl;

}


Measured memory_bytes: 4340
import itertools
s = int(input())
N = len(str(s))
def A(n):
    return (3 ** n) - (3 * 2 ** n) + 3
ans = 0
if s < 357:
    print(0)
elif N > 3:
    for i in range(N-1,2,-1):
        ans += A(i)
    seq = ("3","5","7")
    S = list(itertools.product(seq,repeat=N))
    for j in S:
        j = list(j)
        if "3" in j and "5" in j and "7" in j:
            j = "".join(j)
            if int(j) <= s:
                ans += 1
    print(ans)
elif N == 3:
    seq = ("3","5","7")
    S = list(itertools.product(seq,repeat=N))
    for j in S:
        j = list(j)
        if "3" in j and "5" in j and "7" in j:
            j = "".join(j)
            if int(j) <= s:
                ans += 1
    print(ans)

Measured memory_bytes: 5492
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
	string b;
	cin >> b;
	if (b == "T") {
		cout << "A";
	}
	else if (b == "A") {
		cout << "T";
	}
	else if (b == "C") {
		cout << "G";
	}
	else {
		cout << "C";
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  ll n, ans = 0LL;
  scanf("%lld", &n);
  for (ll i = 1LL; i <= n; i++) {
    if (i % 3LL && i % 5LL) {
      ans += i;
    }
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main()
{
	int r;
	cin >> r;
	cout << 2*r*3.141592 << endl;
	return 0;
}

Measured memory_bytes: 3256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

a, b, c = mapint()

if c-(a+b)>=0:
    if 4*a*b<(c-a-b)**2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 61800