akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int x[10005],y[10005];
  for(int i=0;i<3000;i++){
    cin>>x[i]>>y[i];
    if(x[i]==0 && y[i]==0) break;
    if(x[i]>=y[i]){
      cout<<y[i]<<" "<<x[i]<<"\n";
    }
    else{
      cout<<x[i]<<" "<<y[i]<<"\n";
    }
  }

  


  return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define push_back pb

int main(){
    double x;
    cin >> x;
    double y = (-1 + sqrt(1 + 8 * x)) / 2.0;
    cout << ceil(y);
}

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

const int N = 2e5 + 5;
typedef long long ll;

ll a[N], ans, sum[N], f[N];
int n;


int main() {
	cin>>n; 
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		if(i > 1) sum[i] = sum[i - 2] + a[i];
		else sum[i] = a[i];
	}
	for(int i = 2; i <= n; i++) {
		if(i&1) f[i] = max(f[i - 2] + a[i], f[i - 1]);
		else f[i] = max(f[i - 2] + a[i], sum[i - 1]); 
 	}
 	cout<<f[n]<<endl;
}


Measured memory_bytes: 8336
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	Integer[] a = new Integer[n];
      	for(int i = 0; i < n; i++)
          a[i] = sc.nextInt();
        Arrays.sort(a, ( new Comparator<Integer>(){
                @Override
                public int compare(Integer o1, Integer o2) {
                    return o1.compareTo(o2)*-1;
                }
        }));
      	int ali, bob;
      	ali = bob = 0;
      	for(int i = 0; i < n; i++)
        	if(i % 2 == 0)
            	ali += a[i];
      		else
              	bob += a[i];
        System.out.println(ali-bob);
    }
}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
void err () {
  cout << -1 << endl;
  exit(0);
}
constexpr int inf = 1e9;
inline bool chmin (int& a, int b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
inline bool chmax (int& a, int b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
map<pair<int, int>, int> mp;
int f (int a, int b) {
  auto p = make_pair(a, b);
  if (mp.count(p))return mp[p];
  int ret = inf;
  for (int d = b + 1; d <= a - 1; d++) {
    chmin(ret, max(f(a % d, b), d));
  }
  if (b == 0) ret = 1;
  if (a == b) ret = 0;
  mp[p] = ret;
  return ret;
}
int main() {
  int n;
  cin >> n;
  vector<set<int>> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    a[i].insert(t);
  } 
  for (int i = 0; i < n; i++) cin >> b[i];
  long long ret = 0;
  int crr;
  while (true) {
    crr = 0;
    for (int i = 0; i < n; i++) {
      int tmp = inf;
      for (auto it = a[i].begin(); it != a[i].end(); it++) {
        chmin(tmp, f(*it, b[i]));
      }
      chmax(crr, tmp);
    }
    if (!crr) break;
    for (int i = 0; i < n; i++) {
      vector<int> tmp;
      for (auto it = a[i].begin(); it != a[i].end(); it++) {
        tmp.push_back(*it % crr);
      }
      a[i].insert(tmp.begin(), tmp.end());
    }
    if (crr == inf) err();
    ret += (1LL << crr);
  }
  cout << ret << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int w, d, c;
    
    while(true)
    {
        cin >> w >> d;
        
        if(w == 0 && d == 0) { break; }
        
        vector<int> r(21), s(21);
        
        for(int i = 0; i < w; i++) { cin >> c; r[c]++; }
        for(int j = 0; j < d; j++) { cin >> c; s[c]++; }
        
        int ret = 0;
        
        for(int i = 0; i < 21; i++) { ret += max(r[i], s[i]) * i; }
        
        cout << ret << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

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

    int w = 0;
    int b = 0;
    for (int i = 0; i < n; i++) if (s[i] == '.') w += 1;
    int ans = w + b;
    for (int i = 0; i < n; i++) {
        if (s[i] == '.') {
            w -= 1;
        } else {
            b += 1;
        }
        ans = min(w + b, ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[205];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    
    int ans = 0;
    while(1){
        int flag = 0;
        for(int i = 1; i <= n; i++){
            if(a[i] % 2 != 0) flag = 1;
            else a[i] /= 2;
        }

        if(flag == 1) break;
        ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <cstdio>
using namespace std;

int k,s,ans;

int main()
{
	scanf("%d%d",&k,&s);
	for(int i=0;i<=k;i++)
		for(int j=0;j<=k;j++) {
			if(s-i-j>k||s-i-j<0) continue;
			++ans;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#pragma region header
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define mp make_pair
#define mt make_tuple
#define rep1(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define rrep1(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define rep2(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep2(i, a, b) for (auto i = b - 1; i >= a; i--)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1) (__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep2, rrep1) (__VA_ARGS__)
#define each(i, a) for (auto &&i : (a))
#define split_pair(f, s, p) auto f = p.first; auto s = p.second
using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vvvs = vector<vvs>;
using vd = vector<ld>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using pii = pair<int, int>;
using vp = vector<pii>;
using vvp = vector<vp>;
using vvvp = vector<vvp>;
using mii = map<int, int>;
using vm = vector<mii>;
using vvm = vector<vm>;
using vvvm = vector<vvm>;

template <class T>
void COUT(T x) { cout << x << endl; }

#pragma endregion header

// MOD = 1e9 + 7;
const string YES = "Yes";
const string NO = "No";


void solve(int n, int m, vi l, vi r, vi d) {
  vvp adj(n);
  rep(i, m) {
    adj[l[i]].push_back(mp(r[i], d[i]));
    adj[r[i]].push_back(mp(l[i], -d[i]));
  }
  bool ans = true;
  vi dist(n);
  vb seen(n);
  function<void(int)> dfs = [&](int i) {
    each(e, adj[i]) {
      int next = e.first;
      int value = dist[i] + e.second;
      if (seen[next]) {
        if (dist[next] != value) ans = false;
      } else {
        dist[next] = value;
        seen[next] = true;
        dfs(next);
      }
    }
  };
  rep(i, n) if(!seen[i]) {
    seen[i] = true;
    dfs(i);
  }
  COUT(ans ? YES : NO);
}


#pragma region main
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;
  int m;
  cin >> m;
  vi l(m);
  vi r(m);
  vi d(m);
  for(int i = 0 ; i < m ; i++){
    cin >> l[i];
    cin >> r[i];
    cin >> d[i];
    l[i]--;
    r[i]--;
  }
  solve(n, m, move(l), move(r), move(d));
}
#pragma endregion main


Measured memory_bytes: 15360
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};

typedef struct node *Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

   while(x != NIL){
     y = x;
     if(z->key < x->key){
       x = x->l;
     }
     else{
       x = x->r;
     }
   }

   z->p = y;
   if(y == NIL){
     root = z;
   }
   else{
      if(z->key < y->key){
        y->l = z;
      }
      else{
        y->r = z;
      }
     }
   }

void inorder(Node u){
  if(u == NIL){ return;}
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}

void preorder(Node u){
  if(u == NIL){ return;}
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for(i=0 ; i<n ; i++){
    scanf("%s", com);
    if(com[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    }
    else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25128
import itertools
D,G = list(map(int,input().split()))
PC = []
for i in range(D):
    PC.append(list(map(int,input().split())))

a = [0,1]
Ls = list(itertools.product(a, repeat=D))

out = 1000
for L in Ls:
    num = 0
    point = 0
    for i in range(D):
        if L[i]==1:
            num+=PC[i][0]
            point+=PC[i][1]
            point+=(i+1)*100*PC[i][0]
    hampa = D-1
    while (L[hampa]==1)and(hampa>=0):
        hampa+=-1
    if hampa==-1:
        cnt = 0
    else:
        cnt = 0
        while (point<G)and(cnt<PC[hampa][0]):
            cnt+=1
            num+=1
            point+=(hampa+1)*100
    if (point>=G)and(num<out):
        out=num
print(out)


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

int main(void) {
  string s;
  cin >> s;
  for(int i=s.size()-1;i>=0;i--){
    if(i%2==0){
      // cout << s.substr(0,i/2) << " " <<  s.substr(i/2,i/2) << endl;
      if(s.substr(0,i/2) == s.substr(i/2,i/2)){
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
#mod = 10**9 + 7

mod=2019
l,r=MI()
mn=inf
mods=[]
#print(l,r)

#print(mods)
if (r-l)>=2018:
    ans=0
    #print(1)
else:
    for i in range(l,r+1):
        mods.append(i%mod)
    for i in range(r-l+1):
        for j in range(i+1,r-l+1):
            u=(mods[i])*(mods[j])%mod
            if u<mn:
                mn=u
    ans=mn
print(ans)



Measured memory_bytes: 40684
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	cin >> n;
	cout << (n + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * 各展望台すべて true にしておいて
 * 道でつながっている展望台で低い方を false にしていく
 */

#include <bits/stdc++.h>

int main() {
    /* Input */
    long long N, M;
    std::cin >> N >> M;
    std::vector<long long> H(N);

    for (int i = 0; i < N; i++) {
        std::cin >> H[i];
    }

    /* Solve */
    std::vector<bool> good(N, true);

    for (int i = 0; i < M; i++) {
        // 道を受け取る (0-based インデクシングに変換)
        long long a, b;
        std::cin >> a >> b;
        a--;
        b--;
        
        // 低い方の展望台を false に変更
        if (H[a] > H[b]) good[b] = false;
        else if (H[a] < H[b]) good[a] = false;
        else if (H[a] == H[b]) good[a] = good[b] = false;
    }

    int cnt = 0;
    for (int i = 0; i < good.size(); i++) {
        if (good[i]) cnt++;
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 4044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		// return cnt < N;
		return cnt < 1;
	}

	int A;

	public void readBody(String str) {
		// System.out.println(str);
		A = Integer.parseInt(str);
		cnt++;
	}

	public void solve() {
		// System.out.println(N + " " + A);
		if ((N % 500) <= A)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, m, mod = 1e9 + 7;
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    a.resize(m);
    for(auto &i : a) cin >> i;
    vector <int> dp(n + 1);
    dp[0] = 1;
    for(int i = 1 ; i <= n ; i++){
        if(binary_search(a.begin(), a.end(), i)) continue;
        dp[i] = dp[i - 1];
        if(i >= 2) dp[i] += dp[i - 2];
        if(dp[i] >= mod) dp[i] -= mod;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
ll gcd(ll a,ll b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
ll lcm(ll a,ll b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}






int main(){
  int n;
  cin >> n;
  ll t[n+1];
  rep (i,n) {
    cin >> t[i];
  }
ll ans=t[0];
  for (int i = 1;i < n;i++){
    ans = lcm(ans,t[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            #if i != n // i:
                #divisors.append(n//i)

    # divisors.sort()
    return divisors

div = make_divisors(N)
ans = 10**13;

for i in range(len(div)):
    a = div[i]
    b = N//a
    ans = min(ans,a+b-2)
print(ans)

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

// WH/2が作れればいい
// 重心以外は一本のみ、任意に傾けると小さい方の面積が小さくなる

int main(){
    double W,H,x,y;
    cin >> W >> H >> x >> y;
    if(W/2.0==x && H/2.0==y){
        cout << (W*H)/2.0 << endl;
        cout << "1" << endl;
    }else {
        cout << (W*H)/2.0 << endl;
        cout << "0" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "\t" << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl << "\t", dump_func(__VA_ARGS__);
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
const int MOD = 1e9 + 7;

signed main() {
  int n; cin >> n;
  VI a(n);
  REP (i, n) cin >> a[i];
  sort(RALL(a));
  int ans = 0;
  REP (i, n) {
    ans += a[i] / (i == 0 ? 2 : 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;


int main(){
    int m; cin >> m;
    ll sum=0, dig=0;
    REP(i, m){
        ll d, c; cin >> d >> c;
        sum += d*c; dig += c;
    }
    ll add=0, p=sum;
    while(p >= 10){
        p = p/10 + p % 10;
        if(p >= 10) add += p/10;
    }
    cout << dig - 1 + (sum/10) + add << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

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

int main(void)
{	
	long a1, m1, a2, m2, a3, m3;
	int x, y, z;
	int A, B, C;
	
	while (1){
		scanf("%ld %ld %ld %ld %ld %ld", &a1, &m1, &a2, &m2, &a3, &m3);
		
		if (!a1 && !m1 && !a2 && !m2 && !a3 && !m3){
			break;
		}
		
		x = a1 % m1;
		y = a2 % m2;
		z = a3 % m3;
		
		A = 1;
		while (x != 1){
			x = x * a1 % m1;
			A++;
		}
		B = 1;
		while (y != 1){
			y = y * a2 % m2;
			B++;
		}
		
		C = 1;
		while (z != 1){
			z = z * a3 % m3;
			C++;
		}
		
		printf("%ld\n", lcm(lcm(A, B), C));
	}
	
	return (0);
}

Measured memory_bytes: 600
n = int(input())

def divisors(n):
    nums = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            nums.append(i)
            if i != n // i:
                nums.append(n//i)
    return sorted(nums)

divs = divisors(n)

ans = n-1
for div in divs:
    div2 = n//div
    ans = min(ans, div + div2 - 2)

print(ans)


Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int c0=0,c1=0,c2=0,c3=0;
  
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    
    if(s=="AC"){
      c0++;
    }
    else if(s=="WA"){
      c1++;
    }
    else if(s=="TLE"){
      c2++;
    }
    else{
      c3++;
    }
  }
  
  
  cout << "AC x " << c0 << endl;
  cout << "WA x " << c1 << endl;
  cout << "TLE x " << c2 << endl;
  cout << "RE x " << c3 << endl;

}




Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
#include <sstream>
#include <bitset>
#define PI 3.141592653589793
 
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
    ll a, c;
    double b;
    cin >> a >> b;
    c = b*100+0.01;
    cout << (a*c)/100 << endl;
}

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

int main(void) {
    string s,t;
    cin>>s>>t;
    int cur=0;
    int t_size=t.size(),s_size=s.size();
    bool ok=false;
    int from=0;
    while(cur+t_size<=s_size){
        DEBUG{cout << cur<< endl;}
        bool flg=true;
        for(int i=0;i+cur<s_size&&i<t_size;i++){
            if(!(s[cur+i]=='?'||s[cur+i]==t[i])){
                flg=false;
                break;
            }
        }
        if(flg){
            ok=true;
            from=cur;
        }
        cur++;
    }
    if(!ok){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    s.replace(from,t_size,t);
    replace(s.begin(),s.end(),'?','a');
    cout << s << endl;
    return 0;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 1e5+1;
int n, m, cnt[N];

long POW(long x, long n){
  if (n == 0) return 1;
  long y = POW(x, n / 2);
  y = y * y % MOD;
  if (n % 2) return x * y % MOD;
  else return y;
}

int main()
{
  fastio;
  cin >> n >> m;
  for (int i = 1; i <= m; i++){
    int x = i, cur = 1, d = 0; cnt[i] = -1;
    for (int j = 2; j * j <= x; j++){
      if (x % j == 0){
        d++; cur *= j;
        while (x % j == 0) x /= j;
      }
    }
    if (x > 1) cur *= x, d++;
    if (cur == i) cnt[i] = d;
  }
  long res = 0;
  for (int i = 1; i <= m; i++){
    int k = m / i; int tot = 0;
    for (int j = 1; j <= k; j++){
      if (cnt[j] != -1){
        if (cnt[j] % 2){
          tot -= POW(k / j, n);
          tot %= MOD;  
        }
        else {
          tot += POW(k / j, n);
          tot %= MOD;
        }
      }    
    }
    tot = (tot + MOD) % MOD;
    res += 1ll * i * tot;
    res %= MOD;  
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 3972
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
string s;
int x,y;
int main(){
    cin>>s;
    int len=s.size();
    for(int i=0;i<len;i++)if(s[i]=='A'){x=i;break;}
    for(int i=len-1;i>=0;i--)if(s[i]=='Z'){y=i;break;}
    cout<<y-x+1<<endl;
	return 0;
}

Measured memory_bytes: 640
#lとrの範囲内に2019の倍数があれば、最小値は0になる
#そうでなければ、余りは0<=lの余り<=rの余りなので、小さい方から取れば良い
#lとrの商が同じ、を直接表すと、四捨五入の関係で一緒じゃなくても等しいとされることがある
#とかいう以前に、というか10桁ぐらいなら全然大丈夫で、今回問題だったのは、
#l(l+1)が最小とは限らないということ
#だから、しらみつぶししかない

l,r = map(int, input().split())
if r-l >= 2018: #ただ単に、ミスでここのが逆だっただけ？→違う
  print(0)
elif r-l==r%2019-l%2019:
  minlist = []
  for i in range(l,r+1):
    for j in range(l,r+1):
      if i!=j:
        minlist.append((i*j)%2019)
  print(min(minlist))
else:
  print(0)



Measured memory_bytes: 147680
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		while(h != 0){
			int[][] s = new int[h + 1][5];
			for(int i = 1; i <= h; i++){
				for(int j = 0; j < 5; j++){
					s[i][j] = sc.nextInt();
				}
			}
			int res = 0;
			boolean flg = true;
			while(flg){
				flg = false;
				for(int i = 1; i <= h; i++){
					for(int j = 0; j < 3; j++){
						int cnt = 1;
						for(int k = j + 1; k < 5; k++){
							if(s[i][j] > 0 && s[i][j] == s[i][k]){
								cnt = cnt + 1;
							}else{
								break;
							}
						}
						if(cnt > 2){
							flg = true;
							res += s[i][j] * cnt;
							for(int k = j; k < j + cnt; k++){
								for(int l = i; l > 0; l--){
									s[l][k] = s[l - 1][k];
								}
							}
							break;
						}
					}
				}
				
			}
			System.out.println(res);
			h = sc.nextInt();
		}
		
		sc.close();
	}
}

Measured memory_bytes: 54728
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

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

int main() {
	int N, K;
	cin >> N >> K;
	ll sum = 0;
	if (K != 0) {
		FOR(i, 1, N + 1) {
			sum += 1LL*(N / i)*max(0, i - K);
			sum += max(0, (N % i) - K + 1);
		}
	}
	else sum += 1LL * N*N;
	cout << sum << endl;
	//cin >> N >> K;


	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x+r<=W){
        if(y+r<=H){
            if(x-r>=0){
                if(y-r>=0){
                    cout<<"Yes"<<endl;
                }else{
                    cout<<"No"<<endl;
                }
            }else{
                cout<<"No"<<endl;
            }
        }else{
            cout<<"No"<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#define rr int
using namespace std;
typedef long long ll;
ll read() {
    char i = getchar();
    ll f = 1, res = 0;
    while (i < '0' || i > '9') {
        if (i == '-') f = -1;
        i = getchar();
    }
    while (i >= '0' && i <= '9') {
        res = res * 10 + i - '0';
        i = getchar();
    }
    return f * res;
}
int n;
ll K;
const int N = 3e5 + 50;
ll a[N];
ll sum[N], c[N];
ll ans = 0;
inline void merge(int l, int r) {
    if (l < r) {
        int mid = (l + r) >> 1;
        merge(l, mid);
        merge(mid + 1, r);
        int i = l, j = mid + 1, now = l;
        while (i <= mid && j <= r) {
            if (a[i] <= a[j]) {
                c[now++] = a[i++];
                ans += r - j + 1;
            } else
                c[now++] = a[j++];
        }
        while (i <= mid) c[now++] = a[i++];
        while (j <= r) c[now++] = a[j++];
        for (rr i = l; i <= r; ++i) a[i] = c[i];
    }
}
int main() {
    n = read() + 1, K = read();
    for (rr i = 2; i <= n; ++i) {
        a[i] = read();
        sum[i] = sum[i - 1] + a[i];
        a[i] = sum[i] - K * ll(i - 1);
    }
    // for (rr i = 1; i <= n; ++i) cout << a[i] << ' ';
    merge(1, n);
    // for (rr i = 1; i <= n; ++i) cout << a[i] << endl;
    cout << ans;
}


Measured memory_bytes: 6016
#include <cstdio>
#include <algorithm>

using namespace std;

const int MOD = 1000000007;

long long dp[2][3000];
char s[3001];

int main()
{
    int N;
    scanf("%d", &N);
    scanf("%s", s);

    for (int i = 0; i < N; i++) dp[0][i] = 1;
    int t = 0;
    for (int i = 1; i < N; i++) {
        long long tot = 0;
        if (s[i - 1] == '>') {
            for (int j = 0; j <= N - 1; j++) {
                tot = (tot + dp[t][j]) % MOD;
                if (j <= N - i - 1) dp[1 - t][j] = tot;
                else dp[1 - t][j] = 0;
            }
        }
        else {
            for (int j = N - 1; j >= 0; j--) {
                if (j <= N - i - 1) dp[1 - t][j] = tot;
                else dp[1 - t][j] = 0;
                tot = (tot + dp[t][j]) % MOD;
            }
        }
        t = 1 - t;
    }
    printf("%lld\n", dp[t][0]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>



#define DEBUG(x) do {std::cerr << #x << ": " << x << std::endl; } while (0)


int main(int argc, const char ** argv){

	unsigned long long int a, b, k;
	std::cin >> a >> b >> k;

	if (a + b == k) std::cout << 0 << " " << 0 << std::endl;
	else {

		if (k > a){
			k -= a;

			if (k > b) std::cout << 0 << " " << 0 << std::endl;
			else 
				std::cout << 0 << " " << b - k << std::endl;

		} else {
			std::cout << a - k << " " << b << std::endl;


		}


	} 




    return 0;
}


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

int main() {
  int N, M;
  scanf("%d%d", &N, &M);

  vector<int> buckets(N, 0);

  for (int i = 0; i < M; i++) {
    int a = 0;
    int b = 0;
    scanf("%d%d", &a, &b);
    buckets.at(a - 1)++;
    buckets.at(b - 1)++;
  }

  for (auto bucket : buckets) printf("%d\n", bucket);

  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    M=20000
    A=[M*i for i in range(1,n+1)]
    B=[M*(n-i+1) for i in range(1,n+1)]
    perm=list(map(lambda x:int(x)-1,input().split()))
    for i in range(n):
        A[perm[i]]+=i

    print(*A)
    print(*B)
resolve()

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

int main(){
  int n,k;
  cin >> n >> k;
  int ans = 0;
  for (int i=0; i<n; ++i){
    int x;
    cin >> x;
    ans += min(x,k-x);
  }
  cout << ans*2 << endl;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n, k;
    cin >> n >> k;
    vector<ll> c(n);
    vector<ll> p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }
    rep(i, n) cin >> c[i];

    ll tans = -INF;

    rep(i, n){
        ll now = p[i];
        ll total = c[now];
        ll ma = total;
        ll cnt = 1;
        while(now != i && cnt < k){
            now = p[now];
            total += c[now];
            ma = max(ma, total);
            cnt++;
        }

        if(cnt < k){
            if(total < 0){
                //cout << ma << endl;
                tans = max(tans, ma);
            } else {
                ll rem = k % cnt;
                ll ans = (k / cnt) * total;
                ll ans2 = ((k / cnt) - 1) * total + ma;

                now = p[i];
                total = c[now];
                if(rem != 0){
                    ma = max(0LL, total);
                } else {
                    ma = 0;
                }
                cnt = 1;
                while(cnt < rem){
                    now = p[now];
                    total += c[now];
                    ma = max(ma, total);
                    cnt++;
                }
                //cout << ans + ma << endl;
                tans = max({tans, ans + ma, ans2});
            }
        } else {
            //cout << ma << endl;
            tans = max(tans, ma);
        }
    }
    cout << tans << endl;
}

Measured memory_bytes: 3720
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

string conv(int a, int b)
{
    stringstream ss;

    ss << a;
    ss << ":";
    if (b < 10) ss << 0;
    ss << b;
    return ss.str();
}

struct data {
    int v;
    string s;
    data(){}
    data(int v, string s):v(v),s(s){}
    bool operator<(data d) const  {
        return v < d.v;
    }
};

map<string, bool> A;

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

    vector<data> vs;

    rep(i, N) {
        int a, b; cin >> a >> b;
        string res = conv(a, b);
        A[res] = true;
        vs.push_back(data(a * 100 + b, res));
    }

    int M; cin >> M;
    rep(i, M) {
        int a, b; cin >> a >> b;
        string res = conv(a, b);
        if (A.find(res) != A.end()) continue;
        vs.push_back(data(a * 100 + b, res));
    }

    sort(all(vs));

    rep(i, vs.size()) {
        if (i) cout << ' ';
        cout << vs[i].s;
    }
    cout << endl;
}

Measured memory_bytes: 1256
#include <iostream>
using namespace std;
string a;
string b="CODEFESTIVAL2016";
int n,ans;
int main()
{
	cin>>a;
	for(int i=0;i<=15;i++)
	if(a[i]!=b[i])
	ans++;
	cout<<ans<<endl;
    return 0;
}


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

int main(){
	string str;
	double k;
	cin >> str;
	cin >> k;

	int i =0;
	for(; i <= str.length(); i++){
		if(str[i] != '1')
			break;
	}
	if(k-1 < i){
		cout << '1';
	}else{
		cout << str[i];
	}

	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    vector<int> p(n);
    REP(i,n){
        cin>>p[i];
    }

    int sum = 0;
    FOR(i,1,n-1){
        if(p[i] > p[i+1] && p[i] < p[i-1]) sum++;
        if(p[i] < p[i+1] && p[i] > p[i-1]) sum++;
        
    }
    cout<<sum<<endl;
    // cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import copy

def perm(i, ls):
    if not ls:
        global count
        count += 1
    else:
        for j in ls:
            if cost[i-1][j-1]:
                ls2 = copy.copy(ls)
                ls2.remove(j)
                perm(j, ls2)

n,m = map(int, input().split())

cost = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
    a, b= map(int, input().split())
    cost[a-1][b-1] = cost[b-1][a-1] = 1

count = 0
perm(1, list(range(2, n+1)))

print(count)

Measured memory_bytes: 3444
n = int(input())
a = list(map(int, input().split()))

b = [-1] * n

for i in range(n, 0, -1):
    total = 0
    for j in range(i*2, n+1, i):
        total += b[j - 1]
    if total % 2 == a[i - 1]:
        b[i-1] = 0
    else:
        b[i-1] = 1

c = []
for i in range(n):
    if b[i] == 1:
        c.append(i+1)

print(len(c))
if len(c) > 0:
    print(*c)

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

int main() {
    using namespace std;
    constexpr unsigned long MOD = 998244353;
    unsigned long N;
    cin >> N;
    vector<pair<long, long>> robots;
    for(long i{0}, x, d; i++ < N; robots.emplace_back(x, x + d))cin >> x >> d;
    sort(robots.begin(), robots.end(), greater<>());
    stack<pair<long, unsigned long>> st;
    for(const auto& i : robots){
        unsigned long r{1};
        while(!st.empty() && st.top().first < i.second && ((r *= st.top().second) %= MOD))st.pop();
        st.emplace(i.first, r + 1);
    }
    unsigned long ans{1};
    while(!st.empty() && ((ans *= st.top().second) %= MOD))st.pop();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6512
num, taste = map(int, input().split())

list = []

for i in range(taste, taste + num):
    list.append(i)

if list[0] > 0:
    list.pop(0)
    print(sum(list))
elif list[num-1] < 0:
    list.pop(num-1)
    print(sum(list))
else:
    print(sum(list))

Measured memory_bytes: 3060
#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();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin>>N;
    N%=10;
    if(N==3)
    {
        cout<<"bon";
    }
    else if(N==0 or N==1 or N==6 or N==8)
    {
        cout<<"pon";
    }
    else
    {
        cout<<"hon";
    }
    
    return 0;
}

Measured memory_bytes: 3652
def j_p(a):
    if a<=1:
        return False
    else:

        for i in range(2,a):
            if i**2>a:
                break
            else:
                if a%i==0:
                    return False
                else:
                    continue
        return True
x=int(input())
p=x
while j_p(p)==False:
    p+=1
print(p)


Measured memory_bytes: 2940
#include<stdio.h>
int main(void){
int N, M;
int ac[100001]={0}, wa[100001]={0},good=0, bad=0;
scanf("%d%d", &N, &M);
int P[M];
char S[M][3];
for(int i=0;i<M;i++){
    scanf("%d%s", &P[i], S[i]);
if(S[i][0]=='A' && ac[P[i]]==0){
     ac[P[i]]=1;
  }else if(S[i][0]=='W' &&ac[P[i]]==0){
      wa[P[i]]+=1;
  }
}
for(int i=0;i<=N;i++){
    if(ac[i]){
    good+=ac[i];
    bad+=wa[i];
    }
}
printf("%d %d\n", good, bad);
return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n=0, x=0;
	int a[100];
	int cnt = 0, sum = 0;

	cin >> n >> x;

	a[0] = 0;

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

		if (sum <= x) {
			cnt++;
		}
	}
	
	cout << cnt << endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.typecons;
import std.math;

void main(){
    alias Tuple!(int, int) edge;
    alias Tuple!(int, int, int, int) state; // dist, node, last temp, x

    int n, m, x;
    scanf("%d%d%d", &n, &m, &x);
    auto temp = new int[n];
    foreach(i; 0..n) scanf("%d", &temp[i]);
    auto graph = new edge[][](n);
    foreach(i; 0..m){
        int a, b, d;
        scanf("%d%d%d", &a, &b, &d);
        --a; --b;
        graph[a] ~= edge(b, d);
        graph[b] ~= edge(a, d);
    }

    auto dist = new int[][][](n, 3, 210); // node, last temp, x
    foreach(a; dist) foreach(b; a) b[] = int.max / 2;
    state[] a = [state(0,0,0,x)];
    auto q = new BinaryHeap!(Array!state, "a > b")();
    q.insert(state(0, 0, 0, x));
    int ans = -1;
    while(q.length != 0){
        int cd = q.front[0];
        int cn = q.front[1];
        int ct = q.front[2];
        int cx = q.front[3];
        q.removeFront;
        // writeln([cd, cn, ct, cx]);
        if(cn == n-1){
            ans = cd;
            break;
        }
        if(dist[cn][ct][cx] < cd) continue;

        foreach(const ref e; graph[cn]){
            int nd = cd + e[1];
            int nn = e[0];
            int nt = temp[nn] != 1 ? temp[nn] : ct;
            int nx = temp[nn] != 1 ? x : max(0, cx - e[1]);
            if(abs(nt - ct) == 2 && cx > e[1]) continue;
            if(dist[nn][nt][nx] > nd){
                dist[nn][nt][nx] = nd;
                q.insert(state(nd, nn, nt, nx));
            }
        }
    }
    writeln(ans);
}

Measured memory_bytes: 35348
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1000000007;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=100005;

int x, a, b;

int main()
{
    while(~scanf("%d%d%d", &x, &a, &b)){
        if(b-a<=0)printf("delicious\n");
        else if(b-a<=x)printf("safe\n");
        else printf("dangerous\n");
    }
    return 0;
}



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

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t;	cin>>t;
	while(t--){
		ll a,b,c,d;	cin>>a>>b>>c>>d;
		if(a<b || d<b){
			printf("No\n");	continue;
		}
		if(c>=b-1){
			printf("Yes\n");	continue;
		}
		ll temp=b-(a%b),hcf=gcd(b,d);
		if(temp%hcf==0){
			temp=(temp/hcf)-1;
		}
		else{
			temp/=hcf;
		}
		if(a%b + (temp*hcf) > c)	printf("No\n");
		else	printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 256