akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second

const int maxn = 123;
const int inf = 0x3f3f3f3f;

int n, s;
pii a[maxn];

int main() {
    scanf("%d", &n);
    FOR(i, 1, n) {
        scanf("%d", &a[i]._1);
        a[i]._2 = i;
        s += a[i]._1;
        a[i]._1 *= n;
    }
    sort(a + 1, a + n + 1);
    pii diff = mp(inf, inf);
    FOR(i, 1, n)
        diff = min(diff, mp(abs(a[i]._1 - s), a[i]._2));
    printf("%d\n", diff._2 - 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    std::deque<string> num;
    std::deque<string> lunlun;
    for (int i=1;i<10;i++) {
        num.emplace_back(to_string(i));
    }
    int count=0;
    while (1) {
        count++;
        string tmp=num.front();
        num.pop_front();
        lunlun.emplace_back(tmp);
        int hoge=tmp[tmp.size()-1]-'0';
        if (hoge!=0) {
            string tmp_diff=tmp+to_string(hoge-1);
            num.emplace_back(tmp_diff);
        }
        string tmp_same=tmp+to_string(hoge);
        num.emplace_back(tmp_same);
        if (hoge!=9) {
            string tmp_plus=tmp+to_string(hoge+1);
            num.emplace_back(tmp_plus);
        }
        if (count==n) {
            cout<<lunlun[n-1]<<endl;
            break;
        }
    }
}

Measured memory_bytes: 13072
n, l = map(int, input().split())
all_taste = 0
taste_list = list()
for i in range(n):
  taste = l+(i+1)-1
  taste_list.append(taste)
  all_taste += taste

www = float("inf")
for i in range(n):
  if abs(taste_list[i]) < www:
    www = abs(taste_list[i])
    ind = i
ans = all_taste - taste_list[ind]
print(ans)

Measured memory_bytes: 3064
N,M=map(int, input().split())
class UnionFind():
    """
    UnionFindTreeのクラス
    
    Attributes:
    n: int: ノード数
    parents: そのノードが属する木の根を格納, 根の場合は-1

    """
    def __init__(self, n):
        """ノード数nで初期化"""
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """ノードxが属するグループの根を返す"""
        if self.parents[x] < 0:
            return x
        else:
            #経路圧縮
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """xが属するグループとyが属するグループを併合"""
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        """xが属するグループの要素数を返す"""
        return -self.parents[self.find(x)]

    def same(self, x, y):
        """x, yが同じグループに属するかどうかを返す"""
        return self.find(x) == self.find(y)

    def members(self, x):
        """xが属するグループ内の要素をリストで返す"""
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        """全ての根に対する要素をリストで返す"""
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        """グループの総数を返す"""
        return len(self.roots())

    def all_group_members(self):
        """{root: [そのグループの要素リスト]}の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        """printデバッグ用. root: [要素リスト]をstrで返す"""
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


uf = UnionFind(N)
for _ in range(M):
    a,b=map(int, input().split())
    uf.union(a-1, b-1)
ans = 0
for x in range(N):
    ans = max(ans, uf.size(x))
print(ans)

Measured memory_bytes: 79272
program abc80
 implicit none
 integer(8)::N,K,ia,ib,d,ic
 integer(8),allocatable::a(:),b(:)
 read(*,*)N,K
 allocate(a(N))
 a=0
 do ia=1,K
  read(*,*)d
  allocate(b(d))
  read(*,*)(b(ic),ic=1,d)
  do ib=1,d
   a(b(ib))=a(b(ib))+1
  end do
  deallocate(b)
 end do
 print'(i0)',count(a==0)
 deallocate(a)
end program abc80

Measured memory_bytes: 2932
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

typedef long long ll;



int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int A,B;
    cin >> A >> B;
    A = (A+11)%13;
    B = (B+11)%13;
    if(A>B){
        cout << "Alice" << endl;
    }
    else if(A<B){
        cout << "Bob" << endl;
    }
    else{
        cout << "Draw" << endl;
    }
    return 0;
}


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

signed main(){
    int A,B;
    cin >> A >> B;
    
    for(int i=1;i<10000;i++){
        int tmp = i*0.08;
        int tmp2 = i*0.1;
        if(tmp == A && tmp2 == B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}



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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	long long int N, H;
	cin >> N >> H;
	vector<int> a1;
	vector<int> b1;
	long long int maxa = 0;
	long long int maxb = 0;
	long long int maxhitb = 0;
	long long int count = 0;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		if (a > maxa) {
			maxa = a;
			maxb = b;
		}
		else if (a == maxa) {
			if (b < maxb) {
				maxb = b;
			}
		}
		a1.push_back(a);
		b1.push_back(b);
	}
	sort(b1.begin(), b1.end(), greater<int>());
	sort(a1.begin(), a1.end());
	for (int i = 0; i < N; i++) {
		if (b1[i] >= maxa) {
			maxhitb = maxhitb + b1[i];
			count++;
		}
	}
	if (maxhitb >= H) {
		for (int i = 0; i < N; i++) {
			H = H - b1[i];
			if (H <= 0) {
				cout << i + 1;
				return 0;
			}
		}
	}
	else {
		H = H - maxhitb;
		cout << count + (H + (maxa - 1)) / maxa;
	}
}

Measured memory_bytes: 1276
# -*- coding: utf-8 -*-

N = int(input())
a = [int(i) for i in input().split()]

number = []
over = 0
for i in range(8):
    number.append(False)

for i in a:
    position = int((i / 100) // 4)
    if position < 8:
        number[position] = True
    else:
        over += 1

minimum = number.count(True)
if minimum == 0:
    minimum = 1
maximum = number.count(True) + over
#if maximum > 8:
#    maximum = 8

print(str(minimum) + ' ' + str(maximum))


Measured memory_bytes: 3188
use std::collections::BinaryHeap;
use std::fmt::Debug;
use std::str::FromStr;

pub struct TokenReader {
    reader: std::io::Stdin,
    tokens: Vec<String>,
    index: usize,
}

impl TokenReader {
    pub fn new() -> Self {
        Self {
            reader: std::io::stdin(),
            tokens: Vec::new(),
            index: 0,
        }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index += 1;
        self.tokens[self.index - 1].parse().unwrap()
    }

    pub fn vector<T>(&mut self) -> Vec<T>
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index = self.tokens.len();
        self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()
    }

    pub fn load_next_line(&mut self) {
        let mut line = String::new();
        self.reader.read_line(&mut line).unwrap();

        self.tokens = line
            .split_whitespace()
            .map(String::from)
            .collect();
        self.index = 0;
    }
}

struct Camel {
    offset: usize,
    left: i64,
    right: i64,
}

fn find_best(pairs: &mut Vec<(usize, i64)>, n: usize) -> Vec<i64> {
    pairs.sort();
    pairs.reverse();

    let mut index = 0;
    let mut heap = BinaryHeap::new();
    let mut best = vec![0; n];

    for i in (0..n).rev() {
        while index < pairs.len() && pairs[index].0 >= i {
            heap.push(pairs[index].1);
            index += 1;
        }
        if let Some(value) = heap.pop() {
            best[i] = value;
        }
    }
    for i in 1..n {
        best[i] += best[i - 1];
    }
    best
}

fn solve(camels: &Vec<Camel>) -> i64 {
    let mut left = vec![];
    let mut right = vec![];
    let mut base = 0;

    for camel in camels.iter() {
        let sure = std::cmp::min(camel.left, camel.right);
        base += sure;

        if camel.left >= camel.right {
            left.push((camel.offset - 1, camel.left - sure));
        } else if camel.offset < camels.len() {
            right.push((camels.len() - camel.offset - 1, camel.right - sure));
        }
    }

    let best_left = find_best(&mut left, camels.len());
    let best_right = find_best(&mut right, camels.len());

    let mut extra = 0;
    for i in 0..camels.len() {
        extra = std::cmp::max(extra, best_left[i] + best_right[i]);
    }
    base + extra
}

fn main() {
    let mut reader = TokenReader::new();
    let tests = reader.next();

    for _ in 0..tests {
        let n = reader.next();
        let camels = (0..n).map(|_| {
            Camel {
                offset: reader.next(),
                left: reader.next(),
                right: reader.next(),
            }
        }).collect();

        let res = solve(&camels);
        println!("{}", res);
    }
}


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

#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; in(N);
  int sum = 1;
  int k = 1;
  while (sum < N) {
    ++k;
    sum += k;
  }
  vector<int> v;
  rrep(i, k) {
    if (N - i >= 0) {
      v.push_back(i);
      N -= i;
    }
    if (N == 0)
      break;
  }
  reverse(all(v));
  iter(it, v) out(*it);

  return 0;
}


Measured memory_bytes: 384
import sys

s1 = list(map(str, input()))

n = len(s1)

for i in range(n//2):
    if s1[i] != s1[n-1-i]:
        print('No')
        sys.exit()

s2 = s1[(n+3)//2-1:]
for i in range((n-1)//4):
    if s2[i] != s2[(n-1)//2-1-i]:
        print('No')
        sys.exit()

del s1[(n+1)//2-1:]
for i in range((n-1)//4):
    if s1[i] != s1[(n-1)//2-1-i]:
        print('No')
        sys.exit()

print('Yes')

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){

  long n,m;
  scanf("%ld %ld", &n, &m);
  long a[m];
  for (long i = 0; i < m; i++) {
    scanf("%ld", &a[i]);
  }
  long sum = 0;
  for (long i = 0; i < m; i++) {
    sum += a[i];
  }
  if (sum > n) {
    printf("-1\n");
  } else {
    printf("%ld\n", n-sum);
  }

  return 0;
}

Measured memory_bytes: 1756
#include <iostream>
#include <cmath>

int repsept(int k) {
  if (k % 2 == 0) {
    return -1;
  }

  int t = 0;
  for (int i = 0; i < std::pow(10, 6); i++) {
    t = (t*10 + 7) % k;
    if (t == 0) {
      return i+1;
    }
  }

  return -1;
}

int main(void) {
  long long int k;
  std::cin >> k;

  std::cout << repsept(k) << std::endl;

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n; 
	map<string,int> mp;
	for(int i=0; i<n; ++i){
		string s; cin >> s;
		++mp[s];
	}

	int mx=0;
	for(auto i : mp){
		mx=max(mx,i.second);
	}
	for(auto i : mp){
		if(mx==i.second){
			cout << i.first << endl;
		}
	}
}

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

void Matrix_Chain_Order();

int **m;
int n;
int *P;

int main(void){
	int i;
	int temp;

	scanf("%d",&n);

	P=(int *)malloc(sizeof(int)*(n+1));

	for(i=1;i<=n;i++){
		if(i==1) scanf("%d",&P[0]);
		else scanf("%d",&temp);

		scanf("%d",&P[i]);
	}

	m=(int **)malloc(sizeof(int *)*(n+1));
	for(i=0;i<=n;i++) m[i]=(int *)malloc(sizeof(int)*(n+1));

	Matrix_Chain_Order();

	printf("%d\n",m[1][n]);

	free(P);
	
	for(i=0;i<=n;i++) free(m[i]);
	free(m);

	return 0;
}

void Matrix_Chain_Order(){
	int i,j,k,l;
	int work;
	
	for(i=1;i<=n;i++) m[i][i]=0;

	for(l=2;l<=n;l++){
		for(i=1;i<=n-l+1;i++){
			j=i+l-1;
			m[i][j]=m[i][i]+m[i+1][j]+P[i-1]*P[i]*P[j];
			for(k=i+1;k<j;k++){
				work=m[i][k]+m[k+1][j]+P[i-1]*P[k]*P[j];
				if(work<m[i][j]) m[i][j]=work;
			}
		}
	}
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n;
ll a, b, x;
signed main(){
    // [a, b] = [0, b] - [0, a)
    cin >> a >> b >> x;
    cout << b/x - a/x + ((a%x==0)? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,c,d,max;
  cin>> A>> B;
  
  max=A+B;
  c=A-B;
  d=A*B;
  if(max<c) max = c;
  if(max<d) max = d;
  cout << max <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  long long int a,b,n,i,sum=0,d,min;
  scanf("%lld%lld%lld",&n,&a,&b);
  d=n/(a+b);
  sum+=d*a;
  d=d*(a+b);
  d=n-d;
  //d-=a;
  if(a<d){
    min=a;
  }else{
    min=d;
  }
  if(d>0){
    sum+=min;
  }
  printf("%lld\n",sum);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N,Z,W;
  cin >> N >> Z >> W;
  vector<ll> A(N);
  rep(i,N){
    cin >> A[i];
  }
  if(N == 1){
    cout << abs(W-A[0]) << endl;
  }else{
    cout << max(abs(W-A[N-1]),abs(A[N-2]-A[N-1])) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// C.

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

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

int main(int argc, char *argv[]) {
	int n, ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		ans = gcd(ans, a);
	}
	cout << ans << endl;
	return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    string s;
    cin >> s;
    set<int32> l;
    set<int32> lm;
    set<int32> ans;
    REP(i,n){
        for(auto x : lm){
            ans.insert(x * 10 + (s[i] - '0'));
        }
        for(auto x : l){
            lm.insert(x * 10 + (s[i] - '0'));
        }
        l.insert(s[i] - '0');
    }
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 384
import numpy as np
import sys

buf = sys.stdin.buffer
H,W = map(int,buf.readline().split())

grid = np.frombuffer(buf.read(H*(W+1)), dtype='S1').reshape((H,W+1))
grid = grid[:,:-1]

select_col = (grid == b'#').any(axis = 0)
select_row = (grid == b'#').any(axis = 1)

grid = grid[select_row, :]
grid = grid[:, select_col]
grid = grid.astype(str)

print('\n'.join(''.join(row) for row in grid))

Measured memory_bytes: 12444
#include<iostream>
#include<string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <algorithm>
#include <cstdlib>
using namespace std;
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}

int main() {
	string S;
	cin >> S;
	int A=ctoi(S.at(0)), B = ctoi(S.at(1)), C = ctoi(S.at(2)), D = ctoi(S.at(3));
	int i, j, k;
	for (i = 0; i < 2; i++) {
		for (j = 0; j < 2; j++) {
			for (k = 0; k < 2; k++) {
				int sum = A;
				char p, q, r;
				if (i == 0) {
					sum += B;
					p = '+';
				}
				else {
					sum -= B;
					p = '-';
				}
				if (j == 0) {
					sum += C;
					q = '+';
				}
				else {
					sum -= C;
					q = '-';
				}
				if (k == 0) {
					sum += D;
					r = '+';
				}
				else {
					sum -= D;
					r = '-';
				}
				if (sum == 7) {
					cout << A << p << B << q << C << r << D << "=7";
					exit(0);
				}
			}

		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#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 INF 2e9
#define IPSILON 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  REP(i,n){
    cin >> p[i];
  }
  int result = 0;
  REP(i,n-2){
    vector<int> v(p.begin()+i, p.begin()+(i+3));
    //    cout << v[0] <<"," << v[1] << "," << v[2] << endl;                                                                     
    if((v[0] < v[1] && v[1] <= v[2]) || (v[2] < v[1] && v[1] <= v[0])){
      //cout << "this" << endl;                                                                                                  
      result+=1;
    }
  }
  cout << result << endl;
  return 0;
}




Measured memory_bytes: 256
n,*a=map(int,open(0).read().split())
a=[i%4 for i in a]
if a.count(2)>0:
  print('Yes' if a.count(0)>=a.count(1)+a.count(3) else 'No')
else:
  print('Yes' if 1+a.count(0)>=a.count(1)+a.count(3) else 'No')

Measured memory_bytes: 14052
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int i,tmp,n[]={0,1,2,3};

		while(sc.hasNext()){
			String str[]=sc.next().split(",");
			if(str[0].equals("A") && str[1].equals("B")){
				tmp=n[1];
				n[1]=n[2];
				n[2]=tmp;
			}
			if(str[0].equals("A") && str[1].equals("C")){
				tmp=n[1];
				n[1]=n[3];
				n[3]=tmp;
			}
			if(str[0].equals("B") && str[1].equals("A")){
				tmp=n[1];
				n[1]=n[2];
				n[2]=tmp;
			}
			if(str[0].equals("B") && str[1].equals("C")){
				tmp=n[3];
				n[3]=n[2];
				n[2]=tmp;
			}
			if(str[0].equals("C") && str[1].equals("A")){
				tmp=n[1];
				n[1]=n[3];
				n[3]=tmp;
			}
			if(str[0].equals("C") && str[1].equals("B")){
				tmp=n[3];
				n[3]=n[2];
				n[2]=tmp;
			}
		}//while
		for(i=1;i<4;i++){
			if(n[i]==1){
				if(i==1){
					System.out.println("A");
				}
				else if(i==2){
					System.out.println("B");
				}
				else if(i==3){
					System.out.println("C");
				}

			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
 
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'
 
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
 
template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}
 
signed main()
{
//	freopen("TEXT.inp", "r", stdin); freopen("TEXT.out", "w", stdout);
	fastio();
 
	int n, x; vector<int> a(n + 10);
	cin >> n >> x;
	int cnt = 0;
	a[0] = 0;
	for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i - 1];
	}
	for (int i = 0; i <= n; i++) {
        if (a[i] <= x) {
            cnt++;
        }
	}
	cout << cnt;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

vector<int> G[1000];
int color[1000], cnt[2];
int dfs(int v, int c){
	color[v] = c;
	cnt[c]++;
	rep(i,G[v].size()){
		int to = G[v][i], cc = color[to];
		if(cc != -1 and cc == c)return -1;
		if(cc != -1)continue;
		int tmp = dfs(to, !c);
		if(tmp == -1)return -1;
	}
	return 0;
}

int a[1000][1000], dp[2][1000];
vector<P> vs;
signed main(){
	int n, m;
	fill(color, color+1000, -1);
	scanf("%lld%lld", &n, &m);
	rep(i,m){
		int x, y;
		scanf("%lld%lld", &x, &y);x--;y--;
		a[x][y] = a[y][x] = 1;
	}
	rep(i,n)a[i][i] = 1;
	rep(i,n)rep(j,n)if(a[i][j] == 0)G[i].pb(j);
	
	rep(i,n){
		int tmp = 0;cnt[0] = cnt[1] = 0;
		if(color[i] == -1)tmp = dfs(i, 0);
		if(tmp == -1){printf("-1\n");return 0;}
		vs.pb(P(cnt[0], cnt[1]));
	}
	
	dp[0][0] = 1;
	rep(i,vs.size()){
		fill(dp[1], dp[1]+1000, 0);
		drep(j,n,0){
			if(j-vs[i].fi >= 0)chmax(dp[1][j], dp[0][j-vs[i].fi]);
			if(j-vs[i].se >= 0)chmax(dp[1][j], dp[0][j-vs[i].se]);
		}
		swap(dp[0], dp[1]);
	}
	int ans = INF;
	rep(i,n+1){
		if(dp[0][i] == 0)continue;
		int x = i, y = n-i;
		chmin(ans, x*(x-1)/2+y*(y-1)/2);
	}
	//rep(i,n+1)printf("%lld ", dp[0][i]);
	printf("%lld\n", ans);
	return 0;
}







Measured memory_bytes: 11008
#include<stdio.h>
int main()
{
char a[4];
int i,b[130]={0},t,m=0;
scanf("%s",a);
for(i=0;i<4;i++)
{t=a[i];
	b[t]++;
}
for(i=65;i<129;i++)
{
	if(b[i]==1||b[i]==4)
	{
	printf("No");
	m=1;
	break;}
	}
if(m==0)
printf("Yes");	
 }	

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

int gcd(int x, int y){
  if (y== 0) {
    return x;
  }else{
    return gcd(y,x%y);
  }
}

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

  ll temp = gcd(A,B);

  ll ans = (A*B)/temp;

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef pair<int, int> P;
vector<P> ln[51];

P rot(P p, int k) {
	for(int i = 0; i < k; i++) {
		p = P{ p.second, -p.first };
	}
	return p;
}

bool comp(vector<P>& a, vector<P>& b) {
	if(a.size() != b.size()) return false;
	int n = a.size();
	for(int r = 0; r < 4; r++) {
		bool flag = true;
		for(int i = 0; i < n; i++) {
			P p = rot(b[i], r);
			flag &= a[i].first == p.first && a[i].second == p.second;
		}
		if(flag) return true;
		flag = true;
		for(int i = 0; i < n; i++) {
			P p = rot(b[n - 1 - i], r);
			flag &= a[i].first == p.first && a[i].second == p.second;
		}
		if(flag) return true;
	}
	return false;
}

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

	int n, m;
	while(cin >> n, n) {
		for(int i = 0; i < n + 1; i++) {
			cin >> m;
			ln[i].clear();
			int x1, y1;
			cin >> x1 >> y1;
			for(int j = 0; j < m - 1; j++) {
				int x2, y2;
				cin >> x2 >> y2;
				ln[i].push_back(P{ x2 - x1, y2 - y1 });
				x1 = x2, y1 = y2;
			}
		}
		for(int i = 1; i <= n; i++) {
			if(comp(ln[0], ln[i])) {
				cout << i << endl;
			}
		}
		cout << "+++++" << endl;
	}
}

Measured memory_bytes: 1212
using System;

class Plogram
{
    static void Main()
    {
        var age = int.Parse(Console.ReadLine());
        if(age ==1)
        {
            Console.WriteLine("Hello World");
        }
        else if (age==2)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            Console.WriteLine(A + B);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define int long long 
#define float long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
const int hell = 1e9+7;

void self_add(int& a , int b){
	a += b;
	if(a>=hell)
		a-=hell;
}

void self_dif(int& a, int b){
	a -= b;
	if(a<0)
		a += hell;
}

signed main(){
	IOS;
	int n , k;
	cin >> n >> k ;

	vector<int>dp(k+1);
	dp[0] = 1;
	for(int i=0;i<n;i++){
		int limit;
		cin >> limit;
		vector<int>fake(k+1);
		for(int j=k-1;j>=0;j--){
			int l = j+1;
			int r = j + min(limit,k-j);
			fake[l] += dp[j];
			if(r+1<=k){
				self_dif(fake[r+1],dp[j]);
			}
		}
		int prefix = 0;
		for(int j=0;j<=k;j++){
			self_add(prefix,fake[j]);
			self_add(dp[j],prefix);
		}
		debug() << imie(range(dp.begin(),dp.end()));
	}
	cout << dp[k] << endl;
	return 0;
}







Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <bitset>
#include <map>
#include <set>

using namespace std;

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

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

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;
}

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

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

signed main() {
    int N; cin >> N;
    vector<P> p(N);
    rep(i, N) {
        cin >> p[i].second >> p[i].first;
    }
    sort(all(p));

    int currentTime = 0;
    rep(i, N) {
        currentTime += p[i].second;
        if (currentTime > p[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}
 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<int, int, int, int> tp;
///-------------------------

int main()
{
    Phuong_; /// <3333
    int a,b,c,k;
    cin >> a >> b >> c>> k;
    int sum=0;
    sum += min(k,a);
    k-=a;
    k-=b;
    if (k<=0)
        cout << sum; else {
        sum-= min(k,c);
        cout << sum;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>

using namespace std;

int main() {

    string S;

    cin >> S;

    string month = S.substr(5, 2);
    string day = S.substr(8, 2);


    string tMonth = "04";
    string tDay = "30";

    if (month == tMonth and day == tDay) {
        cout << "Heisei" << "\n";
    } else if (month == tMonth and day <= tDay) {
        cout << "Heisei" << "\n";
    } else if (month < tMonth) {
        cout << "Heisei" << "\n";
    } else {
        cout << "TBD" << "\n";
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ll n,l = - 1,r = -1;
    cin>>n;
    ll a[n];
    for (int i = 0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    for (int i = 0;i<n-1;i++) {
        if (a[i] == a[i+1]) {
            if (l == -1)l = a[i],i++;
            else if (r == -1)r = a[i],i++;
        }
        if (l != -1 && r != -1)break;
    }
    if (l == -1 || r == -1)cout<<0<<endl;
    else cout<<l*r<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    while (true) {
        int a, b;
        cin >> a >> b;
        if (a == 0 && b == 0)return 0;
        for (int i = 0; i < a; i++) {
            for (int j = 0; j < b; j++) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

int main() {
  string S;
  cin >> S;
  stack<char> st;
  bool flag = false;
  for(int i= 0; i < S.size(); i++) {
    if(st.size() == 0 && S[i] == 'A') st.push(S[i]);
    else if(S[i] == 'Z' && st.size()) {
      flag = true;
      cout << st.top() << S[i];
      st.pop();
    }
  }
  if(!flag) cout << -1;
  cout << endl;
  return 0;
}

Measured memory_bytes: 3200
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  int a[100][100] = {0};
  int b[100] = {0};
  int c[100] = {0};

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      c[i] += a[i][j] * b[j];
    }
  }

  for (int i = 0; i < n; ++i) {
    printf("%d\n", c[i]);
  }
  return 0;
}

Measured memory_bytes: 1192
#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(){
string S;
cin>>S;
map<char,bool> m;
rep(i,S.size()){
    if(m[S[i]]){
        cout<<"no"<<endl;
        return 0;
    }else{
        m[S[i]]=true;
    }
}

cout<<"yes"<<endl;
  return 0;
}


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

P = 10**9 + 7

ans = 0
tmp = 0
for num in A:
    tmp += num
    tmp %= P
for num in A:
    ans += (num*tmp)%P
    ans -= pow(num, 2, P)
    ans %= P

ans = ans * pow(2, P-2, P)
ans %= P
print(ans)



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

using i64 = long long int;

struct Data{
    int n;
    string s;
    bool operator<(const Data &obj)const{
        if(n == obj.n)return s < obj.s;
        return n > obj.n;
    }
};

int main(){
    int n;
    string gomi;
    while(cin >> n, n != 0){
        getline(cin, gomi);
        map<string, int> mp;
        string line;
        for(int i=0;i<n;++i){
            getline(cin, line);
            string tmp = "";
            for(auto c : line){
                if(c == ' '){
                    mp[tmp]++;
                    tmp = "";
                }else{
                    tmp += c;
                }
            }
            if(tmp != "")mp[tmp]++;
        }

        char k;
        cin >> k;
        vector<Data> v;
        for(auto e : mp){
            if(e.first[0] == k)
                v.push_back((Data){e.second, e.first});
        }
        sort(v.begin(), v.end());

        if(v.size() == 0)cout << "NA" << endl;
        else{
            for(int i=0;i<min(5, (int)v.size());++i){
                cout << v[i].s;
                if(i == v.size() - 1 || i == 4)cout << endl;
                else cout << " ";
            }
        }
    }

    return 0;
}



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

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  for(int i=0;i<S.size();i++){
    int c=(int)S[i];
    c+=N;
    if(c>(int)'Z'){
      c-=(int)'Z';
      c+=(int)'A'-1;
    }
    cout<<(char)c;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int>L(2 * n);
	int ans = 0;
	for (int i = 0; i < 2 * n; i++)cin >> L[i];
	sort(L.begin(), L.end());
	for (int i = 0; i < 2 * n; i++) {
		if (i % 2 == 0) {
			ans += L[i];
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
 
void _main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, 0, N) cin >> A[i];
 
  ll ans = 0;
  int cnt_minus = 0;
  bool zero_exists = false;
  rep(i, 0, N) {
    if (A[i] < 0) {
      cnt_minus++;
      A[i] *= -1;
    } else if (A[i] == 0) {
      zero_exists = true;
    }
    ans += A[i];
  }
  if (zero_exists) {
    cout << ans << endl;
    return;
  }
  if (cnt_minus % 2 == 1) {
    sort(all(A));
    ans -= A[0]*2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  
  int n,m,a[100],i,j,k,sum=0;
  cin>>n>>m;
  for(i=0;i<n;i++){cin>>a[i];sum+=a[i];}

  sort(a,a+n,greater<int>());
  j=sum/(4*m);
  if(sum%(4*m)!=0){j++;}
  for(i=0;i<m;i++)
  {
    if(a[i]<j){cout<<"No"<<endl;return 0;}
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

count = 0
pre = -1
for a_i in a:
    count += b[a_i-1]
    if pre == a_i - 1:
        count += c[pre-1]
    pre = a_i

print(count)

Measured memory_bytes: 3064
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val abc = readListOfInt() 
    val perm = permutations(abc)
    var ans = perm[0].let { it[0] * 10 + it[1] + it[2] }
    for(i in 0 until perm.size) {
        val (a, b, c) = perm[i]
        val tmp = a * 10 + b + c
        if(ans < tmp) {
            ans = tmp
        }
    }
    println(ans)

    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 35836
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,mx,ans,a[1010][1010],b[1010],cnt[1010];
bool u[1010];
int read() {
	int tmp=0,fh=1; char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') fh=-1; c=getchar();}
	while (c>='0'&&c<='9') tmp=tmp*10+c-48,c=getchar();
	return tmp*fh;
}
int main() {
	n=read(); m=read(); ans=n;
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++) a[i][j]=read();
	for (int i=1;i<=n;i++) b[i]=1, cnt[a[i][b[i]]]++;
	while (1) {
		mx=0;
		for (int i=1;i<=m;i++) mx=max(mx,cnt[i]);
		if (mx==0) break; ans=min(ans,mx);
		for (int i=1;i<=m;i++) if (cnt[i]==mx) u[i]=1;
		for (int i=1;i<=n;i++) if (u[a[i][b[i]]]) {
			cnt[a[i][b[i]]]--; while (u[a[i][b[i]]]) b[i]++;
			cnt[a[i][b[i]]]++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;

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

  sort(p, p + n);

  int result = 0;
  for (int i = 0; i < k; i++)
  {
    result += p[i];
  }

  cout << result << "\n";

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>

#define Free (-1)
#define NonFree (-2)
#define NoQ (-3)
using namespace std;
const int N = 8;
int row[N];
int col[N];
int dpos[15];
int dneg[15];

int inits[N];

void printBoard() {
    for (int r = 0; r < N; ++r) {
        for (int c = 0; c < N; ++c) {
            if (row[r] != c) {
                cout << ".";
            } else {
                cout << "Q";
            }
        }
        cout << endl;
    }
};

void putQueen(int i) {
    int j;
    if (i == N) {
        printBoard();
        return;
    }
    if (inits[i] == Free) {
        for (j = 0; j < N; ++j) {
            if (col[j] == NonFree ||
                dpos[i + j] == NonFree ||
                dneg[i - j + N - 1] == NonFree) {
                continue;
            }
            row[i] = j;
            col[j] = dpos[i + j] = dneg[i - j + N - 1] = NonFree;
            putQueen(i + 1);
            row[i] = NoQ;
            col[j] = dpos[i + j] = dneg[i - j + N - 1] = Free;
        }
    }else{
        putQueen(i + 1);
    }
};
void DeskSetup(int r, int c) {  // Basic
    row[r] = c;
    col[c] = dpos[r + c] = dneg[r - c + N - 1] = NonFree;
}

void InitDesk() { // Basic
    for (int j = 0; j < N; ++j) {
        row[j] = NoQ;
        col[j] = inits[j] = Free;
    }
    for (int j = 0; j < 15; ++j) {
        dpos[j] = dneg[j] = Free;
    }

};

int main() {
    int r, c, i;
    InitDesk();
    cin >> i;
    for (int k = 0; k < i; ++k) {
        cin >> r >> c;
        DeskSetup(r, c);
        inits[r] = NonFree;
    }
    putQueen(0);
    return 0;
}


Measured memory_bytes: 3088
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
		int T = sc.nextInt();
		int [] c = new int [N];
		int [] t = new int [N];
	    
		for(int i =0; i<N; i++){
		    c[i] = sc.nextInt();
		    t[i] = sc.nextInt();
		}
		
		int min =0;
		boolean set = false;
		
		for(int i=0; i<N; i++){
		if(t[i]<=T){
		    if(set == false){
		        min = c[i];
		        set = true;
		    }
		    else if(min>c[i]){
		        min = c[i];
		    }
		}
		}
		
		if(set == false){
		    System.out.println("TLE");
		}
		else{
		System.out.println(min);
		}
 	}
}

Measured memory_bytes: 22996
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		long[] H = nextLongs();

		long ans =0;
		long tmp =0;
		for(int i=0;i<N-1;i++){
			if(H[i]>=H[i+1]){
				tmp++;
			}else{
				ans = Math.max(ans, tmp);
				tmp=0;
			}
		}
		ans = Math.max(ans, tmp);
		tmp=0;
		System.out.println(ans);

	}




	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<vector<int> > ivve;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;  

    string s;
    cin>>m;
    cin>>s;
    n=s.length();
    for(i=0;i<n;i++)
    {
        x=m;
        if(s[i]+m>90) 
        {
            x=(s[i]+m)%90;
            s[i]=char(64+x);
        }
        else s[i]=char(s[i]+x);
        
    }
    cout<<s<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3596