akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
#define Rajpoot ios_base::sync_with_stdio(0);   cin.tie(0);  cout.tie(0);
#define ll long long
#define loo(i,n) for(i=0;i<n;i++)
#define go(i,sp)  for(auto i=sp.begin();i!=sp.end();i++)
#define pb push_back
#define lb lower_bound
#define mo 1000000007
#define pi 3.14159265358979323846264338327950288419716939937510582
#define exp 2.71828182845904523536028747135266249775724709369995957
#define endl "\n"
using namespace std;



int main() 
{
   Rajpoot
      //    freopen("input.txt","r",stdin);
      // freopen("output.txt","w",stdout);

   // int t; cin>>t; 
    int t=1;
    while(t--)
    { 
        ll n; cin>>n;  
        if(n%2==0)  cout<<"-1";
        else
        {
            ll s=7; ll c=1;  ll u=10000000;
            ll p=10;
            while(u--)
            {
               if(s%n==0){ s=-1; break;  }
               c++;
               
               s=(s%n)*p +7;   
               //cout<<s<<"  ";
            }
            
            if(s==-1)  cout<<c;
            else cout<<"-1";
        }
    }    

	return 0;
}

Measured memory_bytes: 3648
import sys
from collections import deque
input = sys.stdin.readline

H, W = map(int, input().split())

m = [[0 for _ in range(W)] for _ in range(H)]
black = []
for i in range(H):
    # m.append(list(map(lambda x: 0 if x=="#" else 1, input()))）
    for j, c in enumerate(input()):
        if c == "#":
            m[i][j] = 1
            black.append((i, j, 0))

# print(m)
# print(root)

queue = deque(black)
queue_append = queue.append
ans = 0
while queue:
    p = queue.popleft()
    if ans < p[2]:
        ans += 1
    for i, j in ((-1, 0), (1, 0), (0, 1), (0, -1)):
        i_next_p, j_next_p = (p[0] + i, p[1] + j)
        if (0 <= i_next_p < H) and (0 <= j_next_p < W):
            if not m[i_next_p][j_next_p]:
                m[i_next_p][j_next_p] = 1
                queue_append((i_next_p, j_next_p, ans+1))
print(ans)


Measured memory_bytes: 138712
from sys import stdin
input = lambda: stdin.readline().rstrip()
na, nb, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
min_a = min_b = 10**9
for i in range(na):
    min_a = min(min_a, a[i])
for i in range(nb):
    min_b = min(min_b, b[i])
ans = min_a + min_b
for i in range(m):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    ans = min(ans, a[x] + b[y] - c)
print(ans)


Measured memory_bytes: 24720
# https://atcoder.jp/contests/abc080/tasks/abc080_d
# 縦時系列の番組表の四角を横にスライドさせてmaxを求めれば良い
# つまりimos法
# ただし予約タイムが存在するので、開始時刻を-1してあげる
# また同じチャンネルで連続するところは連結してしまおう


class Imos1d:
    def __init__(self, N: int):
        '''
        [0]*N の配列に対して、区間の加算を管理する。
        '''
        self.ls = [0] * (N + 1)  # 配列外参照を防ぐため多くとっておく
        self.N = N

    def add(self, l, r, x):
        '''
        [l,r)の区間にxを足し込む O(1)
        '''
        self.ls[l] += x
        self.ls[min(r, self.N)] -= x  # 配列外参照は余分に作ったところにまとめておく(どうせ使わない)

    def get_result(self):
        '''
        O(N) かけて、区間の加算結果を取得する
        '''
        from itertools import accumulate
        return list(accumulate(self.ls[:-1]))


import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


N, C = read_ints()
from collections import defaultdict, Counter
STbyC = defaultdict(lambda: [])
for n in range(N):
    s, t, c = read_ints()
    STbyC[c].append(s)
    STbyC[c].append(t)

kukan = []
for c in STbyC:
    tmp = Counter(STbyC[c])
    tmp = [k for k, v in tmp.items() if v == 1]  # 二回出現したやつというのは連続録画
    kukan.extend(sorted(tmp))


imos = Imos1d(10 ** 5 + 1)
for i in range(0, len(kukan), 2):
    j = i + 1
    imos.add(kukan[i] - 1, kukan[j], 1)


# print(imos.get_result()[:20])
print(max(imos.get_result()))


Measured memory_bytes: 20548
import sys
sys.setrecursionlimit(10**6)#再帰を使うときはこれをする（今回はN=10で深さ110000程度なので10**6)
def dfs(s,mx):
    if len(s) == n:
        print(s)
        return
    for i in range(ord("a"),ord(mx)+1):
        c = chr(i)
        if c == mx:dfs(s+c,chr(ord(mx)+1))#aから一番遠いアルファベットを語尾につけたら、その次までok
        else:dfs(s+c,mx)
n = int(input())
dfs("","a")


Measured memory_bytes: 4340
import java.util.*;

public class Main {

	public static void main(String[] args) {

		 Scanner scan = new Scanner(System.in);
		 int a = scan.nextInt();
		 int b = scan.nextInt();
		 
		 int A = a + b;
		 int B = a - b;
		 int C = a * b;
		 int x = Math.max(A, B);
		 System.out.println(Math.max(x, C));
		
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define inf 0x3f3f3f3f
using namespace std;

const int maxn = 1000050;

int n,m;
int f[maxn];

int main(){
    cin>>n;
    FOR(i,1,n)scanf("%d",&f[i]);
    sort(f+1,f+1+n);
    if(n%2)puts("0");
    else cout<<f[n/2+1]-f[n/2]<<endl;
}


Measured memory_bytes: 640
M=1000003
f=[1]
for i in range(1,M):f.append(f[i-1]*i%M)
for _ in'_'*int(input()):
	x,d,n=map(int,input().split())
	t=x*pow(d,M-2,M)%M
	if d==0:
		print(pow(x,n,M))
	elif t==0 or t+n>M:
		print(0)
	else:
		print(f[t+n-1]*pow(f[t-1],M-2,M)*pow(d,n,M)%M)


Measured memory_bytes: 43284
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = unsafe { _read_value!(_scanned, $t) };
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

fn main() {
    input! {
        s: _bytes,
    }
    let mut stack = vec![];
    let mut r = 0;
    for b in s {
        if stack.last().map_or(false, |&x| x != b) {
            stack.pop();
            r += 2;
        } else {
            stack.push(b);
        }
    }
    println!("{}", r);
}


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

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

  string s;
  cin >> s;
  int count = 0, l = s.size();
  rep(i, l / 2)
  {
    if (s[i] != s[l - 1 - i])
    {
      ++count;
    }
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;
using static ConsoleApp.Util;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            
            var array = ReadLine().Split(' ');
            var n = long.Parse(array[0]);
            var k = long.Parse(array[1]);

            array = ReadLine().Split(' ');
            var h = array.Select(x=>long.Parse(x)).ToArray();
            
            //dpテーブル
            long[] dp = new long[100100];
            for(int i = 0;i < n;i++ )
                dp[i] = long.MaxValue;

            dp[0] = 0;
            
            for(int i = 0;i < n;i++){
                
                for(int j = 1;j <= k ;j++){
                    if(i+j >= n){
                        break;
                    }
                    ChMin(ref dp[i+j],Math.Abs(h[i]-h[i+j])+dp[i]);
                }

            }


            WriteLine(dp[n-1]);
        }
    }


    static class Util{
        public static void ChMin(ref long a,long b){
            
            if(a > b){
                a = b;
            }
        }

        public static void ChMax(ref long a,long b){
            if(a < b){
                a = b;
            }
        }
    }
}


Measured memory_bytes: 21344
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

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

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  int n; cin>>n;
  vi v(n);
  ll sum = 0;
  map<int,int> m;
  for(int i=0;i<n;++i){ cin>>v[i]; sum += v[i]; m[v[i]]++;}
  int q; cin>>q;
  vector<ll> ans(q);
  for(int i=0;i<q;i++){
    int a, b;
    cin>>a>>b;
    int qtd = m[a];
    sum += (b-a)*qtd;
    ans[i] = sum;
    m[a] = 0; m[b] += qtd;
  }
  for(int i=0;i<q;i++)
    cout<<ans[i]<<endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}


Measured memory_bytes: 8660
def check(s):
    if len(s)%2 == 1:
        return False
    if s[len(s)//2:] == s[:len(s)//2]:
        return True
    else:
        return False
 
S = input()
 
for i in reversed(range(1,len(S))):
    if check(S[:i]):
        print(i)
        break

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String str=scan.next();
		int maru=0;
		for(int i=0;i<str.length();i++) {
			char ch=str.charAt(i);
			if(ch=='o') {
				maru++;
			}
		}
		maru+=(15-str.length());
		if(maru>=8) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}
}


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

int mod = 1000000007;
int dp[100005];

int main() {
    int N, M; cin >> N >> M;
    vector<int> S(N+1);
    rep(i, M){
        int a; cin >> a;
        S[a] = 1;
    }

    dp[0] = 1;
    for (int i = 0; i < N; i++){
        if(S[i+1] != 1){
            dp[i+1] += dp[i];
            dp[i+1] %= mod;
        }
        if(S[i+2] != 1){
            dp[i+2] += dp[i];
            dp[i+2] %= mod;
        }
    }

    cout << dp[N] << endl;

    return 0;
}

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

using namespace std;

#define endl "\n"
typedef long long int ll;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}

//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;

ll INF = 1e10;
int MOD = 1e9+7;

int n,k;
int arr[101];
vector<bool> dp;

int main(){
    #ifndef ONLINE_JUDGE
        freopen("debug.txt", "w", stderr);
    #endif
    fastio();
    cin>>n>>k;
    for(int i=0;i<n;++i) cin>>arr[i];
    dp.resize(k+1); //at ith stones, who will win
    for(int i=0;i<n;++i) dp[arr[i]] = 1;
    for(int i=0;i<=k;++i)
        for(int j=0;j<n;++j)
            if(i>=arr[j])
                dp[i] = dp[i] || !dp[i-arr[j]];
    cout<<(dp[k] ? "First" : "Second"); 
    return 0;
}


Measured memory_bytes: 3656
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	static class Task {
		static final long MOD = (long) 1e9 + 7;

		public void solve() {
			Scan sc = new Scan();
			long a = sc.scanLong();
			long b = sc.scanLong();
			long x = sc.scanLong();
			long tillB = (b / x);
			if (a == 0) {
				System.out.println(tillB+1);
				return;
			}
			long tillA = ((a - 1) / x);
			System.out.println(tillB - tillA);
		}
	}

	static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


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

typedef long long ll;
typedef long double ld;

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    char a, b;

    cin >> a >> b;

    cout << (a == b ? 'H' : 'D') << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main( void ) {
	int i, j, tmp, cnt, nData, data[ 100 ];

	while ( cnt = 0, scanf( "%d", &nData ), nData ) {
		for ( i = 0; i < nData; i++ )
			scanf( "%d", &data[ i ] );

		for ( i = 0; i < nData - 1; i++ )
			for ( j = nData - 1; j > i; j-- )
				if ( data[ j - 1 ] > data[ j ] ) {
					tmp = data[ j - 1 ];
					data[ j - 1 ] = data[ j ];
					data[ j ] = tmp;

					cnt++;
				}

		// for ( i = 0; i < nData; i++ )
		// 	printf( "%d ", data[ i ] );
		// printf( "\b\n%d\n", cnt );
		printf( "%d\n", cnt );
	}

	return 0;
}

Measured memory_bytes: 600
n=int(input())
li=list(map(int,input().split()))
li[0]-=1
for i in range(1,n-1):
    if li[i]>=li[i+1] and li[i]>li[i-1]:
        li[i]-=1
li2=sorted(li)
if li==li2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20688
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int cnt[26];
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif

  // For the most-appearing charcter, if there are two different characters after it(excluding the last one),
  // there will be no palindromes as substring.
  // So the answer is the_number <= ceil(string_length)
  // 
  // For 'a' as examples:
  // abcabca
  // abcabc
  // abcab
  // abca

  string s;
  cin >> s;
  for(char c: s) {
    cnt[c - 'a']++;
  }
  int n = s.size();
  int max_char = *(MAX(cnt, cnt + 26));
  if(n == 1 || (max_char <= (n + 3 - 1) / 3))
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}



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

int main(){
	int k;
	int ans=0;
	std::vector<int> point{ 1, 0, -1};
	std::vector<int> n(3);

	std::cin >> n[0] >> n[1] >> n[2] >> k;
	for(int i=0; i<3; i++){
		if(k==0){
			std::cout << ans << std::endl;
			return 0;
		}
		if(k > n[i]){
			ans += point[i]*n[i];
			k -= n[i];
		}
		else{
			ans += point[i]*k;
			std::cout << ans << std::endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3512
s = gets.chomp
t = gets.chomp
i = 0
check1 = true
stack = []
while i <= s.length - t.length
  t.length.times do |j|
    unless s[i+j] == "?" || s[i+j] == t[j]
      check1 = false
      break
    end
  end
  if check1
    stack << s.dup
    stack.last[i, t.length] = t
    s.length.times do |j|
      stack.last[j] = "a" if stack.last[j] == "?"
    end
  end
  check1 = true
  i += 1
end
puts stack == [] ? "UNRESTORABLE" : stack.sort.first

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

//#include "All.h"

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

int N;
string S[100010];
int ans[10] = {};

int main() {
    cin >> N;
    rep(i, N) cin >> S[i];
    rep(i, N) {
        if (S[i] == "AC") {
            ans[0]++;
        }
        else if (S[i] == "WA") ans[1]++;
        else if (S[i] == "TLE") ans[2]++;
        else if (S[i] == "RE") ans[3]++;
    }
    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;
}

Measured memory_bytes: 6720
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int n;
  cin>>n;
  int ans=0;
  vector<long long int> hoge(n);
  for(long long int i=0; i<n; i++){
    cin>>hoge.at(i);
  }
  for(int i=0; i<n; i++){
    int minj=i;
    for(int j=i; j<n; j++){
      if(hoge.at(j)<hoge.at(minj)){
        minj=j;
      }
    }
    if(i!=minj){
    int change=hoge.at(i);
    hoge.at(i)=hoge.at(minj);
    hoge.at(minj)=change;
    ans++;
    }
  }
  for(int i=0; i<n; i++){
    cout<<hoge.at(i);
    if(i!=n-1){
      cout<<" ";
    }else{
      cout<<endl;
    }
  }
  cout<<ans<<endl;
}


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

#define rep(i,N) for(int i=0;i<(int)N;++i)
#define rep1(i,N) for(int i=1;i<=(int)N;++i)

using int64 = long long;
using i64 = long long;

const int inf = 1 << 30;
const i64 inf64 = 1ll << 60;

const int mod = 1e9 + 7;

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

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

struct LowLink {
	const vector<vector<int>>& g;
	vector<int> used, ord, low;
	vector<pair<int, int>> bridge;
	vector<int> articulation;

	LowLink(const vector<vector<int>>& g) : g(g) {}

	void dfs(int u, int par, int& k) {
		ord[u] = low[u] = k++;
		used[u] = true;
		int cnt = 0;
		bool is_articulation = false;
		for (auto& v : g[u]) {
			if (!used[v]) {
				dfs(v, u, k);
				cnt++;
				low[u] = min(low[u], low[v]);
				if (ord[u] < low[v]) bridge.emplace_back(make_pair(min(u, v), max(u, v)));
				is_articulation |= (par != -1 && ord[u] <= low[v]);
			} else if (par != v) {
				low[u] = min(low[u], ord[v]);
			}
		}
		is_articulation |= (par == -1 && cnt > 1);
		if (is_articulation) articulation.emplace_back(u);
	}

	virtual void build() {
		used.assign(g.size(), 0);
		ord.assign(g.size(), 0);
		low.assign(g.size(), 0);
		int k = 0;
		for (int i = 0; i < g.size(); ++i) {
			if (!used[i]) dfs(i, -1, k);
		}
	}
};

struct TwoEdgeConnectedComponents : LowLink {
	vector<int> comp;

	TwoEdgeConnectedComponents(const vector<vector<int>>& g) : LowLink(g) {}

	int operator[](const int& k) {
		return comp[k];
	}

	void dfs(int u, int par, int& k) {
		if (par != -1 && ord[par] >= low[u]) comp[u] = comp[par];
		else comp[u] = k++;
		for (auto& v : g[u]) {
			if (comp[v] == -1) dfs(v, u, k);
		}
	}

	void build(vector<vector<int>>& t) {
		LowLink::build();
		comp.assign(g.size(), -1);
		int k = 0;
		for (int i = 0; i < g.size(); ++i) {
			if (comp[i] == -1) dfs(i, -1, k);
		}
		t.resize(k);
		for (auto& e : bridge) {
			int x = comp[e.first], y = comp[e.second];
			t[x].emplace_back(y);
			t[y].emplace_back(x);
		}
	}
};

int main() {
	int N; cin >> N;
	vector<vector<int>> g(N);
	rep(i, N) {
		int u, v; cin >> u >> v, u--, v--;
		g[u].emplace_back(v);
		g[v].emplace_back(u);
	}

	TwoEdgeConnectedComponents bcc(g);
	vector<vector<int>> buff;
	bcc.build(buff);

	int Q; cin >> Q;
	rep(i, Q) {
		int a, b; cin >> a >> b, a--, b--;
		if (bcc[a] == bcc[b]) cout << 2 << endl;
		else cout << 1 << endl;
	}
}


Measured memory_bytes: 22196
/*

*/

#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
using namespace std;

int main()
{
 	ios::sync_with_stdio(false);
	int N;
	int i,j,k;
	while(cin>>N)
	{
		if(N<1200)
		{
			cout<<"ABC"<<endl;
		}
		else if(N<2800)
			cout<<"ARC"<<endl;
		else if(N<=4208)
			cout<<"AGC"<<endl;
	}
	
	
	
	
	
	
	return 0;
}


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

int main()
{
	int N;
	scanf("%d", &N);
	int count{};
	for (int i{}; i < N; i++)
	{
		int p;
		scanf("%d", &p);
		if (i + 1 != p) count++;
	}
	if (count <= 2) puts("YES");
	else puts("NO");

	return 0;
}

Measured memory_bytes: 256
A,B = [int(i) for i in input().split()]

deal_count = 2
get_coin = 0

for i in range(deal_count) :
    if (A == max([A,B])) :
        get_coin += A
        A -= 1
    else :
        get_coin += B
        B -= 1

print(get_coin)

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

int main() {
  int H, W;
  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0) return 0;
    for (int h = 0; h < H; h++) {
      for (int w = 0; w < W; w++) {
        if ((h + w) % 2 == 0) cout << '#';
        else cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#define INF 100000000000000000
using namespace std;

int main(){
	int V,E,r;
	cin >> V >> E;
	long long int d[V][V] = {};
	for(int i = 0;i < V;i++) {
		for(int j = 0;j < V;j++) d[i][j] = INF;
		d[i][i] = 0;
	}
	for(int i = 0;i < E;i++){
		int a,b,c;
		cin >> a >> b >> c;
		d[a][b] = c;
	}
	for(int k = 0;k < V;k++){
		for(int i = 0;i < V;i++){
			for(int j = 0;j < V;j++) {
				if(d[i][k] != INF && d[k][j] != INF) d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
			}
		}
	}
	for(int i = 0;i < V;i++) {
		if(d[i][i] < 0){
			cout << "NEGATIVE CYCLE" << endl;
			return 0;
		}
	}
	for(int i = 0;i < V;i++) {
		if(d[i][0] == INF) cout << "INF";
		else cout << d[i][0];
		for(int j = 1;j < V;j++){
			if(d[i][j] == INF) cout << " INF";
			else cout << " " << d[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

cvt [i,u,a,p] = ((i,u),(a,p))
cmp = comparing (negate . fst . snd) <> comparing (snd . snd) <> comparing (fst . fst)


select n count [] = []
select n count ((i,u):ds)
  | (n<10 && ct<3) || (n<20 && ct<2) || (n<26 && ct<1) = i : select (n+1) (count//[(u,ct+1)]) ds
  | otherwise = select n count ds
  where
    ct = count!u

main = do
    n <- getInt
    unless (n==0) $ do
        ds <- map fst . sortBy cmp . map cvt <$> replicateM n getInts
        mapM_ print $ select 0 (listArray (1,1000) $ repeat 0) ds
        main


Measured memory_bytes: 4456
#include <cstdio>
#include <string>

const int N = 100005;
const long MAX = 2000000000;

struct Card {
    char name[10];
    int number;
};


void merge(struct Card *A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    struct Card L[N / 2 + 3], R[N / 2 + 3];
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = A[0]; R[n2] = A[0];
    L[n1].number = MAX; R[n2].number = MAX;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i].number <= R[j].number) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(struct Card *A, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}



int partition(struct Card *A, int p, int r) {
    int x = A[r].number;
    int i, j;
    i = p - 1;
    struct Card tmp;
    for( j = p; j < r; j ++) {
        if(A[j].number <= x) {
            i++;
            tmp = A[j];
            A[j] = A[i];
            A[i] = tmp;
        }
    }
    tmp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = tmp;
    return i + 1;
}

void quickSort(struct Card *A, int left, int right) {
    if (left > right) return;
    int q = partition(A, left, right);
    // q の場所は既にソートが終わっているので
    // q より左、および q より右の場所に関するソートをする必要がある
    quickSort(A, left, q - 1);
    quickSort(A, q + 1, right);
}

int main() {
    int n;
    scanf("%d", &n);
    struct Card A[N], B[N];
    for(int i = 0; i < n; i++) {
        scanf("%s", A[i].name);
        scanf("%d", &A[i].number);
        B[i] = A[i];
    }
    mergeSort(B, 0, n);
    quickSort(A, 0, n-1);
    bool flg = true;
    for(int i = 0; i < n; i++) {
        if (B[i].name[0] != A[i].name[0]) flg = false;
    }
    if (flg) printf("Stable\n");
    else printf("Not stable\n");
    for(int i = 0; i < n; i++) {
        printf("%s %d\n", A[i].name, A[i].number);
    }
    return 0;
}



Measured memory_bytes: 7296
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		String n=sc.next();
		int ans=0;
		for(int j=0;j<4;j++) {
		
			if(n.charAt(j)=='2') {
				ans++;
			}
		}
		System.out.println(ans);
	}
		
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}





Measured memory_bytes: 22612
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;


int gcd(int x, int y)
{
	int r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}

int N;
int A[100000];

signed main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
	}

	int l = gcd(A[0], A[1]);
	for (int i = 2; i < N; i++)
	{
		l = gcd(l, A[i]);
	}

	cout << l << endl;
}









Measured memory_bytes: 1024
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <utility>
#include <vector>

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

  std::map<char, intmax_t> count;
  for (int i = 0; i < n; ++i) {
    char c;
    scanf(" %c%*[^\n]", &c);
    ++count[c];
  }

  std::vector<std::string> const tt{
    "MAR", "MAC", "MAH", "MRC", "MRH", "MCH", "ARC", "ARH", "ACH", "RCH",
  };
  intmax_t res = 0;
  for (auto const& t: tt) {
    res += count[t[0]] * count[t[1]] * count[t[2]];
  }

  printf("%jd\n", res);
}


Measured memory_bytes: 256
#include<iostream>
#include <string.h>
#include<string>
#include <map> 
#include <utility> 


using namespace std;

int main()
{
	/*long long h, a, attacks = 0;
	cin >> h >> a;
	while (h > 0)
	{
	attacks++;
	h -= a;
	}
	cout << attacks << endl;*/
	/*long long n;
	string s;
	cin >> n;
	getline(cin, s);
	getline(cin, s);
	char currentchar = s[0];
	int cnt = 1;

	for (int i = 1; i < s.size(); i++)
	{
	if (s[i] != currentchar)
	{
	currentchar = s[i];
	cnt++;
	}
	}

	cout << cnt << endl;*/

	/*int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && a != c) || (a == c && a!=b) || (b == c && b!=a))
	cout << "Yes" << endl;
	else
	cout << "No" << endl;*/

	/*string S;
	getline(cin, S);
	//getline(cin, S);
	bool StingEnd = false;

	while (true)
	{
	int i;
	if (S.empty())
	break;
	for (i = 0; i < S.size()-1; i++)
	{

	if (S[i] == 'S' && S[i + 1] == 'T')
	{
	S.erase(i, 2);
	if (S.empty())
	break;
	//break;
	}
	}
	if (i == S.size()-1)
	break;
	}
	cout << S.size() << endl;*/

	/*int N, occurrence = 0;
	char S[100];
	cin >> N;
	cin >> S;
	for (int i = 0; i<N - 2; i++)
	{
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
			occurrence++;
	}
	cout << occurrence << endl;*/
	
	int Bingo[3][3];
	bool Exist[3][3];
	map <int, pair<int, int>> places;
	for (int i=0;i<3;i++)
	{
		for (int j=0;j<3;j++)
		{
			cin>>Bingo[i][j];
			Exist[i][j] =false;
			pair<int, int> current;
			current.first = i;
			current.second = j;
			places[Bingo[i][j]] = current;
			
			//places.insert(pair<int, pair>(Bingo[i][j], current)); 
		}
	}
	int N,B;
	cin>>N;
	for (int i=0;i<N;i++)
	{
		cin >>B;
		map<int, pair<int,int>>::iterator it = places.find(B);
		if ( it != places.end() ) 
			// not found
			{
				//pair<int, int> place= places.find(B);
				Exist[it->second.first][it->second.second] = true;
			}
	}
	
	bool IsBingo = false;
	
	if (Exist[0][0]&&Exist[0][1]&&Exist[0][2])
		IsBingo = true;
	else if(Exist[1][0]&&Exist[1][1]&&Exist[1][2])
		IsBingo = true;
	else if(Exist[2][0]&&Exist[2][1]&&Exist[2][2])
		IsBingo = true;
	else if(Exist[0][0]&&Exist[1][0]&&Exist[2][0])
		IsBingo = true;
else if(Exist[0][1]&&Exist[1][1]&&Exist[2][1])
		IsBingo = true;
else if(Exist[0][2]&&Exist[1][2]&&Exist[2][2])
		IsBingo = true;
else if(Exist[0][0]&&Exist[1][1]&&Exist[2][2])
		IsBingo = true;
else if(Exist[0][2]&&Exist[1][1]&&Exist[2][0])
		IsBingo = true;

	
	if (IsBingo)
		cout<< "Yes"<<endl;
	else
		cout<<"No" <<endl;
	

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll N;
    cin >> N;
    VL a(N);
    ll ans=0;

    rep(i,0,N){
        cin >> a[i];
        if((i+1)%2==1 && a[i]%2==1)ans++;
    }

    cout << ans << endl;
    return 0;
}

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

signed main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	vector<ll> ans(n);
	rep(i, n){
		ans[a[i ] - 1] = i + 1;
	}
	rep(i, n) cout << ans[i] << ' ';
	cout << endl;
}

Measured memory_bytes: 2432
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let nm:Vec<usize> = read_vec();
    let (n, m) = (nm[0], nm[1]);
    println!("{}", ((n-1)*n)/2 + ((m-1)*m)/2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,d,a;
    cin>>n>>d>>a;
    vector<pair<ll,ll> > v;
    ll x,h;
    for(int i=0;i<n;i++){
    	cin>>x>>h;
    	v.pb(make_pair(x,h));
    }
    sort(be(v));
    ll p[n],q[n];
    for(int i=0;i<n;i++){
    	p[i]=v[i].first;
    	q[i]=v[i].second;
    }
    ll ans=0,num=0,maki=0,c[n];
    memset(c,0LL,sizeof(c));
    for(int i=0;i<n;i++){
    	num-=c[i];
    	q[i]-=num;
    	q[i]=max(q[i],0LL);
    	maki=(q[i]+a-1)/a;
    	ans+=maki;
    	maki*=a;
    	num+=maki;
    	q[i]=0;
    	c[upper_bound(p,p+n,p[i]+2*d)-p]+=maki;
    }
    cout << ans<<endl;
    return 0;
}


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

int main()
{
  string s, t;
  cin >> s >> t;
  int m, n;
  m = s.size();
  n = t.size();
  for(int i = 0; i < n; i++){
    cout << s[i] << t[i];
  }
  if(m > n){
    cout << s[n];
  }
  cout << endl;
}

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

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

int main()
{
    int ans = 0, mxans = 0;
    string s;
    cin >> s;
    
    rep(i, s.length())
    {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            ans++;
            mxans = max(ans, mxans);
        }
        else
        {
            ans = 0;
        }
    }

    cout << mxans << endl;
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
filed = []
for i in range(H):
    filed.append(list(input()))
dy = [1, 0, -1, 0, 1, -1, 1, -1]
dx = [0, 1, 0, -1, 1, 1, -1, -1]

for y in range(H):
    for x in range(W):
        count = 0
        if filed[y][x] == '#':
            continue
        for k in range(8):
            ny = y + dy[k]
            nx = x + dx[k]
            if ny < 0 or H <= ny or nx < 0 or W <= nx:
                continue
            if filed[ny][nx] == '#':
                count += 1
        filed[y][x] = str(count)

for y in range(H):
    print("".join(filed[y]))

Measured memory_bytes: 3188
#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() {

    int N;
    cin >> N;
    int A[N];
    int B[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
        B[i] = A[i];
    }

    sort(B,B + N);
    int max_v = B[N-1];
    int sec_max_v = B[N-2];

    int max_idx = -1;
    int sec_max_idx = -1;

    for(int i = 0; i < N; i++ ){
        if(A[i] == max_v) max_idx = i;
        if(A[i] == sec_max_v) sec_max_idx = i;
    }

    for(int i = 0; i < N; i++){
        if(i != max_idx) cout << A[max_idx] << endl;
        else if(i == max_idx) cout << A[sec_max_idx] << endl;
    }

    return 0;
}

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

int main() {
  int x =911;
  cin >> x;
  string y=to_string(x);
  if(y[0]=='1'){
    y[0]='9';
  } else{
    y[0]='1';
  }
  if(y[1]=='1'){
    y[1]='9';
  } else{
    y[1]='1';
  }
  if(y[2]=='1'){
    y[2]='9';
  } else{
    y[2]='1';
  }
	cout<<y;
	return 0;
}


Measured memory_bytes: 3680
PROGRAM lowElements
      IMPLICIT NONE
      integer(16) :: n,ans
      integer(16),allocatable :: p(:)
      integer(16) :: mi,i
      
      read*,n
      allocate(p(n))
      read*,p(:)
      
      ans = 0
      mi = p(1)
      do i = 1,n
        if( mi>=p(i) )then
          mi = p(i)
          ans = ans + 1
        end if
      end do
      
      print*,ans
      
      
      
      
      
      END PROGRAM

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int n;cin>>n;
  cout<<(n+999)/1000*1000-n<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std; typedef long long ll;
ostream &debug = cout;

/* AOJ 2249 */

const int N = 10005;
const int M = 40005;
const int INF = 0x3f3f3f3f;

int n, m, ans, dis[N], vis[N];
int hd[N], to[M], nt[M], vl[M], ct[M], tot;

struct Node {
	int dis, wei, ver;
	friend bool operator <(Node a, Node b) {
		if (a.dis != b.dis)
			return a.dis > b.dis;
		return a.wei > b.wei;
	}
};

priority_queue<Node> pq;

inline void addEdge(int x, int y, int w, int c) {
	nt[tot] = hd[x], to[tot] = y, vl[tot] = w, ct[tot] = c, hd[x] = tot++;
}

signed main(void) {
	while (scanf("%d%d", &n, &m), n) {
		/* input & prepare */
		{
			memset(hd, -1, sizeof(hd)), tot = ans = 0;
			for (int i = 1, u, v, w, c; i <= m; i++)
				scanf("%d%d%d%d", &u, &v, &w, &c),
				addEdge(u, v, w, c), addEdge(v, u, w, c);
		}
		/* dijkstra */
		{
			pq.push(Node{0, 0, 1});
			memset(vis, 0, sizeof(vis));
			while (!pq.empty()) {
				Node top = pq.top(); pq.pop();
				if (vis[top.ver])continue;
				ans += top.wei, vis[top.ver] = 1;
				for (int i = hd[top.ver]; ~i; i = nt[i])
					pq.push(Node{ top.dis + vl[i], ct[i], to[i] });
			}
		}
		/* output */
		printf("%d\n", ans);
	}
}

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

#include <math.h>
#include <stdlib.h>


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

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int h, w; cin >> h >> w;
    vector<string> s(h);
    for(int i = 0; i < h; i++) cin >> s[i];
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#')continue;
            int cnt = 0;
            for(int k = -1; k < 2; k++){
                if(i+k < 0 || i+k >= h) continue;
                for(int l = -1; l < 2; l++){
                    if(j+l < 0 || j+l >= w) continue;
                    if(k == 0 && l == 0) continue;
                    if(s[i+k][j+l] == '#')cnt++;
                }
            }
            s[i][j] = '0' + cnt;
        }
    }

    for(int i = 0; i < h; i++) cout << s[i] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head



int main(){

  ll a = in();
  ll b = in();
  ll c = in();

  REP(i, 100000){
    if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
      printf("%lld\n", i);
      return 0;
    }
    ll na = (b + c) / 2;
    ll nb = (a + c) / 2;
    ll nc = (a + b) / 2;
    a = na;
    b = nb;
    c = nc;
  }
  puts("-1");
  
  return 0;
}


Measured memory_bytes: 256