akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;

 ll mod=1e9 +7;
const ll M=500006;
ll f[M],inv[M];
ll expo(ll base,ll exponent){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

vector<bool>  prime(1000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=1000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=1000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
    // freopen("alchemy_input.txt", "r", stdin);
 //    // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
 //    #endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // compute();
    ll tests=1,t=1;
   // cin>>tests;
    while(tests--)
    {
    	ll x;
    	cin>>x;
    	if(x>=30) cout<<"Yes";
    	else cout<<"No";
    }

	return 0;
}

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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
#define int long long

signed main(){
    int n, k;
    cin >> n >> k;
    int x = 1;
    rep(i,n){
        x += min(x, k);
    }
    cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    long long int a , b ,c ;
    cin >> a >> b >> c;
    if(!(a%2) || !(b%2) || !(c%2))
        cout << 0;
    else {
        cout << min(a*b , min(b*c,a*c)) ;
    }
    return 0;
}

Measured memory_bytes: 256
# atcoderのテスト用
# ./iunput/input.txt に入力を書き込む
n, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
w = [wv[i][0] for i in range(n)]
v = [wv[i][1] for i in range(n)]
inf = float('inf')
V = max(v)
vmax = 10**5+1
# dp[i][sum_v] 
# := i-1番目までの品物で価値がsum_vを超えないように選んだときの重さの総和の最小値
# 価値の合計はどれくらい大きくなるかわからないので十分に用意しとく
dp = [[inf for _ in range(vmax)] for _ in range(n+1)]
# 初期条件
dp[0][0] = 0
for i in range(n):
    for sum_v in range(vmax):
        # i番目の品物を選べるとき
        if sum_v - v[i] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i])
        # i番目の品物を選ばないとき
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])


# 最適解を探す
ans = 0
for sum_v in range(vmax):
    if dp[n][sum_v] <= W:
        ans = sum_v
print(ans)

Measured memory_bytes: 332212
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int N, s, t;
  cin >> N;
  t = N;
  
  s = N / 100;
  
  t %= 100;
  t %= 10;
  
  if(s == t) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
  
}

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

int main() {
  int K, A=0;
  long long X;
  cin >> K;
  vector<long long> Q;
  rep(i, 9) Q.push_back(i+1);
  while(Q.size()<=K){
    X=Q.at(A);
    if(X%10!=0) Q.push_back(10*X+X%10-1);
    Q.push_back(10*X+X%10);
    if(X%10!=9) Q.push_back(10*X+X%10+1);
    A++;
  }
  cout << Q.at(K-1) << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    int maxValue = 0;
    int seconMax = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i]>maxValue){
            //seconMax=maxValue;
            maxValue=a[i];
        }
    }
    int num = 0;
    for(int i = 0; i < n; i++){
        if(a[i]==maxValue){
            num++;
        }else{
            seconMax=max(seconMax,a[i]);
        }
    }
    if(num>1){
        for(int i = 0; i < n; i++){
            cout << maxValue << endl;
        }
    }else{
        for(int i = 0; i < n; i++){
            if(a[i]==maxValue){
                cout << seconMax << endl;
            }else{
                cout << maxValue << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4020
N = int(input())
D = [input().split() for i in range(N)]

DD = []

for i in range(N):
    DD.append([int(D[i][0]),int(D[i][1]),int(D[i][2])])

diff = [[0,0,0],[DD[0][0]-0,DD[0][1]-0,DD[0][2]-0]]

for i in range(N-1):
    diff.append([DD[i+1][0]-DD[i][0],DD[i+1][1]-DD[i][1],DD[i+1][2]-DD[i][2]])

def judge(t, x, y):
    if t < (abs(x) + abs(y)):
        return 1
    else:
        if (t % 2) == ((abs(x) + abs(y)) % 2):
            return 0
        else:
            return 1

count = 0
for i in range(N+1):
    count += judge(diff[i][0], diff[i][1], diff[i][2])

if count >= 1:
    print("No")
else:
    print("Yes")

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

int main() {
	// your code goes here
	ll n;
	cin>>n;
	if(n%7==0 || n%4==0){
		cout<<"Yes"<<endl;
		return 0;
	}
	for(ll i=1;n-i*4>0;i++){
		if((n-(i*4))%7==0){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
H = [int(x) for x in input().split()]

score = [0]*N
for n in range(N-2,-1,-1):
    if H[n] >= H[n+1]:
        score[n] = score[n+1] + 1

print(max(score))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b,c,d;
  cin>>a>>b>>c;
  d=b.at(0);
  
  cout<<"A"<<d<<"C"<<endl;
//    if(c=="a"||c=="i"||c=="u"||c=="e"||c=="o"){
//    cout<<"vowel"<<endl;
 //   }
//    else{
//    cout<<"consonant"<<endl;
//    }
}

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

cum = [0]
for x in range(1, N+1):
    cum.append(cum[-1]+x)

ans = 0
for k in range(K, N+2):
    ans += (cum[N] - cum[max(0,N-k)]) - cum[k-1] + 1
    ans %= MOD

print(ans)

Measured memory_bytes: 82736
from collections import Counter
def solve(N, XY):
    if N == 1:
        return 1
    XY = sorted(XY)
    cnt = Counter()
    d = []
    for x0, y0 in XY:
        for x1, y1 in XY:
            if x0 == x1 and y0 == y1:
                continue
            d.append((x0 - x1, y0 - y1))
    m = Counter(d).most_common()[0]
    return len(XY) - m[1]

def main():
    N = int(input())

    XY = []
    for i in range(N):
        XY.append(tuple([int(x) for x in input().split()]))

    print(solve(N, XY))

main()



Measured memory_bytes: 3948
import java.io.*;


public class Main {


	// メイン return falseでおしまい
	boolean main() throws IOException {

	    int[] a = readIntArray();
	    int X = a[0];
	    int A = a[1];
	    int B = a[2];
        int N = readIntArray()[0];
//		if (N == 0)
//			return false; /* おしまい */

		for(int i = 0; i < N; i++) {
		      String s = reader.readLine();
		      if (s.equals("nobiro")) {
		          X += A;
		      }
		      else if (s.equals("tidime")) {
                  X += B;
              }
              else if (s.equals("karero")) {
                  X = 0;
              }
		      if (X < 0)
		          X = 0;
		}
		System.out.printf("%d\n", X);

		//return true; /* 正常終了 次へ */
		return false;
	}


//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;

			String inputStr = "10 30 10\r\n" +
			        "3\r\n" +
			        "nobiro\r\n" +
			        "nobiro\r\n" +
			        "tidime\n";
//			String inputStr = "4\n0 0 10 0 10 10 0 10\n10\n12\n0 0\n9 1\n0\n"; // 96.63324958071081
//			String inputStr = "4\n0 0 10 0 10 10 0 10\n10\n12\n0 1\n9 1\n0\n"; // 103.2664991614216
//			String inputStr = "8\n2 0 4 0 6 2 6 4 4 6 2 6 0 4 0 2\n10\n12\n3 0\n3 5\n0\n"; // 60.0

			reader = new BufferedReader(new StringReader(inputStr));

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // 書き捨て
			reader = new BufferedReader(new InputStreamReader(System.in)); // コンソールから
		}

		for(int loop = 0;; loop++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}

		reader.close();
	}


	static PrintStream log;
	static BufferedReader reader;


	// 標準入力より　1行分のスペース区切りの整数値を読む
	private int[] readIntArray() throws IOException {

		String s = reader.readLine();
		String[] sp = s.split(" ");
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}

}





Measured memory_bytes: 24880
n, k, s = map(int, input().split())

ans = [s for _ in range(k)]
if s == 10**9:
    others = [1 for _ in range(n-k)]
    ans = ans + others
    print(' '.join(map(str, ans)))
else:
    others = [10**9 for _ in range(n-k)]
    ans = ans + others
    print(' '.join(map(str, ans)))



Measured memory_bytes: 18920
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;cin>>n;
  set<string> s;
  for(int i=0;i<n;i++){
  	string ss;cin>>ss;
    s.insert(ss);
  }
  cout<<s.size()<<endl;
}


Measured memory_bytes: 19208
#include <iostream>
#include <string>
using namespace	std;
int main(){

  string a[256],b;
  bool tf=0,c=0;
  int i,j,n,m;

  cin>>n;
  for(i=0;i<n;i++) cin>>a[i];
  cin>>m;
  for(i=0;i<m;i++){
    cin>>b;
    for(j=0;j<n;j++){
      if(a[j]==b){
        if(tf==0){
          cout<<"Opened by "<<b<<endl;
          tf=1;
	}
        else{
          cout<<"Closed by "<<b<<endl;
          tf=0;
	}
        c=1;
        break;
      }
    }
    if(c==0) cout<<"Unknown "<<b<<endl;
    c=0;

  }

  return 0;

}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll a,b,k;
    cin >> a >> b >> k;

    if(b-a+1 > 2*k){
        for(int i=a; i<a+k; i++){
            cout << i << endl;
        }
        for(int j=b-k+1; j<=b; j++){
            cout << j << endl;
        }
    }
    else{
        for(int i=a; i<=b; i++){
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
s = gets.chomp
n = s.length

if s[0] == 'A' and s[2,n-3].count("C") == 1
    s[s[2, n-3].index("C")+2] = "c"
    s[0] = "a"
    if s.downcase == s
        puts "AC"
    else
        puts "WA"
    end
else
    puts "WA"
end


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

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine()) - 1;

            var ans = "";
            while (true)
            {
                ans += (char)(97 + N % 26);
                N /= 26;

                if (N-- <= 0) break;
            }

            Console.WriteLine(ans.Reverse().ToArray());
        }
    }
}


Measured memory_bytes: 27976
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int ans = 0;
  if(s[0] == s[1] && s[0]=='R') ans++;
  if(s[1] == s[2] && s[1]== 'R') ans++;
  if(ans) ans++;
  else if(s[0] == 'R' || s[1] =='R' || s[2]== 'R') ans++;
  cout << ans << '\n';
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_set>

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

using namespace std;
using ll = long long;
using ld = long double;

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

    int N, i;
    cin >> N >> i;

    cout << N - i + 1 << endl;

    return 0;
}


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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if(s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3616
a,b=map(int,input().split())
s=input()
ls=list("1234567890")
for x in range(a):
  if s[x] not in ls:
    print("No")
    exit()
if s[a] != "-":
  print("No")
  exit()
for x in range(b):
  if s[a+x+1] not in ls:
    print("No")
    exit()
print("Yes")

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF  numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()

using namespace std;
using ll = long long;

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

    int N, M;
    std::cin >> N >> M;

    vector<pair<int, int>> ba;
    REP(i, M) {
        int a, b;
        std::cin >> a >> b;
        ba.push_back(make_pair(b, a));
    }

    sort(ba.begin(), ba.end());

    int ans = 0;
    int prev_remove_index = 0;
    for(const auto& v : ba) {
        if(prev_remove_index < v.second) {
            prev_remove_index = v.first - 1;
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


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

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

  int c1 = floor(N / 1.08);
  int c2 = c1 + 1;

  if (floor(c1 * 1.08) == N) {
    cout << c1 << endl;
    return 0;
  }
  if (floor(c2 * 1.08) == N) {
    cout << c2 << endl;
    return 0;
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 3588
import java.util.*;
import java.io.*;
 
public class Main {
  public static void main(String[] args) throws Exception{
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int[] num = new int[n];
    for(int i = 0; i < n; ++i) {
      num[i] = sc.nextInt();
    }
    new Solution(n, num);
  }
}

class Solution {
  public Solution(int n, int[] num) {
    long[][] dp = new long[n + 1][3];
    dp[1][1] = num[0];
    dp[2][1] = Math.max(num[0], num[1]);
    if(n == 2) {
      System.out.println(dp[2][1]);
      return;
    }
    dp[3][1] = Math.max(num[2], dp[2][1]);
    dp[3][2] = num[0] + num[2];
    for(int i = 4; i < n + 1; ++i) {
      if(i % 2 == 0) {
        dp[i][0] = Math.max(dp[i - 1][1], dp[i - 1][0] + num[i - 1]);
        dp[i][1] = Math.max(dp[i - 1][2], dp[i - 2][1] + num[i - 1]);
      } else {
        dp[i][0] = Math.max(dp[i - 1][0], dp[i - 2][0] + num[i - 1]);
        dp[i][1] = Math.max(dp[i - 1][1], dp[i - 2][1] + num[i - 1]);
        dp[i][2] = dp[i - 2][2] + num[i - 1];
      }
    }
    System.out.println(dp[n][1]);
  }
}

class FastScanner {
  private final InputStream in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  public FastScanner(InputStream source) {
    in = source;
  }

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) return buffer[ptr++];
    else return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext()) throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
      throw new NumberFormatException();
    return (int) nl;
  }

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

Measured memory_bytes: 47472
import math
A,B,C,D,E,F = map(int,input().split())
water = []
for i in range(math.floor(F/(100*A))+1):
    M = 100*A*i
    while M <= F:
        if M not in water and M != 0:
            water.append(M)
        M += 100*B
def max_dens(w):
    max_s = min(F-w,w*E/100)
    max_d = 0
    for i in range(math.floor(max_s/D)+1):
        sugar = math.floor((max_s-i*D)/C)*C+i*D
        max_d = max(max_d,sugar)
    return max_d
den = [max_dens(x)/x for x in water]
index = den.index(max(den))
print(water[index]+max_dens(water[index]),max_dens(water[index]))

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    def main():
        X=int(input())
        N=-(-X//100)

        for i in range(1,N+1):
            if 100*i<=X<=105*i:
                return 1
        return 0
    print(main())

resolve()

Measured memory_bytes: 38376
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  int N;
  cin>>N;
  int a[N];
  FOR(i,0,N) cin>>a[i];
  int ans = 0;
  FOR(i,0,N)
  {
    if(a[a[i]-1] == i + 1) ans++;
  }
  cout << ans / 2 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef vector<int> vi;


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(), a.rend());

    vector<int> resx(n-1),resy(n-1);
    int pos = 0;
    if(a[0]*a[n-1] <= 0) {
        for(int i = 1; i < n-1; ++i) {
            if(a[i] >= 0) {
                resx[pos] = a[n-1], resy[pos] = a[i];
                pos++;
                a[n-1] -= a[i];
            }
        }

        for(int i = 1; i < n; ++i) {
            if(a[i] < 0) {
                resx[pos] = a[0], resy[pos] = a[i];
                pos++;
                a[0] -= a[i];
            }
        }
    }
    else if(a[0] > 0 && a[n-1] > 0) {
        for(int i = 1; i < n-1; ++i) {
            resx[pos] = a[n-1], resy[pos] = a[i];
            pos++;
            a[n-1] -= a[i];
        }

        resx[pos] = a[0], resy[pos] = a[n-1];
        a[0] -= a[n-1];
    }
    else if(a[0] < 0 && a[n-1] < 0) {
        for(int i = 1; i < n; ++i) {
            resx[i-1] = a[0], resy[i-1] = a[i];
            a[0] -= a[i];
        }
    }

    cout << a[0] << endl;
    rep(i,n-1) cout << resx[i] << ' ' << resy[i] << endl;

    return 0;
}

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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long llint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double pi = 3.14159265358979323846;

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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(0);

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  bool ok = true;
  rep(i, n) {
    if (a[i] % 2 == 0) {
      if (!(a[i] % 3 == 0 || a[i] % 5 == 0)) {
        ok = false;
      }
    }
  }
  if (ok) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }

  return 0;
}

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

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}

std::vector<uint64_t> factorization(uint64_t N){
	std::vector<uint64_t> ans;
	uint64_t current_prime = 2;
	uint64_t power = 1;
	if( N % 2 == 0){
        // cout << 2 << " pow ";
		//ans.push_back(current_prime);
		N = N / 2;
		while( N % 2 == 0){
			power++;
			N /= 2;
		}
		ans.push_back(power);
        // cout << power << endl;
	}
	for(current_prime = 3 ; current_prime < sqrt(N) ; current_prime += 2){
		//cout << "Examine " << current_prime << endl;
	       if( N % current_prime == 0){
	       	//ans.push_back(current_prime);
		power = 1;
		N /= current_prime;
		while( N % current_prime == 0){
			power++;
			N /= current_prime;
		}
		ans.push_back(power);
	       }
	}
	if( N > 1){
	//	ans.push_back(N);
		ans.push_back(1);
	}
	return ans;	
}
uint64_t choices(uint64_t power){
    float ans = (sqrt(8 * power + 1) - 1) / 2;
    // cout << "ans is " << ans << endl;
	return floor(ans);
}


void func_to_create(){
    uint64_t N;
    cin >> N;
    auto factors = factorization(N);
    //print_vect(factors);
	uint64_t count = 0;
	for(const auto & p : factors){
		count += choices(p);
	}
    cout << count << endl;
}
int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 5;
    while(TEST_CASES--){
    #endif // DEBBUG

    func_to_create();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3580
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

INF = float("inf")
con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	H, N = getlist()
	A = []
	B = []
	for i in range(N):
		a, b = getlist()
		A.append(a)
		B.append(b)

	#DP初期化
	DP = [INF] * (2 * (10 ** 4) + 1)
	DP[0] = 0

	for i in range(10 ** 4):
		for j in range(N):
			a = A[j]
			DP[i + a] = min(DP[i + a], DP[i] + B[j])

	ans = INF
	for i in range(H, 10 ** 4 + 1):
		ans = min(ans, DP[i])
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 45276
#include<bits/stdc++.h>       
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b,c,d;cin>>a>>b>>c>>d;
    while(c>0&&a>0)
    {
        c=c-b;
        if(c<=0)
        {
            cout<<"Yes";
            break;
        }
        a=a-d;
        if(a<=0)
        {
            cout<<"No";
            break;
        }
    }
}


Measured memory_bytes: 3644
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int

int main() {
lli n, m;
  cin >> n >> m;
  lli sum = 0;
  vector<lli> vect;
  for(int i = 0; i < m; i++){
  	int temp;
    cin >> temp;
    vect.push_back(temp);
  }
  
  for(int i = 0; i < m; i++) {
  	sum += vect[i];
  } 
  
  if(sum <= n){
  cout << n-sum << endl;
  }else cout << -1 << endl;
 }


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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n,k; cin>>n>>k;
    vector<int> boat(n+1);
    rep(i,k){
        int m; cin>>m;
        rep(j,m){
            int b; cin>>b;
            boat[b]=i;
        }
    }
    int r; cin>>r;
    vector<bool> no(n+1,false);
    rep(i,r){
        int a,b; cin>>a>>b;
        if(boat[a]==boat[b]){
            no[a]=no[b]=true;
        }
    }
    int res=0;
    loop(i,1,n+1){
        res+=no[i];
    }
    cout<<res<<endl;

}

Measured memory_bytes: 1196
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    for(;;){
        int a,b,x = 0;
        int field[100] = {0};
        for(;;){
            if(scanf("%d %d",&a,&b) == EOF){
goto jump;
}
            if(!a && !b){break;}
            field[a]++;
            field[b]++;
        }
        for(int i=0; i<100; i++){
            if(field[i]%2 == 1){x++;}
        }
        if(x == 2){cout <<"OK"<<endl;}
        else{cout <<"NG"<<endl;}
    }
    jump:;
    return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>
int main(void){
int i,k,a,b,count=0;
scanf("%d",&k);
scanf("%d %d",&a,&b);
for(i=a; i<=b; i++){
    if((i%k)== 0){
    printf("OK\n");
    count=0;
    break;
    }
    count=1;
}  
if(count==1)
printf("NG\n");
return 0;     
}

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

#define MAX_V 400
#define INF (1LL<<55)
struct edge{ll to,cap,cost,rev;};

int V;
vector<edge> G[MAX_V];
ll dist[MAX_V];
ll prevv[MAX_V];
ll preve[MAX_V];

void add_edge(ll from,ll to,ll cap,ll cost){
  G[from].push_back((edge){to,cap,cost,(ll)G[to].size()});
  G[to].push_back((edge){from,0,-cost,(ll)G[from].size()-1});
}

ll min_cost_flow(int s,int t,ll f){
  ll res=0;
  while(f>0){
    fill(dist,dist+V,INF);
    dist[s]=0;
    bool update=true;
    while(update){
      update=false;
      for(int v=0;v<V;v++){
        if(dist[v]==INF)continue;
        for(int i=0;i<(int)G[v].size();i++){
          edge &e=G[v][i];
          if(e.cap>0&&dist[e.to]>dist[v]+e.cost){
            dist[e.to]=dist[v]+e.cost;
            prevv[e.to]=v;
            preve[e.to]=i;
            update=true;
          }
        }
      }
    }
    if(dist[t]==INF)return -1;
    ll d=f;
    for(int v=t;v!=s;v=prevv[v])
      d=min(d,G[prevv[v]][preve[v]].cap);
    f-=d;
    res+=d*dist[t];
    for(int v=t;v!=s;v=prevv[v]){
      edge &e=G[prevv[v]][preve[v]];
      e.cap-=d;
      G[v][e.rev].cap+=d;
    }
  }
  return res;
}

int n;
ll a,b,c;
int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<MAX_V;i++)G[i].clear();
    V=400;



    for(int i=0;i<390;i++){
      add_edge(i,i+1,2,0);
    }

    for(int i=0;i<n;i++){
      cin>>a>>b>>c;
      b++;      
      add_edge(a,b,1,-c);
    }
    
    ll ans=min_cost_flow(0,390,2);
    cout<<-ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1460
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main() {
    ll Q,H,S,D;
    cin >> Q >> H >> S >> D;
    ll N;
    cin >> N;
    ll one = min(4*Q,min(2*H,S));
    if(2*one<=D){
        cout << one*N << endl;
    }
    else {
        if(N&1) cout << D*(N-1)/2+one << endl;
        else cout << D*N/2 << endl;
    }
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

int main(){
    int N; cin >> N;
    vector<int> A(N+1);
    vector<vector<ll> > B(N+1,vector<ll>(20,-1));
    rep(i,N){
        cin >> A[i];
        rep(j,A[i]){
            int x,y; cin >> x >> y; x--;
            B[i][x] = y;
        }
    }
    int res = 0;
    rep(bit,1<<N){
        bool ok = true;
        rep(i,N){
            if(bit&(1<<i)){
                rep(j,N){
                    if(B[i][j]!=-1){
                        bool bl = bit&(1<<j);
                        if(bl ^ B[i][j]) ok=false;
                    }
                }
            }
            if(!ok) break;
        }
        if(ok) chmax(res,__builtin_popcount(bit));
    }
    cout << res << endl;
}

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

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

int main(){
    int n;
    while(cin>>n,n){
    vector<int> T,H;
        rep(i,n){
            int a;
            cin>>a;
            T.push_back(a);
        }
        sort(T.begin(),T.end());
        for(int i=1;i<=2*n;i++){
            if(!binary_search(T.begin(),T.end(),i))
                H.push_back(i);
        }
        int card=0,turn=1;
        while(!T.empty() && !H.empty()){
            vector<int>::iterator p;
            if(turn%2){
                p = upper_bound(all(T), card);
                if(p!=T.end()){
                    card = *p;
                    T.erase(p);
                }
                else card=0;
            }
            else{
                p = upper_bound(all(H), card);
                if(p!=H.end()){
                    card = *p;
                    H.erase(p);
                }
                else card=0;
            }
            turn++;
        }
        cout << H.size() << "\n" << T.size() << endl;
    }
}

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

int main() {
	int n;
	while (scanf("%d", &n), n) {
		unordered_map<int, int>mp;
		rep(i, n) {
			int a; scanf("%d", &a);
			mp[a]++;
		}
		for (auto p : mp) {
			if (p.second * 2 > n) { printf("%d\n", p.first); goto g; }
		}
		puts("NO COLOR");
	g:;
	}
}

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

using namespace std;

typedef long long   ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii > vpi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)*(b))/__gcd((a), (b)))
#define MAXN 100000

int v[MAXN];
int n;

int main() {
	cin.tie(0);
	cin.sync_with_stdio(0);
	
	int n;
	cin >> n;
	
	bool res = false;
	
	for(int i=0; i<n; i++){
		int x;
		cin >> x;
		
		res |= (x%2);
	}
	
	if(res)
		cout << "first" << endl;
	else
		cout << "second" << endl;
		
	return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

vi solve(int N, int x) {
	vi arr (2 * N - 1);
	
	if (x == N) {
		F0R(i, 2 * N - 1) arr[i] = i + 1;	
		return arr;
	}
	arr[N - 1] = x;
	arr[N - 2] = 1;
	arr[N - 3] = x + 1;
	int c = 1;
	F0R(i, 2 * N - 1) if (arr[i] == 0) {
		while (c == 1 || c == x || c == x + 1) ++c;
		arr[i] = c++;
	}
	return arr;
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, x; cin >> N >> x;
	
	if (x > N) {
		x = 2 * N - x;
		if (x == 1) {
			print("No");
			return 0;
		}
		vi res = solve(N, x);
		F0R(i, 2 * N -1) res[i] = 2 * N - res[i];
		print("Yes");
		for (int x : res) print(x);
	} else {
		if (x == 1) {
			print("No");
			return 0;
		}
		vi res = solve(N, x);
		print("Yes");
		for (int x : res) print(x);
	}
}

Measured memory_bytes: 2304
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    System.out.println(0);
    System.out.flush();
    String s0 = sc.next();
    if(s0.equals("Vacant")) System.exit(0);
    int left = 0;
    int right = n;
    int ans = 0;
    while(left < right) {
      int med = (left + right) / 2;
      System.out.println(med);
      System.out.flush();
      String s = sc.next();
      if(s.equals("Vacant")) System.exit(0);
      if((med - left) % 2 == 0) {
        if(s.equals(s0)) {
          left = med;
          ans = left;
        } else {
          right = med;
          ans = med - 1;
        }
      } else {
        if(s.equals(s0)) {
          right = med;
          ans = med - 1;          
        } else {
          left = med;
          ans = left;
          s0 = s;          
        }        
      }           
    }
    System.out.println(ans);
    System.out.flush();
    String sfi = sc.next();
    System.exit(0);    
  }
}

Measured memory_bytes: 25636
#include <stdio.h>
#include <iostream>

using namespace std;

int solver(int n)
{
	int low = 1;
	int up = 10;

	int sum = 0;

	while (low <= n)
	{
		if (up == n) {
			sum += n - low;
		}
		else if(up > n) {
			sum += n - low + 1;
		}
		else {
			sum += up - low;
		}
		up *= 100;
		low *= 100;
	}
	return sum;
}

int main(void)
{
	int n;
	cin >> n;
	cout << solver(n) << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; ++i) cin >> a.at(i);
	sort(a.begin(), a.end());
	cout << a.at(n - 1) - a.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long 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 ll INF=(1LL<<60);

int main(void){
    int n,t,a; cin >> n >> t >> a;
    double cmp=1000000.0;
    int h[n];
    int ans=0;
    for(int i=0; i<n; i++) cin >> h[i];

    for(int i=0; i<n; i++){
        if(abs(t-h[i]*0.006-a)<cmp){
            ans=i+1;
            cmp=abs(t-h[i]*0.006-a);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var cakes = Enumerable.Repeat(0, nm[0]).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
        long res = 0;
        for (int i = -1; i <= 1; i += 2)
        {
            for (int j = -1; j <= 1; j += 2)
            {
                for (int k = -1; k <= 1; k += 2)
                {
                    var sum = cakes.Select(x => i * x[0] + j * x[1] + k * x[2]).OrderByDescending(x => x).Take(nm[1]).Sum();
                    res = Max(res, sum);
                }
            }
        }
        Console.WriteLine(res);
    }
}

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

int main(){
	long long b,c1,c2,q1,q2,aizu,ord;
	bool flag;
	
	while(cin>>q1,q1){
		flag=false;
		cin>>b>>c1>>c2>>q2;
		if(b/c1>q2){
			aizu=q2;
			ord=(b-c1*q2)/c2;
		}else{
			aizu=b/c1;
			ord=(b%c1)/c2;
		}
		//cout<<aizu<<" "<<ord<<endl;
		if(aizu==0){cout<<"NA"<<endl;}
		else if((aizu+ord)<q1){
			for(int i=aizu-1;i>0;i--){
				if((b-c1*i)/c2>=q1-i){
					flag=true;
					cout<<i<<" "<<(b-c1*i)/c2<<endl;
					break;
				}
			}
			if(!flag){
				cout<<"NA"<<endl;
			}
		}else{
			cout<<aizu<<" "<<ord<<endl;
		}
	}
	return 0;
}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
struct song{
    string name;
    int duration;
};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vector<song> vec(n);
    for(int i=0;i<n;++i)
        cin>>vec[i].name>>vec[i].duration;

    string str;
    cin>>str;
    int i=0;
    for(i=0;i<n;++i)
        if(str==vec[i].name)
        break;

    long total=0;
    for(int j=i+1;j<n;++j)
        total+=vec[j].duration;

    cout<<total<<endl;
    return 0;
}


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

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	
	if(a < b){
		if(b < c){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;
int v[5];
int main()
{
    int i,n,cif;
    scanf("%c%c%c%c",&v[1],&v[2],&v[3],&v[4]);
    for(i=1; i<4; i++)
        if(v[i]==v[i+1])
        {
            printf("Bad");
            return 0;
        }
    printf("Good");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int main () {
  int x, y;
  scanf("%d %d", &x, &y);
  if (x * 2 <= y && y <= x * 4 && (~y & 1)) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

int main(){
  long long a,b,c,x,y,sum=0;
  cin>>a>>b>>c;
  if(a%2==0||b%2==0||c%2==0){
    cout<<0<<endl;
    return 0;
  }
  x=b*c*(a/2);
  y=b*c*(1+a/2);
  sum=abs(x-y);
  x=a*c*(b/2);
  y=a*c*(1+b/2);
  sum=min(sum,abs(x-y));
  x=a*b*(c/2);
  y=a*b*(1+c/2);
  sum=min(sum,abs(x-y));
  cout<<sum<<endl;
}


Measured memory_bytes: 256
import sys


def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))


def input():
    return sys.stdin.readline().rstrip()


#############
# Main Code #
#############
sa = list(input())
sb = list(input())
sc = list(input())

s = [sa, sb, sc]
now = s[0].pop(0)

while True:
    if not len(s[ord(now) - 97]):
        break

    now = s[ord(now) - 97].pop(0)

if now == 'a':
    print('A')
elif now == 'b':
    print('B')
else:
    print('C')


Measured memory_bytes: 61900
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define dl double long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

int main()
{
  ll N, sum=0;
  cin >> N;

  REP(i, 1, N+1){
    if(i%3 == 0 || i%5 == 0) continue;
    sum += i;
  }
  cout << sum << "\n";
}


Measured memory_bytes: 3612
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

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 nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (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){
    string s;
    cin >> s;

    string ans = "";
    bool a = false;
    for(int i = 0; i < s.size(); i++){
        if(!a && s[i] == 'A'){
            a = true;
            continue;
        } else if(a && s[i] == 'A'){
            cout << "NO" << endl;
            return 0;
        } else {
            a = false;
            ans += s[i];
        }

        if(s[i] == 'K' && s[i + 1] == 'A'){
            cout << "NO" << endl;
            return 0;
        }
        if(s[i] == 'I' && s[i + 1] == 'A'){
            cout << "NO" << endl;
            return 0;
        }
    }

    if(ans == "KIHBR"){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <climits>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n), q(n), v(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  iota(v.begin(), v.end(), 1);
  int a, b, i = 1;
  do {
    if (v == p)
      a = i;
    if (v == q)
      b = i;
    i++;
  } while (next_permutation(v.begin(), v.end()));
  cout << abs(a-b) << endl;
  return 0;
}

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

using namespace std;
using LL = long long;

constexpr int N = 2e5 + 5;
vector< int> conn[N];
int val[N];

void dfs(int a, int prt, int v) {
    val[a] += v;
    for (const int &b : conn[a]) {
        if (b == prt) continue;
        dfs(b, a, val[a]);
    }
}

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

    int n, q;
    cin >> n >> q;

    for (int i = 1; i < n; i++) {
        int x, y;
        cin >> x >> y;
        conn[x].push_back(y);
        conn[y].push_back(x);
    }

    while (q--) {
        int p, x;
        cin >> p >> x;
        val[p] += x;
    }

    dfs(1, 1, 0);
    for (int i = 1; i <= n; i++) cout << val[i] << " \n"[i == n];
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

int main()
{
  int s, sum;
  REP(i, 10){
    cin >> s;
    sum += s;
  }
  cout << sum << endl;
}

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

using namespace std;


int main() {
	string c;
	cin >> c;
	if (c == "a" || c == "e" || c == "i" || c == "o" || c == "u")
	{
		cout << "vowel" << endl;
	}
	else
	{
		cout << "consonant" << endl;
	}
}

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

int main() {
    ll n,y;
    cin >> n >> y;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            int k = n - i - j;
            if(k<0||k>n)continue;
            if(10000*i+5000*j+1000*k != y) continue;
            cout << i << " " << j << " " << k << endl;
            return 0;
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 3636