akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}


static void exec()
{
	int N, M;
	get(N, M);

	std::vector<std::string> ai(N), bi(M);
	for (int i = 0; i < N; i++) {
		get(ai[i]);
	}
	for (int i = 0; i < M; i++) {
		get(bi[i]);
	}

	for (int h = 0; h < N; h++) {
		if (h + M > N) break;
		for (int w = 0; w < N; w++) {
			if (w + M > N) break;

			bool match = true;
			for (int i = 0; (i < M) && match; i++) {
				for (int j = 0; (j < M) && match; j++) {
					if (bi[i][j] != ai[h + i][w + j]) {
						match = false;
					}
				}
			}
			if (match) {
				printf("Yes\n");
				return;
			}
		}
	}
	printf("No\n");
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 3e5 + 124;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int p[N + 1], sum[N + 1];
string s;
int t[4 * N + 1], a[N + 1];
void pull(int v, int tl, int tr)
{
    t[v] = t[2 * v] + t[2 * v + 1];
}
void build(int v, int tl, int tr)
{
    if (tl == tr) {
        t[v] = a[tl];
        return;
    }
    int tm = (tl + tr) >> 1;
    build(2 * v, tl, tm);
    build(2 * v + 1, tm + 1, tr);
    pull(v, tl, tr);
}
void upd(int v, int tl, int tr, int id, int x)
{
    if (tl == tr) {
        t[v] = x;
        return;
    }
    int tm = (tl + tr) >> 1;
    if (id <= tm) {
        upd(2 * v, tl, tm, id, x);
    }
    else {
        upd(2 * v + 1, tm + 1, tr, id, x);
    }
    pull(v, tl, tr);
}
int getSum(int v, int tl, int tr, int L, int R)
{
    if (L > R) {
        return 0;
    }
    if (tl == L && tr == R) {
        return t[v];
    }
    int tm = (tl + tr) >> 1;
    if (R <= tm) {
        return getSum(2 * v, tl, tm, L, R);
    }
    else if (L > tm) {
        return getSum(2 * v + 1, tm + 1, tr, L, R);
    }
    return getSum(2 * v, tl, tm, L, tm) + getSum(2 * v + 1, tm + 1, tr, tm + 1, R);
}
main() {
    cin >> s;
    int n = s.size();
    s = "$" + s;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        a[i] = (s[i] == 'A');
    }
    build(1, 1, n);
    for (int i = 3; i <= n; i++) {
        if (s[i] == 'C' && s[i - 1] == 'B' && s[i - 2] == 'A') {
            int lf = 0, rg = i;
            while (rg - lf > 1) {
                int mid = (lf + rg) >> 1;
//                cout << mid << " " << i - 2 << "  " << getSum(1, 1, n, mid, i - 2) << "\n";
                if (getSum(1, 1, n, mid, i - 2) < i - 2 - mid + 1) {
                    lf = mid;
                } else {
                    rg = mid;
                }
            }
            int f = lf;
            ans += i - 2 - lf;
//            cout << f << "\n";
            swap(s[i - 1], s[f + 1]);
            swap(s[i], s[f + 2]);
            upd(1, 1, n, f + 1, 0);
            upd(1, 1, n, f + 2, 0);
            if (s[i - 1] == 'A') {
                upd(1, 1, n, i - 1, 1);
            }
            if (s[i] == 'A') {
                upd(1, 1, n, i, 1);
            }
            if (s[i - 2] == 'A') {
                upd(1, 1, n, i - 2, 1);
            }
        }
    }
//        cout << getSum(1, 1, n, 1, 4) << "\n";
//    cout << s << "\n";
    cout << ans;
}

/**
AAAAAABCABC
AAAAABCAABC
BCAAAAAAABC

CAAAABCBC
**/



Measured memory_bytes: 10304
H, W = map(int, input().split())
G = [input().split() for _ in range(H)]

for y in range(H):
	for x in range(W):
		if G[y][x] == "snuke":
			print("ABCDEFGHIJKLMNOPQRSTUVWXYZ"[x] + "{:d}".format(y + 1))
			exit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0; i<n; i++)
int main()
{
	string inp;
	int AC = 0;
	int WA = 0;
	int TLE = 0;
	int RE = 0;
	int N;
	cin >> N;
	rep(i,N){
		cin >> inp;
		if(inp == "AC")
			AC++;
		if(inp == "WA")
			WA++;
		if(inp == "TLE")
			TLE++;
		if(inp == "RE")
			RE++;
	}

	cout << "AC x " << AC << "\nWA x " << WA << "\nTLE x " << TLE << "\nRE x " << RE;
	cin >> N;

	return 0;	
}


Measured memory_bytes: 3628
# coding: utf-8
import sys
input = sys.stdin.readline

n = int(input())

ai = list(map(int, input().split()))
dic = {}
for i in range(1, n + 1):
    dic[ai[i-1]] = i

ans = sorted(dic.items())


for i in range(len(ans)):
    print(ans[i][1], end="")
    if i != len(ans)-1:
        print(end=" ")
    else:
        print()


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

int main(){
  string s;
  while(cin>>s){
    for(int i=0; i<s.length(); i++){
      if(s[i]=='@'){
        for(int j=0; j<s[i+1]-'0'; j++){
          cout<<s[i+2];
        }
        i+=2;
      }
      else{
        cout<<s[i];
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
#define mp make_pair
#define pb push_back

using namespace std;

int main() 
{
	int n, k;
	scanf("%d %d", &n, &k);
	long long sum = 0;
	for (int i = k+1; i<=n; ++i) {
		int a = n/i;
		int b = n%i;
		sum += (i-k)*a;
		if (b >= k)
			sum += (b-k + 1);
		if (k == 0)
			sum --;
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	
	int i, j, k, n, x;
        int sum = 0;

	while (1) {
	
	scanf("%d %d", &n, &x);

	if ( n == 0 && x == 0){
	break;
	}


	for( i = 1; i <= n-2; i++ ){
	 for( j = i+1; j <= n-1; j++){
	  for( k = j+1; k <= n; k++){
		 if ( i+j+k == x){
		  sum++;

   }
  }
 }
}
	 printf("%d\n", sum);
         sum = 0;
}
	return 0;
}


	
	

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

int main() {
    int a, b, ans = -1;
    cin >> a >> b;
    if(a <= 9 && b <= 9) ans = a * b;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] h = new int[N];
        int min = -1;
        int sum =0;
        for (int i =0; i<N; i++) {
            h[i] = sc.nextInt();
        }

        Arrays.sort(h);

        for (int i =0; i<N-K+1; i++) {
            int diff = h[i+K-1] - h[i];
            if (diff < min || min < 0) {
                min = diff;
            }
        }

        System.out.println(min);
    }

}

Measured memory_bytes: 51360
#include<iostream>
using namespace std;
int main(){
    long long n,m,l,num;
    cin>>n>>m>>l;
    int A[n][m],B[m][l];
    
    for (int a=0;a<n;a++){
        for (int b=0;b<m;b++){
            cin>>num;
            A[a][b]=num;
        }
    }
    
    for (int a=0;a<m;a++){
        for (int b=0;b<l;b++){
            cin>>num;
            B[a][b]=num;
        }
    }
    
    long long sum=0;
    for (int a=0;a<n;a++){
        for (int c=0;c<l;c++){
            for(int b=0;b<m;b++){
                sum=sum+A[a][b]*B[b][c];
            }cout<<sum;
            sum=0;
            if(c!=l-1) cout<<" ";
        }cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

void dfs(int num,int depth);

vector<int> tree[1001];
string m[1001];

int main(){
	int n;
	cin >> n;
	
	for(int i = 0;i < n;i++){
		int tmp;
		cin >> tmp;
		if(tmp-1 >= 0){
			tree[tmp-1].push_back(i);
		}
		cin >> m[i];
	}
	
	dfs(0,0);
	return 0;
}

void dfs(int num,int depth){
	for(int i = 0;i < depth;i++){
		cout << ".";
	}
	cout << m[num] << endl;
	for(int i = 0;i < tree[num].size();i++){
		dfs(tree[num][i],depth+1);
	}
}


Measured memory_bytes: 3368
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[])
{
	while(true)
	{
		int n, y;
		scanf("%d", &n);
		if (n == 0) break;
		scanf("%d", &y);
		int b, r, t;
		int number = 0;
		float maxVal = 0.0;
		REP(i, n)
		{
			scanf("%d %d %d", &b, &r, &t);
			float val = 1.0;
			if (t == 1)
			{
				val = 1.0 + ((float)r / 100. * (float)y);
			}
			else
			{
				float a = 1.0 + ((float)r / 100.);
				REP(j, y)
				{
					val *= a;
				}
			}
			if (val > maxVal)
			{
				number = b;
				maxVal = val;
				// printf("num:%d, val:%f\n", number, val);
			}
		}
		printf("%d\n", number);
	}
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=0;i<50100;i++){
    if(int(i*1.08)==n){
      cout<<i<<endl;
      break;
    }
    if(i==50090)
      ans=1;
  }
  if(ans==1)
    cout<<":("<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 1e6 + 10;
struct Edge
{
    int v, next;
} e[N << 1];

int head[N], cnt, n, m;

void ins(int u, int v)
{
	e[cnt].v = v;
	e[cnt].next = head[u];
	head[u] = cnt ++;
}

void insert(int u, int v)
{
    ins(u, v);
    ins(v, u);
}

int P[N][2], vis[N], as[2];

void cal(int u)
{
    queue<pii> Q;
    as[0] = as[1] = 0;
    memset(P, 0, sizeof(P));
    P[u][0] = 1;
    Q.push(mp(u, 0));
    while (!Q.empty())
    {
        pii now = Q.front();
        Q.pop();
        for (int i = head[now.X]; ~i; i = e[i].next)
        {
            if (!P[e[i].v][!now.Y])
            {
                P[e[i].v][!now.Y] = 1;
                Q.push(mp(e[i].v, !now.Y));
            }
        }
    }
    rep(i, 1, n)
    {
        if (P[i][0]) as[0] ++;
        if (P[i][1]) as[1] ++;
    }
}

ll ans = 0;
int flag = 0;

void dfs(int u)
{
    vis[u] = 1;
    ans += as[flag ^ 1];
    if (P[u][flag ^ 1]) ans --;
    for (int i = head[u]; ~i; i = e[i].next)
        if (!vis[e[i].v])
        {
            vis[e[i].v] = 1;
            flag = flag ^ 1;
            dfs(e[i].v);
            flag = flag ^ 1;
        }

}

int main()
{
	memset(head, -1, sizeof(head));
    n = read();
    m = read();
    rep(i, 1, m)
    {
        int a, b;
        a = read();
        b = read();
        insert(a, b);
    }
    rep(i, 1, n)
        if (!vis[i])
        {
            flag = 0;
            cal(i);
            dfs(i);
        }
    cout << ans / 2 - m << endl;
    return 0;
}


Measured memory_bytes: 17456
using System;
using System.Text.RegularExpressions;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            string test = Console.ReadLine();

            int count = 0;
            while (true)
            {
                string input = Console.ReadLine();
                if(input == "END_OF_TEXT")
                {
                    break;
                }

                MatchCollection mc = Regex.Matches(input, @"\b" + test + @"\b", RegexOptions.IgnoreCase);
                count += mc.Count;
            }

            Console.WriteLine(count);
        }
    }
}

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

int main(){
    int a[3][3];
    bool bingo[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> a[i][j];
            bingo[i][j] = false;
        }
    }
    int n; cin >> n;
    for(int i = 0; i < n; i++){
        int b; cin >> b;
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(a[i][j] == b){
                    bingo[i][j] = true;break;
                }
            }
        }
    }

    for(int i = 0; i < 3; i++){
        if(bingo[i][0] & bingo[i][1] & bingo[i][2]){
            cout << "Yes" << endl; return 0;
        }
    }
    for(int i = 0; i < 3; i++){
        if(bingo[0][i] & bingo[1][i] & bingo[2][i]){
            cout << "Yes" << endl; return 0;
        }
    }
    if(bingo[0][0] & bingo[1][1] & bingo[2][2]){
            cout << "Yes" << endl; return 0;
    }
    if(bingo[0][2] & bingo[1][1] & bingo[2][0]){
            cout << "Yes" << endl; return 0;
    }

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

Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
ev, od = [], []
for i in range(n):
    if i % 2 == 0:
        ev.append(v[i])
    else:
        od.append(v[i])

cnt_ev = sorted(Counter(ev).items(), key=lambda x: x[1], reverse=True)
cnt_od = sorted(Counter(od).items(), key=lambda x: x[1], reverse=True)
if len(cnt_ev) == 1 and len(cnt_od) == 1:

    if cnt_ev[0][0] == cnt_od[0][0]:
        res = n // 2
        print(res)
    else:
        res = 0
        print(res)
elif len(cnt_ev) == 1:
    if cnt_ev[0][0] == cnt_od[0][0]:
        res = n // 2 - cnt_od[1][1]
        print(res)
    else:
        res = n // 2 - cnt_od[0][1]
        print(res)
elif len(cnt_od) == 1:
    if cnt_ev[0][0] == cnt_od[0][0]:
        res = n // 2 - cnt_ev[1][1]
        print(res)
    else:
        res = n // 2 - cnt_ev[0][1]
        print(res)
else:
    if cnt_ev[0][0] == cnt_od[0][0]:
        res1 = n - cnt_ev[0][1] - cnt_od[1][1]
        res2 = n - cnt_ev[1][1] - cnt_od[0][1]
        res = min(res1, res2)
        print(res)
    else:
        res = n - cnt_ev[0][1] - cnt_od[0][1]
        print(res)


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

absA = [abs(A[i]) for i in range(N)]
minA = min(absA)
sumA = sum(absA)
minus = 0
for i, a in enumerate(A):
    if a < 0:
        minus += 1

if minus % 2 == 0:
    ans = sumA
else:
    ans = sumA - 2 * minA

print(ans)

Measured memory_bytes: 14284
//author Forsaken
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<numeric>
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) < (y) ? (x) : (y))
#define lowbit(x) ((x) & (-(x)))
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.in", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.out", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%lld\n", x)
#define memset0(arr) memset(arr, 0, sizeof(arr))
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 1e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1.0);
il int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll quick_pow(ll base, ll index, ll p) {
	ll res = 1;
	while (index) {
		if (index & 1)res = res * base % p;
		base = base * base % p;
		index >>= 1;
	}
	return res;
}
vector<int> g[maxn + 5];
bool vis[maxn + 5][3];
int n, m, dis[maxn + 5][3];
int s, t;
void BFS(int s) {
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j < 3; ++j)
			dis[i][j] = INF;
	dis[s][0] = 0;
	queue<pii> q;
	q.push(pii(s, 0));
	vis[s][0] = 1;
	while (!q.empty()) {
		pii now = q.front(); q.pop();
		int u = now.first, d = now.second;
		for (int i = 0; i < g[u].size(); ++i) {
			int v = g[u][i];
			int l = (d + 1) % 3;
			if (vis[v][l])continue;
			else {
				dis[v][l] = dis[u][d] + 1;
				q.push(pii(v, l));
				vis[v][l] = 1;
			}
		}
	}
}
int main()
{
	n = read_int(), m = read_int();
	for (int i = 1, u, v; i <= m; ++i) {
		u = read_int(), v = read_int();
		g[u].push_back(v);
	}
	s = read_int(), t = read_int();
	BFS(s);
	if (dis[t][0] == INF)outd(-1);
	else outd(dis[t][0] / 3);
	//system("pause");
	return 0;
}

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

int main(){
  long long a[300000],b[300000],c,e[300000]={};
  int n,m;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  e[0]=a[0];
  for(int i=1;i<n;i++)e[i]+=e[i-1]+a[i];
  cin>>m;
  for(int i=0;i<m;i++) cin>>b[i];
  for(int i=0;i<m;i++){
    cin>>c;
    int hi=n-1,lo=0;
    while(hi>lo){
      int mid=(hi+lo)/2;
      if(a[mid]>b[i]) hi=mid;
      else lo=mid+1;
    }
    if(a[hi]<=b[i])hi++;
    if(c<=e[hi-1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }

  return 0;
}

Measured memory_bytes: 8212
/*
 * atcoder/abc146_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
#include <map>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 100000;
int N;
vector<int> G[MAX];
vector<int> C(MAX, -1);
map<pair<int, int>, int> M;
void dfs(int n=0, int prev=-1, int prev_c=-1) {
  int c = prev_c == 0 ? 1 : 0;
  for (auto&& u: G[n]) {
    if (u == prev) continue;
    C[M[make_pair(n, u)]] = c;
    dfs(u, n, c);
    c++; if (c==prev_c) c++;
  }
}

void solve() {
  cin >> N;
  int a, b;
  loop(n,0,N-1) {
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
    M[make_pair(a, b)] = n;
    M[make_pair(b, a)] = n;
  }
  dfs();
  int k = 0;
  for (auto &&c: C) chmax(k, c);
  k++;
  cout << k << endl;
  loop(n,0,N-1) cout << C[n]+1 << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 18944
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    if((a+b)%2){
        printf("IMPOSSIBLE\n");
    }
    else{
        printf("%d\n",(a+b)/2);
    }
}

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

int main(void){
  int n, m, i, j, x, y, distance;
  cin >> n >> m;
  int students[n][3] = {};
  int checkpoint[n] = {};
  for(i = 0; i < n; i++){
    cin >> students[i][0] >> students[i][1];
    students[i][2] = INT_MAX;
  }
  for(i = 1; i <= m; i++){
    cin >> x >> y;
    for(j = 0; j < n; j++){
      distance = abs(students[j][0]-x) + abs(students[j][1]-y);
      if(distance < students[j][2]){
        students[j][2] = distance;
        checkpoint[j] = i;
      }
    }
  }
  for(i = 0; i < n; i++){
    cout << checkpoint[i] << endl;
  }
  return 0;
}


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

int main(){

  vector <long long> a;

  long long N,b;
  cin >> N;
  for(int i = 0;i < N;i++){
    cin >> b;
    a.push_back(b);
  }

  sort(a.begin(),a.end(),greater<int>());
  long long num = 0,t = 0,r[1000];
  for(int i = 0;i < N-1;i++){
    if(a[i] == a[i+1]){
      r[num] = a[i];
      num++;
      i++;
    }
    if(num == 2){
      break;
    }
  }

  if(num >= 2){
    cout << r[0]*r[1] << endl;
  }
  else{
    cout << "0" << endl;
  }
}


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

even_numbers = [a for a in A if a % 2 == 0]

is_approved = all([even_num % 3 == 0 or even_num % 5 == 0 for even_num in even_numbers])

if is_approved:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 9112
#include<iostream>
#include<cstring>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[2001][2001][4];

int H,W;
char board[2001][2001];

int maxbeam(int x, int y, int d) {
    if(x<0 || x>=H || y<0 || y>=W) return 0;

    if(dp[x][y][d]!=-1) return dp[x][y][d];

    if(board[x][y] == '#') return dp[x][y][d]=0;
    else {
        return dp[x][y][d]=1+maxbeam(x+dx[d],y+dy[d],d);
    }
}

int main() {
    memset(dp, -1, sizeof(dp));
    scanf("%d %d",&H, &W);
    for(int i=0;i<H;i++) {
        scanf("%s",board[i]);
    }
    
    int res = 0;
    for(int x=0;x<H;x++) {
        for(int y=0;y<W;y++) {
            if(board[x][y]!='#') {
                int val=1;
                for(int d=0;d<4;d++) val+=maxbeam(x+dx[d], y+dy[d], d);
                res=max(res, val);
            }
        }
    }
    cout<<res;
}

Measured memory_bytes: 66688
#include<stdio.h>
#define swap(a,b) (a+=b,b=a-b,a-=b)

int main(){
  int a,b,c,k,i;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  if(a<b) swap(a,b);
  else if(a<c) swap(a,c);
  for(i=0;i<k;i++){
    a*=2;
  }
  printf("%d",a+b+c);
}

Measured memory_bytes: 128
import math
N=int(input())
A={}
mod=10**9+7
AZ,BZ,ZZ=0,0,0
for i in range(N):
  a,b=map(int, input().split())
  if a==b and a==0:
    ZZ+=1
  elif a==0:
    AZ+=1
    if (0,-1) not in A:
      A[(0,-1)]=1
    else:
      A[(0,-1)]+=1
  elif b==0:
    BZ+=1
    if (1,0) not in A:
      A[(1,0)]=1
    else:
      A[(1,0)]+=1
  else:
    if a<0:
      a*=-1
      b*=-1
    d=math.gcd(abs(a),abs(b))
    a//=d
    b//=d
    if (a,b) not in A:
      A[(a,b)]=1
    else:
      A[(a,b)]+=1
c=0
D=[]
for x,y in A:
  if (y,-x) in A:
    D.append((A[(x,y)],A[(y,-x)]))
    c+=A[(x,y)]+A[(y,-x)]
n=N-c-ZZ
p=pow(2,n,mod)
ans=p
for a,b in D:
  f=pow(2,a+b,mod)-(pow(2,a,mod)-1)*(pow(2,b,mod)-1)
  ans*=f
ans-=1
print((ans+ZZ)%mod)

Measured memory_bytes: 46580
N, K = map(int, input().split())
M = N - K
MOD = 10 ** 9 + 7

f = [1] * (N + 1)
for i in range(1, N + 1):
    f[i] = f[i-1] * i

for i in range(1, K + 1):
    ans = f[M+1] // (f[i] * f[M+1-i])
    ans %= MOD
    ans *= (f[K-1] // (f[i-1] * f[K-i]))
    ans %= MOD
    print(ans)

Measured memory_bytes: 11664
// Score: /200

#include <iostream>
#include <string>

using namespace std;

int main()
{
	string S;
	int w;
	cin >> S >> w;
	for (int i = 0; i < S.size(); ++i)
	{
		if (i % w == 0)
		{
			cout << S[i];
		}
	}
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            out.println(n * (n + 1) / 2);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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 long nextLong() {
            return Long.parseLong(next());
        }

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

    }

}

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

int main() {
  int n, m;
  cin >> n >> m;
  if (n >= m) return cout << 0 << endl, 0;
  vector<int> x(m), d(m - 1);
  for (int i = 0; i < m; i++) cin >> x[i];
  sort(begin(x), end(x));
  for (int i = 1; i < m; i++) d[i - 1] = x[i] - x[i - 1];
  sort(begin(d), end(d), greater<int>());
  int ans = x[m - 1] - x[0];
  for (int i = 0; i < n - 1; i++) ans -= d[i];
  cout << ans << endl;
}


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

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

    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    cout << fixed << setprecision(8) << sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))
         << endl;
}


Measured memory_bytes: 3312
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

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

    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));

    vector<ll> suf(n + 1);
    rep(i, n) suf[i + 1] = a[n - 1 - i];
    rep(i, n) suf[i + 1] += suf[i];

    // lb以上
    auto calc = [&](ll lb) {
        vector<int> ct(n);
        rep(i, n) {
            // a[i]+x >= lb
            // x >= lb-a[i]
            int idx = lower_bound(all(a), lb - a[i]) - a.begin();
            ct[i] = n - idx;
        }
        return ct;
    };

    ll ng = 0, ok = 222222;
    while (ok - ng > 1) {
        ll mid = (ok + ng) / 2;

        vector<int> v = calc(mid);
        ll s = 0;
        for (int i : v) s += i;

        if (s <= m)
            ok = mid;
        else
            ng = mid;
    }

    vector<int> x = calc(ok);
    ll sx = 0;
    for (int i : x) sx += i;

    ll ans = (ok - 1) * (m - sx);
    rep(i, n) {
        ans += a[i] * x[i];
        ans += suf[x[i]];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2184
import java.util.*;
 
public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        long H = sc.nextLong();
        long W = sc.nextLong();
        sc.close();

        long Smax;
        long Smin;

        if(H%3 == 0 || W%3 == 0){
            System.out.println(0);
        } else {
            long same = Math.min(H, W); //同じ方向で分割した場合の最小値
            long cross1 = H*W; //縦横で分割した場合の最小値
            long cross2 = H*W;
            for(int i = 1; i <= H / 2; i++){
                long A = i * W;
                long B = (H-i) * (W/2);
                long C;
                if(W%2 == 0)
                    C = B;
                else
                    C = (H-i) * (W/2 + 1);
                Smax = Math.max(A, C);
                Smin = Math.min(A, B);
                cross1 = Math.min(cross1, Math.abs(Smax-Smin));
            }
            if(H==W){
                cross2 = cross1;
            } else {
                for(int i = 1; i <= W / 2; i++){
                    long A = i * H;
                    long B = (W-i) * (H/2);
                    long C;
                    if(H%2 == 0)
                        C = B;
                    else
                        C = (W-i) * (H/2 + 1);
                    Smax = Math.max(A, C);
                    Smin = Math.min(A, B);
                    cross2 = Math.min(cross2, Math.abs(Smax-Smin));
                }
            }
            System.out.println(Math.min(same, Math.min(cross1, cross2)));
        }


    }
}

Measured memory_bytes: 24020
#include<iostream>
using namespace std;
void solve(string str){
	bool flag  =false;
	for(int i =0;i<str.length();i++){
		if(str[i]=='R'&&(i+1)%2==0){
			flag = true;
			break;
		}
		if(str[i]=='L' && (i+1)%2!=0){
			flag=true;
			break;
		}
    }
	if(flag){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}
	cout<<endl;
}

int main(){
	string str;
	cin>>str;
	solve(str);
	return 0;
}



Measured memory_bytes: 256
/**
 *      ABC 95 B
 *      author  : kyomukyomupurin
 *      created : 2018/08/23
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n, x; cin >> n >> x;
    vector<int> m;
    int a;

    for (int i = 0; i < n; ++i) {
        cin >> a;
        m.push_back(a);
    }
    
    int min = *min_element(m.begin(), m.end());
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += m.at(i);
    }
    cout << n + (x - sum) / min << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
double helon(double x1,double y1,double x2,double y2,double x3,double y3){
	double a,b,c,s,area;
	a = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	b = sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
	c = sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
	s = (a+b+c)/2;
	area = sqrt(s*(s-a)*(s-b)*(s-c));
	return area;
}

int main(){
	double e=0.0000001;
	double x1,y1,x2,y2,x3,y3,xp,yp;
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
		double s,s1,s2,s3;
		s = helon(x1,y1,x2,y2,x3,y3);
		s1 = helon(xp,yp,x1,y1,x2,y2);
		s2 = helon(xp,yp,x2,y2,x3,y3);
		s3 = helon(xp,yp,x3,y3,x1,y1);
		//cout<<s<<" "<<s1<<" "<<s2<<" "<<s3<<endl;
		if(fabs(s1)<e || fabs(s2)<e || fabs(s3)<e)
			cout<<"NO"<<endl;
		else if(fabs(s-(s1+s2+s3))<e)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef VP::iterator VPI;

int h, w, ans = 0, near[1000][1000];
char beach[1000][1000];
VP broken1, broken2;
VPI p;
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main()
{
  cin >> h >> w;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++) cin >> beach[i][j];
  }

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(beach[i][j] == '.') near[i][j] = -1;
      else{
	for(int k = 0; k < 8; k++) if(beach[i + dx[k]][j + dy[k]] == '.') near[i][j]++;
	if(beach[i][j] - '0' <= near[i][j]){
	  broken2.push_back(make_pair(i, j));
	  near[i][j] = -1;
	}
      }
    }
  }

  while(!broken2.empty()){
    ans++;
    broken1 = broken2;
    broken2.clear();
    for(p = broken1.begin(); p != broken1.end(); p++){
      for(int i = 0; i < 8; i++){
	PII next = make_pair(p->x + dx[i], p->y + dy[i]);
	if(near[next.x][next.y] != -1){
	  near[next.x][next.y]++;
	  if(beach[next.x][next.y] - '0' <= near[next.x][next.y]){
	    broken2.push_back(next);
	    near[next.x][next.y] = -1;
	  }
	}
      }
    }
  }

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

Measured memory_bytes: 6096
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, map) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, M; cin >> N >> M;
    if(M < 2 * N){
        cout << M / 2 << endstr;
    }
    else{
        ll x = (M - 2 * N) / 2;
        ll ret = 0;
        for(int i = -4; i < 4; i++){
            ll xx = x + i;
            if(xx % 2 == 0 && 2* N + xx <= M - xx){
                ret = max(ret, N + xx / 2);
            }
        }
        cout << ret << endstr;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b&&b==c)pr('1');
    else if(a==b||b==c||c==a)pr('2');
    else pr('3');
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 998244353
#define ll long long
using namespace std;
map<string,int> f[2];
string s;
int F(string x,int y){
	if (f[y][x])return f[y][x]-1;
	ll ans=0;int n=x.length();
	if (n==0)return 1;
	if (y==0){
		ans=F(x.substr(1,n-1),0)*(x[0]-'0' +1)%mo;
		for (int j=0;j<n;j++){
			ans=(ans+1ll*F(x.substr(0,j+1),1)*F(x.substr(j+1,n),0))%mo;
		}
	}else{
		for (int i=2;i<=n;i++){
			if (n%i==0){
				string p="";
				for (int k=0;k<(n/i);k++){
					int s='1';
					for (int j=0;j<i;j++)s=s&x[k+j*(n/i)];
					p+=s;
				}
				ans=(ans+F(p,0))%mo;
			}
		}
	}
	f[y][x]=ans+1;
	return ans;
}
int main(){
	cin>>s;cout<<F(s,0)<<endl;
	return 0;
}

Measured memory_bytes: 12928
#include <iostream>
#include <queue>
#define ll long long
#define MAXN 1000005
using namespace std;
struct node {
    ll num, step;
    node(){}
    node(ll n, ll s) : num(n), step(s){}
};
deque <node> q;
bool vst[MAXN];
ll k;
void slove() {
    q.push_front(node(1, 1));
    while(!q.empty()) {
        node t = q.front();
        q.pop_front();
        if(vst[t.num]) continue;
        vst[t.num] = 1;
        if(t.num == 0) {
            cout << t.step << "\n";
            return;
        }
        q.push_front(node(t.num*10%k, t.step));
        q.push_back(node((t.num+1)%k, t.step+1));
    }
}

int main () {
    cin >> k;
    slove();
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
using namespace std;
#define mod 1000000007
const int maxn=1000000;
void solve() {
    int n;
    cin>>n;
    vector<pair<int,int>> vec(n);
    for(int i=0;i<n;++i){
        cin>>vec[i].first>>vec[i].second;
    }
    int curr=0;
    bool flag=false;
    for(int i=0;i<n;++i){
       if(vec[i].first==vec[i].second) curr++;
       else curr=0;
       if(curr==3){
           flag=true;
           cout<<"Yes";
           return;
       }

    }
    cout<<"No";


}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3660
package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var n, k int
	fmt.Fscanf(r, "%d %d\n", &n, &k)

	fmt.Fprintln(w, n-k+1)
}


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

#define MAX_N 2000
#define MAX_K 2000
ll C[MAX_N+1][MAX_K+1] = {};

ll comb_mod(int n, int k) {
  if (n < k) return 0;
  if (C[n][k] > 0) return C[n][k];
  if (n == k || k == 0) return C[n][k] = 1;
  return C[n][k] = (comb_mod(n-1, k) + comb_mod(n-1, k-1) ) % MOD;
}

int main() 
{
  int n, k;
  cin >> n >> k;
  
  for (int i = 1; i <= k; ++i) {
    ll ans;
    ans = comb_mod(n-k+1, i) * comb_mod(k-1, i-1) % MOD;
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    int a,b,k;  cin >> a >> b >> k;
    for(int i = min(a , b);i>=1;i--){
        if(a % i == 0 && b % i == 0){
            if(k == 1)  return cout << i , 0;
            k--;
        }
    }
    return 0;
}


Measured memory_bytes: 256
using System;
class Program{
    static void Main(){
        int how_many = int.Parse(Console.ReadLine());
        for(int i=0;i<how_many;i++){
            string str = Console.ReadLine();
            string[] stArray = str.Split(' ');
            int[] intArray = new int[3];
            int j, k;// This is count val for forloop.
            for(j=0;j<3;j++){
                intArray[j] = int.Parse(stArray[j]);
            }
            //sort three size of side.
            int tmp;
            for(j=0;j<3;j++){
                for(k=j+1;k<3;k++){
                    if(intArray[k] > intArray[j]){
                        tmp = intArray[k];
                        intArray[k] = intArray[j];
                        intArray[j] = tmp;
                    }
                }
                
            }
            if(intArray[0] * intArray[0]  == intArray[1] * intArray[1] + intArray[2] * intArray[2]){
                Console.WriteLine("YES");
            }else{
                Console.WriteLine("NO");
            }
        }

    }

}

Measured memory_bytes: 8880
s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
x=-1
if a+b+c+d==7:
    x=str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'='+'7'
elif a+b+c-d==7:
    x=str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'='+'7'
elif a+b-c+d==7:
    x=str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'='+'7'
elif a+b-c-d==7:
    x=str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'='+'7'
elif a-b+c+d==7:
    x=str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'='+'7'
elif a-b+c-d==7:
    x=str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'='+'7'
elif a-b-c+d==7:
    x=str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'='+'7'
elif a-b-c-d==7:
    x=str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'='+'7'
print(x)


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

int main() {
  int N,K,x,sum=0;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    cin >>x;
    if(K-x<x)sum+=(K-x)*2;
    else sum+=x*2;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  int N;
  std::cin >> N;

  if (N == 1) {
    std::cout << "Hello World" << std::endl;
  } else if (N == 2) {
    int A, B;
    std::cin >> A >> B;
    std::cout << (A + B) << std::endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define MAXN 3000

int main(void)
{
    int n, r, inner;

    scanf("%d %d", &n, &r);
    if( n>=10 )
        inner = r;
    else
        inner = r+100*(10-n);
    printf("%d", inner);

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>


int main(void)
{
	int			i,money=100000,  week, surplus;
	
	scanf("%d",&week);
	for(i=0; i<week; i++){
		money = money*1.05;
		surplus = money % 1000;
		if(surplus){
			money = money + 1000 -surplus;
		}
	}

	printf("%d\r\n", money);
	return 0;
}

Measured memory_bytes: 588
from collections import deque
import sys
sys.setrecursionlimit(4100000)
def main():
    H, W = map(int, input().split())
    A = [list(input()) for _ in range(H)]
    Q = deque([])
    visited = [[float('inf')] * W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#':
                Q.append((h,w))
                visited[h][w] = 0
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    ans = 0
    while Q:
        y, x = Q.popleft()
        now = visited[y][x]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]

            if 0 <= nx < W and 0 <= ny < H:
                if visited[ny][nx] == float('inf'):
                    visited[ny][nx] = now + 1
                    Q.append((ny,nx))
                    ans = max(ans, now + 1)

    print(ans)




if __name__ == "__main__":
    main()


Measured memory_bytes: 161724
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int times[10000/2];
		memset(times, 0, sizeof(times));
		vector<int> v;
		for (int i = 1; i < n; ++i)
			v.push_back(i*i%n);
		sort(v.begin(), v.end());
		int m = unique(v.begin(), v.end()) - v.begin();
		for (int i = 0; i < m; ++i)
		{
			for (int j = i+1; j < m; ++j)
			{
				int t = v[j] - v[i];
				if (t > n/2)
					t = n - t;

				++times[t];
			}
		}

		for (int i = 1; i <= n/2; ++i)
			printf("%d\n", 2*times[i]);
	}

	return 0;
}

Measured memory_bytes: 1040
N, D = map(int, input().split())
X = [input().split() for _ in range(N)]

res = 0
for i in range(N - 1):
    for k in range(i + 1, N):
        ans = 0.0
        for j in range(D):
            ans += abs( (int(X[i][j]) - int(X[k][j]))**2 )
    
        ans = ans ** (1/2)
        if ans.is_integer():
            res += 1

print(res)

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

int Prime[100001];
int Prime2017[100001];

int main(){
	for(int i=0;i<100001;i++)Prime[i]=1;
	Prime[0]=Prime[1]=0;
	for(int i=2;i*i<100001;i++){
		if(Prime[i]){
			int j=i;
			while(j<100001){
				j+=i;
				Prime[j]=0;
			}
		}
	}

	for(int i=3; i+1<100001; i+=2){
		if( Prime[i] && Prime[(i+1)/2] )Prime2017[i]=1;
	}

	//for(int i=0;i<20;i++)if(Prime2017[i])cout<<i<<" ";
	//cout<<endl;

	for(int i=1;i<100001;i++){
		Prime2017[i]+=Prime2017[i-1];
	}

	
	int q;	cin>>q;
	vector<pair<int,int>> in(q);
	for(int i=0;i<q;i++){
		cin>>in[i].first>>in[i].second;
	}

	for(int i=0;i<q;i++){
		int L=in[i].first, R=in[i].second;
		cout<<Prime2017[R]-Prime2017[L-1]<<endl;
	}

	return 0;
}


Measured memory_bytes: 2176
#include<cstdio>
using namespace std;

const int MAX_N = 200005;

int main(){
  int n, k;
  int p[MAX_N];

  scanf("%d %d", &n, &k);

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

  double ans, cand = 0;

  for(int i = 0; i < k; i++){
    cand += ((double)p[i] + 1) / 2;
  }

  ans = cand;


  for(int i = 0; i < n-k; i++){
    cand -= ((double)p[i] + 1) / 2;
    cand += ((double)p[k+i] + 1) / 2;

    if (cand > ans) ans = cand;
  }

  printf("%lf\n", ans);

  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<cstring>
#include <stdio.h>
 
int main ()
{
    int a, b, c, x, i, j, k, cnt=0;
    scanf("%d%d%d%d", &a, &b, &c, &x);
    for (i=0; i <= a && 500*i<=x; i++)
    {
        for (j=0; j <= b && 100*j+500*i<=x; j++)
        {
            for (k=0; k <= c && 50*k+100*j+500*i<=x; k++)
            {
                if (500*i+100*j+50*k==x)
                {
                    cnt++;
                }
            }
        }
    }
 
    printf("%d", cnt);
 
    return 0;
}
 

Measured memory_bytes: 128
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define INF 1000000000000000000LL
#define MOD 1000000007

int main(){
	ll n,m,q;
	cin>>n>>m>>q;
	vector<ll> vn,vm;
	rep(i,0,n){
		ll a;
		cin>>a;
		vn.pb(a);
	}
	rep(i,0,m){
		ll a;
		cin>>a;
		vm.pb(a);
	}
	vn.pb(-INF);
	vn.pb(INF);
	vm.pb(-INF);
	vm.pb(INF);
	sort(all(vn));
	sort(all(vm));
	rep(i,0,q){
		ll a;
		cin>>a;
		vector<ll>::iterator itr1 = lower_bound(all(vn),a);
		vector<ll>::iterator itr2 = itr1-1;
		vector<ll>::iterator itr3 = lower_bound(all(vm),a);
		vector<ll>::iterator itr4 = itr3-1;
		ll ln = vn[itr2-vn.begin()];
		ll rn = vn[itr1-vn.begin()];
		ll lm = vm[itr4-vm.begin()];
		ll rm = vm[itr3-vm.begin()];
		vector<ll> ans;
		ans.pb(a-min(ln,lm));
		ans.pb(max(rn,rm)-a);
		ans.pb((a-ln)*2+(rm-a));
		ans.pb((a-ln)+(rm-a)*2);
		ans.pb((a-lm)*2+(rn-a));
		ans.pb((a-lm)+(rn-a)*2);
		sort(all(ans));
		cout << ans[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 3060