akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, PP> PPP;
typedef vector<int> vec;
typedef vector<vec> mat;
typedef complex<double> Point;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

bool operator < (const Point & a, const Point & b){
	return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}


int res;
bool use[10];
int s1[10];
int s2[10];
int num[10]; 
map<char, int> mp;
map<char, bool> used;
map<int , bool> bad;

void dfs(int n, int val){
	if(n == 0){
		if(val == 0){
			res++;
		}
		return ;
	}

	if(val > 0 && val + s1[n - 1] > 0) return;
	if(val <= 0 && val + s2[n - 1] < 0) return ;

	for(int i = 0; i < 10; i++){
		if(i == 0 && bad[n - 1]) continue;
		if(!use[i]){
			use[i] = true;
			dfs(n - 1, val + i * num[n - 1]);
			use[i] = false;
		}
	}
}

int pow(int n){
	int res = 1;
	for(int i = 0; i < n; i++) res *= 10;
	return res;
}

int main(){
	int n;
	while(cin >> n && n){
		string s;
		int c = 0;
		fill(num, num + 10, 0);
		mp.clear();
		bad.clear();
		used.clear();
		for(int i = 0; i < n; i++){
			cin >> s;
			for(int j = 0; j < (int)s.size(); j++){
				if(!used[s[s.size() - 1 - j]]){
					mp[s[s.size() - 1 - j]] = c++;
					used[s[s.size() - 1 - j]] = true;
				}
				ll d = pow(j);
				if(i == n - 1){
					num[mp[s[s.size() - 1 - j]]] -= d;
				}else{
					num[mp[s[s.size() - 1 - j]]] += d;
				}
				if(j == s.size() - 1 && s.size() > 1) bad[mp[s[0]]] = true;
			}
		}
		s1[0] = min(0, num[0]) * 9;
		s2[0] = max(0, num[0]) * 9;
		for(int i = 1; i < c; i++){
			s1[i] = s1[i-1] + min(0, num[i]) * 9;
			s2[i] = s2[i-1] + max(0, num[i]) * 9;
		}
		res = 0;
		memset(use, false, sizeof(use));
		dfs(c, 0);
		cout << res << endl;
	}
}

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

long long a, b;
int ans;

int main()
{
	scanf("%lld%lld", &a, &b);
	while(b >= a)
	{
		a *= 2;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
const int INF=1e9+5;
int main()
{
	int n,k;
	cin>>n>>k;
	int h[n];
	for(int i=0;i<n;i++)
		cin>>h[i];
	vector<int> dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<=(i+k);j++)
		{
			if(j<n)
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
		}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
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; }

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  cout << a[0] << b[0] << c[0] << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	c := nextInt()

	if a > c-2 || b > c-2 || (a+b) > c-2 {
		fmt.Println(b + c)
		return
	}

	fmt.Println(a + b + 1 + b)

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);

        int power2 = 1;
        for (int i = 0; i < M; i++) power2 *= 2;

        Console.WriteLine(power2 * (1900 * M + (N - M) * 100));
        Console.ReadLine();
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define num(a) a-'0'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define vl vector<long long int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	int n;
	cin>>n;
	vi a(n);
	vi f(n,0);
	for(int i=0;i<n-1;i++){
		cin>>a[i];
		f[a[i]-1]++;
	}
	for(int i=0;i<n;i++){
		cout<<f[i]<<ln;
	}
}	

int main(){
	boost_io;
	cout<<setprecision(10);
	solve();
	return 0;
}


Measured memory_bytes: 4744
/**
 *    author:  tourist
 *    created: 02.09.2017 15:16:11       
**/
#include <bits/stdc++.h>

using namespace std;

const int MAX = 1234567;

int a[MAX];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int foo;
    scanf("%d", &foo);
    a[foo]++;
  }
  int ans = 0;
  for (int i = 0; i < MAX - 2; i++) {
    ans = max(ans, a[i] + a[i + 1] + a[i + 2]);
  }
  printf("%d\n", ans);
  return 0;
}


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

int main(){

int A,B,C,X;
  int count=0;
  cin >> A >> B >> C >> X;
  for(int a=0;a <=A;a++){
   for(int b=0;b <=B;b++){
     for(int c=0;c <=C;c++){
   int total;    
       total=500*a+100*b+50*c;
      if(total==X)count++; 
     }
   } 
  } 
  cout << count << endl;
}
     
     
     
     

Measured memory_bytes: 3460
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    

L,R=map(int,input().split())

ans=2019**2
if R-L>2019:
	print(0)
	
else:
	for i in range(L,R):
		for j in range(i+1,R+1):
			ans=min(ans,(i*j)%2019)
	print(ans)

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

using namespace std;

int main(){
    int b1;
    int b2;
    int b3;
    cin >> b1 >> b2 >> b3;
    string result = "";
    if(b1 == 1 && b2 == 0 && b3 == 0){
        result = "Close";
    }
    if(b1 == 0 && b2 == 1 && b3 == 0){
        result = "Close";
    }
    if(b1 == 1 && b2 == 1 && b3 == 0){
        result = "Open";
    }
    if(b1 == 0 && b2 == 0 && b3 == 1){
        result = "Open";
    }
    if(b1 == 0 && b2 == 0 && b3 == 0){
        result = "Close";
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> c;
long long dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
long long dy[8] = {-1, 0, 1, 1, -1, -1, 0, 1};
long long W, H;

void DFS(long long y, long long x)
{
    c[y][x] = 0;
    for (long long i = 0; i < 8; i++)
    {
        long long tx = x + dx[i];
        long long ty = y + dy[i];

        if (tx < 0 || ty < 0 || tx >= W || ty >= H)
            continue;

        if (c[ty][tx] == 0) //if(tx~)と逆だとover
            continue;

        DFS(ty, tx);
    }
}

int main()
{

    while (cin >> W >> H)
    {
        if (H == 0 && W == 0)
            break;
        long long cnt = 0;
        c.assign(H, vector<long long>(W, 0));
        //bool seen[H][W] = {false};

        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                cin >> c[i][j];
            }
        }

        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                //if (c[i][j] == 1) この条件だと,海の近くに島があるとそれを塗りつぶしてしまう。
                //    cnt++;
                if (c[i][j] == 0) //この条件を入れないと,海隣の島を塗りつぶしてしまう。
                    continue;
                DFS(i, j);
                cnt++;
            }
        }

        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3176
// D.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    int kazu[1005];
    int ans = 0;
    cin >> n;
    int ruiseki[1005];
    vector<int>a;
    for (int i = 0; i < n; i++) {
        int l;
        cin >> l;
        a.push_back(l);
        
    }
    sort(a.begin(), a.end());

    for (int i = 0; i < a.size() - 2; i++) {
        for (int j = i+1; j < a.size() - 1; j++) {
            for (int k = j+1; k < a.size(); k++) {
                if (a[i] + a[j] > a[k]) {
                    ans++;
                }
                else {
                    
                }
            }
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long dis[305][305],n,m,i,j,k,ans,vis[305][305];
int main()
{
	cin>>n;
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n;j++)
		{
			cin>>dis[i][j];
			ans+=dis[i][j];
		}
	}
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n;j++)
		{
			if (dis[i][j]!=dis[j][i])
			{
				 cout<<-1;
				 return 0;
			}
		}
	}
	for (k=1;k<=n;k++)
	{
		for (i=1;i<=n;i++)
		{
		 	for (j=1;j<=n;j++)
		 	{
			 	if (i!=j&&j!=k&&i!=k)
				{
					if (dis[i][j]>dis[i][k]+dis[k][j])
					{
						cout<<-1;
						return 0;
					}
					if (dis[i][j]==dis[i][k]+dis[k][j])
					{
						if (!vis[i][j]) ans-=dis[i][j];
						vis[i][j]=1;
					}
				}
			}
		}
	}
	ans/=2;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1664
#3問目
X, N = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
resultPlus = X
resultMinus = X
flag = True
if(N == 0):
    print(X)
else:
    if X in p:
        while flag == True:
            resultMinus -= 1
            resultPlus += 1
            if resultMinus not in p:
                flag = False
                print(resultMinus)
                break
            if resultPlus not in p:
                flag = False
                print(resultPlus)
                break
    else:
        print(X)

Measured memory_bytes: 9200
/* 
    AtCoder Beginner Contest 085
    A:Already 2018
    AC
*/

#include <iostream>
using namespace std;

int main(void)
{
    int i;
    string s;
    string ans;
    cin >> s;
    ans = s;
    ans[3] = '8';
    // for (i = 0; i < 3; i++)
    // {
    //     if(s[i] == 'o')
    //         charge += 100;
    // }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = sc.nextInt();
    int count = 0;
    StringBuffer pre = new StringBuffer();
    StringBuffer tail = new StringBuffer();
    for(int i = 0; i < n; ++i) {
      int op = sc.nextInt();
      if(op == 1) {
        ++count;
      }
      if(op == 2) {
        int mid = sc.nextInt();
        if((mid == 1) && (count & 1) == 0 || (mid == 2 && (count & 1) == 1)) {
          pre.append(sc.next().charAt(0) + "");
        } else {
          tail.append(sc.next().charAt(0) + "");
        }
      }
    }
    s = ope1(pre.toString()) + s + tail.toString();
    if((count & 1) == 1) s = ope1(s);
    System.out.println(s);
  }
  
  private static String ope1(String s) {
    StringBuffer str = new StringBuffer();
    char[] a = s.toCharArray();
    for(int i = a.length - 1; i > -1; --i) {
      str.append(a[i] + "");
    }
    return str.toString();
  }
}

Measured memory_bytes: 153284
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    a=std::abs(x-a);
    b=std::abs(x-b);
    if(a<b){
        cout << "A" << endl;
    }
    else{
        cout << "B" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
INF=10**9
n,a,b,c=map(int,input().split())
l=[int(input()) for i in range(n)]
def dfs(i,x,y,z):
    if i==n:
        if min(x,y,z)>0:
            return abs(x-a)+abs(y-b)+abs(z-c)-30
        else:
            return INF
    ans=dfs(i+1,x,y,z)
    ant=dfs(i+1,x+l[i],y,z)+10
    anu=dfs(i+1,x,y+l[i],z)+10
    anv=dfs(i+1,x,y,z+l[i])+10
    return min(ans,ant,anu,anv)
print(dfs(0,0,0,0))

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

int main() {
    long money = 1000;
    long n;
    cin >> n;
    long a[n],b[n];
    int j = 0;
    int index = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        if(i!=n-1){
            if(a[i]<a[i+1]){
                b[j]=a[i];
                b[j+1]=a[i+1];
                //cout << a[i+1] << endl;
                j+=2;
                index += 2;
            }
        }
    }
    long c[index];
    long kab=0;
    bool ch = true;
    for(int i=0;i<index;i++){
        c[i]=b[i];
    }
    for(int i=0;i<index;i+=2){
            kab = money/c[i];
            money = money%c[i];
            money = kab*c[i+1]+money;
            //cout << money << c[i] << endl;
    }
        //cout <<c[i]<< endl;

        cout << money << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N, M;
    cin >> N >> M;

    ll ans = (N * (N - 1)) / 2;
    ans += (M * (M - 1)) / 2;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define llint long long int
#define ldouble long double

//setprecision()<<

using namespace std;

int main() {
    int N,K;
    string S;
    cin>>N>>S>>K;
    char x=S.at(K-1);
    for(int i=0;i<S.size();i++){
        if(x!=S.at(i)){
            S.at(i)='*';
        }
    }

    cout<<S<<endl;
return 0;
}

Measured memory_bytes: 256
"use strict"

function Main(input) {
  input = input.trim().split('\n');
  const H = input[0].trim().split(' ').map(Number)[0];
  const W = input[0].trim().split(' ').map(Number)[1];
  const S = input.slice(1).map(val => val.trim().split(''));
  const dh = [-1, -1, -1, 0, 0, 1, 1, 1];
  const dw = [-1, 0, 1, -1, 1, -1, 0, 1];

  // 全てのS[h][w]のパターンを探索
  for (let h=0; h<H; h++) {
    for (let w=0; w<W; w++) {
      // 対象が爆弾(#)の場合、スキップ
      if (S[h][w] === '#') continue;

      // 対象から移動範囲の8マスを探索
      let cnt = 0;
      for (let d=0; d<8; d++) {
        let nh = h + dh[d];
        let nw = w + dw[d];
        
        if (nh >= 0 && nh < H && nw >= 0 && nw < W) {
          // 移動範囲が指定された範囲から外に出ていない場合、
          // 対象の移動範囲8マス内に爆弾(#)があるか否かを探索。
          // 爆弾が存在する場合、cnt(自身の周囲に爆弾数)を+1する。
          let t = S[nh][nw];
          if (t === '#') cnt += 1;
        };
      };

      // 対象をcnt(自身の周囲に爆弾数)に置き換える
      S[h][w] = cnt;
    };
  };

  console.log(S.map(s => s.join('')).join('\n'));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7756
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

const ll lim = 1e18;

int main(){
  int n;
  cin >> n;
  ll ans = 1;
  rep(i, n){
    ll in;
    cin >> in;
    if(in == 0){
      cout << 0 << endl;
      return 0;
    }
    if(in > lim/ans || ans * in > lim || ans == -1){
      ans = -1;
    }else{
      ans *= in;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
  int n, k; cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int h; cin >> h;
    if (h >= k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int ans,n;

int dfs(long long x){
    if(x>n) return 0;
    int num=0;
    bool ok3=false,ok5=false,ok7=false;
    for(int i=1;x/i;i*=10){
        int X=(x%(i*10))/i;
        if(X==3)ok3=true;
        if(X==5)ok5=true;
        if(X==7)ok7=true;
    }
    if(ok3&&ok5&&ok7) num++;
    num+=dfs(x*10+3);
    num+=dfs(x*10+5);
    num+=dfs(x*10+7);
    return num;
}

int main(){
    cin>>n;
    cout<<dfs(0);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;

int main() {
    string S; cin >> S;
    if(S == "hi") cout << "Yes" << endl;
    else if(S == "hihi") cout << "Yes" << endl;
    else if(S == "hihihi") cout << "Yes" << endl;
    else if(S == "hihihihi") cout << "Yes" << endl;
    else if(S == "hihihihihi") cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    vector<int> v(100);
    int count = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'I'){
            count++;
           // cout << count << endl;
            v.push_back(count);
        }
        else{
           count--;
           //cout << count << endl;
           v.push_back(count);
        }
    }
    cout << *max_element(v.begin(), v.end()) << endl;

    return 0;
}


Measured memory_bytes: 256
N,W = list(map(int, input().split()))
v = []
m = []
dp = [[-1 for i in range(W+1)]for j in range(N+1)]
for i in range(N):
    a,b = list(map(int, input().split()))
    m.append(a)
    v.append(b)

for i in range(N):
    for j in range(W):
        if j == 0:
            dp[i][j] = 0
        if dp[i][j] >= 0:
            if j+m[i] <= W:
                dp[i+1][j+m[i]] = max(dp[i][j] + v[i], dp[i+1][j+m[i]])
                dp[i+1][j] = max(dp[i][j], dp[i+1][j])
            else:
                dp[i+1][j] = max(dp[i][j],dp[i+1][j])

print(max(dp[-1]))

Measured memory_bytes: 171528
#include <bits/stdc++.h>
using namespace std;
int s[110];
int main(){
    int n, Ans = 0, flag = 0; scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &s[i]);
        if (i == 1) continue;
        if (s[i] == s[i - 1] && !flag) {
            Ans ++;
            flag = 1;
        }
        else flag = 0;
    }
    cout << Ans << endl;
    return (0-0);
}

Measured memory_bytes: 256
#include<stdio.h>
long int x[200001][25]={},n,i,j,a,r;
int J(long int s,long int t){for(int k=0;k<25;k++)if(x[t][k]-x[s-1][k]>1)return 0;return 1;}
int main(){
  scanf("%ld%ld",&n,&a);r=0;
  for(i=0;i<25;i++)x[1][i]=(a&(1<<i))==1<<i;
  for(i=2;i<=n;i++){scanf("%ld",&a);for(j=0;j<25;j++)x[i][j]=x[i-1][j]+((a&(1<<j))==1<<j);}
  a=0;for(i=1;i<=n;i++){while(a<=n&&J(i,a))a++;r+=a-i;}
  printf("%ld",r);
}


Measured memory_bytes: 40788
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,temp,tempa,c,i;
	while(1){
		cin >> n >> m;
		if(n==m && n==0) break;
		int a[n],b[m],suma=0,sumb=0,d=0;
		for(i=0;i<n;i++){
			cin >> a[i];
			suma+=a[i];
		}
		for(i=0;i<m;i++){
			cin >> b[i];
			sumb+=b[i];
		}
		
		for(i=0;i<n-1;i++){
			for(int j=n+1;j<n;j++){
				if(a[i]>a[j]){
					temp=a[i];
					a[i]=a[j];
					a[j]=temp;
				}
			}
		}
		for(i=0;i<n-1;i++){
			for(int j=n+1;j<n;j++){
				if(b[i]>b[j]){
					temp=b[i];
					b[i]=b[j];
					b[j]=temp;
				}
			}
		}
		if(suma>sumb){
			c=suma-sumb;
			if(c%2==1){
				cout << -1 << endl;
			}else{
				c=c/2;
				for(i=0;i<n;i++){
					for(int j=0;j<m;j++){
						if(c==a[i]-b[j]){
							cout << a[i] << ' ' << b[j] << endl;
							d=1;
							break;
						}
					}
		
					if(d==1){
						break;
					}
				}
				if(i==n){
					cout << -1 << endl;
				}
			}
		}else{
			c=sumb-suma;
			if(c%2==1){
				cout << -1 << endl;
			}else{
				c=c/2;
				for(i=0;i<m;i++){
					for(int j=0;j<n;j++){
						if(c==b[i]-a[j]){
							cout << a[j] << ' ' << b[i] << endl;
							d=1;
							break;
						}
					}
					if(d==1){
						break;
					}
				}
				if(i==m){
					cout << -1 << endl;
				}
			}
		}
	}
}




Measured memory_bytes: 2936
#include<stdio.h>

int main(void)
{
  char S[100];
  int i;
  int j=0;
  scanf("%s",&S);
  for(i=0;i<=98;i=i+2){
    if(S[i]=='L'){
      j++;
    }
  }
  for(i=1;i<=99;i=i+2){
    if(S[i]=='R'){
      j++;
    }
  }
  if(j==0){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

unsigned long gcd(unsigned long a, unsigned long b) {
	if(a == 0 || b == 0) return 0;
	while(a != b) {
		if(a > b) a -= b;
		else b -= a;
	}
	return a;
}

unsigned long lcm(unsigned long a, unsigned long b) {
	if(a == 0 || b == 0) return 0;
	return (a / gcd(a, b)) * b;
}

int main() {
	unsigned long a, b;
	unsigned int arg[0xfFf][2] = { 0 };
	int cnt = 0;
	while(scanf("%d %d", &a, &b) != EOF) {
		arg[cnt][0] = a;
		arg[cnt++][1] = b;
	}
	int i;
	for(i = 0; i < cnt; i++) {
		printf("%d %d\n", gcd(arg[i][0], arg[i][1]), lcm(arg[i][0], arg[i][1]));
	}
}

Measured memory_bytes: 1064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

template <class T>
void cout_vec2(const vector<vector<T>> &vec){
  rep(i,vec.size()){
    rep(j,vec[i].size()){
      cout<<vec[i][j]<<' ';
    }
    cout<<endl;
  }
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  ll ans=0;
  set<P> cnt;
  FOR(i,1,n+1){
    if(i<n-i) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
ll koubaisu(ll a,ll b){
  ll x=a;
  ll y=b;
  /* 自然数 a > b を確認・入替 */ 
  if(a<b){ 
    ll tmp=a; 
    a=b; 
    b=tmp; 
  }
  /* ユークリッドの互除法 */ 
  ll r=a%b; 
  while(r!=0){ 
    a=b; 
    b=r; 
    r=a%b; 
  }
 
  /* 最小公倍数を出力 */ 
  return x/b*y; 
}
int main(){
  int n;
  cin>>n;
  ll now=1;
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    now=koubaisu(now,a);
  }
  cout<<now<<endl;
  return 0;
}


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

int main(){
  long double a,b,c; cin >>a >>b >>c;
  long double e = 1.0e-14;
  if(sqrt(a)+sqrt(b)+e<sqrt(c)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {
    static int binarySearchRightMost(int arr[],int key){
        int l=0,r=arr.length-1;
        while (l<r){
            int mid=Math.floorDiv(l+r,2);
            if(arr[mid]>key){
                r=mid;
            }
            else{
                l=mid+1;
            }
        }
        return r-1;

    }

    public static void main(String[] args) {
//        int arr[]={1,2,3,4,4,4,6,7};
//        System.out.println(binarySearchRightMost(arr,4));
        Scanner scanner=new Scanner(System.in);
        long n=scanner.nextLong();
        long ss=n;
        long total=0;
        if(ss>1) {
            for (int j = 0; j < 100; j++) {
                n/=2;
                //n = (long) Math.floorDiv((long) (long) n, (long) 2);
                total = (long) ((long) total + (long) Math.pow(2, j));
                if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                }
            }
        }
        if(ss==1){
            System.out.println(1);
        }else{
        System.out.println(total);}
//        int k=scanner.nextInt();
//        long arr[]=new long[n];
//        for(int j=0;j<n;j++){
//            arr[j]=scanner.nextLong();
//        }
//        Arrays.sort(arr);
//        int c=0;
//        if(k>0) {
//            for (int j = arr.length - 1; j >= 0; j--) {
//                arr[j] = 0;
//                c++;
//                if (c == k) {
//                    break;
//                }
//            }
//        }
//        long ans=0;
//        for(int j=0;j<arr.length;j++){
//            ans=(long)((long)ans+(long)arr[j]);
//        }
//        System.out.println(ans);
//        int arr[]=new int[b];
//        for(int j=0;j<b;j++){
//            a-=scanner.nextInt();
//            if(a<=0){
//                System.out.println("Yes");
//                break;
//            }
//        }
//        if(a>0){
//            System.out.println("No");
//        }
//        System.out.println(a%b==0?Math.floorDiv(a,b):Math.floorDiv(a,b)+1);
    }
}


Measured memory_bytes: 21844
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[m];
		int[] c = new int[m];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}
		Cards cards = new Cards(a);
		for(int i = 0; i < m; i++){
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		cards.operate(b, c);
		cards.printAns();
		
	}
}
class Cards{
	int[] a;
	Command[] commands;
//	int[] operate;
	Cards(int[] a){
		this.a = a;
		Arrays.sort(a);
//		operate = new int[a.length];
	}
	void operate(int[] b, int[] c){
		int m = b.length;
		commands = new Command[m];
		for(int i = 0; i < m; i++){
			commands[i] = new Command(b[i], c[i]);
		}
		Arrays.sort(commands, (com1, com2) -> com2.val - com1.val);
		int aIndex = 0;
		loop:
		for(int i = 0; i < commands.length; i++){
			int value = commands[i].val;
			int nextNum = commands[i].num + aIndex;
			if(a.length < nextNum) {
				nextNum = a.length;
			}
			for(; aIndex < nextNum; aIndex++){
				if(a[aIndex] < value){
					a[aIndex] = value;
				}else{
					break loop;
				}
			}
		}
	}
	void printAns(){
		long ans = 0;
		for(int i = 0; i < a.length; i++){
			ans += a[i];
		}
		System.out.println(ans);
	}
}
class Command {
	int num;
	int val;
	Command(int b, int c){
		this.num = b;
		this.val = c;
	}
}


Measured memory_bytes: 95436
#
# File    : A.rb
# Author  : Kazune Takahashi
# Created : 4/13/2019, 8:50:21 PM
# Powered by Visual Studio Code
#

a, b = gets.chomp.split(" ").map{|i| i.to_i}
puts [a + (a-1), b + (b - 1), a + b].max


Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur=nil->next;
  while(cur!=nil&&cur->key!=key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur=nil->next;
  int isf=1;
  while(1){
    if(cur==nil) break;
    if(isf==0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if(t==nil) return;
  deleteNode(t);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void delete(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size=0;
  char com[20];
  int np=0, nd=0;

  scanf("%d", &n);

  init();

  for(i=0; i<n; i++){
    scanf("%s%d", com, &key);
    if(com[0]=='i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0]=='d'){
      if(strlen(com)>6){
        if(com[6]=='F') deleteFirst();
        else if(com[6]=='L') deleteLast();
      }
      else{
        delete(key);
        nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}


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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    LL n, m;
    cin >> n >> m;
    vector<pair<LL, LL>> v(n);
    for(LL i = 0; i < n; i++){
        cin >> v[i].first >> v[i].second;
    }
    SORT(v);
    LL ans = 0, num = 0;
    for(LL i = 0; i < n; i++){
        if(m - num >= v[i].second){
            ans += v[i].first*v[i].second;
            num += v[i].second;
        } else {
            ans += v[i].first*(m - num);
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	int r, g, b, n; cin >> r >> g >> b >> n;
	int ans = 0;
	for (int i = 0; i <= n + 2; i++) {
		for (int j = 0; j <= n + 2; j++) {
			int a = n - r*i - g*j;
			if (a >= 0 && a%b == 0) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N,M;
	int i,f;
	int like,m;
	int ans;
	
	scanf("%d %d",&N,&M);
	
	int cnt[M];
	
	for(i=0;i<M;i++){
		cnt[i]=0;
	}
	
	for(i=0;i<N;i++){
		scanf("%d",&like);
		for(f=0;f<like;f++){
			scanf("%d",&m);
			
			cnt[m-1]++;
		}
	}
	
	ans=0;
	for(i=0;i<M;i++){
		if(cnt[i]==N)	ans++;
	}
	
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> dice = new ArrayList<Integer>();
        for(int i = 0; i < 6; i++){
            dice.add(sc.nextInt());
        }
        int q = sc.nextInt();
        int[] ans = new int[q];
        for(int i = 0; i < q; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int index_a = dice.indexOf(a);
            int index_b = dice.indexOf(b);
            if((index_a == 3 && index_b == 1) || (index_a == 1 && index_b == 2) || (index_a == 2 && index_b == 4) || (index_a == 4 && index_b == 3)){
                ans[i] = dice.get(0);
            }else if((index_a == 0 && index_b == 3) || (index_a == 3 && index_b == 5) || (index_a == 5 && index_b == 2) || (index_a == 2 && index_b == 0)){
                ans[i] = dice.get(1);
            }else if((index_a == 0 && index_b == 1) || (index_a == 1 && index_b == 5) || (index_a == 5 && index_b == 4) || (index_a == 4 && index_b == 0)){
                ans[i] = dice.get(2);
            }else if((index_a == 0 && index_b == 4) || (index_a == 1 && index_b == 0) || (index_a == 5 && index_b == 1) || (index_a == 4 && index_b == 5)){
                ans[i] = dice.get(3);
            }else if((index_a == 0 && index_b == 2) || (index_a == 2 && index_b == 5) || (index_a == 5 && index_b == 3) || (index_a == 3 && index_b == 0)){
                ans[i] = dice.get(4);
            }else if((index_a == 1 && index_b == 3) || (index_a == 3 && index_b == 4) || (index_a == 4 && index_b == 2) || (index_a == 2 && index_b == 1)){
                ans[i] = dice.get(5);
            }
        }
        for(int i = 0; i < q; i++){
            System.out.println(ans[i]);
        }
    }
}


Measured memory_bytes: 26208
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a>=b){
        printf("No\n");
    }
    else if(b>=c){
        printf("No\n");
    }
    else{
    printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 1008
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
    K = II()
    d = dict()
    value = 7
    ans = 0
    r = 0
    flag = False
    while not r in d:
        d[r] = True
        r = r*10+7
        r = r % K
        ans += 1
        if r == 0 :
            flag=True
            break
    if flag:
        print(ans)
    else:
        print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 92432
#include <iostream>

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

int main() {

    int A, B, C, X;
    scanf("%d%d%d%d", &A, &B, &C, &X);

    int ans = 0;

    REP(a, A+1){
        REP(b, B+1){
            REP(c, C+1){
                if (X == 500 * a + 100 * b + 50 * c) {
                    ans += 1;
                }
            }
        }
    }

    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define for1(a,b,i) for(int i=a;i<=b;++i)
#define FOR2(a,b,i) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;

#define M 2005
int n;
char a[M][M];
int f[M][M],l[M][M],r[M][M];

int main () {
	//freopen("a.in","r",stdin);
	scanf("%d",&n);
	for1(1,n,i) scanf("%s",a[i]+1);
	
	ll ans=0;
	FOR2(n,1,i) FOR2(n,1,j) 
		if(isdigit(a[i][j])) {
			bool t[2]={isdigit(a[i+1][j]),isdigit(a[i][j+1])};
			if(!t[0]&&!t[1]) {
				l[j][i]=r[j][i]=j;
				for1(i+1,n,k) l[j][k]=n+1,r[j][k]=0;
			}
			else if(!t[0]) {
				f[i][j]=f[i][j+1];
				l[j][i]=j,r[j][i]=r[j+1][i];
				for1(i+1,n,k) l[j][k]=l[j+1][k],r[j][k]=r[j+1][k];
			}
			else if(!t[1]) {
				f[i][j]=f[i+1][j];
				l[j][i]=r[j][i]=j;
			}
			else {
				int las=0;
				int tot=f[i+1][j]+f[i][j+1];
				l[j][i]=j,r[j][i]=r[j+1][i];
				
				for1(i+1,n,k) {
					if(l[j+1][k]<=r[j][k]&&l[j+1][k]>las) tot-=f[k][l[j+1][k]];
					las=max(las,r[j][k]);
					l[j][k]=min(l[j][k],l[j+1][k]);
					r[j][k]=max(r[j][k],r[j+1][k]); 
				}
				f[i][j]=tot;
			}
			ans+=f[i][j]*(a[i][j]-'0');
			f[i][j]+=a[i][j]-'0';
		}
		else l[j][i]=n+1,r[j][i]=0;
	cout<<ans<<endl;
}

Measured memory_bytes: 44288
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    map<string,int> mp;
    int N;
    cin >> N;
    REP(i,N){
        string s;
        cin >> s;
        mp[s]++;
    }
    int M;
    cin >> M;
    REP(i,M){
        string t;
        cin >> t;
        mp[t]--;
    }
    int ans = 0;
    for(auto itr = mp.begin();itr != mp.end();itr++){
        if(itr->second > ans) ans = itr->second;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
 int n;
 cin >> n;
 int *a = new int[n];
 int min = 1000000;
 int max = -1000000;
 long sum = 0;
 for (int i = 0; i < n; i++)
 {
  cin >> a[i];
  sum += a[i];
  if (a[i] >= max)
  {
   max = a[i];
  }
  if (a[i] <= min)
  {
   min = a[i];
  }
 }
 cout << min << " " << max << " " << sum << endl;
}


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

class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int x = fs.nextInt();
        int y = fs.nextInt();
        System.out.println(x+y/2);
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

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

Measured memory_bytes: 22484
#define _USE_MATH_DEFINES  
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>

using namespace std;

int main(void) {
    int R;

    cin >> R;

    cout << setprecision(20) << (R * 2) * (double)M_PI << endl;

    return 0;
}


Measured memory_bytes: 3784
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        if (n % 2 != 0) {
            System.out.println(0);
            return;
        }
        long ans = 0;
        long i = 10;
        while (i <= n) {
            ans += n / i;
            i *= 5;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 23636
fun main(args: Array<String>) {
    val (x, y, a, b, c) = readLine()!!.split(" ").map{it.toInt()}
    val p: LongArray = readLine()!!.split(" ").map{it.toLong()}.toLongArray()
    val q: LongArray = readLine()!!.split(" ").map{it.toLong()}.toLongArray()
    val r: LongArray = readLine()!!.split(" ").map{it.toLong()}.toLongArray()
    val aa: LongArray = p.sortedDescending().take(x).toLongArray()
    val bb: LongArray = q.sortedDescending().take(y).toLongArray()
    val apple = ( aa + bb + r).sortedDescending().take(x+y)
    var ans = 0L
    repeat(x+y){ans += apple[it]}
    println(ans)
}


Measured memory_bytes: 127208
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX

using namespace std;
using LL=long long;

struct Node{
    int key;
    Node *next,*prev;
};

Node *nil;

Node *listSearch(int key){
    Node *cur=nil->next;
    while(cur!=nil&&cur->key!=key){
        cur=cur->next;
    }
    return cur;
}

void init(){
    nil=(Node *)malloc(sizeof(Node));
    nil->next=nil;
    nil->prev=nil;
}

void printList(){
    Node *cur=nil->next;
    int isf=0;
    while(1){
        if(cur==nil) break;
        if(isf++>0) printf(" ");
        printf("%d",cur->key);
        cur=cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t){
    if(t==nil) return;
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x=(Node *)malloc(sizeof(Node));
    x->key=key;
    x->next=nil->next;
    nil->next->prev=x;
    nil->next=x;
    x->prev=nil;
}

int main(){
    int key,n;
    int size=0;
    char com[20];
    int np=0,nd=0;
    scanf("%d",&n);
    init();
    LP(i,n){
        scanf("%s%d",com,&key);
        if(com[0]=='i'){insert(key);np++;size++;}
        else if(com[0]=='d'){
            if(strlen(com)>6){
                if(com[6]=='F') deleteFirst();
                else if(com[6]=='L') deleteLast();
            }
            else{
                deleteKey(key);nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
}




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

using namespace std;

const int N = 15;

int n, m, x;
int c[N], a[N][N];

int now[N];

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

	for(int i = 0; i < n; i++) {
		scanf("%d", c + i);
		for(int j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}

	int ans = -1;

	for(int b = 1; b < (1 << n); b++) {
		memset(now, 0, sizeof now);
		int price = 0;
		for(int i = 0; i < n; i++) if(b >> i & 1) {
			price += c[i];
			for(int j = 0; j < m; j++) {
				now[j] += a[i][j];
			}
		}

		bool ok = true;
		for(int i = 0; i < m; i++) ok &= now[i] >= x;
		if(!ok) continue;
		if(ans == -1 or ans > price) ans = price;
	}

	printf("%d\n", ans);
}


Measured memory_bytes: 3840
#include<iostream>

using namespace std;

int main()
{
    int a, b, c, d;
    int count = 0;

    cin >> a >> b >> c;

    for(d = a; d <= b; d++){
        if(c % d == 0){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int n;
    vector<int> c, s, f;

    cin >> n;
    c = vector<int>(n - 1);
    s = vector<int>(n - 1);
    f = vector<int>(n - 1);
    for (int i = 0; i < n - 1; i++){
        cin >> c[i] >> s[i] >> f[i];
    }

    for (int i = 0; i < n; i++){
        int now = 0;

        for (int j = i; j < n - 1; j++){
            if (now < s[j]){
                now = s[j];
            } else if (now % f[j] != 0){
                now += (f[j] - now % f[j]);
            }

            now += c[j];
        }

        cout << now << endl;
    }

    return 0;
}


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

int main(){
string S,T,X;
int a,b;
cin >> S>>T;
cin >> a >> b;
cin >> X;
if(S==X){
  cout << a-1 << ' ' << b << endl;
}else {
  cout << a << ' ' << b-1 << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 2000000005;
const int MAX = 105;

int n, d[MAX][MAX];

void floyd() {
  rep(k, n) {
    rep(i, n) {
      if (d[i][k] == INF) continue;
      rep(j, n) {
        if (d[k][j] == INF) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  int m, s, t, c;
  cin >> n >> m;

  rep(i, n) {
    rep(j, n) {
      if (i == j) d[i][j] = 0;
      else d[i][j] = INF;
    }
  }

  rep(i, m) {
    cin >> s >> t >> c;
    d[s][t] = c;
  }

  floyd();

  rep(i, n) {
    if (d[i][i] < 0) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }

  rep(i, n) {
    rep(j, n) {
      if (j) cout << " ";
      if (d[i][j] == INF) cout << "INF";
      else cout << d[i][j];
    }
    cout << endl;
  }


  
  return 0;
}


Measured memory_bytes: 3128
#include<stdio.h>
  int main(){
  int N,A,B,sum=0;
  scanf("%d",&N);
if(N==1)
{
   printf("Hello World");
}
  else if(N==2)
{
    scanf("%d%d",&A,&B);
    sum=A+B;
    printf("%d",sum);
}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vi a(n), b(n);
  cin>>a>>b;
  priority_queue<P> q;
  rep(i,n) q.push(P(b[i],i));
  ll ans = 0;
  while (sz(q)) {
    P p = q.top(); q.pop();
    int i = p.se;
    if (b[i] < a[i]) break;
    if (b[i] == a[i]) continue;
    int l = (i-1+n)%n, r = (i+1)%n;
    int s = b[l]+b[r];
    if (!s) break;
    int x = (b[i]-a[i])/s;
    ans += x;
    b[i] -= x*s;
    if (x) q.push(P(b[i],i));
  }
  rep(i,n) if (a[i] != b[i]) ans = -1;
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 4980