akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
static const int MAXN = 1e5 + 4;
static const int LOGN = 19;

int mx, my, n;

inline int get_point(int x, int y)
{
    if (y == 0) return x;
    if (x == mx) return mx + y;
    if (y == my) return mx + my + (mx - x);
    if (x == 0) return mx + my + mx + (my - y);
    return -1;
}

typedef std::pair<int, int> num;
std::vector<num> c;
std::map<int, int> dis;

int a[MAXN * 2];

namespace rmq {
    int min[LOGN][MAXN * 2], max[LOGN][MAXN * 2];
    inline void build(int n, int *a) {
        for (int i = 0; i < n; ++i) min[0][i] = max[0][i] = a[i];
        for (int j = 1; j < LOGN; ++j)
            for (int i = 0; i < n - (1 << j); ++i) {
                max[j][i] = std::max(max[j - 1][i], max[j - 1][i + (1 << (j - 1))]);
                min[j][i] = std::min(min[j - 1][i], min[j - 1][i + (1 << (j - 1))]);
            }
    }
    inline std::pair<int, int> query(int l, int r) {
        if (l == r) return std::make_pair(min[0][l], max[0][l]);
        int sz = 8 * sizeof(int) - __builtin_clz(r - l) - 1;
        return std::make_pair(
            std::min(min[sz][l], min[sz][r - (1 << sz) + 1]),
            std::max(max[sz][l], max[sz][r - (1 << sz) + 1])
        );
    }
}

int main()
{
    scanf("%d%d%d", &mx, &my, &n);
    for (int i = 0, x1, y1, x2, y2; i < n; ++i) {
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        int p1 = get_point(x1, y1),
            p2 = get_point(x2, y2);
        if (p1 != -1 && p2 != -1) {
            if (p1 > p2) std::swap(p1, p2);
            c.push_back(num(p1, p2));
            dis.insert(std::make_pair(p1, 0));
            dis.insert(std::make_pair(p2, 0));
        }
    }
    int ct = 0;
    for (auto &kv : dis) kv.second = ct++;
    for (auto &p : c) {
        p.first = dis[p.first], p.second = dis[p.second];
        a[p.first] = p.second;
        a[p.second] = p.first;
    }
    rmq::build(ct, a);

    std::sort(c.begin(), c.end());
    for (auto p : c) if (p.second >= p.first + 2) {
        auto val = rmq::query(p.first + 1, p.second - 1);
        if (val.first < p.first || val.second > p.second) {
            puts("NO"); return 0;
        }
    }

    puts("YES"); return 0;
}


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


int main(){
    int n,a,b;
    cin >> n >> a >> b;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    ll ans = 0;
    for(int i =0;i<n-1;i++){
        if((x[i+1]-x[i])>(b/a)) ans += b;
        else ans += (x[i+1]-x[i])*a;
    }

    cout << ans << endl;
 }

Measured memory_bytes: 3756
N,M = list(map(int,input().split()))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
def twocount(n):
    c = 0
    while n%2 == 0:
        n //= 2
        c += 1
    return c
 
a2 = [int(i//2) for i in map(int,input().split())]
count2 = set()
for i in a2:
    tc = twocount(i)
    count2.add(tc)
if len(count2) == 1:
 
    if len(a2) == 1:
        div = M//a2[0]
        print((div+1)//2)
    else:
        gcda = a2[0]*a2[1]//gcd(a2[0],a2[1])
        for i in range(2,N):
            gcda = gcda*a2[i]//gcd(gcda,a2[i])
        div = M//gcda
        print((div+1)//2)
    
else:
    print(0)

Measured memory_bytes: 64112
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
int main(){
	
	string s;
	cin>>s;
	string t="keyence";
	int d=s.size()-7;
	for(int i=0;i<s.size()-d;i++){
		int k=0;
		string r=s.substr(0,i)+s.substr(i+d,s.size()-i-d);
		DEB(r)END
		if(t==r){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	

}

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

int n, S[100000];
int q, T[50000];

bool check(int key){
    int left = 0;
    int right = n;
    int mid;
    while(left < right){
        mid = (left+right)/2;
        if(S[mid]==key) return true;
        if(S[mid] < key) left=mid+1;
        else if(key<S[mid]) right = mid;
    }
    return false;
}

int main(){
    int sw=0;
    
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> S[i];
    }
    
    cin >> q;
    for(int i=0; i<q; i++){
        cin >> T[i];
        if(check(T[i])) sw++;
    }
    
    cout << sw << endl;
    
    return 0;
}

Measured memory_bytes: 3688
#include <stdio.h>

int main()
{
  int i, j, n, m, upper, a[200001], b[200001];
  scanf("%d", &n);
  for(i=1;i<=n;i++){
    scanf("%d", &a[i]);
    b[i]=0;
  }
  m=0;
  for(i=n;i>=1;i--){
    upper=0;
    j=2;
    while(i*j<=n){
      if(b[i*j]) upper++;
      j++;
    }
    if((a[i]+upper)%2==1){
      b[i]=1;
      m++;
    }else{
      b[i]=0;
    }
  }

  printf("%d\n", m);
  int first=1;
  for(i=1;i<=n;i++){
    if(b[i]){
      if(first){
        printf("%d", i);
        first=0;
      }else{
        printf(" %d", i);
      }
    }
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000;
int n;
int main()
{
    while(cin>>n){
        if(n/10==0){
            cout<<n<<endl;
        }
        else if(n/100==0){
            int pre=n/10;
            int suf=n%10;
            int maxcnt=max(pre,suf);
            cout<<maxcnt<<maxcnt<<endl;
        }
        else{
            int l=n/100;
            int mid=(n/10)%10;
            int r=n%10;
            if(l>mid){
                cout<<l<<l<<l<<endl;
            }
            else if(l==mid){
                if(r>l){
                    cout<<l+1<<l+1<<l+1<<endl;
                }
                else{
                    cout<<l<<l<<l<<endl;
                }
            }
            else {
                //int need=min(mid,r);
                cout<<l+1<<l+1<<l+1<<endl;
            }
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c,d;
    scanf("%d%d%d\n",&a,&b,&c);
    
    while(a>b||b>c){
        if(a>b){
            d=a;
            a=b;
            b=d;
        }
        if(b>c){
            d=b;
            b=c;
            c=d;
        }
    }
    
    //printf("%d %d %d\n",a,b,c);
    
    printf("%d\n",c-a);
    
}


Measured memory_bytes: 128
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
Mod = 10**9 + 7
a.sort()
c = [0] * (n+1)
c[k - 1] = 1
for i in range(n+1):
    if i >= k:
        c[i] = ((c[i - 1]*i * pow(i - k + 1, Mod - 2, Mod))) % Mod
ans = 0
for i in range(1, n + 1):
    ans += (a[i - 1] * (c[i - 1] - c[n - i])) % Mod
print(ans % Mod)

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

int N,Y;
int main(){
  cin>>N>>Y;
  int x,y,z;
  for(x=0;x<=N;x++){
    for(y=0;y<=N-x;y++){
      z=N-x-y;
      if(10000*x+5000*y+1000*z==Y){
        cout<<x<<' '<<y<<' '<<z<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<' '<<-1<<' '<<-1<<endl;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

l = []
for i in range(n):
  a = [int(x) for x in input().split()]
  for j in range(1, a[0] + 1):
    l.append(a[j])

ans = 0
for i in range(m + 1):
  if l.count(i) == n:
    ans += 1

print(ans)

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {


    public static void solve() {
        int n = in.nextInt();
        int[] stones = new int[n];

        for(int i = 0; i < n; i ++)
            stones[i] = in.nextInt();

        long[][] store = new long[n][n];

        for(int i = 0; i < n; i += 1) {
            store[i][i] = stones[i];
        }

        for(int i = n-1; i >= 0; i -= 1) {
            for(int j = i+1; j < n; j += 1) {
                store[i][j] = Math.max(stones[i] - store[i+1][j], stones[j] - store[i][j-1]);
            }
        }

        out.println(store[0][n-1]);
    }


    public static InputReader in = new InputReader();
    public static PrintWriter out;

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

        /**
         * When you call next(), that entire line will be skipped.
         * No flushing buffers.
         * Doesn't work when you want to scan the remaining line.
         *
         * @return entire line
         */
        public String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
                tokenizer = null;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }
    }
}

Measured memory_bytes: 130636
n = gets.to_i
a = gets.split.map(&:to_i)
q = gets.to_i
b, c = q.times.map{gets.split.map(&:to_i)}.transpose

ns = Array.new(10**5 + 1, 0)
for i in 0..(n-1)
  ns[a[i]] += 1
end
sum = 0
a.each{|e| sum += e}

for i in 0..(q-1)
  bn = ns[b[i]]
  ns[b[i]] = 0
  sum -= b[i] * bn
  sum += c[i] * bn
  ns[c[i]] += bn
  
  puts sum
end

Measured memory_bytes: 24552
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, l;
  cin >> n >> l;
  deque<pair<double, ll>> q;
  ll sumV = 0;
  double sumVT = 0;
  cout << fixed << setprecision(10);
  for(int i = 0; i < n; i++) {
    ll t, v;
    cin >> t >> v;
    while(sumV + v > l) {
      auto p = q.front();
      q.pop_front();
      ll wd = sumV + v - l;
      ll del = min(wd, p.second);
      sumV -= del;
      p.second -= del;
      sumVT -= del * p.first;
      if(p.second) q.push_front(p);
    }

    double o = (sumVT + v * t) / l;

    cout << o << "\n";

    pair<double, ll> p(t, v);
    while(q.size() && p.first < q.back().first) {
      auto r = q.back();
      q.pop_back();
      sumV -= r.second;
      sumVT -= r.first * r.second;
      p.first = (p.first * p.second + r.first * r.second) / (p.second + r.second);
      p.second += r.second;
    }

    q.push_back(p);
    sumV += p.second;
    sumVT += p.first * p.second;
  }
  return 0;
}


Measured memory_bytes: 18704
//50
#include<iostream>
#include<stack>
#include<queue>

using namespace std;

struct C{
  int t,n;
};

int main(){
  for(int m,n;cin>>m>>n,m|n;){
    int o=0;
    stack<C> s[10];
    queue<C> que;
    for(int i=0;o!=n;i++){
      for(int j=0;j<m;j++){
	while(!s[j].empty()&&s[j].top().t<=i){
	  o++;
	  cout<<s[j].top().n<<((o==n)?'\n':' ');
	  s[j].pop();
	}
      }
      if(i%10==0&&i/10<n){
	int t;
	cin>>t;
	C a={t,i/10+1};
	que.push(a);
      }
      while(!que.empty()){
	C c=que.front();
	c.t+=i;
	int x=-1;
	for(int i=0;i<m;i++){
	  if(s[i].empty()){
	    s[i].push(c);
	    que.pop();
	    goto next;
	  }else if(s[i].size()==1){
	    int ct=s[i].top().t;
	    int xt=(x==-1)?0:s[x].top().t;
	    if(x==-1
	       ||(ct>=c.t&&(xt<c.t||ct-c.t<xt-c.t))
	       ||(xt<c.t&&ct<c.t&&xt<ct)){
	      x=i;
	    }
	  }  
	}
	if(x!=-1){
	  s[x].push(c);
	  que.pop();
	  goto next;
	}
	break;
      next:
	;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1200
N,q=list(map(int,input().split()))
name=[]
time=[]
sum_time=0

for n_temp in range(N):
    na,ti=input().split()
    name.append(na)
    time.append(int(ti))

while True:
#     print(time,name,ans_name)
    t = time.pop(0)
    n = name.pop(0)
    
    if t-q>0:
        time.append(t-q)
        name.append(n)
        sum_time+=q
    else:
        sum_time+=t
        print(n,sum_time)

    if len(name)<=0:
        break


Measured memory_bytes: 9532
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
typedef double D;
struct P {
	D x, y, z;
	P(){}
	P(D xx, D yy, D zz):x(xx), y(yy), z(zz){}
};

D dis(P a, P b) {
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));
}

const double EPS = 0.05;

int main()
{
	int N; cin>>N;
	while (N--) {
		D QR, RP, PQ;
		cin>>QR>>RP>>PQ;
		int M; cin>>M;
		vector<P> points;
		
		for (int i=0; i<M; i++) {
			double x, y, z;
			cin>>x>>y>>z;
			points.push_back(P(x, y, z));
		}
		
		for (int p=0; p<M; p++) {
			for (int q=0; q<M; q++) {
				for (int r=0; r<M; r++) {
					if (p!=q && p!=r) {
						D a = dis(points[p], points[q])/PQ;
						D b = dis(points[q], points[r])/QR;
						D c = dis(points[r], points[p])/RP;
						if (fabs(a-b)<EPS && fabs(b-c)<EPS && fabs(c-a)<EPS) {
							cout << (p+1) << " " << (q+1) << " " << (r+1) << endl;
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 1248
//find the minimum first
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
ll min(ll a,ll b){return a<b?a:b;}
ll max(ll a,ll b){return a>b?a:b;}

int n,m,i,l[200010],r[200010],d[400010];
ll x[100010];
struct kk
{
	int a,d;
};
vector<kk>c[100010];
bool vis[100010];

queue<int> q;
int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++)//x_r-x_l=d,DFS
	{
		scanf("%d%d%d",&l[i],&r[i],&d[i]);
		kk t;
		t.a=r[i];t.d=d[i];
		c[l[i]].push_back(t);
		t.a=l[i];t.d=-d[i];
		c[r[i]].push_back(t);

	}
	/*for (i=1;i<=n;i++)
	{
		for (int j=0;j<c[i].size();j++)
		  printf("%d ",c[i][j]);
		printf("\n");
	}*/
    for (i=1;i<=n;i++)
    {
    	if (!vis[i])
    	{
    		x[i]=0;
    		vis[i]=1;
    		q.push(i);
    		//printf("%d\n",i);
    		while (!q.empty())
    		{
    			int h=q.front();q.pop();
    			for (int j=0;j<c[h].size();j++)
    			{
    				int t=c[h][j].a,dd=c[h][j].d;
    				if (!vis[t])
    				{
    					vis[t]=1;
    					q.push(t);
    					x[t]=x[h]+dd;
					}
				}
			}
		}
	}
	for (i=1;i<=m;i++)
	{
		if (x[r[i]]-x[l[i]]!=d[i])
		{
			printf("No\n");
			return 0;
		}
	}
	ll minn=0,maxx=0;
	for (i=1;i<=n;i++)
	  if (vis[i])
	  {
	  	minn=min(minn,x[i]);
	  	maxx=max(maxx,x[i]);
	  }
	if (maxx-minn<=1e9) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 12928
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>


using namespace std;
typedef long long int ll;


int main() {
    int N;
    std::cin >> N;
    std::vector<int> a(N);
    
    for(size_t i = 0; i < N; i++)
    {
        std::cin >> a[i];
    }

    sort(a.begin(), a.end(), std::greater<int>());
    int total1 = 0;
    int total2 = 0;
    if(N % 2 == 1) {
        for(size_t i = 0; i < N; i = i + 2)
        {
            total1 += a[i];
        }
        for(size_t i = 1; i < N; i = i + 2)
        {
            total2 += a[i];
        }
    }
    if(N%2==0) {
        for(size_t i = 0; i < N; i = i + 2)
        {
            total1 += a[i];
        }
        for(size_t i = 1; i < N; i = i + 2)
        {
            total2 += a[i];
        }
    }
    std::cout << total1 - total2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	Int a, b,c; cin >> a >>b>>c;
	if (abs(b-a)>abs(c-a))cout << "B";
	else cout << "A";
	


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
//author : raghav_0901
#include <bits/stdc++.h>
#define long double int
using namespace std;

signed main()
{
    string s;cin>>s;
    if(s.length()==1)
    {
        if(s=="?")
            cout<<"D\n";
        else
            cout<<s<<'\n';
        return 0;
    }
    int i=0;
    while (s[i])
    {
        // if(i==0)
        // {
        //     if(s[i]=='?')
        //     {
        //         if(s[i+1]=='D')
        //             s[i]='P';
        //         else
        //             s[i]='D';
        //     }
        // }
        // else if(i==s.length()-1)
        // {
        //     if(s[i]=='?')
        //         s[i]='D';
        // }
        // else
        // {
        //     if(s[i-1]=='P')
        // }
        if(s[i]=='?')
            s[i]='D';
        i++;
    }
    cout<<s<<'\n';
    return 0;   
}


Measured memory_bytes: 3724
import copy
import math
import time
import statistics
import math
import itertools
import bisect
import sys
from decimal import *
from collections import deque


def get_int():
    return int(input())

def get_string():
    return input()

def get_int_list():
    return [int(x) for x in input().split()]

def get_string_list():
    return input().split()

def get_int_multi():
    return map(int, input().split())

def get_string_char_list():
    return list(str(input()))

# print("{} {}".format(a, b))
# a_list = [0] * a
sys.setrecursionlimit(10 ** 6)

def main():
    start = time.time()

    if get_int() == 0:
        ans = 1
    else:
        ans = 0
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 11096
# coding: utf-8


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    edges = [set() for _ in range(n)]
    for AB in args[1:]:
        a, b = map(int, AB.split())
        edges[a-1].add(b-1)
        edges[b-1].add(a-1)

    count = 0
    stack = [(0, 0)]
    while stack:
        node, visited = stack.pop()
        visited |= 1 << node

        if visited+1 == 1 << n:
            count += 1

        for dist in edges[node]:
            if visited & (1 << dist) == 0:
                stack.append((dist, visited))

    return str(count)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
#define SEG_LEN (1 << 18)
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int A[100][100];
int main(){
  ll n,m,x;
  cin >> n >> m >> x;
  vector<int>c(n);
  rep(i,n){
    cin >> c[i];
    rep(j,m)cin >> A[i][j];
  }
  int ans = INF;
  rep(i,(1 << n)){
    vector<int>cnt(m);
    int tmp = 0;
    rep(j,n){
      if(i & (1 << j)){
        tmp += c[j];
        rep(k,m)cnt[k] += A[j][k];
      }
    }
    bool ok = true;
    rep(I,m)if(cnt[I] < x)ok = false;
    if(ok)ans = min(ans,tmp);
  }
  if(ans == INF)cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}
 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
 
  
  for(int i = 1; i < 10;i++){
    int x = i * 100 + i * 10 + i;
    if(N <= x){
      cout << x << endl;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#include <numeric>
using namespace std;

int main()
{
    int x;
    cin >> x;
    long long ans = 0;

    for(int i=1;i<=x;i++){
        for(int j=1;j<=x;j++){
            for(int k=1;k<=x;k++){
                ans += gcd(gcd(i,j),k);
            }
        }
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define p pair<ll,ll>
#define pb push_back
#define mp make_pair
#define PI 3.14159265359

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<p> > vec(n);
    int a;
    int x,y;
    rep(i,n){
        cin >> a;
        rep(j,a){
            cin >> x >>y;
            x--;
            vec[i].pb(mp(x,y));
        }
    }
    vector<bool> h(n);
    ll ans = 0;
    ll tmp = 0;
    ll m = 0;

    for(ll i = 0;i < (1ll << n);i++){
        m = 0;
        tmp = 0;
        rep(j,n) h[j] = false;

        rep(j,n){
            if(i & (1ll << j)){
                h[j] = true;
                m++;
            }
            else{
                h[j] = false;
            }
        }

        rep(j,n){
            if(i & (1ll << j)){
                rep(k,vec[j].size()){
                    if((h[vec[j][k].first] == true && vec[j][k].second == 0) || (h[vec[j][k].first] == false && vec[j][k].second == 1)){
                        m = -1;
                        break;
                    }
                }
            }
            if(m < 0){
                break;
            }
        }
        ans = max(ans,m);
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

typedef double Real;

const Real EPS = 1e-8;

int sign(Real d){
	return d > EPS ? 1 : d < -EPS ? -1 : 0;
}

struct Point{
	Real x,y;
	
	Point(Real x_ = 0,Real y_ = 0):x(x_),y(y_){}

	Point operator+(const Point &p) const {return Point(x+p.x,y+p.y);}
	Point operator-(const Point &p) const {return Point(x-p.x,y-p.y);}
	Point operator*(Real s) const {return Point(x*s,y*s);}
	Point operator/(Real s) const {return Point(x/s,y/s);}
	bool operator<(const Point &p) const{return sign(x-p.x) == -1 || (sign(x-p.x) == 0 && sign(y-p.y) == -1);}
	bool operator==(const Point &p) const{return sign(x-p.x) == 0 && sign(y-p.y) == 0;}
};

struct Segment : public array<Point,2>{
	Segment(const Point &a,const Point &b){	at(0) = a; at(1) = b;}
};

struct Line : public array<Point,2>{
	Line(const Point &a,const Point &b){at(0) = a; at(1) = b;}
};

struct Circle{
	Point c;
	Real r;

	Circle(const Point &c_, Real r_):c(c_),r(r_){}
};

typedef vector<Point> Polygon;


Point rotate90(const Point &p){
	return Point(-p.y,p.x);
}

Point rotate(const Point &p,Real theta){
	const Real s = sin(theta),c = cos(theta);
	return Point(c*p.x-s*p.y,s*p.x+c*p.y);
}

Real angle(const Point &p){
	return atan2(p.y,p.x);
}

Real dot(const Point &a,const Point &b){ //??????????????????
	return a.x*b.x+a.y*b.y;
}

Real cross(const Point &a,const Point &b){ //??????????????????
	return a.x*b.y-a.y*b.x;
}

Real norm(const Point &p){
	return p.x*p.x+p.y*p.y;
}

Real abs(const Point &p){
	return sqrt(norm(p));
}

int main(){
	int q;
	cin >> q;
	rep(i,q){
		int x0,y0,x1,y1,x2,y2,x3,y3;
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		Line l1(Point(x0,y0),Point(x1,y1)),l2(Point(x2,y2),Point(x3,y3));
		
		if(sign(dot(l1[0]-l1[1],l2[0]-l2[1]))==0) cout << 1 << endl;
		else if(sign(cross(l1[0]-l1[1],l2[0]-l2[1]))==0) cout << 2 << endl;
		else cout << 0 << endl;

	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
using ll = long long;
int main() {
	int k;
	cin >> k;
	int ans = -1;
	int a = 0, b = 0, c = 0, d = 0;
	for(int i = 0; i < 10000000; ++i){
	    a = (c + 7) % k;
	    
	    if(a == 0){
	        ans = i + 1;
	        break;
	    }
	    
	    d = a;
	    c = (d * 10) % k;
	    
	   // cout << a << " " << c << " " << d << endl;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
/**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200002;
const int mod = 1000000000007ll;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------


int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);

    int n, m, k, p, l;
    cin >> n >> m >> k >> p >> l;

    cout << max( 0ll , ( k * 60 + p ) - ( n * 60 + m ) - l ) << '\n';


    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int Q;
int dp[200][200][200];

int dfs(int c, int a, int n){
  if(dp[c][a][n] >= 0) return dp[c][a][n];
  int res = 0;
  if(c > 0 && a > 0 && n > 0) res = max(res, dfs(c-1, a-1, n-1)+1);
  if(c > 1 && a > 0) res = max(res, dfs(c-2, a-1, n)+1);
  if(c > 2) res = max(res, dfs(c-3, a, n)+1);
  return dp[c][a][n] = res;
}

int main(){
  cin >> Q;
  rep(i, Q){
    memset(dp, -1, sizeof(dp));
    int c, a, n;
    cin >> c >> a >> n;
    int res = 0;
    while(c > 10 && a > 5 && n > 0){
      res++;
      c--;
      a--;
      n--;
    }

    while(c > 10 && a > 5){
      res++;
      c-=2;
      a--;
    }

    while(c > 10){
      res++;
      c-=3;
    }
    res += dfs(c, a, n);
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 32404
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int X = scanner.nextInt();
        scanner.close();

        int count = 0;
        for (int i = 0; i <= A; i++) {
            for (int j = 0; j <= B; j++) {
                for (int k = 0; k <= C; k++) {
                    if (X == (500 * i + 100 * j + 50 * k)) {
                        count++;
                    }
                }
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 22100
N,K = map(int, input().split())
nums = list(map(int, input().split()))

sum_K = [0]*(N-K+1)
sum_K[0] = sum(nums[:K])
for pos in range(1,N-K+1):
    sum_K[pos] = sum_K[pos-1] -   \
        nums[pos-1] + nums[pos+K-1]

print((max(sum_K)+K)/2)

Measured memory_bytes: 25060
#!/usr/bin/ruby 
#encoding: utf-8

a,b,c,d = gets.split.map(&:to_i)

ab = (a-b).abs
bc = (b-c).abs
ac = (a-c).abs

if ( ab <= d and bc <= d ) or ac <=d then
  puts "Yes"
else
  puts "No" 
end


Measured memory_bytes: 1788
S = int(input())
mod = 10**9 + 7

anss = [0]*2010
anss[3] = 1
anss[4] = 1
anss[5] = 1

for i in range(6,S+1):
  anss[i] += 1
  anss[i] %=mod
  b = i-6+1
  for j in range(b):
    if j >= 3:
      anss[i] += 1 * anss[i-3-j]
      anss[i] %= mod
    else:
      #print(i, 3+j, i-3-j)
      anss[i] += anss[3+j] * anss[i-3-j]
      anss[i] %= mod
  #print(anss[i])
print(anss[S]%mod)

Measured memory_bytes: 9052
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<li, li> pt;

#define fi first
#define se second
#define lson ((p<<1))
#define rson ((p<<1)+1)
#define mid ((L+R)>>1)
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n;
pt a[100007];

int main() {
    fastIO;
    cin >> n;
    for(li i = 0; i < n; i ++) cin >> a[i].fi, a[i].se = i + 1;
    sort(a, a + n);
    for(li i = 0; i < n; i ++) cout << a[i].se << " ";

}


Measured memory_bytes: 2432
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a, b  = map(int, input().split())
if b % a == 0:
    print(a + b)
else:
    print(b - a)






Measured memory_bytes: 7752
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
N, X = map(int, input().split())
a = sorted(list(map(int, input().split())))
count = 0
for i in range(N):
    if X >= a[i]:
        count += 1
        X = X - a[i]
    else:
        break
if count == N and X > 0:
    count -= 1  # 全員に配りきってお菓子が余った場合、一人喜ばない子供が出る。
print(str(count))


Measured memory_bytes: 2940
solve h w = [replicate w '#'] ++ replicate (h-2) ("#" ++ replicate (w-2) '.' ++ "#") ++ [replicate w '#']

main = do
    str <- getLine
    let (h:w:_) = map read $ words str
    if (h,w) == (0,0) then
        return ()
    else do
        putStrLn $ unlines $ solve h w
        main

Measured memory_bytes: 4088
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int main() {
	string MARCH = "MARCH";
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,a,b,c,d;
	cin >> N;
	vector<pair<int, int>> blue(N), red(N);
	REP(i, N) {
		cin >> a >> b;
		red[i] = make_pair(a, b);
	}
	sort(red.begin(), red.end());
	REP(i, N) {
		cin >> c >> d;
		blue[i] = make_pair(c, d);
	}
	sort(blue.begin(), blue.end());
	int ans = 0;
	//青い点を x 座標の小さい順に見ていき
	REP(i, N) {
		pair<int, int> finded = make_pair(-1, -1);
		int findIdx = -1;
		REP(j, red.size()) {
			if (red[j].first > blue[i].first) {
				break;
			}
			else if(red[j].second < blue[i].second && red[j].second > finded.second) {
				finded = red[j];
				findIdx = j;
			}
		}
		if (finded.first >= 0) {
			ans++;
			red.erase(red.begin() + findIdx);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, s, e) for (int i = s; i < e; i++)
#define endl '\n'
int main()
{
    int A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << A[K-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

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

int main(){
        long long a, b;
        while (cin >> a >> b){
                if (a < b) swap(b, a);
                long g = gcd(a, b);
                cout << g << " " << a * b / g << endl;
        }
        return 0;
}

Measured memory_bytes: 2960
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,W,X,Y,Z;
string S,T;
ll V[100007];

int main(){
  cin >> S >> T;
  cout << T << S << endl;
}

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

D = 0
for i in range(1, N):
    D += abs(A[i] - A[i-1])
D += abs(A[0] - 0)
D += abs(A[N-1] - 0)

ans = []
for i in range(N):
    if i == 0:
        a = abs(A[i+1] - A[i]) + abs(A[i] - 0)
        b = abs(A[i+1] - 0)
    elif i == N - 1:
        a = abs(0 - A[i]) + abs(A[i] - A[i-1])
        b = abs(0 - A[i-1])
    else:
        a = abs(A[i+1] - A[i]) + abs(A[i] - A[i-1])
        b = abs(A[i+1] - A[i-1])
    ans.append(D - a + b)

for x in ans:
    print(x)


Measured memory_bytes: 14036
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N;
cin >> N;
vector<int> vec(N);
map<int,int> seito;
for (int i = 0;i < N;i++) {
    cin >> vec.at(i);
    seito[vec.at(i)] = i+1;
}
for (auto p : seito) {
    auto key = p.first;
    auto value = p.second;
    cout << value << " ";
}
cout << endl;

return 0;
}

Measured memory_bytes: 5888
#include <iostream>
using namespace std;
int main(){
        int a[3];
        int ans[3];
        cin >> a[0] >> a[1] >> a[2];
        if(a[0] > a[1]){
                int temp = a[0];
                a[0] = a[1];
                a[1] = temp;
        };
        if(a[1] > a[2]){
                int temp = a[1];
                a[1] = a[2];
                a[2] = temp;
        };
        if(a[0] > a[1]){
                int temp = a[0];
                a[0] = a[1];
                a[1] = temp;
        }
        cout << a[0] << " " << a[1] << " " << a[2] << endl;
        return 0;
}


Measured memory_bytes: 3080
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] dp = new int[n + 1];
		Arrays.fill(dp, 1000000);
		dp[0] = 0;
		for (int i = 1; i <= n; i++) {
			dp[i] = Math.min(dp[i], dp[i - 1] + 1);
			for (int j = 6; j <= 100000; j *= 6) {
				if (i >= j)
					dp[i] = Math.min(dp[i], dp[i - j] + 1);
			}
			for (int j = 9; j <= 100000; j *= 9) {
				if (i >= j)
					dp[i] = Math.min(dp[i], dp[i - j] + 1);
			}
		}
		System.out.println(dp[n]);
		sc.close();
	}

}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define ff first
#define ss second
typedef pair<int,int> pii;

int32_t main()
{
 int x ;
 cin >> x ;
 if(x >= 30)cout << "Yes" ;
 else cout << "No" ;
 cout << endl ;
 return 0;
}        

Measured memory_bytes: 3616
# A - Rotation
line1 = input()
line2 = input()
my_list1 = []
my_list2 = []
 
for i in line1:
    my_list1.append(i)
 
for i in line2:
    my_list2.append(i)
 
my_list2.reverse()
 
if my_list1 == my_list2:
    print('YES')
else:
    print('NO')
 
# print(my_list1, my_list2)
 

Measured memory_bytes: 9016
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int n, k, sc;
  char hit, s[32];
  sc = scanf("%d", &n);
  sc = scanf("%s", s);
  sc = scanf("%d", &k);
  hit = s[k - 1];
  for(int i = 0; i < n; i++) {
    if(s[i] != hit) {
      s[i] = '*';
    }
  }
  printf("%s", s);
  return 0;
}

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

using namespace std;

int main() {
	int n, m;
	while ( cin >> n >> m, n || m ) {
		vector<int> a(n);
		int A = 0;
		for (int i = 0; i < n; ++i) {
			cin >> a[i];
			A += a[i];
		}
		vector<int> b(m);
		int B = 0;
		for (int i = 0; i < m; ++i) {
			cin >> b[i];
			B += b[i];
		}
		int I = -1, J = -1;
		int s = 1e9;
		int cnt = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				if ( A - a[i] + b[j] == B + a[i] - b[j] ) {
					++cnt;
					if (a[i] + b[j] < s) {
						I = i+1, J = j+1;
						s = a[i] + b[j];
					}
				}
			}
		}
		if (I < 0) cout << -1 << endl;
		else if (cnt > 0) cout << a[I-1] << " " << b[J-1] << endl;
		else cout << I << " " << J << endl;
	}
}

Measured memory_bytes: 1204
a=input()
total=0
total2=0
i=0
while True:
    if i==len(a):
        break
    elif a[i]=="A" or a[i]=="T" or a[i]=="C" or a[i]=="G":
        total+=1
        i+=1
    else:
        i+=1
        if total2<total:
            total2=total
        total=0
if total2<total:
    print(total)
else:
    print(total2)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<long long> v(n), ans(n, 0);
    map<long long, long long> m;
    map<long long, int> p;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        m[-v[i]]++;
        if (m[-v[i]] == 1) p[v[i]] = i;
    }
    m[0] = 0;
    long long cnt = 0;
    int cur = n+1;
    long long prev = -1;
    for (auto it: m) {
        long long x = -it.first;
        if (prev != -1) {
            ans[cur] += (prev - x) * cnt;
        }
        cnt += it.second;
        cur = min(cur, p[x]);
        prev = x;
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 15104
n,m = map(int,input().split())
res = 0
Q = []
for i in range(m):
    Q.append(list(map(int,input().split()))[1:])
P = list(map(int,input().split()))

for s in range(1<<n):
    tmp = 0
    for i in range(len(Q)):
        cnt = 0
        for t in Q[i]:
            if s>>(t-1) &1 == 1:
                cnt += 1
        if cnt % 2 == P[i]:
            tmp += 1
    if tmp == m:
        res += 1
print(res)

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

int main()
{
	int x;
	cin>>x;
	if(x>=400 && x<=599)	cout<<8;
	else if(x>=600 && x<=799)	cout<<7;
	else if(x>=800 && x<=999)	cout<<6;
	else if(x>=1000 && x<=1199)	cout<<5;
	else if(x>=1200 && x<=1399)	cout<<4;
	else if(x>=1400 && x<=1599)	cout<<3;
	else if(x>=1600 && x<=1799)	cout<<2;
	else	cout<<1;
	return 0;
 } 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void) {
    int N, K;
    cin >> N >> K;
    int A[N];
    int memo;
    for (int i=0; i<N; i++) cin >> A[i];
    cout << ((N-1)+(K-2))/(K-1) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;
 
int main() 
{
	fast;
	ll N,M; cin>>N>>M;
	vector<ll>v;
	v.clear();
	ll x;
	ld sum = 0;
	for(ll i = 0; i < N; i++)
	{
		cin>>x; sum += x;
		v.pb(x);
	}
//	cout << sum << endl;
	sum /= 4*M;
//	cout << sum << endl;
	sort(v.begin(),v.end(),greater<ll>());
	ll count = 0;
	for(ll i = 0; i < N; i++)
	{
		if(v[i] >= sum) count++;
	}
	if(count >= M)
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  char tmp;
  int counter_r = 0;
  int counter_w = 0;
  vector<int> stone;
  for(int i=0; i<N; i++){
    cin >> tmp;
    if(tmp == 'W'){
      counter_w++;
      stone.push_back(1);
    }else{
      counter_r++;
      stone.push_back(0);
    }
  }
//  for(int i=0; i<N; i++){
//    cout << stone.at(i);
//  }
//  cout << endl;
  if(counter_r==0 || counter_w==0){
    cout << 0 << endl;
    return 0;
  }
  int tmp_counter=0;
  int result=-1;
  if(counter_r < counter_w){
    for(int i=0; i<counter_r; i++){
      if(stone.at(i) == 1) tmp_counter++;
    }
    result = tmp_counter;
  }else{
    for(int i=0; i<counter_w; i++){
      if(stone.at(N-1-i) == 0) tmp_counter++;
    }
    result = tmp_counter;
  }
  cout << result << endl;
  
  return 0;
}


Measured memory_bytes: 4308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
#define endl '\n'
#define pb(a) push_back(a)
#define al(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define IOS ios::sync_with_stdio(0);

int main() {
	int l, r, d;
	cin >> l >> r >> d;
	cout << r / d - (l - 1) / d << endl;

	return 0;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<cmath>

struct Point{ double x, y;};

double getDistance(Point p1, Point p2){
    return sqrt( (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y));
}
main(){
    Point P[20];
    int n = 0;
    double z, S = 0;
    while( scanf("%lf,%lf", &P[n].x, &P[n].y) != EOF ){
	n++;
    }
    for ( int i = 1; i < n-1; i++ ){
	double a = getDistance(P[0], P[i]);
	double b = getDistance(P[i], P[i+1]);
	double c = getDistance(P[0], P[i+1]);
	z = (a + b + c )/2.0;
	S += sqrt(z*(z-a)*(z-b)*(z-c));
    }
    printf("%.8lf\n", S);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

string s;

int main(){
    cin >> s;

    int former = (s[0]-'0')*10+s[1]-'0';
    int latter = (s[2]-'0')*10+s[3]-'0';

    if(former >= 1 && former <= 12){
        if(latter >= 1 && latter <= 12) dunk("AMBIGUOUS");
        else dunk("MMYY");
    }
    else{
        if(latter >= 1 && latter <= 12) dunk("YYMM");
        else dunk("NA");
    }
    
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        // 出力
        Console.WriteLine("{0} {1} {2}", n[2], n[0], n[1]);
    }
}

Measured memory_bytes: 11348