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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int a,b;
	cin >> a >> b;
	cout << (a <= 9 && b <= 9 ? a*b : -1) << endl;
 	return 0;
}

Measured memory_bytes: 256
#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 a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k <= a){
        cout << k << endl;
    } else if (k - a <= b){
        cout << a << endl;
    } else {
        cout << a*2 + b - k << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
s = input()
y, m, d = s.split('/')

if int(y) > 2019:
    print("TBD")
    exit()
if int(m) > 4:
    print("TBD")
    exit()
if int(d) > 30:
    print("TBD")
    exit()

print("Heisei")


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int getMostProfit_byBook(int* arr, int size) {
    if(!arr && size <= 0 ) {
        return -1;
    }
    int minv = arr[0], maxv = arr[1] - arr[0];
    for (int i = 1; i < size ; ++i) {
        maxv = max(maxv, arr[i]-minv); // 取当前值与最小值的差值最大的
        minv = min(minv, arr[i]); // 维护最小值
    }
    return maxv;
}


int main() {
    int size = 0;
    cin>>size;
    int* arr = new int[size];
    for (int i = 0; i < size; ++i) {
        cin>>arr[i];
    }
    int max = getMostProfit_byBook(arr, size);
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 3904
#include<functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <string.h>
#include <string>
#include <math.h>
#include <time.h>
#include <vector>
#include <queue>
#include<stack>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int M = 1000000007;
double const pi = acos(-1);
int n;
vector<vector<int>>v;
int dp[1 << 21];
int calc(int idx, int mask) {
	if (idx == n)
		return 1;

	int &ret = dp[mask];
	if (ret != -1)
		return ret;
	ret = 0;
	for (int i = 0; i < n; ++i) {
		if (v[idx][i] && !(mask&(1 << i)))
			ret = (ret + calc(idx + 1, mask | (1 << i))) % M;
	}
	return ret;
}

int main() {
	memset(dp, -1, sizeof dp);
	cin >> n;
	v.resize(n, vector<int>(n));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			cin >> v[i][j];
	cout << calc(0, 0) << endl;
	return 0;
}

Measured memory_bytes: 8448
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	private class Vector<E> {

		private Object[] a = new Object[10];
		private int size = 0;
		
		private void add(E element) {
			if (size + 1 > a.length) {
				expand();
			}
			a[size] = element;
			size++;
		}
		
		private void expand() {
			Object[] tmp = new Object[size*2];
			for (int i = 0; i < a.length; i++) {
				tmp[i] = a[i];
			}
			a = tmp;
		}

		@SuppressWarnings("unchecked")
		private E get(int i) {
			return (E)a[i];
		}
		
		@SuppressWarnings("unchecked")
		private E pop() {
			E element = (E)a[size-1];
			a[size-1] = null;
			size--;
			return element;
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	public void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Vector<Integer> vector = new Vector<Integer>();
		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(reader.readLine());
			int cmd = Integer.parseInt(st.nextToken());
			if (cmd == 0) {
				vector.add(Integer.parseInt(st.nextToken()));
			} else if (cmd == 1) {
				System.out.println(vector.get(Integer.parseInt(st.nextToken())));
			} else if (cmd == 2) {
				vector.pop();
			}
		}
		reader.close();
	}
}



Measured memory_bytes: 78948
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long o=0;
        long x=sc.nextLong();
        long y=sc.nextLong();
      	long z=sc.nextLong();
        long a=sc.nextLong();
      	if(a>x){
        	o+=x;  
          	a-=x;
          	a-=y;
          if(a>0){
          	o-=a;
          }
        }else{
          o=a;
        	      	
        }
        
      System.out.println(o);
    }
}  

Measured memory_bytes: 35604
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;

const double PI  = 3.141592653589793238463;

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n; i++){
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
int max;

Node root,NIL;

/*Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}
*/
Node treeSearch(Node u, int k){
  while( u != NIL && k != u ->key){
    if(k < u->key)u = u->left;
    else u = u->right;
  }
  return u;

}
/*
Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  int H;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }

  z->parent = y;

  if( y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}





void inorder( Node u){
  if( u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder( Node u){
  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
 }


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  max = 0;
  /* for(i = 0; i < n; i++){
    scanf("%s",com);
    if( strcmp(com, "insert") == 0){
      scanf("%d",&x);
      insert(x);
    }
    else if( strcmp(com, "print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    }*/
   for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
   }

  return 0;
}



Measured memory_bytes: 20440
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t;
	cin >> t;
	map<string, int>ans;
	while (t--) {
		string s;
		cin >> s;
		ans[s]++;
	}
	cout << "AC x " << ans["AC"] << "\n";
	cout << "WA x " << ans["WA"] << "\n";
	cout << "TLE x " << ans["TLE"] << "\n";
	cout << "RE x " << ans["RE"] << "\n";
	return 0;
}

Measured memory_bytes: 3632
/*
				C++
				encoding: UTF-8
				Last Modified: 29/Aug/20 05:47:00 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

#define int int64_t

template < typename T > void print (const T& t) {
	cout << t << '\n';
}

template < typename T, typename U, typename... ARGS >
void print (const T& t, const U& u, const ARGS&... args) {
	cout << t << " ";
	print (u, args...);
}

int power (int a, int b, int m) {
	int r = 1;
	while (b) {
		if (b & 1) r = r * a % m;
		b >>= 1;
		a = (a * a) % m;
	}
	return r;
}

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int n;
	cin >> n;
	const int mod = 1e9 + 7;
	vector< int > arr (n);
	int sum = 0;
	for (auto& i : arr) {
		cin >> i;
		sum += i;
		sum %= mod;
	}

	int sq = (sum * sum) % mod;
	int p = 0;
	for (auto& i : arr) {
		p += i * i;
		p %= mod;
	}

	int ans = (sq - p + mod) % mod;
	int d = power (2, mod - 2, mod);

	print (ans * d % mod);

	return 0;
}

Measured memory_bytes: 4780
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn main() {
    let input = read_line().split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect::<Vec<_>>();
    let a = input[0];
    let b = input[1];

    let mut v = Vec::new();
    v.push(a + b);
    v.push(a - b);
    v.push(a * b);
    
    println!("{}", v.iter().max().unwrap())
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
using namespace std;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
vector<int>G[10001];
int cnt[101][101],n,a[101][101];
bool used[10001];
main()
{
	cin>>n;
	for(int a,b;cin>>a>>b;)
	{
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int r=0;r<4;r++)
			{
				int tx=i+dx[r],ty=j+dy[r];
				cnt[i][j]+=tx>=0&&ty>=0&&tx<n&&ty<n;
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i==0&&j==0)
			{
				int k;
				for(k=1;G[k].size()!=2;k++);
				used[k]=1;
				a[i][j]=k;
			}
			else
			{
				int c[10001]={},ret=0;
				for(int r=0;r<4;r++)
				{
					int tx=i+dx[r],ty=j+dy[r];
					if(tx<0||ty<0||tx>=n||ty>=n)continue;
					if(a[tx][ty]==0)continue;
					ret++;
					for(int u:G[a[tx][ty]])c[u]++;
				}
				for(int u=1;u<=n*n;u++)
				{
					if(cnt[i][j]!=G[u].size())continue;
					if(used[u])continue;
					if(c[u]<ret)continue;
					a[i][j]=u;
					used[u]=1;
					break;
				}
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)cout<<a[i][j]<<(j==n-1?"\n":" ");
	}
}


Measured memory_bytes: 3828
str = input()
sp = str.split(' ')
n = int(sp[0])
m = int(sp[1])
l = int(sp[2])

a = []
for i in range(n):
    str = input()
    sp = str.split(' ')
    a_row = []
    for s in sp:
        a_row.append(int(s))
    a.append(a_row)

b = []
for i in range(m):
    str = input()
    sp = str.split(' ')
    b_row = []
    for s in sp:
        b_row.append(int(s))
    b.append(b_row)

c = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    str = ''
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
            
        str += '{}'.format(c[i][j])
        if j < l - 1:
            str += ' '
    print(str)



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

int countsum(int& n)
{
    static int a, b, c, d;
    static int count;
    count = 0;
    for(a=0; a < 10; a++)
    {
        if(a > n) break;
        for(b=0; b < 10; b++)
        {
            if(a + b > n) break;
            for(c=0; c < 10; c++)
            {
                if(a + b + c > n) break;
                for(d=0; d < 10; d++)
                {
                    if(a + b + c + d > n) break;
                    if(a + b + c + d == n) count++;
                }

            }
            
        }
        
    }

    return count;
}

int main()
{
    int n;
    while(cin >> n)
    {
        cout << countsum(n) << endl;
    }
    return EXIT_SUCCESS;
}

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

using namespace std;
typedef long long int ll;
ll N1097 = 1000000007LL;

int d[100000];
int main(){
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        scanf("%d", &d[i]);
    }
    sort(d, d+N);
    cout << d[N/2]-d[N/2-1] << endl;
}




Measured memory_bytes: 640
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

def janken(s):
  if s == "r":
    return P
  if s == "s":
    return R
  if s == "p":
    return S

answer = 0
for i in range(K):
  j = 0
  flag = 0
  while i + K * j < N:
    if j == 0:
      answer += janken(T[i + K * j])
    else:
      if T[i + K * j] != T[i + K * (j - 1)] or flag == 1:
        answer += janken(T[i + K * j])
        flag = 0
      else:
        flag = 1
    #print(T[i + K * j], answer)
    j += 1
print(answer)

Measured memory_bytes: 44144
function main(input) {
    const nums = input.split(' ').map(v => parseInt(v));
    const a = nums[0]; const b = nums[1]; const c = nums[2];
    const yum = b + c;
    const med = a + b;
    console.log(Math.min(yum, med + 1 + b));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
//using mint = modint1000000007;
//using mint = modint998244353;



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

  rep(i,K){
    cout << "ACL";
  }
  cout << endl;
  
  return 0;
}


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

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

	int score[cntarry];

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

    int ci;
    int cntarry2;

	cntarry2 = cntarry;
  
	int score2[cntarry];

	for (int i2 = 0; i2 < cntarry; i2++)
	{
		score2[i2] = score[i2];
	}

	ci = 0;
  int hasexit ;
  hasexit = 0;
	while(ci < 1000){
		for (int i3 = 0; i3 < cntarry2; i3++)
		{
			if (score2[i3] % 2 == 0)
			{
				score2[i3] = score2[i3] / 2;
			}else{
              	hasexit = 1;
				break;
			}
		}
      if( hasexit == 1){
        break;
      }
	ci = ci + 1;
	}
	
	cout << ci;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int N=100+10;

int n,a[N],b[N],c[N],d[N];

int cnt,linker[N],used[N];

bool dfs(int u)
{
	for(int i=1;i<=n;++i)
		if(a[u]<c[i]&&b[u]<d[i]&&!used[i])
		{
			used[i]=true;
			if(!linker[i]||dfs(linker[i]))
			{
				linker[i]=u;
				return true;
			}
		}
	return false;
}

int main()
{
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;++i)
		scanf("%d%d",a+i,b+i);
	for(i=1;i<=n;++i)
		scanf("%d%d",c+i,d+i);
	for(i=1;i<=n;++i)
	{
		memset(used,0,sizeof used);
		cnt+=dfs(i);
	}
	printf("%d",cnt);
	return 0;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    a--, b--;
    int s[h][w];
    rep (i, h) {
        rep (j, w) {
            if (i <= b && j <= a) s[i][j] = 0;
            else if (i > b && j > a) s[i][j] = 0;
            else s[i][j] = 1;
        }
    }
    rep (i, h) {
        rep (j, w) cout << s[i][j];
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 5120
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+2;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;

int main()
{
    IOS();
   
    int n,m,i,j=0;
    string s,t;
    cin>>s>>t;
    f(i,0,3)
    {
      if(s[i]==t[i])
        j++;

    }
    cout<<j;

    return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (int)(b) - 1; i >= (a); i--)

using namespace std;

string fliphw(string s) {
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'L') {
      s[i] = 'U';
    } else if (s[i] == 'R') {
      s[i] = 'D';
    } else if (s[i] == 'U') {
      s[i] = 'L';
    } else {
      s[i] = 'R';
    }
  }
  return s;
}

bool solve() {
  int H, W, N;
  cin >> H >> W >> N;
  int sy, sx;
  cin >> sy >> sx;
  string S, T;
  cin >> S >> T;
  for (int ii = 0; ii < 2; ii++) {
    int dpl = 0;
    int dpr = W+1;
    REPR(i, N) {
      if (dpl + 1 >= dpr) { dpl++; break; }
      if (S[i] == 'L' && T[i] == 'L') {
        // (dp[j-1]&dp[j-2]) | (dp[j]&dp[j-1])
        dpl++;
        dpr++;
      } else if (S[i] == 'L' && T[i] == 'R') {
        // (dp[j-1]&dp[j]) | (dp[j]&dp[j+1])
        dpl = max(dpl, 1);
      } else if (S[i] == 'R' && T[i] == 'L') {
        // (dp[j+1]&dp[j]) | (dp[j-1]&dp[j])
        dpr = min(dpr, W);
      } else if (S[i] == 'R' && T[i] == 'R') {
        // (dp[j+2]&dp[j+1]) | (dp[j]&dp[j+1])
        dpl--;
        dpr--;
      } else if (S[i] == 'L') {
        // dp[j] | dp[j-1]
        dpl++;
      } else if (S[i] == 'R') {
        // dp[j] | dp[j+1]
        dpr--;
      } else if (T[i] == 'L') {
        // dp[j]&dp[j-1]
        dpr++;
      } else if (T[i] == 'R') {
        // dp[j]&dp[j+1]
        dpl--;
      }
      dpl = max(dpl, 0);
      dpr = min(dpr, W+1);
      if (dpl >= dpr) break;
    }
    if (sx <= dpl || sx >= dpr) return false;
    swap(H, W);
    swap(sy, sx);
    S = fliphw(S);
    T = fliphw(T);
  }
  return true;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << (solve() ? "YES" : "NO") << '\n';
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  cout << A.at(N-1)-A.at(0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define MAXN 101
#define MAXM 101
using namespace std;

int n,m,temp;
int stu[MAXN];
int baton;
int main(){
	cin >>n >>baton;
	for(int i=1;i<=n;i++){
		cin >> stu[i];
	}
	for(int k=1;k<=baton;k++){
		for(int i=1;i<n;i++){
			if((stu[i]%k)>(stu[i+1]%k)){
				temp=stu[i];
				stu[i]=stu[i+1];
				stu[i+1]=temp;
			}
		}
	}


	for(int i=1;i<=n;i++){
		cout << stu[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 3056
N = int(input())
X = []
Y = []
P = []
for _ in range(N):
    x, y, p = map(int, input().split())
    X.append(x)
    Y.append(y)
    P.append(p)

DX = [[0] * N for _ in range(1 << N)]
DY = [[0] * N for _ in range(1 << N)]

for i, x in enumerate(X):
    for k in range(1 << N):
        d = abs(x)
        for j, xx in enumerate(X):
            if k & (1 << j):
                d = min(d, abs(xx - x))
        DX[k][i] = d * P[i]
for i, y in enumerate(Y):
    for k in range(1 << N):
        d = abs(y)
        for j, yy in enumerate(Y):
            if k & (1 << j):
                d = min(d, abs(yy - y))
        DY[k][i] = d * P[i]

ANS = [1 << 100] * (N + 1)
PC = [0] * (1 << N)
for i in range(1, 1 << N):
    PC[i] = PC[i^1] + 1 if i % 2 else PC[i//2]

RA = []
for i in range(1 << N):
    t = []
    for j in range(N):
        if i & (1 << j):
            t.append(j)
    RA.append(t)

mm = (1 << N) - 1
for i in range(1 << N):
    m = i ^ mm
    j = m
    dxi = DX[i]
    pci = PC[i]
    while 1:
        dyj = DY[j]
        ans = 0
        for k in RA[i^j^mm]:
            ans += min(dxi[k], dyj[k])
        
        pc = pci + PC[j]
        if ans < ANS[pc]:
            ANS[pc] = ans
        
        if not j:
            break
        j = m & (j - 1)


print(*ANS, sep = "\n")


Measured memory_bytes: 88944
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#define ll long long int
using namespace std;

int main() {
	int num = 11;
	int a[12], flag=0;
	ll N, t=0;
	std::string Q = "";
	char X ='a', s;
	cin >> N ;
	for (int i = 0; i <= num; i++){
		for (int k = 0; (flag==0)&&(k<=(num-i)); k++){
			t += std::pow(26, ((num-i) - k));
		}
		if (N >= t){
			flag = 1;
			if (t>0){
				N = N - t;
			}
			a[i] = N / std::pow(26, (num - i));
			N = N - std::pow(26, (num - i))*a[i];
			s = X + a[i];
			Q = Q + s;
		}
		else if (flag == 1){
			a[i] = N / std::pow(26, (num - i));
			N = N - std::pow(26, (num - i))*a[i];
			s = X + a[i];
			Q = Q + s;
		}
		t = 0;
	}
	cout << Q << endl;

	return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define i_love_u_Phuong ios_base::sync_with_stdio(0); cin.tie(0);
using ll = long long;
using namespace std;
using ld = long double;






int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif // ONLINE_JUDGE
    i_love_u_Phuong;
    string s;
    cin >> s;
    int res=0;
    int len=0;
    for(int i=0; i<s.size(); ++i)
    {
        if (s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C')
            len++;
        else
        {
            res=max(res,len);
            len=0;
        }
    }
    res=max(res,len);
    cout << res;
    return 0;
}



Measured memory_bytes: 256
import copy
key = list(input())
hantei=0
length=len(key)
if "".join(key)=="keyence":
    hantei=1
for i in range(length):
    if hantei==1:
        break
    a=copy.deepcopy(key)
    if i==length-1:
        j=length-2
    else:
        j=i
    while j<length-1:
        del a[i]
        j+=1
        if "".join(a)=="keyence":
            hantei=1
            break
if hantei==1:
    print("YES")
else:
    print("NO")
        




Measured memory_bytes: 3444
/*
*
*   解説見てないお
*
*/
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

// 最小全域木 O(ElogV)?
struct Edge {
    int cost, to;
    bool operator>(const Edge e)const {
        return this->cost > e.cost;
    }
    bool operator<(const Edge e)const {
        return this->cost < e.cost;
    }
};

int Prim(const vector<vector<Edge>> &G) {
    int res = 0;
    vector<bool> used(G.size(), false);
    priority_queue<Edge, vector<Edge>, greater<Edge>> pq;
    for (const Edge &e : G[0]) {
        pq.push(e);
    }
    used[0] = true;
    while (!pq.empty()) {
        Edge e = pq.top(); pq.pop();
        if (used[e.to]) continue;
        used[e.to] = true;
        res += e.cost;
        for (const Edge &u : G[e.to]) {
            if (used[u.to]) continue;
            pq.push(u);
        }
    }
    return res;
}

//ワーシャルフロイド法
int V; //頂点数
const int MAX_V = 300;
ll d[MAX_V][MAX_V]; //最短距離(INFで初期化,d[i][i]=0,d[i][j]=辺ijのコスト)
ll d2[MAX_V][MAX_V]; //最短距離(INFで初期化,d[i][i]=0,d[i][j]=辺ijのコスト)
bool d3[MAX_V][MAX_V];
void warshall_floyd() {
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                if (d[i][j] > d[i][k] + d[k][j]) {
                    d[i][j] = d[i][k] + d[k][j];
                }
                else if (i != k && j != k && d[i][j] == d[i][k] + d[k][j]) {
                    d3[i][j] = true;
                    d3[j][i] = true;
                }
            }
        }
    }
}

int main() {
    int n; cin >> n;
    V = n;
    REP(i, n) {
        REP(j, n) {
            int a; scanf("%d", &a);
            d[i][j] = a;
            d2[i][j] = a;
            if (i == j) continue;
        }
    }
    warshall_floyd();
    ll ans = 0;
    REP(i, n-1) {
        FOR(j, i + 1, n) {
            if (d[i][j] != d2[i][j]) {
                puts("-1");
                return 0;
            }
            if (!d3[i][j]) {
                ans += d[i][j];
            }
        }
    }
    /*
    REP(i, n) {
        REP(j, n) {
            cout << (d3[i][j] ? 1 : 0) << " ";
        }
        cout << endl;
    }
    */
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  cout << (x-a)%b << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    int time=100*n+1800*m;
    int ans=time;
    for(int i=0;i<m;i++){
        ans=ans*2;
    }
    cout<<ans;
    return 0;
}


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

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

  vector<int> vec(N);

  for (int i = 0; i < N; i++)
  {
    cin >> vec.at(i);
  }

  int sum = 0;

  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      sum += vec.at(i) * vec.at(j);
    }
  }

  cout << sum << endl;
}


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

int main(){
    string s;
    cin >> s;
    if(s.size()==2)cout<<s<<endl;
    else if(s.size()==3){
    reverse(s.begin(),s.end());
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n <= 1000:
        break

for i in range(1, n+1):
    l = list(map(int, input().split()))
    l.sort()
    if l[0]*l[0]+l[1]*l[1] == l[2]*l[2]:     
        print('YES')
    else :
        print('NO')


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,m,ans[N],a[N],b[N],t[N<<2],t1[N<<2],t2[N<<2];
void update(int l,int r,int k)
{
    t1[k]=t[k]+r-l;t2[k]=t[k];
    if(l!=r)
    {
        int m=l+r>>1;
        t[k<<1]=t[k];t[k<<1|1]=t[k]+m+1-l;
    }
    t[k]=0;
}
int query(int l,int r,int k,int x)
{
    if(t[k]) update(l,r,k);
    if(l>x) return m+1;
    if(r<=x) return t1[k];
    int m=l+r>>1;
    int a=query(l,m,k<<1,x),b=query(m+1,r,k<<1|1,x);
    if(x<=r) a+=x>=m?x-m:0;
    else a+=r-m;
    t2[k]=min(t2[k<<1],t2[k<<1|1]);
    t1[k]=min(t1[k<<1]+r-m,t1[k<<1|1]);
    return min(a,b);
}
void update(int l,int r,int k,int x,int y,int d)
{
    if(t[k]) update(l,r,k);
    if(r<x||l>y) return;
    if(l>=x&&r<=y)
    {
        t[k]=d+l-x;
        update(l,r,k);
        return;
    }
    int m=l+r>>1;
    update(l,m,k<<1,x,y,d);update(m+1,r,k<<1|1,x,y,d);
    t2[k]=min(t2[k<<1],t2[k<<1|1]);
    t1[k]=min(t1[k<<1]+r-m,t1[k<<1|1]);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
    for(int i=1;i<=n;i++)
    {
        int d=m+1;
        d=min(d,query(1,m,1,a[i]-1)+1);
        update(1,m,1,a[i],b[i],d);
        //cout<<"I: "<<i<<' '<<d<<' '<<a[i]<<' '<<b[i]<<' '<<t2[1]<<endl;
        ans[i]=t2[1];
    }
    for(int i=1;i<=n;i++)
    {
        if(ans[i]>=m) ans[i]=-1;
        else ans[i]+=i;
        printf("%d\n",ans[i]);
    }
}


Measured memory_bytes: 12260
i, o, t, j, l, s, z = (int(a) for a in input().split())

a = o + i//2*2 + j//2*2 + l//2*2
if i > 0 and j > 0 and l > 0:
    b = 3 + o + (i-1)//2*2 + (j-1)//2*2 + (l-1)//2*2
else:
    b = 0
print(max(a,b))

Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll combination (ll a, ll b) {
    ll ret = 1;
    ll tmp_b = b;
    while(1) {
        if (tmp_b == 0) break;
        ret *= a;
        --tmp_b;
        --a;
    }
    while(1) {
        if (b == 0) break;
        ret /= b;
        --b;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 2; i <= n; ++i) {
        int num = i;
        for (int j = 2; j * j <= i; ++j) {
            while(1) {
                if (num % j != 0) break;
                ++mp[j];
                num /= j;
            }
        }
        if (num != 1) ++mp[num];
    }
    vector<vector<int>> dp(n+1, vector<int>(76, 0));
    dp[1][1] = 1;
    for (int i = 1; i < n; ++i) {
        for (int have = 0; have <= 75; ++have) {
            for (int take = 1; take <= mp[i] + 1; ++take) {
                if (have * take > 75) continue;
                dp[i+1][have * take] += dp[i][have];
            }
        }
    }
    cout << dp[n][75] << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld                long long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
//Bitwise 
#define isOn(S, j) (S & (1<<j))
#define setBit(S, j) (S |= (1<<j))
#define clearBit(S, j) (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
db eps       =          0.000001;
ll mod       =          (1e9+7);   //998244353
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  
    iota(B,B+r,1);     

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
const int SIZE=1e6+5;
bool judgePermutation(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}
vector<int> adj[1010]; 

int main(){ 
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(10);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	ll ans=1,f=0;
	rep(i,0,n){
		ll temp;
		cin>>temp;
		if(temp==0){
			cout<<0<<endl;
			return 0;
		}
		if(temp<=1000000000000000000LL/ans) ans*=temp; else f=1;
		
	}
	if(f) cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}

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

int main() {
	char a;
  	cin >> a;// >>b >> c >>d;
  if(a=='A')cout<<"T"<<endl;
  else if(a=='C') cout<<"G"<<endl;
  else if(a=='G') cout<<"C"<<endl;
  else if(a=='T') cout<<"A"<<endl;
  
}
 

Measured memory_bytes: 256
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.05.26 20:48:27
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
    int n;
    string s[110];
    int p[110];
    cin >> n;
    rep(i, n) {
        cin >> s[i] >> p[i];
    }
    vector<pair<int, pair<string, int>>> vec;
    rep(i, n) {
        vec.pb(mp(i + 1, mp(s[i], p[i])));
    }
    sort(vec.begin(), vec.end(),
         [](const pair<int, pair<string, int>> a, const pair<int, pair<string, int>> b) {
             string as = a.sc.fr;
             string bs = b.sc.fr;
             int ap = a.sc.sc;
             int bp = b.sc.sc;
             if (as != bs)
                 return as < bs;
             else
                 return ap > bp;
         });
    rep(i, n) {
        cout << vec[i].fr << '\n';
    }

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, t) = readLine()!!.split(' ').map { it.toInt() }
    val routes = (0 until n).map {
        val (ci, ti) = readLine()!!.split(' ').map { it.toInt() }
        ci to ti
    }
    routes.filter { it.second <= t }
            .minBy { it.first }
            .let { println(it?.first ?: "TLE") }
}


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

using namespace std;

int main() {
	int N; cin >> N;
	for (int i=0; i<N; i++) {
		string a, b;
		cin >> a >> b;
		int sum, ret=0;
		if (a.length() < b.length()) swap(a,b);
		int l = b.length()-1;
		for (int i=a.length()-1; i>=0; i--) {
			if (l >= 0) {
				sum = (a[i]-48)+(b[l]-48)+ret;
				l--;
			} else {
				sum = (a[i]-48)+ret;
			}
			if (sum>=10) {
				ret = 1;
				sum -= 10;
			} else {
				ret = 0;
			}
			a[i] = sum+48;
		}
		if (ret != 0) {
			a.insert(a.begin(), ret+48);
		}
		if (a.length() > 80) cout << "overflow" << endl;
		else cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<cmath>
#include<map> 
#include<string>
#include<queue>
#include<stack> 
#include<bitset>
#include<list>
#include<set>
#include<utility>
#include<iomanip>
#define IO ios::sync_with_stdio(false)
#define eps 1e-7
//#define int long long
using namespace std;
string s,t;
int ans=0;
int main()
{
	cin>>s;
	cin>>t;
	for(int i=0;i<s.size();i++)
	{
		ans+=(s[i]!=t[i]);
	}
	cout<<ans;
 } 

Measured memory_bytes: 3820
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a;
  vector<int> b;
  for(int i = 0; i < n ; i++){
    int t;
    cin >> t;
    auto res = find(a.begin(), a.end(), t);
    if( res == a.end() ){
      a.push_back(t);
      b.push_back(1);
    }
    else b[res - a.begin()]++;
  }
  if(a.size() == 3){
    if(b[0] == b[1] && b[1] == b[2]){
      if( (a[0]^a[2]) == a[1] && (a[1]^a[0]) == a[2] && (a[2]^a[1]) == a[0]){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  else if(a.size() == 2){
    if((b[0]*2 == b[1] && a[0] == 0) || (b[1]*2 == b[0] && a[1] == 0)){
      cout << "Yes" << endl;
      return 0;
    }
  }
  else if(a.size() == 1 && (a[0]^a[0])==a[0]){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 1276
#include<stdio.h>

int main(){
    int r,c;
    int i,j;
    int a[101][101];
    
    int sum=0;
    
    for(i=0;i<101;i++){
        for(j=0;j<101;j++){
            a[i][j]=-1;
        }
    }
    
    scanf("%d %d",&r,&c);
    
    for(i=0;i<r;i++){
        sum=0;
        for(j=0;j<c;j++){
            scanf("%d",&a[i][j]);
            sum+=a[i][j];
        }
        a[i][c]=sum;
    }
    
    for(j=0;j<c;j++){
        sum=0;
        for(i=0;i<r;i++){
            sum+=a[i][j];
        }
        a[r][j]=sum;
    }
    
    a[r][c]=0;
    
    for(i=0;i<r;i++){
        a[r][c]+=a[i][c];
    }
    
    for(i=0;i<=r;i++){
        for(j=0;j<c;j++){
            printf("%d ",a[i][j]);
        }
        printf("%d\n",a[i][c]);
    }
    
    return 0;
}

Measured memory_bytes: 1836
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int n,m;
	int taro[128],hana[128],sumt,sumh;
	while(scanf("%d%d",&n,&m),n|m){
		sumt=sumh=0;
		rep(i,n){ scanf("%d",taro+i); sumt+=taro[i]; }
		rep(i,m){ scanf("%d",hana+i); sumh+=hana[i]; }
		int k = INT_MAX;
		int ta,ha;
		rep(i,n) rep(j,m) if( sumt-taro[i]+hana[j]==sumh-hana[j]+taro[i] ){
			if( k>taro[i]+hana[j] ){
				k = taro[i]+hana[j];
				ta = taro[i];
				ha = hana[j];
			}
		}
		if( k==INT_MAX ){
			puts("-1");
		}else{
			printf("%d %d\n",ta,ha);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    for (int i = 1; i <= 9; i++) {
        if (N <= 111 * i) {
            cout << 111 * i << endl;
            return 0;
        }
    }
    cout << "1111" << endl;
}


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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    cout<<(n+x-1)/x*t<<endl;
}


Measured memory_bytes: 3628
#AOJ ALDS1_8_B
#binary_search_tree 2

class FindMixin
  def find(n)
    # printf("find %d:[%d][%d]\n",n,self.key,(n == self.key)?1:0)
    if n == self.key
      return 1
    end
    ret = 0
    if self.left != nil && self.key > n 
      return self.left.find(n)
    end
    if self.right != nil && self.key < n 
      return self.right.find(n)
    end
  end
end

class Node < FindMixin
  attr_accessor :key,:parent,:left,:right

  def initialize(n)
    @key    = n
    @parent = nil
    @left   = nil
    @right  = nil
  end

  def add_left(child)
      self.left    = child
      child.parent = self
  end

  def add_right(child)
      self.right    = child
      child.parent = self
  end

  def preorder
    printf(" %d",self.key)
    if(left != nil)
      left.preorder
    end
    if(right!= nil)
      right.preorder
    end
  end

  def inorder
    if(left != nil)
      left.inorder
    end
    printf(" %d",self.key)
    if(right!= nil)
      right.inorder
    end
  end

  def postorder
    if(left != nil)
      left.postorder
    end
    if(right!= nil)
      right.postorder
    end
    printf(" %d",self.key)
  end

end

class Bin_search_tree
  attr_accessor :root

  def initialize
    @root = nil
  end

  def inorder
    self.root.inorder
  end

  def preorder
    self.root.preorder
  end

  def insert(node)
    y = nil
    x = self.root
    while x != nil
      y = x
      if node.key < x.key
        x = x.left
      else
        x = x.right
      end
    end
    
    node.parent = y

    if y == nil
      self.root = node
    elsif node.key < y.key
      y.left = node
    else
      y.right= node
    end
  end

  def find(n)

    self.root.find(n)
  end
end

$n = STDIN.gets.split[0].to_i
$b_s_tree = Bin_search_tree.new

0.upto($n-1){|i|
  s = STDIN.gets.split
  if s[0].to_s == "insert"
    node = Node.new(s[1].to_i)
    $b_s_tree.insert(node)
  elsif s[0].to_s == "print"
    $b_s_tree.inorder
    printf("\n")
    $b_s_tree.preorder
    printf("\n")
  elsif s[0].to_s == "find"
    ky = s[1].to_i
    if 1==$b_s_tree.find(ky)
      puts "yes"
    else
      puts "no"
    end
  end
}

Measured memory_bytes: 66420
class restaurant:
    def __init__(self, name, point, num):
        self.name = name
        self.point = point
        self.num = num
    def __repr__(self):
        return "%d" % (self.num)



def main():
    N  = int(input())
    restaurants = []
    for i in range(N):
        S = input().split()   
        restaurants.append(restaurant(str(S[0]),int(S[1]),i+1))

    restaurants = sorted(restaurants, key=lambda x: x.point , reverse=True)
    restaurants = sorted(restaurants, key=lambda x: x.name)

    
    for i in range(N):
        print(restaurants[i])



if __name__ == '__main__':
    main()


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

using namespace std;


int main()
{
    int a,b;
    cin>>a>>b;
    int ans=0,socket=0,limit=b;
    if(b==1)ans=0;
    else{
    while(1){
        //cout<<socket<<endl;
        if((socket+a)<limit){
            socket+=a;
            socket--;
            ans++;
        }
        else{
            ans++;
            break;
        }
    }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#define rep(i,x) for (int i = 0; i < x; i++)
#define MOD 998244353
#define INF (1<<31)-1
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;


int main() {
	int n;
	cin >> n;
	int dp[110][5][5][5] = {};
	dp[0][1][1][1] = 1;
	rep(len,n){
		rep(k, 4) {
			rep(j, 4) {
				rep(i, 4) {
					rep(l, 4) {
						if (j == 0 && k == 3 && l == 2) continue;
						if (j == 2 && k == 0 && l == 3) continue;
						if (j == 0 && k == 2 && l == 3) continue;
						if (i == 0 && k == 2 && l == 3) continue;
						if (i == 0 && j == 2 && l == 3) continue;
						dp[len + 1][j][k][l] += dp[len][i][j][k];
						dp[len + 1][j][k][l] %= mod;
					}
				}
			}
		}
	}
	ll ans = 0;
	rep(i, 4) {
		rep(j, 4) {
			rep(k, 4) {
				ans += dp[n][i][j][k];
				ans %= mod;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define endl "\n"

using namespace std;

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

    ll n;
    cin >> n;

    vector<int> arr(n);

    for (int i = 0; i < n; i++)
        cin >> arr[i];

    int count = 0;
    for (int i = 1; i < n - 1; i++)
    {
        int p[3] = {arr[i - 1], arr[i + 1], arr[i]};
        sort(p, p + 3);
        if (p[1] == arr[i])
            count++;
    }

    cout << count;
}

Measured memory_bytes: 256
import itertools
import math
import sys
import numpy as np
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().strip()


def main():
    K = int(input())
    num_list = np.array([i for i in range(1,K+1)])
    print(np.sum(np.gcd.outer(np.gcd.outer(num_list,num_list),num_list)))

main()


Measured memory_bytes: 89636
#include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;

int main() {
  int n;
  cin >> n;
  for( int i = 0; i < n; i++ ) {
    double xa, ya, ra, xb, yb, rb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    
    double dsq = pow( xb - xa, 2.0 ) + pow( yb - ya, 2.0 );
    if( sqrt( dsq ) > ra + rb ) {
      cout << 0 << endl;
      continue;
    }
//     b in a
    if( sqrt( dsq ) < ra - rb ) {
      cout << 2 << endl;
      continue;
    }

//     a in b 
    if( sqrt( dsq ) < rb - ra ) {
      cout << -2 << endl;
      continue;
    }

    cout << 1 << endl;
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define ll long long 
#pragma GCC optimize("Ofast", "unroll-loops")
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define pii pair<int,int>
#define SZ(x) x.size()
#define ALL(x) x.begin(), x.end()
#define ull unsigned ll 
#define pb push_back
#define f first 
#define s second
using namespace std;
int arr[100005];
int dp[100005];
int main (){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n; cin>>n;
	REP(i,n) cin>>arr[i];
	dp[0]=0;
	dp[1]=abs(arr[0]-arr[1]);
	FOR(i,2,n) {
		int a=abs(arr[i-2]-arr[i]);
		int b=abs(arr[i-1]-arr[i]);
		dp[i]=min(dp[i-2]+a,dp[i-1]+b);
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
    	int k=x.nextInt();
		int r=x.nextInt();
		for(int i=r-(k-1);i<r+k;i++)
		{
			System.out.print(i+" ");
		}
	}
}

Measured memory_bytes: 22484
#include <stdio.h>
#include <string.h>

int main(){
  char s[103], t[103];  scanf("%s %s", s, t);
  int len = strlen(s), flag = 0;
  for(int start=0; start<len; start++){
    for(int i=0; i<len; i++){
      if(s[(i+start)%len] != t[i])
	break;
      if(i == len-1){
	flag = 1;
	break;
      }
    }
    if(flag)  break;
  }

  if(flag)  printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 128