akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define int long long
#define REP(i, s, n) for (signed i = (s); i < signed(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c).begin(), (c).end()


const int INF = 1 << 29;

using namespace std;

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

int dr[] = { -1, 0, 1, 0 };
int dc[] = { 0, -1, 0, 1 };
const int MOD = 1000000007;

signed main() {

	const int Maxnum = 1000000;
	vector<int> seisi = { 1 };
	int num = 2;
	while (seisi.back() <= Maxnum)
	{
		seisi.push_back(num * (num + 1) * (num + 2) / 6);
		num++;
	}

	vector<int> dp(Maxnum + 1, INF), kidp(Maxnum + 1, INF);
	dp[0] = 0;
	kidp[0] = 0;
	rep(i, Maxnum) {

		rep(j, seisi.size()) {
			if (i + seisi[j] > Maxnum) break;
			dp[i + seisi[j]] = min(dp[i + seisi[j]], dp[i] + 1);

			if (seisi[j] % 2) {
				kidp[i + seisi[j]] = min(kidp[i + seisi[j]], kidp[i] + 1);
			}
		}
	}

	int n;
	while (cin >> n && n) {

		cout << dp[n] << " " << kidp[n] << endl;
	}

}

Measured memory_bytes: 18192
#演習２－１ 

while True:
    n, x = map(int,input().split())
    if n == 0 and x ==0:
        break
    else:
        count=0
        #i < j < kと仮定することで、以下のように書ける
        for i in range(1,n-1):
            for j in range(i+1, n):
                for k in range(j+1,n+1):
                    if i + j + k == x:
                        count = count+1
                        
        print(count)




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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(string S, ll w) {
    for (int i = 0; i < S.size(); i++) {
        if (i % w == 0) cout << S[i];
    }
    cout << endl;
}


void main_(istream &cin) {
    ll w;
    string S;
    cin >> S;
    cin >> w;
    solve(S, w);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 256
"use strict"
function Main(input) {
  const args = input.trim().split('\n');
  const A = Number(args[0]);
  const B = Number(args[1]);
  const C = Number(args[2]);
  const X = Number(args[3]);

  let ret=0;
  for(let a=0; a<=A; ++a){
    for(let b=0; b<=B; ++b){
      for(let c=0; c<=C; ++c){
        let cnt = 500*a+100*b+50*c;
        if(X == cnt) ++ret;
      }
    }
  }

  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  bool ans = true;
  rep(j, n-1){
    ans = true;
    while (ans) {
      if(j+1 < n){
        if(s.at(j) == s.at(j+1)){
          s.erase(j+1, 1);
          n--;
        }
        else{
          ans = false;
        }
      }
      else{
        break;
      }
    }
  }
  std::cout << s.size() << '\n';
  return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;


int main()
{

    string p;
    long long int n;
    cin >> p >> n;

    long long int ans = 0;

    if (p.size() == 1) {
        cout << n / 2 << endl;
        return 0;
    }
    set<char>f;
    f.insert(p[0]);
    string d = p;
    for (int i = 1; i < p.size(); i++) {
        f.insert(p[i]);
        if (p[i] == p[i - 1]) {
            p[i] = '?';
            ans++;
        }
    }
    

        
        long long int r = n / 2,w;
        w= p.size() * (r) +p.size()/2 * (n % 2) ;
 
        long long int g = 0;
    if (d[0] == p[p.size() - 1]) {
        g++; d[0] = '?';
    }
    for (int i = 1; i < p.size(); i++) {
        if (d[i] == d[i - 1]) {
            d[i] = '?'; g++;
        }
    }
    cout << min(ans+g*(n-1),w) << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int32_t INF = 0x3F3F3F3F;
typedef int64_t ll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll a, b, c, ans = INF;
        in >> a >> b >> c;
        ll cnt = 0;
        ll na = a, nb = b, nc = c;
        ll pa = -1, pb = -1, pc = -1;
        while ((na & 1) == 0 && (nb & 1) == 0 && (nc & 1) == 0) {
            pa = na;
            pb = nb;
            pc = nc;
            na /= 2;
            nb /= 2;
            nc /= 2;
            ll ta = na, tb = nb, tc = nc;
            na = ta + tb;
            nb = tb + tc;
            nc = tc + ta;
            if (pa == na && pb == nb && pc == nc) {
                cnt = -1;
                break;
            }
            cnt++;
        }
        ans = min(ans, cnt);
        out << ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979323846;

int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int time = 60*(H2-H1)+M2-M1;
  if (time<=K) cout << 0 << endl;
  else cout << time-K << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    var yymm = mutableSetOf<String>()
    var mmyy = mutableSetOf<String>()
    (0..99).forEach { y ->
        (1..12).forEach { m ->
            yymm.add("%02d%02d".format(y, m))
            mmyy.add("%02d%02d".format(m, y))
        }
    }
    val s = sc.next()
    if (yymm.contains(s) && mmyy.contains(s)) {
        println("AMBIGUOUS")
    } else if (yymm.contains(s)) {
        println("YYMM")
    } else if (mmyy.contains(s)) {
        println("MMYY")
    } else {
        println("NA")
    }
}

Measured memory_bytes: 39692
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var NK = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NK[0];
        var K = NK[1];
        WriteLine(N % K);
    }
}


Measured memory_bytes: 13396
//defines e includes
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define rep1(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, a, b) for(int i=(int)a;i<(int)b;i++)
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define p_b pop_back
#define p_f pop_front
#define mp make_pair
#define MAX 100010
#define oo INT_MAX
using namespace std;
//tipagem de pares
typedef pair<int, int> ii;
typedef pair<char, char> cc;
typedef pair<int, char> ic;
typedef pair<char, int> ci;
//tipagem de vetores
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<bool> vb;
//tipagem de outras estruturas
typedef queue<int> qi;
typedef deque<int> dqi;
//tipagem de tipos primitivos
typedef long long int ll;
typedef unsigned long long int ull;

int main()
{
	
	fastio;
	int h, n;
	cin >> h >> n;
	int a[n], att=0;
	rep1(i, n){
		cin >> a[i];
		if(h > 0){
			att++;
			h-=a[i];
		}
	}
	if(h <= 0){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}


	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#define N 8
#define M 15
#define FREE -1
#define NOT_FREE 1

int col[N],row[N],dpops[M],dneg[M],p[N][N];

void printBoard(){
  int i,j;

  for(i=0;i<N;i++){
    for (j=0;j<N;j++){
      if(p[i][j]){
        if(row[i]!=j) return;
      }

      /* code */
    }
  }

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
   printf("\n");
  }
}

void putQueen(int i){
  int j;
  if (i == N) {
    printBoard();
    return;
  }

  for (j = 0;j<N;j++){
    if (col[j] == NOT_FREE ||dpops[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE) continue;
    // put a queen at (i, j)
    row[i] = j;
    col[j] = dpops[i+j] = dneg[i-j+N-1] = NOT_FREE;
    // try the next row
    putQueen(i+1);
    // remove the queen at (i, j) for backtracking
    col[j] = dpops[i+j] = dneg[i-j+N-1] = FREE;
  }
}

int main(){
int i,j,k,n,r,c;

for(i=0;i<M;i++){
  dpops[i]=FREE;
  dneg[i]=FREE;
}

for(i=0;i<N;i++){
  col[i]=FREE;
  row[i]=FREE;
  for(j=0;j<N;j++){
    p[i][j]=0;
  }
}

scanf("%d",&k);

for(i=0;i<k;i++){
  scanf("%d%d",&r,&c);
  p[r][c]=1;
}
putQueen(0);

return 0;
}

Measured memory_bytes: 572
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int nn = sc.nextInt();
		String ss = sc.next();
		String encryptedData="";
		
		for (int i = 0; i < ss.length(); i++) {
			encryptedData = encryptedData + String.valueOf((char)((ss.charAt(i) + nn-65)%26 + 65));
		}
		
		System.out.print(encryptedData);
	}
}

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

int main() {
  string S;
  cin >> S;
  
  char prev = S.at(0);
  for (int i = 1; i < 4; i++) {
    if (S.at(i) == prev) {
      cout << "Bad" << endl;
      return 0;
    }
    prev = S.at(i);
  }
  cout << "Good" << endl;
  return 0;
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

lli comb_table[51][51];


void cal() {
    for (int i = 0; i < 51; i++)
        comb_table[i][0] = 1;

    for (int j = 0; j < 51; j++)
        comb_table[j][j] = 1;


    for (int i = 2; i < 51; ++i) {
        for (int j = 1; j < 51 and j < i; ++j) {
            comb_table[i][j] = ( comb_table[ i-1 ][j] + comb_table[ i-1 ][ j-1 ] );
        }
    }
    return;
}
int main() {
    lli n, a, b;
    cin3(n, a, b);
    lli v[n];
    ncin1(n, v);

    sort(v, v+n, greater<lli>());
    map<lli, lli> m;
    REP(i, 0, n){
        m[v[i]]++;
    }

    cal();
    if (m[v[0]] >= a) {
        // ex. 5 2 3 3 3 3 3 3
        // 全部それで良い
        lli ans = 0;
        REP(i, a, min(m[v[0]]+1, b+1)) {
            //cout << m[v[0]] << "C" <<i << ": " << comb_table[m[v[0]]][i] << endl;
            //cout << comb_table[m[v[0]]][i] << endl;
            ans += comb_table[m[v[0]]][i];
        }
        cout << v[0] << endl;
        cout << ans << endl;
    }
    else {
        lli cnt = 0;
        lli total = 0;
        lli ans = 1;
        auto it = m.rbegin();
        for(; it != m.rend(); it++) {
            //cout << it->first << ": " << it->second << endl;
            cnt += it->second;
            if (cnt >= a) {
                total += it->first * (a - (cnt-it->second));
                //cout << it->second << endl;
                //cout << a - (cnt-it->second) << endl;
                //cout << comb_table[it->second][a - (cnt-it->second)] << endl;
                ans *= comb_table[it->second][a - (cnt-it->second)];
                break;
            }
            total += it->first * it->second;
        }
        //cout << (it)->first << endl; // 10
        //cout << (it)->second << endl; // 3

        cout.precision(20);
        cout << fixed << ((double)total) / a << endl;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

/*const int MM = 4e8;
int mpos = 0;
char mem[MM];
inline void * operator new ( size_t n )
{
	char *res = mem + mpos;
	mpos += n;
	return (void *)res;
}
inline void operator delete ( void * ) { } */

#define TIME (clock() * 1.0 / CLOCKS_PER_SEC)

const ld pi = acos(-1.0);
const ll INF = 1e18 + 239;
const int BIG = 1e9 + 239;
const ll MOD = 1e9 + 7;
const ll MOD2 = MOD * MOD;
const int M = 2 * 1e5 + 239;
const int N = 2 * 1e3 + 239;
const int X = 1e4 + 239;
const int L = 18;
const int T = (1 << 18);
const int two = 2;
const int th = 3;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{   /*
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout); /**/
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k & 1LL) cout << (b - a);
    else cout << (a - b);
    return 0;
}


Measured memory_bytes: 764
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Int
import Data.Char
import Data.Bits
import qualified Data.ByteString.Char8 as BS
import Numeric

readBin :: String -> Integer
readBin s = case readInt 2 (\c -> c == '0' || c == '1') digitToInt s of
              [(a, _)] -> a

naive :: String -> N
naive s = let l = readBin s
          in sum [ 1
                 | a <- [0..l]
                 , b <- [0..l - a]
                 , a `xor` b == a + b
                 ]

main = do
  l <- BS.getLine
  let loop :: BS.ByteString -> N
      loop s = case BS.uncons s of
                   Just ('0', s') -> loop s'
                   Just ('1', s') -> 2 * loop s' + 3^(BS.length s')
                   Nothing -> 1
  print $ loop l

---

modulo = 10^9+7 :: Int64
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y = (x + y) `rem` modulo
subMod !x !y = (x - y) `mod` modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  N x + N y = N ((x + y) `rem` modulo)
  N x - N y = N ((x - y) `mod` modulo)
  N x * N y = N ((x * y) `rem` modulo)
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined


Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		
		int n=sc.nextInt();
		int p[]=new int[n];
		int c = 0;
		for(int i=0;i<n;i++) {
			p[i]=sc.nextInt();
			if(p[i]!=i+1)c+=1;
		}
		if(c<=2) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}

}
	
	
	
}





Measured memory_bytes: 23252
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

pair<ll,int> a[N];
int main(){
    //freopen("A.in","r",stdin);
    //freopen("B.out","w",stdout);
    //cout<<setprecision(9)<<fixed;
    int i,j,k,ca=0,m,n;
    ll K=0,L,T;
    scanf("%d%lld%lld",&n,&L,&T);
    rep(i,0,n)scanf("%lld%d",&a[i].x,&a[i].y);
    rep(i,1,n){
        if(a[i].y!=a[0].y){
            if(a[0].y==1){
                ll d=(a[i].x-a[0].x);
                if(d<=T*2){
                    K+=1+(2*T-d)/L;
                }
            }
            else{
                ll d=(L-a[i].x+a[0].x);
                if(d<=T*2){
                    K+=1+(2*T-d)/L;
                }
            }
        }
    }
    K%=n;if(a[0].y==2)K=(n-K)%n;
    rep(i,0,n){
        if(a[i].y==1)a[i].x=(a[i].x+T)%L;
        else a[i].x=((a[i].x-T)%L+L)%L;
    }
    int pos=a[0].x,sn=a[0].y;
    sort(a,a+n);
    rep(i,0,n)if(a[i].x==pos){pos=i;break;}
    if(sn==1)
    while(pos+1<n&&a[pos+1].x==a[pos].x)pos++;
    K=(pos-K+n)%n;
    rep(i,K,n)printf("%lld\n",a[i].x);
    rep(i,0,K)printf("%lld\n",a[i].x);
    //cerr<<clock()*1./CLOCKS_PER_SEC<<"ms\n";
    return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;

int maximum;

int max_count(std::vector<int> H, int i, int maximum){
  if(i == H.size()){
	return 0;
  }

  if(maximum <= H.at(i)){
	maximum = H.at(i);
	return 1+ max_count(H, i+1, maximum);
  }
  else{
    return max_count(H, i+1, maximum);
  }
}

int main(){
  int i=0;
  int maximum=0;
  int N;
  cin >> N;
  vector<int> H(N);
  
  for(int i=0; i<N; i++){
	cin >> H.at(i);
  }

  cout << max_count(H, i=0, maximum) << endl;

  return 0;
}




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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll W, H; cin >> W >> H;

  vector<pair<ll, int>> edge;
  REP(_, W) {
    ll p; cin >> p;
    edge.emplace_back(p, 0);
  }
  REP(_, H) {
    ll q; cin >> q;
    edge.emplace_back(q, 1);
  }

  sort(ALL(edge));
  W++, H++;
  ll ans = 0;
  for (auto e : edge) {
    ll w; int s; tie(w, s) = e;
    //cout << w << ',' << s << ':' << W << ',' << H << endl;
    if (s == 0 and H) {
      ans += H * w;
      W--;
    } else if (s == 1 and W) {
      ans += W * w;
      H--;
    }
  }
  //assert(H == 1 and W == 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4464
mat = []
 
for i in range(3):
  a = list(map(int, input().split()))
  mat.append(a)
  
ans = False
if mat[1][0] - mat[0][0] == mat[1][1] - mat[0][1] == mat[1][2] - mat[0][2]:
  if mat[2][0] - mat[0][0] == mat[2][1] - mat[0][1] and mat[2][1] - mat[0][1] == mat[2][2] - mat[0][2]:
    ans = True
 
if ans:
  print("Yes")
else:
  print("No")

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int solve(int R, int C, vector<vector<bool> >& mochi) {
  int result = 0;
  vector<vector<bool> > mochi2(R, vector<bool>(C));
  for (int mask = 0; mask < (1 << R); mask++) {
    for (int i = 0; i < R; i++) {
      for (int j = 0; j < C; j++) {
        mochi2[i][j] = mochi[i][j] ^ ((mask & (1 << i)) >> i);
      }
    }
    int count = 0;
    REP(j, C) {
      int rowCount = 0;
      REP(i, R) {
        if (mochi2[i][j] == true) rowCount++;
      }
      rowCount = max(rowCount, R - rowCount);
      count += rowCount;
    }
    result = max(result, count);
  }
  return result;
}

int main() {
  while (true) {
    int R, C;
    cin >> R >> C;
    if (R == 0 && C == 0) break;

    vector<vector<bool> > mochi(R, vector<bool>(C, false));
    REP(i, R) REP(j, C) {
      int x; cin >> x;
      mochi[i][j] = (x == 1);
    }

    int answer = solve(R, C, mochi);
    cout << answer << endl;
  }
}

Measured memory_bytes: 932
# ARC 092 C 最大マッチング問題


class Edge(object):

    def __init__(self, src, dst, cap):
        self.src = src
        self.dst = dst
        self.cap = cap
        self.rev = None

    def create_rev(self):
        """
        対応する残余グラフの辺を作成して返す。
        本来の辺と残余グラフの辺は相互に参照を持ち合うため、このメソッド以外から生成しないこと。
        """
        rev = Edge(self.dst, self.src, 0)
        self.rev = rev
        rev.rev = self
        return rev


class FordFulkerson:

    def __init__(self, N):
        self.N = N
        self.G = [list() for _ in range(N)]  # G[i]: 頂点iに接続している全ての有向辺のリスト

    def add_edge(self, src, dst, cap):
        forward = Edge(src, dst, cap)
        backward = forward.create_rev()
        self.G[src].append(forward)
        self.G[dst].append(backward)

    def flow(self, src, dst):
        max_flow = 0
        while True:
            self.used = [0] * self.N
            flow = self._dfs(src, dst)
            if flow == 0:  # f=0 が返るのは全てのパスを走査してこれ以上検討するパスがなくなったタイミング
                break
            max_flow += flow
        return max_flow

    def _dfs(self, v, t, f=float('inf')):
        """
        深さ優先でグラフを走査し、目的地に達するパスがあるか検索する。
        パスが存在すればその時の最大流を返し、存在しなければ0を返す。
        最大流量がFである時、高々F回のDFSをすることになるため、 O(F|E|) となる。

        :param v: 始点のインデックス
        :param t: 終点のインデックス
        :param f: 現在の再帰スタックにおける暫定の最大流
        """
        if v == t:
            return f
        used = self.used
        used[v] = 1
        for e in self.G[v]:
            if e.cap and not used[e.dst]:
                d = self._dfs(e.dst, t, min(f, e.cap))
                if d:
                    e.cap -= d
                    e.rev.cap += d
                    return d
        return 0


N = int(input())
reds = [tuple(map(int, input().split())) for _ in range(N)]
blues = [tuple(map(int, input().split())) for _ in range(N)]

# 0: s
# 1 to N: reds
# N + 1 to 2N: blues
# 2N + 1: t
ff = FordFulkerson(2 * N + 2)
for i in range(N):
    r_x, r_y = reds[i]
    r_idx = i + 1
    ff.add_edge(0, r_idx, 1)  # sから赤の各点への辺
    for j in range(N):
        b_x, b_y = blues[j]
        b_idx = j + N + 1
        if r_x < b_x and r_y < b_y:
            ff.add_edge(r_idx, b_idx, 1)  # 赤の各点から青の各点への辺
for i in range(N + 1, 2 * N + 1):
    ff.add_edge(i, 2 * N + 1, 1)  # 青の各点からtへの辺

# 最大流 = 最大マッチング数
print(ff.flow(0, 2 * N + 1))

Measured memory_bytes: 4724
import sys

n,a,b,c,d = map(int, input().split())
s = input()

tmp = ""
for i in range(a,c):
	if s[i] == tmp == "#":
		print("No")
		sys.exit()
	tmp = s[i]

for i in range(b,d):
	if s[i] == tmp == "#":
		print("No")
		sys.exit()
	tmp = s[i]

if c < d:
	print("Yes")
	sys.exit()

else:
	cnt = 0
	for i in range(b-2,d+1):
		if s[i] == ".":
			cnt += 1
			if cnt == 3:
				print("Yes")
				sys.exit()
		else:
			cnt = 0

print("No")

Measured memory_bytes: 3572
#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;
const int nmax=2005;
int ans[2][nmax],a[nmax];
int w,h,i,j,n;
int abss(int x)
{
    if(x<0) return -x;
    return x;
}
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n>>w>>h;
    for(i=1;i<=n;i++)
        cin>>a[i];
    ans[0][n-1]=ans[1][n-1]=abss(a[n-1]-a[n]);
    for(i=n-2;i>=1;i--)
    {
        ans[0][i]=(1<<30);
        for(j=i+1;j<=n-1;j++) ans[0][i]=min(ans[0][i],max(ans[0][j+1],abss(a[j]-a[n])));
        for(j=i+1;j<=n-1;j++) ans[1][i]=max(ans[1][i+1],min(ans[1][j+1],abss(a[j]-a[n])));
    }
    cout<<max(ans[0][1],abss(h-a[n]));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int k, x; cin >> k >> x;
    for (int i = x - k + 1; i <= x + k - 1; i++) {
        cout << i << " ";
    }
    cout << "\n";
}


Measured memory_bytes: 256
/*
	Powered by C++11.
	Author : Alex_Wei.
*/

#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize(3)
//#define int long long

#define ll long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define mem(x,v) memset(x,v,sizeof(x))

// Templates start.

namespace IO{
	char buf[1<<21],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
	#ifdef __WIN32
		#define gc getchar()
	#else
		#define gc (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
	#endif
	#define pc(x) (*O++=x)
	#define flush() fwrite(obuf,O-obuf,1,stdout)

	inline int read(){
		int x=0,sign=0; char s=gc;
		while(!isdigit(s))sign|=s=='-',s=gc;
		while(isdigit(s))x=(x<<1)+(x<<3)+(s-'0'),s=gc;
		return sign?-x:x;
	}
	void print(int x) {if(x>9)print(x/10); pc(x%10+'0');}
}

namespace math{
	const int mod=998244353;
	const int maxn=1e6+5;

	ll ksm(ll a,ll b){ll s=1,m=a; while(b){if(b&1)s=s*m%mod; m=m*m%mod,b>>=1;} return s;}
	ll inv(ll x){return ksm(x,mod-2);}

	ll fc[maxn],ifc[maxn];
	void init_m(int n){
		fc[0]=1; for(int i=1;i<=n;i++)fc[i]=fc[i-1]*i%mod;
		ifc[n]=inv(fc[n]); for(int i=n-1;i>=0;i--)ifc[i]=ifc[i+1]*(i+1)%mod;
	}
	ll C(ll n,ll m){return fc[n]*ifc[m]%mod*ifc[n-m]%mod;}
}

// Templates end. Please give me more points.

using namespace IO;
//using namespace math;

const int N=3000+5;
const int mod=998244353;

ll a,b,c,d,f[N][N],u[N][N],r[N][N];

int main(){
	cin>>a>>b>>c>>d,f[a][b]=1;
	for(int i=a;i<=c;i++)for(int j=b;j<=d;j++)if(i!=a||j!=b){
		f[i][j]=(f[i-1][j]*j+f[i][j-1]*i-f[i-1][j-1]*(i-1)%mod*(j-1)%mod+mod)%mod;
//		u[i][j]=f[i-1][j]*j%mod,r[i][j]=f[i][j-1]*i%mod;
//		f[i][j]=(f[i][j]-r[i-1][j]-u[i][j-1]+mod*2)%mod;
//		cout<<i<<" "<<j<<" "<<u[i][j]<<" "<<r[i][j]<<" "<<f[i][j]<<endl;
	}
	cout<<f[c][d]<<endl;
	return 0;
}


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

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print(x*y)


Measured memory_bytes: 14252
#include <stdio.h>
#include <math.h>

int main(void){
	int a, b, c;
	while( scanf(" %d %d %d", &a, &b, &c) != EOF){
		double area = sqrt(b*b - (a/2.0)*(a/2.0)) * (a/2.0);
		double y = (b+c)/2.0;
		area += sqrt(y*y - (b/2.0)*(b/2.0)) * (b/2.0) * 2;
	
		printf("%.10lf\n", area);
	}

	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int f[61][100000]={0};

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

    vector<int> x(n);
    rep(i,n) scanf(" %d", &x[i]);

    int m;
    ll k;
    scanf(" %d %lld", &m, &k);

    vector<int> a(m);
    rep(i,m)
    {
        scanf(" %d", &a[i]);
        --a[i];
    }

    rep(i,n-1) f[0][i]=i;
    rep(i,m) swap(f[0][a[i]],f[0][a[i]-1]);
    for(int i=1; i<=60; ++i)rep(j,n-1) f[i][j]=f[i-1][f[i-1][j]];

    vector<ll> d(n-1);
    rep(i,n-1) d[i]=x[i+1]-x[i];

    vector<int> pos(n-1);
    rep(i,n-1) pos[i]=i;

    for(int i=60; i>=0; --i)
    {
        if(k-(1LL<<i)>=0)
        {
            vector<int> newpos(n-1);
            rep(j,n-1) newpos[j]=f[i][pos[j]];

            k-=(1LL<<i);
            pos=newpos;
        }
    }

    vector<ll> E(n,0);
    E[0]=x[0];
    rep(i,n-1) E[i+1]=E[i]+d[pos[i]];

    rep(i,n) printf("%lld\n", E[i]);
    return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define FORE(i,a,b) for (int i=(int)(a);i<=(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FOR(i,0,n)
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define OUT(x) cout<<x<<endl;

typedef long long ll;
typedef pair<ll, ll> P;

bool sort_by_first(P a, P b) {
  return a.first > b.first;
}
bool sort_by_second(P a, P b) {
  return a.second > b.second;
}

int main() {
  int N; cin >> N;
  int upper[100000];
  int lower[100000];
  REP(i,100000) {
    upper[i] = 0;
    lower[i] = 0;
  }

  REP(i,N) {
    int v;cin >> v;
    if (i%2==0) upper[v-1]++;
    else lower[v-1]++;
  }
  vector<P> up;
  vector<P> low;
  REP(i,100000) {
    if (upper[i] > 0) up.push_back({upper[i],i});
    if (lower[i] > 0) low.push_back({lower[i],i});
  }
  sort(ALL(up),sort_by_first);
  sort(ALL(low),sort_by_first);

  up.push_back({0,-1});
  low.push_back({0,-1});

  int ans = N;
  if (up[0].second != low[0].second) {
    ans -= up[0].first+low[0].first;
  } else {
    ans -= max(up[0].first+low[1].first, up[1].first+low[0].first);
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 2804
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
const ll E=1e17+7;
#define F first
#define S second
#define MK make_pair




int main(){
    ll x,t;
    cin>>x>>t;
    x-=t;
    if(x<0){x=0;}
    cout<<x<<endl;
    
    
    return 0;
}


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

template<typename T>
struct LazySegtreeAdd {
    int n;
    T e;
    vector<T> dat, laz;
    typedef function<T(T a, T b)> Func;
    Func f;

    LazySegtreeAdd(int n_input, Func f, T e_input):f(f), e(e_input){
        n = 1;
        while(n < n_input) n <<= 1;
        dat.resize(2*n-1, e);
        laz.resize(2*n-1, 0);
    }

    void initialize(vector<T>& v){
        for(int i=0; i<v.size(); i++) dat[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) dat[i] = f(dat[i*2+1], dat[i*2+2]);
        fill(laz.begin(), laz.end(), 0);
    }

    void eval(int k, int l, int r){
        if(laz[k] == 0) return;
        dat[k] += laz[k];
        if(r-l > 1){
            laz[2*k+1] += laz[k];
            laz[2*k+2] += laz[k];
        }
        laz[k] = 0;
    }

    void add_between(int a, int b, T x){
        add(a, b+1, x, 0, 0, n);
    }

    void add(int a, int b, T x, int k, int l, int r){
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b){
            laz[k] = x;
            eval(k, l, r);
        }else{
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    T get_between(int a, int b){
        return query(a, b+1, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r){
        eval(k, l, r);
        if(r<=a || b<=l) return e;
        if(a<=l && r<=b) return dat[k];
        T vl = query(a, b, 2*k+1, l, (l+r)/2);
        T vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

int L[200000], R[200000], A[200000];
vector<int> L2i[200001], R2i[200001];

int main(){
    int N, M;
    cin >> N >> M;
    for(int i=0; i<M; i++){
        cin >> L[i] >> R[i] >> A[i];
        L2i[L[i]].push_back(i);
        R2i[R[i]].push_back(i);
    }

    const int64_t INF = 1e18;
    LazySegtreeAdd<int64_t> st(N+1, [](int64_t a, int64_t b){ return max(a, b);}, -INF);
    vector<int64_t> init(N+1, 0);
    st.initialize(init);

    for(int i=1; i<=N; i++){
        int64_t result = st.get_between(0, i-1);
        st.add_between(i, i, result);
        for(int j : R2i[i]) st.add_between(L[j], R[j], A[j]);
    }
    int64_t ans = st.get_between(0, N);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 34176
from collections import deque

n,q = map(int,input().split())
queue = deque()
for i in range(n):
	name,time = input().split()
	queue.append((name, int(time)))

t = 0
while queue:
	name,time = queue.popleft()
	t += min(q, time)
	if time > q:
		queue.append((name, time-q))
	else:
		print(name,t)


Measured memory_bytes: 12536
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    const int MOD = 1000000007;
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int n = cin.NextInt();
        int k = cin.NextInt();

        if (k != 1)
        {
            Console.WriteLine(n - k);
        }
        else
        {
            Console.WriteLine(0);
        }
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
int main() {
	int a, b, c;
	int i;
	int cnt = 0;

	scanf("%d %d %d", &a, &b, &c);

	if (a > b)return -1;

	for (i = a; i <= b; i++) {
		!(c % i) ? cnt++ :0 ;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 2752
#include <stdio.h>

#define MAX 1000000

int main(void) {
	int n;
	double x[4], y[4];
	int i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x[0], &y[0], &x[1], &y[1], &x[2], &y[2], &x[3], &y[3]);
		if ( (y[1]-y[0])/(x[1]-x[0]) == (y[3]-y[2])/(x[3]-x[2]) )
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 0
S = int(input())
A = list(map(int,input().split()))

def main():
    flag = 0
    new_A = sorted(A)

    for i in range(S-1):
        if new_A[i] == new_A[i+1]:
            flag = 1
            break
        else:
            continue

    if flag == 0:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    main()
    

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20

typedef long long ll;
using namespace std;

int n;
int d = 0,e = 0;
ll ans=0;
int main() {
    scanf("%d",&n);
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<int> b(n);
    rep(i, 0, n) cin >> b[i];
    vector<int> c(n);
    rep(i, 0, n) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    int j = n/2;
    rep(i,0,n){
        ll A=lower_bound(a.begin(),a.end(),b[i])-a.begin();
		ll B=n-(upper_bound(c.begin(),c.end(),b[i])-c.begin());
		ans+=A*B;
    }
    printf("%lld\n",ans);
    return 0;    
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
 
 
int main() {
    string s;
	cin >> s;
    int n = s.length();
    bool a = true;
    int kaisuu=0;
    fr(i,n){
      if(a==(s[i]=='1'))kaisuu+=1;
      if(a)a=false;
      else a=true;
    }
    cout << min(kaisuu,n-kaisuu) << endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int D;
    cin >> D;
    string ans = "Christmas";
    if(D == 22) {
        ans += " Eve Eve Eve";
    }
    else if(D == 23) {
        ans += " Eve Eve";
    }
    else if(D == 24) {
        ans += " Eve";
    }
    printf("%s\n", ans.c_str());
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

int main() {
    char b;
    string ans;

    cin>>b;

    switch (b)
    {
    case 'A':
        ans = 'T';
        break;
    case 'C':
        ans = 'G';
        break;
    case 'G':
        ans = 'C';
        break;
    case 'T':
        ans = 'A';
        break;
    default:
        break;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int arr[105];
int dp[100005];
//safe is 1, unsafe is 0;
int main()
{
	
	int n,k;
	cin>>n>>k;
	memset(dp,0,sizeof(dp));
	for(int i=0; i<n; i++)
	{
		cin>>arr[i];
	}
	dp[0]=0;
	for(int i=0; i<=k; i++)
	{
		
		for(int j=0; j<n; j++)
		{
			if(i+arr[j]<=k)
				dp[i+arr[j]]=((dp[i+arr[j]]==1)?1:(!dp[i]));
		}
	}
	if(dp[k])
		cout<<"First";
	else
		cout<<"Second";
	return 0;
}

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
const int maxn = 100050;
typedef long long ll;

int n, x, y, z;
ll cur, ans, delta, pre[maxn], suf[maxn];
struct person
{
	int a, b, c;
	friend bool operator<(person a, person b){return a.a-a.b<b.a-b.b;}
}g[maxn];
priority_queue<int,vector<int>,greater<int> > q;

int main()
{
	scanf("%d%d%d",&x,&y,&z); n = x + y + z; ans = -(1ll<<61);
	fo(i,1,n) 
	{
		scanf("%d%d%d",&g[i].a,&g[i].b,&g[i].c);
		g[i].a -= g[i].c; g[i].b -= g[i].c;
		delta += g[i].c;
	}
	sort(g+1,g+n+1);
	fo(i,1,n) 
	{
		q.push(g[i].b); cur += g[i].b;
		if(q.size()>y) {cur -= q.top(); q.pop();}
		if(q.size()==y) pre[i] = cur;
	}
	while(!q.empty()) q.pop(); cur = 0;
	fd(i,n,1)
	{
		q.push(g[i].a); cur += g[i].a;
		if(q.size()>x) {cur -= q.top(); q.pop();}
		if(q.size()==x) suf[i] = cur; 
	}
	fo(i,y,n-x) ans = max(ans, pre[i]+suf[i+1]);
	printf("%lld\n",ans+delta);
	return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
const int INF = 1001001001;


int MAX_V = 100; // 頂点数
vector<vector<int>> d(MAX_V, vector<int>(MAX_V, INF));
void warshall_floyd() {
  for (int i = 0; i < MAX_V; ++i) d[i][i] = 0;
  for (int k = 0; k < MAX_V; ++k)
    for (int i = 0; i < MAX_V; ++i)
      for (int j = 0; j < MAX_V; ++j)  d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m), c(m);
  rep(i, m) {
    int s, t, u;
    cin >> s >> t >> u;
    s--; t--;
    a[i] = s;
    b[i] = t;
    c[i] = u;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }

  warshall_floyd();

  int ans = 0;
  rep(i, m) {
    int na = a[i], nb = b[i], nc = c[i];
    bool used = false;
    rep(j, n) {
      if (d[na][j] + nc == d[nb][j]) used = true;
    }
    if(!used) ans++;
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <sstream>

using namespace std;

int main() {
    string a,b,c;

    cin >> a >> b >> c;

    int lena = a.length(),lenb = b.length();

    if(a[lena - 1] == b[0] && b[lenb - 1] == c[0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
    return 0;
}


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


int main(void) {
    int n, k; 
    cin >> n >> k;
    vector<long long> h;
    for (int i = 0; i < n; i++){
        long long t;
        cin >> t;
        h.push_back(t);
    } 

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

    long long mindelta = 10000000001;

    for (int i = 0; i <= n - k; i++) {
        mindelta = min(h[i + k - 1] - h[i], mindelta);
    }

    cout << mindelta << endl;
    

    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main()
{
  long long int N,T;
  cin>>N>>T;
  long long int minimum=2000000000,max=0,ans=1;
  vector <long long int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    minimum=min(A[i],minimum);
    if (A[i]-minimum > max){
      max=A[i]-minimum;
      ans=1;
    }else if(A[i]-minimum==max){
      ans++;
    }
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
	int s, w;
	cin >> s >> w;
	if (s <= w) cout << "unsafe" << endl;
	else cout << "safe" << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<cstring>

using namespace std;

int main()
{
	int n;
	cin>>n;
	int ary[n];
	int i;
	for(i=0;i<n;i++)
	{
		cin>>ary[i];
	}
	int count=0;
	for(i=0;i<n;i++)
	{
		count+=ary[i];
	}
	int p,a,b,temp;
	cin>>p;
	for(i=0;i<p;i++)
	{
		cin>>a>>b;
		temp=count+(b-ary[a-1]);
		cout<<temp<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 764
A,B = map(int,input().split())

goukei = 0
for i in range(2):
    if A>=B:
        goukei = goukei + A
        A = A - 1
        continue
    
    if B > A :
        goukei = goukei + B
        B = B - 1
        continue
        
print(goukei)

Measured memory_bytes: 2940
def resolve():
    A, B, C = list(map(int, input().split()))
    K = int(input())
    cnt = 0
    left = A
    right = B
    while left >= right:
        right *= 2
        cnt += 1
        if cnt > K:
            print("No")
            return
    left = right
    right = C
    while left >= right:
        right *= 2
        cnt += 1
        if cnt > K:
            print("No")
            return
    print("Yes")
    
    
if '__main__' == __name__:
    resolve()

Measured memory_bytes: 61736
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
 
constexpr int INF = 1e9;
 
int main() {
    vector<pll> v(4);
    ll l = 1;
    for(int i = 0; i < 4; ++i) {
        cin >> v[i].first;
        v[i].second = l;
        l *= 2;
    }
    ll N;
    cin >> N;
    N = 4 * N;
    for(auto it = v.begin(); it != v.end() - 1;) {
        if(it->first * ((it + 1)->second / it->second) <= (it + 1)->first) {
            v.erase(it + 1);
        } else {
            it++;
        }
    }
    ll res = 0;
    for(int i = v.size() - 1; i >= 0; --i) {
        res += N / v[i].second * v[i].first;
        N = N % v[i].second;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string n;
	cin>>n;
	ll size=(ll)n.size();
	if(size==1) {
		cout<<stol(n)<<endl;
		return 0;
	}
	ll ans=(size-1)*9;
	ll buf=0;
	REP(i,size) {
		buf+=(n[i]-'0');
		if(n[0]!='0') ans=max(ans,buf-1+(size-1-i)*9);
	}
	ans=max(ans,buf);
	cout<<ans<<endl;
}


Measured memory_bytes: 256