akhauriyash/Code-Regression huggingface dataset:
from collections import deque
from collections import defaultdict

n = int(input())

graph = defaultdict(set)
visited = [1] * 2 + [0] * (n - 1)
ans = [0] * (n + 1)

for _ in range(n - 1):
    u, v, w = map(int, input().split())
    graph[u].add((v, w))
    graph[v].add((u, w))

q = deque([1])

while q:
    curr = q.popleft()
    visited[curr] = 1
    for v, w in graph[curr]:
        if not visited[v]:
            ans[v] = (ans[curr] + w) % 2
            q.append(v)
        else:
            continue

print(*ans[1:], sep="\n")

Measured memory_bytes: 63888
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int main(){
 int a,b,c,x;
  cin>>a>>b>>c>>x;
  int count=0;
  rep(i,a+1){
    rep(j,b+1){
      if(x-500*i-100*j>=0&&(x-500*i-100*j)/50<=c) count++;
    }
  }
  cout<<count<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 100100
//#define NIL -1

int main() {
    LL n;
    LL ans=0;
    cin >> n;
    vector<LL> num_cnt(MAX, 0);
    LL tmp_a;

    for(LL i=0; i<n; i++){
        cin >> tmp_a;
        ans+=tmp_a;
        num_cnt[tmp_a]++;
    }

    LL q;
    cin >> q;
    vector<LL> b(q);
    vector<LL> c(q);

    for(LL i=0; i<q; i++){
        cin >> b[i] >> c[i];
    }

    for(LL i=0; i<q; i++){
        LL tmp=num_cnt[b[i]];
        if(tmp!=0){
            ans=ans+tmp*(c[i]-b[i]);
            num_cnt[c[i]]+=tmp;
            num_cnt[b[i]]=0;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 5616
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		int N = nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < N; i++){
			list.add(nextInt());
		}
		Collections.sort(list, Comparator.reverseOrder());
		int output = list.get(0) / 2;
		for(int i = 1; i < N; i++){
			output += list.get(i);
		}
		myout(output);

	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32888
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <array>

#include <cmath>

using namespace std;

typedef long long LL;

int main() {
	int n;
	// building, floor, room, person
	vector<array<int, 4>> notices;
	int b, f, r, v;

	array<array<array<int, 10>, 3>, 4> buildings{0};
	string sep = "####################";
	
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> b >> f >> r >> v;
		array<int, 4> temp = { b - 1, f - 1, r - 1, v };
		notices.emplace_back(temp);
	}

	for (auto&& notice : notices) {
		buildings[notice[0]][notice[1]][notice[2]] += notice[3];
	}

	for (int j = 0; j < 4; ++j) {
		for (auto&& floor : buildings[j]) {
			for (auto&& room : floor) {
				printf(" %d", room);
			}
			printf("\n");
		}
		if (j != 3) cout << sep << "\n";
	}

	return 0;
}



Measured memory_bytes: 3256
import numpy as np
N, M, C = map(int, input().split(' '))
B = [int(b) for b in input().split(' ')]
results = []
for i in range(N):
    A = [int(a) for a in input().split(' ')]
    result = 0
    for a, b in zip(A, B):
        result += a * b
    result += C
    if result > 0:
        results.append(result)
print(len(results))




Measured memory_bytes: 14552
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const llong MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname);
int range_check(int val, int min, int max) {
	if (val < min) {
		return -1;
	}
	if (val > max) {
		return -1;
	}
	return val;
}
template<class T,class T1>
bool array_find(const T& array, const T1& dst) {
	auto result = find(array.first(), array.end(), dst);
	if (result == array.end()) {
		return false;
	}
	else {
		return true;
	}
}
int main() {
	string str;
	cin >> str;
	str[0] = str[0] + 1;
	cout << str[0] << endl;
	return 0;
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname) {
	ofstream ofs(fname);
	if (ofs.fail()) { cerr << "cannot open file. :" + fname << endl; return -1; }
	for (auto dp_row : dp) {
		for (auto dp_cell : dp_row) {
			ofs << dp_cell << ",";
		}
		ofs << endl;
	}
	ofs.close();
	return 0;
}


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

void Main() {
  string s;
  cin >> s;

  if (s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
  else cout << "Yes" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
n, m = map( int, input().split())
 
a = [ -1 ] * n
 
ret = 0
for _ in range(m):
  s, c = map( int, input().split() )
  if ( not ( a[ s - 1 ] in [ - 1, c ] ) ) or ( ( n > 1 ) and ( s == 1 ) and ( c == 0 ) ):
    ret = -1
    break
  a[ s - 1 ] = c
if ret != -1:
  ret = ""
  for i in range( n ):
    if a[i] == -1:
      if ( n > 1 ) and ( i == 0 ):
        a[ i ] = 1
      else:
        a[ i ] = 0
    ret += str( a[ i ] )
print( ret )

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

using namespace std;

typedef long long ll;

int main()
{ 
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);

int n,i;cin>>n;
string s1,s2;
cin>>s1>>s2;
for(i=0;i<n;i++)cout<<s1[i]<<s2[i];

return 0;
}
     


    

    

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

int main(){
    int n;
    cin >> n;
    ve<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    int max = a[n-1];
    ve<bool> c(max+1,true);
    rep(i,n){
        if(!c[a[i]])continue;
        else{
            for(int j = a[i] * 2; j<=max; j+=a[i]){
                c[j] = false;
            }
        }
    }
    int i = 0;
    while(i<n){
        if(c[a[i]]){
            if(i == n-1){
                ans++;
                break;
            }
            if(a[i] != a[i+1]){
                ans++;
            }else{
                while(i<n){
                    i++;
                    if(a[i] != a[i+1])break;
                }
            }
        }
        i++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
ll a;
cin>>a;
double b;
cin>>b;
int B=b*100+0.5;
cout<<a*B/100<<endl;
  return 0;
}


Measured memory_bytes: 3676
primes = [2]
(3..999999).each do |i|
   isq = Math.sqrt(i)
   prime_flag = 0 #flag 0 means prime
   catch(:exit){
	  primes.each do |p|
		 if p > isq
			break
		 end
		 if i % p == 0
			throw :exit
		 end
	  end
	  primes.push(i)
   }
end
def prime_num(num, primes)
   primes.each_with_index do |each, index|
	  if num < each
		 return index
	  end
   end
   return primes.length
end
while line = gets
   num = line.to_i
   puts prime_num(num,primes)
end

Measured memory_bytes: 6852
import sys
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7

def dfs(state, a):
    if a == N:
        if state == (1 << N) - 1:
            return 1
        else:
            return 0
    if dp[state] != -1:
        return dp[state]
    res = 0
    for i in range(N):
        if ((state >> i) & 1 == 0) and A[a][i] == 1:
            res += dfs(state | (1 << i), a + 1)
            res %= mod
    dp[state] = res
    return dp[state]

N = int(input())
A = []
for i in range(N):
    A.append(list(map(int, input().split(" "))))
dp = [-1 for i in range((1 << N))]

print(dfs(0, 0))


Measured memory_bytes: 123496
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<functional>
#include<deque>
#include<queue>
#include<string>
#include<iostream>
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pb push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<33);
const llint ban = (big<<20);
//14:30~
//国際空港をNこ建設するときの道の最小コストを求める(0)
//N-1このとき　union-find 最小のみち
//N-2この時.... union-findで求められるだろう
int main(void){
	llint n,k,ans=0,i,j;
	scanf("%lld %lld",&n,&k);
	if(n>13){
		ans=((n-3)/11)*5;//割る
		n-=(ans/5)*11;//実質あまり
	}
	for(i=1;i<n-1;i++){
		for(j=1;j<7-1;j++){
			if(((i*7+j+1)*9)%11==k){
				ans++;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool a=false;
char s[500];
int main()
{
	cin>>s;
	for(int i=0;i<strlen(s);i++)
	{
		if(s[i]=='F' && a==true)
		{
			cout<<"Yes";
			return 0;
		}
		if(s[i]=='C')
		{
			a=true;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define ALL(x) x.begin(), x.end()
using namespace std;
using ll=long long;
signed main()
{
	ll N,M; cin >> N >> M;
	ll ans = 0;
	if ( N * 2 > M) {
		ans = M/2;
	} else if (N * 2 == M) {
		ans = M/2;
	} else {
		ans = N;
		M -= N*2;
		ans += M/4;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  long long a,v,b,w,t;
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;
  
  if (a>b){
    if (v*t>=a-b+w*t) cout << "YES";
    else cout << "NO";
  }else if (a<b){
    if (v*t>=b-a+w*t) cout << "YES";
    else cout << "NO";
  }
}


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

public class Main {

	static int lcs(String left,String right){

		int left_len = left.length();
		int right_len = right.length();

		int dp[][] = new int[left_len+1][right_len+1];

		for(int i = 0; i <= left_len; i++){
			for(int k = 0; k <= right_len; k++){
				dp[i][k] = 0;
			}
		}

		for(int i = 0; i < left_len; i++){
			for(int k = 0; k < right_len; k++){
				if(left.charAt(i) == right.charAt(k)){
					dp[i+1][k+1] = dp[i][k]+1;
				}else{
					dp[i+1][k+1] = Math.max(dp[i+1][k], dp[i][k+1]);
				}
			}
		}

		return dp[left_len][right_len];
	}

	public static void main(String args[]){

		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		 try{

			int N = Integer.parseInt(br.readLine());

			String left,right;

			for(int i = 0; i < N; i++){
				left = br.readLine();
				right = br.readLine();

				System.out.printf("%d\n", lcs(left,right));
			}

		 }catch(IOException ex){
			 ex.printStackTrace();
		 }
	}
}

Measured memory_bytes: 63852
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var dic = S
                .GroupBy(elem => elem)
                .ToDictionary(elem => elem.Key, elem => elem.Count(c => c == elem.Key));
            var answer = (long)dic.GetValueOrDefault('R') * dic.GetValueOrDefault('G') * dic.GetValueOrDefault('B');

            foreach (var i in Enumerable.Range(0, N))
            {
                foreach (var j in Enumerable.Range(i + 1, N - i - 1))
                {
                    var k = j + j - i;
                    if (k >= S.Length)
                    {
                        continue;
                    }

                    if (S[i] != S[j] && S[i] != S[k] && S[j] != S[k])
                    {
                        answer--;
                    }
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28568
/*
	Author: Luis Manuel Díaz Barón (LUISMO)
	Problem:
	Online Judge:
	Link:
	Idea:
*/
#include<bits/stdc++.h>
// Types
#define ll long long
#define ull unsigned long long
// IO
#define sf scanf
#define pf printf
#define mkp make_pair
#define fi first
#define se second
#define endl "\n"

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e16 + 3;
const int mod = 1e9 + 7;
const int lim = 2e5 + 2;

string str;
int arr[3];
void solve()
{
	cin >> str;
	for(int i = 0; i < str.size(); i++)
	{
		if(str[i] == 'A') 
			arr[0]++;
		else arr[1] ++;
	}

	// cout << arr[0] << " " << arr[1];

	if(arr[0] == 0 || arr[1] == 0)
		cout << "No";
	else cout << "Yes";
}

void fastIO()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
}

void IO()
{
	if(fopen("d:\\lmo.in","r") != NULL)
	{
		freopen("d:\\lmo.in","r",stdin);
	}
	else if(fopen("/media/Beijing/lmo.in","r") != NULL)
	{
		freopen("/media/Beijing/lmo.in", "r", stdin);
	}
}

int main()
{
	IO();

	fastIO();

	solve();
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    switch(n){
        case 25: puts("Christmas"); break;
        case 24: puts("Christmas Eve"); break;
        case 23: puts("Christmas Eve Eve"); break;
        case 22: puts("Christmas Eve Eve Eve"); break;
        
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//________
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define show(x) cerr << #x << ':' << (x) << endl
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef pair<int,int> Pii;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
inline int updiv(int a, int b){return((a+b-1) / b);}
const int INF = 1 << 29;
const int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
#define Size 1000011
#define NIL -1
//________


signed main()
{
    FAST();
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a += b;
    c += d;
    if(a > c)
        outl("Left");
    else if(a == c)
        outl("Balanced");
    else 
        outl("Right");
}



Measured memory_bytes: 896
n , c = map(int,input().split())
iwaka = [list(map(int,input().split())) for i in range(c)]
masu = [list(map(int,input().split())) for i in range(n)]
amari = [{} for i in range(3)]

for i in range(n):
    for j in range(n):
        amari[(i+j)%3][masu[i][j]] = amari[(i+j)%3].get(masu[i][j],0) + 1

kouho = []
for i in range(c):
    for j in range(c):
        for k in range(c):
            if i != j and j != k and k != i:
                kouho.append((i+1,j+1,k+1))
ans = 10**9
for p in kouho:
    cou = 0
    for i in range(3):
        for k , v in amari[i].items():
            cou += iwaka[k-1][p[i]-1]*v
    ans = min(ans,cou)
print(ans)


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

using namespace std;
long n,t,a[12],cs,c,d,m,kq;
int main()
{
    cin >> t;
    while (t--){
        cin >> m >> n;
        cs=0;c=n;kq=0;d=0;
        for (int i=1;i<=10;i++) a[i]=0;
        if (m==1){
            cout << n << endl;
            continue;
        }
        while (c!=0){
            a[++cs]=c%2;
            c=c/2;
        }
        for (int i=7;i>=1;i--){
            if (a[i]==0) d=d+pow(2,i-1);
        }
        if (m%2==0) kq=127*(m-1)+d;
        else kq=127*(m-1)+n;
        cout << kq << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# abc104_a.py
# https://atcoder.jp/contests/abc104/tasks/abc104_a

# A - Rated for Me /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# プログラミングコンペティションサイト AtCode は、プログラミングコンテストを定期的に開催しています。
# AtCode で次に開催されるコンテストは ABC と呼ばれ、レーティングが 1200未満の参加者のレーティングが変動します。
# その次に開催されるコンテストは ARC と呼ばれ、レーティングが 2800未満の参加者のレーティングが変動します。
# そのさらに次に開催されるコンテストは AGC と呼ばれ、すべての参加者のレーティングが変動します。
# 高橋くんの AtCode でのレーティングは Rです。彼のレーティングが変動する次のコンテストは何でしょうか？

# 制約
#     0≤R≤4208
#     Rは整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# R

# 出力
# 高橋くんのレーティングが変動する次のコンテストの名称（ABC, ARC, AGC のいずれか）を出力せよ。

# 入力例 1
# 1199

# 出力例 1
# ABC

# 1199は 1200未満なので ABC でレーティングが変動します。

# 入力例 2
# 1200

# 出力例 2
# ARC

# 1200は 1200 未満ではないので ABC ではレーティングが変動しませんが、2800未満ではあるので ARC でレーティングが変動します。

# 入力例 3
# 4208

# 出力例 3
# AGC


def calculation(lines):
    R = int(lines[0])
    if R < 1200:
        ret = 'ABC'
    elif R < 2800:
        ret = 'ARC'
    else:
        ret = 'AGC'
    return [ret]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['1199']
        lines_export = ['ABC']
    if pattern == 2:
        lines_input = ['1200']
        lines_export = ['ARC']
    if pattern == 3:
        lines_input = ['4208']
        lines_export = ['AGC']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')


# 起動処理
if __name__ == '__main__':
    main()


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

int main() {
	/*
	ifstream ifs("test.txt");
	char str[256];

	if (ifs.fail()) {
		cerr << "失敗" << endl;
		return -1;
	}
	while (ifs.getline(str, 256 - 1)) {
		cout << "[" << str << "]" << endl;
	}
	*/

	int a, b;

	cin >> a >> b;

	cout << a * b << " " << 2 * a + 2 * b << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

int n, m, x[112345], y[112345];
V g[112345];
int dist[112345];

int dfs(int i)
{
    if (dist[i] != -1)
        return dist[i];

    if (!g[i].size())
        return 0;

    int res = 0;

    REP(j, g[i].size())
    res = max(res, dfs(g[i][j]));

    dist[i] = res + 1;

    return res + 1;
}

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

    cin >> n >> m;

    REP(i, m)
    {
        cin >> x[i] >> y[i];

        g[x[i]].push_back(y[i]);
    }

    memset(dist, -1, sizeof(dist));

    int res = 0;

    for (int i = 1; i <= n; i++)
        res = max(res, dfs(i));

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 9344
/*

*/
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<cmath>
#include<bitset>
using namespace std;
#define ll long long
#define N 100003
#define INF  0x3f3f3f3f3f3f3f3f
#define mod 998244353
#define mkp make_pair
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
//#define _DEBUG_
int n, a[N];
struct point{
	int x, y;
};

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int i, j, t, cnt = 0;
	int h, w, k, n;
	char c;
	point black[37];
	#ifdef _DEBUG_
	freopen("C.in", "r", stdin);
	//freopen(".out", "w", stdout);
	#endif
	cin>>h>>w>>k;
	for(i=0; i<h; i++)
		for(j=0; j<w; j++){
			cin>>c;
			if(c == '#'){
				black[cnt].x = i;
				black[cnt++].y = j;
			}
		}
	int ret = 0, cnt1;
	for(i=0; i<(1<<h); i++)
		for(j=0; j<(1<<w); j++){
			cnt1 = cnt;
			for(n=0; n<cnt; n++){
				if(((i>>black[n].x) & 1) || ((j>>black[n].y) & 1))
					cnt1--;
			}
			if(cnt1 == k)
				ret ++;
		}
	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
main()
{
  int i;
  int j;
  int length;
  int key;
  int *buf;

  scanf("%d",&length);

  buf = (int *)malloc(sizeof(int)*length);

  for(i = 0;i < length;i++)
    {
      scanf("%d",&buf[i]);
    }

  for(i = 1;i < length;i++)
    {
      for(j = 0;j < length;j++)
	{
	  printf("%d",buf[j]);
	  if(j != length - 1)
	    {
	      printf(" ");
	    }
	}
      printf("\n");
      key = buf[i];
      j = i - 1;
      while(j >= 0 && buf[j] > key)
	{
	  buf[j + 1] = buf[j];
	  j--;
	  buf[j + 1] = key;
	}
    }
  for(j = 0;j < length;j++)
    {
      printf("%d",buf[j]);
      if(j != length - 1)
	{
	  printf(" ");
	}
    }
  printf("\n");
  return 0;
}

Measured memory_bytes: 604
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <list>
#include <string>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

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

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

    if (A == B && B == C)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void cheatsheet()
{
    // loop
    // vector<int> vec(10);
    vector<int> vecloop;
    REP(i, 10)
    {
        vecloop.push_back(i);
    }

    // swap
    int a = 1;
    int b = 5;
    swap(a, b); // -> a = 5, b = 1

    // sort
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    sort(arr, arr + 9, greater<int>()); // 9 8 7 6 5 4 3 2 1

    // lower
    vector<int> vec(arr, end(arr));
    sort(vec.begin(), vec.end());
    cout << lower_bound(vec.begin(), vec.end(), 2)[0]; // 2

    // map
    map<Pll, ll> m;
    m[Pll(10, 100)] = 100;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int main(){
  char buf[312];
  while(~scanf("%s",buf)){
    printf("%d\n",
	   min(min(count(buf,buf+312,'K'),count(buf,buf+312,'U')),
	       min(count(buf,buf+312,'P'),count(buf,buf+312,'C'))
	       ));
  }
}

Measured memory_bytes: 1140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

ll L[110];

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i) cin >> L[i];
	int ans=0;
	for(int i=0; i<N; ++i){
	    for(int j=i+1; j<N; ++j){
	        for(int k=j+1; k<N; ++k){
	            if(L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i]){
	                if(L[i]<L[j]+L[k] && L[i]>abs(L[j]-L[k])) ++ans;
	            }
	        }
	    }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
//#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
#define res resize
//CF408C
const llint mod=1000000007;
const llint big=1e18;
inline int sa(int a,int b,int c){
	return max(a,max(b,c))-min(a,min(b,c));
}
int main(void){
	llint N,ans=-big,H,W,i,j,q,gen;
	vector<llint> a,mae,usi;
	priority_queue<llint> qe;
	scanf("%lld",&N);
	a.res(3*N);
	for(i=0;i<N*3;i++){
		scanf("%lld",&q);
		a[i]=q;
	}
	
	usi.pub(0);
	mae.pub(0);
	gen=0;
	for(i=0;i<N;i++){
		qe.push(-a[i]);
		mae[0]+=a[i];
	}
	for(i=N;i<N*2;i++){
		qe.push(-a[i]);
		mae.pub(mae.back()+qe.top()+a[i]);
		qe.pop();
	}
	while(!qe.empty()){qe.pop();}
	for(i=3*N-1;i>=2*N;i--){
		qe.push(a[i]);
		usi[0]-=a[i];
	}
	for(i=2*N-1;i>=N;i--){
		qe.push(a[i]);
		usi.pub(usi.back()+qe.top()-a[i]);
		qe.pop();
	}
	for(i=0;i<=N;i++){
		ans=max(ans,mae[i]+usi[N-i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6516
flag = 0
a = []
for x in range(3):
    a +=list(map(int,input().split()))
if a.count(1) == 2:
    flag += 1
if a.count(2) == 2: 
    flag += 1
if a.count(3) == 2:
    flag += 1
if a.count(4) == 2:
    flag += 1
if flag == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#define DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using ll = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto chmin = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto chmax = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif
 
template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }
 
template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
 
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, q; std::cin >> n >> q;
  vector<int> ac(n, false);
  vector<int> wa(n, 0);
  while(q--) {
    int p; string s; cin >> p >> s;
    p--;
    if (s=="AC") {
      ac[p] = true;
    } else {
      if (!ac[p]) {
        wa[p]++;
      }
    }
  }
  debug(ac,wa);
 
  int ac_ = std::accumulate(all(ac), 0);
  int wa_ = 0;
  for(int i = 0;i<n;i++){
    if (ac[i]) {
      wa_ += wa[i];
    }
  }
  std::cout << ac_ << " " << wa_ << std::endl;
  return 0;
}

Measured memory_bytes: 3968
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] h = new int[n];
		int[] max = new int[n]; 
		for(int i = 0; i < n; i++) {
			h[i] = scan.nextInt();
			max[i] = 0;
		}
		
		for(int i = 0; i < m; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();
			max[a-1] = Math.max(max[a-1], h[b-1]);
			max[b-1] = Math.max(max[b-1], h[a-1]);
		}
		
		int ans = 0;
		for(int i = 0; i < max.length; i++) {
			if(h[i] > max[i]) {
				ans++;
			}
		}
		System.out.print(ans);
		
	}

}


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

using namespace std;

int main()
{
	int N , M;
	char C;
	cin >> N >> M;
	vector<vector<pair<int , int>>>data(N);
	for(size_t i = 0; i < M; i++)
	{
		int a , b , c , d;
		cin >> a >> C >> b >> C >> c >> C >> d;
		a--; b--;
		data[a].push_back(make_pair(b , c));
		data[b].push_back(make_pair(a , d));
	}
	int x1 , x2 , y1 , y2;
	cin >> x1 >> C >> x2 >> C >> y1 >> C >> y2;
	x1--; x2--;
	vector<int>cost1(N , INT_MAX / 6);
	auto cost2 = cost1;
	priority_queue<pair<int , int> , vector<pair<int , int>> , greater<pair<int , int>>>que1 , que2;
	que1.push(make_pair(0 , x1));
	cost1[x1] = 0;
	while(que1.size())
	{
		auto now = que1.top(); que1.pop();
		if(now.second == x2)break;
		for(auto x : data[now.second])
		{
			if(cost1[x.first] > now.first + x.second)
			{
				cost1[x.first] = now.first + x.second;
				que1.push(make_pair(cost1[x.first] , x.first));
			}
		}
	}
	y1 -= cost1[x2];
	que2.push(make_pair(0 , x2));
	cost2[x2] = 0;
	while(que2.size())
	{
		auto now = que2.top(); que2.pop();
		if(now.second == x1)break;
		for(auto x : data[now.second])
		{
			if(cost2[x.first] > now.first + x.second)
			{
				cost2[x.first] = now.first + x.second;
				que2.push(make_pair(cost2[x.first] , x.first));
			}
		}
	}
	y1 -= cost2[x1];
	y1 -= y2;
	cout << y1 << endl;
}

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

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

    vector<int> xl, xr;
    int xi;
    for (int i = 0; i < N; i++)
    {
        cin >> xi;
        if (xi < 0)
        {
            xl.push_back(abs(xi));
        }
        else if (xi > 0)
        {
            xr.push_back(xi);
        }
        else
        {
            K--;
        }
    }
    reverse(xl.begin(), xl.end());

    if (K == 0)
    {
        cout << 0 << endl;
        return 0;
    }

    int res = INT_MAX;
    for (unsigned int nl = 0; nl <= (unsigned int)K; nl++)
    {
        unsigned int nr = K - nl;
        if (nl > xl.size() || nr > xr.size())
        {
            continue;
        }
        int l = (nl == 0) ? 0 : xl.at(nl - 1);
        int r = (nr == 0) ? 0 : xr.at(nr - 1);
        res = min(res, min(2 * l + r, l + 2 * r));
    }
    cout << res << endl;
}

Measured memory_bytes: 1020
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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;}



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

  ll H , W; cin >> H >>  W;
  vector<string> before;
  
  rep(i,H){
    string inp; cin >> inp;
    before.pb(inp);
  }

  rep(i,H){
    cout << before[i] << endl;
    cout << before[i] << endl;
  }
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n,m;

struct edge { int v,w,nxt; } e[N<<1];
int head[N];
void addEdge(int u,int v,int w) {
	static int cnt=0;
	e[++cnt]=(edge){v,w,head[u]},head[u]=cnt;
}

int szn,szm,flag;
int vis[N],col[N],cnt[3];
int nxt(int c,int w) { return (c+w+3)%3; }
void dfs(int u,int c) {
	vis[u]=1,col[u]=c,++cnt[c],++szn;
	for (int i=head[u];i;i=e[i].nxt) {
		int v=e[i].v,w=e[i].w;
		if (w==1) ++szm;
		if (!vis[v]) dfs(v,nxt(c,w));
		else if (col[v]!=nxt(c,w)) flag=1;
	}
}

int main() {
	n=read(),m=read();
	for (int i=1;i<=m;++i) {
		int u=read(),v=read();
		addEdge(u,v,1),addEdge(v,u,-1);
	}
	ll ans=0;
	for (int i=1;i<=n;++i) {
		if (vis[i]) continue;
		szn=szm=cnt[0]=cnt[1]=cnt[2]=flag=0,dfs(i,0);
		if (flag) ans+=1ll*szn*szn;
		else if (cnt[0]&&cnt[1]&&cnt[2])
			ans+=1ll*cnt[0]*cnt[1]+1ll*cnt[1]*cnt[2]+1ll*cnt[2]*cnt[0];
		else ans+=szm;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6912
N, M = map(int, input().split())
A = [[1, int(i)] for i in input().split()]
for i in range(M):
    b, c = map(int, input().split())
    A.append([b, c])

total = 0
D = []
A = sorted(A, key=lambda x:x[1], reverse=True)
for b, c in A:
    if len(D) >= N:
        break
    D.extend([c]*b)
print(sum(D[:N]))


Measured memory_bytes: 38520
#!/usr/bin/env pypy3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import math
from collections import defaultdict
pc = True
n = int(input())
a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)

LIMIT=max(a)
minPrime = [0]*(LIMIT+1)
minPrime[1] = 1
def make():
    for i in range(2,LIMIT+1):
        if minPrime[i] == 0:
            minPrime[i] = i
            #print(i)
            for j in range(i+i,LIMIT+1,i):
                #print(i,j)
                if minPrime[j] == 0:
                    minPrime[j] = i
make()
# class Sieve_of_Eratosthenes:
#     def __init__(self, N):
#         self.sieve = [-1] * (N+1)

#         for i in range(2,N+1):
#             if self.sieve[i] == -1:
#                 for j in range(1,1+N//i):
#                     self.sieve[i*j] = i

#     def isprime(self, num):
#         if num <= 1:
#             return False
#         else:
#             return self.sieve[num] == num

#     def factorization(self, num):
#         ret = set([])
#         while num != 1:
#             div = self.sieve[num]
#             ret.add(div)
#             num //= div
#         return ret

def factrial(N):
    ret = set()
    while 1 != N:
        ret.add(minPrime[N])
        N = N//minPrime[N]
    if N != 1:
        ret.add(N)
    return ret

#sofe = Sieve_of_Eratosthenes(M)
ddic = defaultdict()
judge = set([])

for i in a:
    if not pc:
        break
    #asf = sofe.factorization(i)
    asf = factrial(i)

    if judge & asf != set():
        pc = False
    judge |= asf
if pc:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")
# import sys,collections

# N = int(sys.stdin.readline())
# #a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = list(map(int,input().split()))

# import math

# # def factrial(N):
# #     ret = []
# #     while minPrime[N] != N:
# #         ret.append(minPrime[N])
# #         N = N//minPrime[N]
# #     if N != 1:
# #         ret.append(N)
# #     return ret

# def factrial(N):
#     ret = set()
#     while 1 != N:
#         ret.add(minPrime[N])
#         N = N//minPrime[N]
#     if N != 1:
#         ret.add(N)
#     return ret

# for i in range(N):
#     acc = math.gcd(acc,a[i])
# if acc != 1:
#     print("not coprime")
#     exit()

# pairwise = True
# p = set() #all prime
# for e in a:
#     if not pairwise:
#         break
#     f = factrial(e)
#     if p & f != set():
#         pairwise = False
#         print("setwise coprime")
#         exit(0)
#     p = p | f

# if pairwise:
#     print("pairwise coprime")
# else:
#     print("setwise coprime")


Measured memory_bytes: 187136
#include <iostream>

using namespace std;

int N;
int p[200100];

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int x; cin >> x;
        p[x-1] = i;
    }

    int ans = 1;
    int cres = 1;
    for (int i = 1; i < N; i++)
    {
        if (p[i] > p[i-1])
            cres++;
        else
            cres = 1;
        ans = max (ans, cres);
    }
    cout << N - ans << "\n";
}

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

using namespace std;
using ll = long long;

template <int T_MOD>
struct ModInt {
  static constexpr int MOD = T_MOD;
private:
  using ll = long long;
  int v;

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

public:

  ModInt() : v(0) {}
  template<class T> ModInt(T v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
  explicit operator int() const { return v; }
  friend std::ostream& operator << (std::ostream& out, const ModInt& n) { return out << int(n); }
  friend std::istream& operator >> (std::istream& in, ModInt& n) { ll v_; in >> v_; n = ModInt(v_); return in; }
  friend bool operator == (const ModInt& a, const ModInt& b) { return a.v == b.v; }
  friend bool operator != (const ModInt& a, const ModInt& b) { return a.v != b.v; }

  ModInt inv() const {
    ModInt res;
    res.v = minv(v, MOD);
    return res;
  }

  ModInt neg() const {
    ModInt res;
    res.v = v ? MOD - v : 0;
    return res;
  }

  ModInt operator- () const {
    return neg();
  }

  ModInt operator+ () const {
    return ModInt(*this);
  }

  ModInt& operator ++ () {
    v++;
    if (v == MOD) v = 0;
    return *this;
  }

  ModInt& operator -- () {
    if (v == 0) v = MOD;
    v --;
    return *this;
  }

  ModInt& operator += (const ModInt& o) {
    v += o.v;
    if (v >= MOD) v -= MOD;
    return *this;
  }

  ModInt& operator -= (const ModInt& o) {
    v -= o.v;
    if (v < 0) v += MOD;
    return *this;
  }

  ModInt& operator *= (const ModInt& o) {
    v = int(ll(v) * ll(o.v) % MOD);
    return *this;
  }

  ModInt& operator /= (const ModInt& o) {
    return *this *= o.inv();
  }

  friend ModInt operator ++ (ModInt& a, int) { ModInt r = a; ++a; return r; }
  friend ModInt operator -- (ModInt& a, int) { ModInt r = a; --a; return r; }
  friend ModInt operator + (const ModInt& a, const ModInt& b) { return ModInt(a) += b; }
  friend ModInt operator - (const ModInt& a, const ModInt& b) { return ModInt(a) -= b; }
  friend ModInt operator * (const ModInt& a, const ModInt& b) { return ModInt(a) *= b; }
  friend ModInt operator / (const ModInt& a, const ModInt& b) { return ModInt(a) /= b; }  
};

const int mod = 1000000007;
using Mint = ModInt<mod>;

Mint power(Mint x, int p) {
  Mint ans = Mint(1);
  while(p) {
    if(p & 1) {
      ans *= x;
    }
    x *= x;
    p >>= 1;
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  auto Get = [&](int n, int k) {
    Mint res = 1;
    k = min(k, n - k);
    for(int i = 0; i < k; ++i) {
      res *= Mint(n - i);
      res /= (i + 1);
    }
    return res;
  };
  int n, a, b;
  cin >> n;
  cin >> a >> b;
  Mint res = power(2, n) - 1;
  cout << res - Get(n, a) - Get(n, b) << '\n';
  return 0;
}


Measured memory_bytes: 384
int n,c,dp[4010][4010];
char s[2010];
int main(){
	scanf("%s",s);
	n=strlen(s);
	dp[0][0]=1;
	for(int i=0;i<2*n;i++){
		if(i<n)c+=s[i]-48;
		for(int j=0;j<4005;j++)if(j<=c&i+1-j<=2*(i+1<n?i+1:n)-c){
			if(j)dp[i+1][j]=(dp[i][j]+dp[i][j-1])%998244353;
			else dp[i+1][j]=dp[i][j];
		}
	}
	printf("%d",dp[2*n][c]);
}

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

int main() {
  string s;
  cin >> s;
  int a = 0;
  rep(i, s.size()) {
    if (a == 1 && s[i] == 'F') a++;
    if (a == 0 && s[i] == 'C') a++;
  }
  if (a == 2) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
int main(void){
    // Your code here!
    char NUM[10000]={0};
    int i, num, sum;
    
    while(1){
        sum=0;
        for(i=0; i<=10000; i++){
            scanf("%c", &NUM[i]);
            if (NUM[i]=='\n') break;
            if (NUM[0]=='0') return 0;
            num = NUM[i]-'0';
            sum += num;
            //printf("num=%d, sum=%d\n", num, sum);
        }
        printf("%d\n", sum);
    }
    
    
    
}



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

int counter = 0;
rep(i,n-2)
{
    if(str.substr(i,3)=="ABC") counter++;
}

cout << counter << endl;

return 0;
}

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

int main() {
  int n;
  cin >> n;
  int min = n+1;
  int count = 0;
  for(int i=0; i<n; i++) {
    int p;
    cin >> p;
    if(p < min) {
      min = p;
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 384
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
oddA = A[0::2]
evenA = A[1::2]

oc = Counter(oddA)
omode = oc.most_common()
ec = Counter(evenA)
emode = ec.most_common()
if omode[0][0] != emode[0][0]:
    print(n-omode[0][1]-emode[0][1])
else:
    if len(omode) == 1:
        omode.append((0, 0))
    if len(emode) == 1:
        emode.append((0, 0))
    a = n-omode[0][1]-emode[1][1]
    b = n-omode[1][1]-omode[0][1]
    print(min(a, b))

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    vector<int> a(5);
    int ans = 0, mi = INF;
    for(int i = 0; i < 5; ++i){
        cin >> a[i];
        ans += CEIL(a[i], 10) * 10;
        if(a[i] % 10 != 0) mi = min(mi, a[i] % 10);
    }
    if(mi == INF) mi = 10;
    ans -= 10 - mi;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

 /* Coding Space*/
int main(){
  ll a,b; cin >> a>> b;
  cout << (b*1900+(a-b)*100)*pow(2,b,LLINF) << endl;
  SHOW((b*1900+(a-b)*100),pow(2,b,LLINF));
}

Measured memory_bytes: 256