akhauriyash/Code-Regression huggingface dataset:
import sys

class Node:
    def __init__(self):
        self.parent=-1
        self.left=-1
        self.right=-1

depthList = []
nodeList = []

def readinput():
    global nodeList
    n=int(input())
    nodeList=[Node() for _ in range(n)]
    for _ in range(n):
        s=list(map(int,input().split()))
        id=s[0]
        deg=s[1]
        child=s[2:]
        if (deg>0):
            nodeList[id].left=child[0]
            for i in range(deg-1):
                nodeList[child[i]].parent=id
                nodeList[child[i]].right=child[i+1]
            nodeList[child[deg-1]].parent=id
    return

def findRoot(nodeList):
    for i, node in enumerate(nodeList):
        if(node.parent==-1):
            return i
    return -1

def setDepth(id,depth):
    #sys.setrecursionlimit(3700)
    global depthList
    global nodeList

    depthList[id]=depth
    r=nodeList[id].right
    #if(r!=-1):
    #    setDepth(r,depth)
    while(r!=-1):
        depthList[r]=depth
        if(nodeList[r].left!=-1):
            setDepth(nodeList[r].left,depth+1)
        r=nodeList[r].right
    l=nodeList[id].left
    if(l!=-1):
        setDepth(l,depth+1)

def nodeType(node):
    if node.parent==-1:
        return 'root'
    elif node.left==-1:
        return 'leaf'
    else:
        return 'internal node'

def childList(p, nodeList):
    child=[]
    c=nodeList[p].left
    while(c!=-1):
        child.append(c)
        c=nodeList[c].right
    return child

def printNodeList(nodeList, depthList):
    for i,node in enumerate(nodeList):
        print('node {}: parent = {}, depth = {}, {}, {}'.format(i,node.parent, depthList[i], nodeType(node), childList(i,nodeList)))

def main():
    global depthList
    global nodeList

    depthList=[0]*len(nodeList)
    root=findRoot(nodeList)
    setDepth(root,0)
    printNodeList(nodeList, depthList)

if __name__=='__main__':
    sys.setrecursionlimit(10000)
    readinput()
    main()



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

int main() {
	int a, b, c, n;
	cin >> a >> b >> c;
	if(a == b){
		n = c;
	}else if(b == c){
		n = a;
	}else{
		n = b;
	}
	cout << n << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const ll INF = 1<<30;
const ll MOD = (ll)1e9 + 7;
const ll MAX_N = (ll)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k, q; cin >> n >> k >> q;
    vector<ll> p(n, k), v(n, 0);
    ll sum = 0;
    for(ll i = 0; i < q; i++)
    {
        ll a; cin >> a; a--;
        sum += a;
        v[a]++;
    }
    for(int i = 0; i < n; i++)
    {
        p[i] -= q - v[i];
    }
    for(ll i = 0; i < n; i++)
    {
        if(p[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}



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

int main() {
  char input[4], output[4] = "No";
  scanf("%s", input);

  for (short i = 0; i < 4; i += 1) {
    if ('7' == input[i]) {
      strcpy(output, "Yes");
      break;
    }
  }

  printf("%s\n", output);

  return 0;
}

Measured memory_bytes: 1644
#include<queue>
#include<stack>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>

//#include<windows.h>


using namespace std;



#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9 + 7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;
Int fib_memo[1000001] = {};

Int mfib(Int n) {
	if (n <= 1) return n;
	if (fib_memo[n] != 0) return fib_memo[n];
	return fib_memo[n] = mfib(n - 1) + mfib(n - 2);
}


Int fib(Int n) {
	if (n <= 1) return n;
	return fib(n - 1) + fib(n - 2);
}

//ここまでライブラリ

//ここから本編

int main() {
	int x;
	cin >> x;
	cout << ((x < 1200) ? "ABC" : "ARC") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define   ll   long long int
#define   sz   200010

using namespace std;

queue<ll>q;
char mat[30][30];
ll vis[30][30];
ll dx[]={1,-1,0,0};
ll dy[]={0,0,-1,1};

ll bfs(ll s,ll e,ll n, ll m)
{
    vis[s][e]=1;
    q.push(s);
    q.push(e);
    q.push(0);

    ll x,y,r,cl,c,p;
    ll mx=0;


    while(!q.empty())
    {
        x=q.front();q.pop();
        y=q.front();q.pop();
        c=q.front();q.pop();
        mx=max(mx,c);




        for(ll i=0;i<4;i++)
        {
            r=x+dx[i];
            cl=y+dy[i];
            if(vis[r][cl]==0 && r>=1 && r<=n && cl>=1 && cl<=m && mat[r][cl]!='#')
            {
                 q.push(r);
                 q.push(cl);
                 q.push(c+1);
                 vis[r][cl]=1;
            }
        }

    }

    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=m;j++)
        {
            vis[i][j]=0;
        }
    }

    return mx;
}

int main()
{

    ll i,j,l,r,c,x,y,mn,mx,k,p,d,m,n;
    cin>>n>>m;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cin>>mat[i][j];
        }
    }
    mx=0;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {

            if(mat[i][j]=='.')
            {
                k=bfs(i,j,n,m);
                mx=max(mx,k);
            }
        }
    }
    cout<<mx<<endl;
    return 0;
}



Measured memory_bytes: 256
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())

# 複数個の数値を、intの配列として取得
H = list(map(int, input().split()))

ans=0
tmp=0
for i in range(1,N):
    if H[i]<=H[i-1]:
        tmp+=1
    else:
        ans=max(ans,tmp)
        tmp=0
ans=max(ans,tmp)

print(ans)

Measured memory_bytes: 14380
using System;
using System.Linq;
public class c
{
  public static void Main()
  {
    int[] x=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    int sx=x[0];
    int sy=x[1];
    int tx=x[2];
    int ty=x[3];
    int dirx=tx-sx;
    int diry =ty-sy;
    string S="";
    for(int i=0;i<diry;i++)S+="U";
    for(int i=0;i<dirx;i++)S+="R";
    for(int i=0;i<diry;i++)S+="D";
    for(int i=0;i<dirx;i++)S+="L";
    S+="L";
    for(int i=0;i<diry+1;i++)S+="U";
    for(int i=0;i<dirx+1;i++)S+="R";
    S+="D";S+="R";
    for(int i=0;i<diry+1;i++)S+="D";
    for(int i=0;i<dirx+1;i++)S+="L";
    S+="U";
    Console.WriteLine(S);
    
    
  }
}

Measured memory_bytes: 37076
#include <stdio.h>

int main(void)
{
	
	int a, b, c;
	int min, mi,m;
	
	scanf("%d %d %d", &a,&b,&c);
	
	if(a<= b)
	{
		if(c<=a)
		{
			min = c; mi = a; m = b;
		}
		else{
			min = a;
			if(b<= c)
			{
				mi = b; m = c;
			}
			else{
				mi = c; m = b;
			}
		}
	}
	else
	{
		if(c<=b)
		{
			min = c; mi = b; m = a;
		}
		else{
			min = b;
			if(a<=c)
			{
				mi = a; m = c;
			}
			else{
				mi = c; m = a;
			}
		}
	}
	printf("%d %d %d\n", min, mi, m);
	return 0;
}
			
	
	


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

using ll = long long;

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

ll lcm(ll a, ll b)
{
  ll g = gcd(a, b);
  return a / g * b;
}

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

  ll ans = 1LL;
  for (int i = 0; i < N; i++) {
    ll t;
    cin >> t;
    ans = lcm(ans, t);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using namespace std;
#include<string>
#include<cmath>
#include<list>
#include <map>
#include <unordered_map>
#include <set>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ml map<ll,ll>
#define pb push_back
#define mp make_pair
#define ppl pair<ll,ll>
#define F first
#define S second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 1e9 + 7;
#include<iterator>
#define EPSILON numeric_limits<double>::epsilon()





void solve() {
	ll n, sumsq = 0, sum = 0; cin >> n;
	ll a[n], sums[n - 1];
	fr(i, 0, n) {
		cin >> a[i];
		sum += (a[i] % N);
	}
	fr(i, 0, n - 1) {
		sums[i] = (sum - a[i]) % N;
		sum -= a[i];
	}
	fr(i, 0, n - 1) {
		sumsq += (sums[i] * a[i]) % N;
	}
	cout << sumsq % N;
}






int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif

	ll t;
	if (1)
		t = 1;
	else
		cin >> t;
	while (t--) {
		//cout << "Case #" << h << ": ";
		solve();
		//h++;
		cout << '\n';
	}
	return 0;
}






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

using namespace std;

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

    int q;
    cin>>q;

    map<string,int> mp;
    while(q--){
        int op;
        string s;
        cin>>op>>s;
        switch(op)
        {
            case 0:
                int x;
                cin>>x;
                mp[s]=x;
                break;
            case 1:
                 {auto ite=mp.find(s);
                 cout<<(ite==mp.end()?0:ite->second)<<endl;}
                 break;
            case 2:
                mp.erase(s);
                break;
            case 3:
                string l=s,r;
                cin>>r;
                for(auto i=mp.lower_bound(l),e=mp.upper_bound(r);i!=e;i++)
                {
                    cout<<i->first<<" "<<i->second<<endl;
                }
                break;
        }
    }

    return 0;
}





Measured memory_bytes: 25956
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    N=I()
    t=LI()
    v=LI()
    T=sum(t)*2+1#0.5秒刻み
    
    for i in range(N-1):
        t[i+1]+=t[i]
    t.append(0)#-1用
        
    vt=[1000]*T    
        
    #[l,r]の区間(秒)で上限がmvという条件の時，各時間での速度上限
    def set_v(l,r,mv):
        ll=2*l
        rr=2*r
        for i in range(T):
            if ll<=i and i<=rr:
                vt[i]=min(vt[i],mv)
            else:
                x=min(abs(i-ll),abs(i-rr))
                vv=mv+x/2
                vt[i]=min(vt[i],vv)
                
    for i in range(N):
        set_v(t[i-1],t[i],v[i])
    
    #両端
    set_v(0,0,0)
    set_v((T-1)//2,(T-1)//2,0)    
    
        
    ans=0
    for i in range(T-1):
        ans+=(vt[i]+vt[i+1])/4
        
    print(ans)
        

        
    
    
main()


"""

#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    t=LI()
    mv=LI()
    mv.append(0)
    
    
    
    #v0で始まってv1でおわる,最高vmまで出して良い,t廟の区間
    def calc(v0,v1,vm,t):
        vv = (t-abs(v1-v0))/2+max(v0,v1) #vmを気にしなければどこまで上がれるか
        
        if abs(v1-v0)==t:
            return (v0+v1)*t/2
        elif v1==vm or v0==vm:
            return (v1+v0)*abs(v1-v0)/2 +max(v1,v0)*(t-abs((v1-v0)))
        elif vv<vm:
            return (vv+v0)*(vv-v0)/2 + (vv+v1)*(vv-v1)/2
        else:
            return (v0+vm)*(vm-v0)/2 + vm*(t-(vm-v0)-(vm-v1)) + (vm+v1)*(vm-v1)/2 
         
         
    #区間端での速度,手前から決めていき，無理が生じたら手前を下げていく(Nが小さいので)
    v=[1000]*(N+1)
    v[0]=0
    v[-1]=0
    
    for i in range(N):
        v[i+1]=min(v[i]+t[i],mv[i],mv[i+1])
        if v[i]-v[i+1]>t[i]:#下げきれないなら
            j=i
            while v[j]-v[j+1]>t[j]:
                v[j]=v[j+1]+t[j]
                j-=1
                
                
    ans=0
    for i in range(N):
        ans+=calc(v[i],v[i+1],mv[i],t[i])
    print(ans)
 

main()


"""

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

int main() {
  int N;
  cin >> N ;
  vector<int> card(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    card.at(i) = a;
  }
  int alice = 0,bob = 0;
  for (int i = 0; i < N; i++) {
    int maxNum = 0;
    int maxNo;
    for (int j = 0; j < N; j++) {
      if (maxNum < card.at(j)) {
        maxNum = card.at(j);
        maxNo = j;
      }
      
    }
    if (i % 2 == 0) {
      alice += maxNum;
    } else {
      bob += maxNum;
    }
    card.at(maxNo) = 0;
  }
  //cout << "alice:" << alice << ", bob:" << bob << endl;
  cout << alice - bob << endl;
}


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

int main(void){
    int n, r;
    cin >> n >> r;
    
    if(n>=10) cout << r << endl;
    else cout << r + 100*(10-n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = -1;
    for(int c = 0; c <= 2 * max(X, Y); c += 2) {
        ll cost = C * c + A * max(0, (X - c / 2)) + B * max(0, (Y - c / 2));
        if(ans == -1) {
            ans = cost;
        } else {
            ans = min(ans, cost);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(1,n-1):
    if (a[i] < a[i-1] and a[i]>a[i+1]) or (a[i]> a[i-1]and a[i]< a[i+1]):
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			// input
			int h = in.nextInt();
			int w = in.nextInt();
			int d = in.nextInt();

			Point[] p = new Point[90001];
			Arrays.fill(p, new Point(-1, -1));
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					int a = in.nextInt();
					p[a] = new Point(i, j);
				}
			}
			int q = in.nextInt();
			int[] l = new int[q];
			int[] r = new int[q];
			for (int i = 0; i < q; i++) {
				l[i] = in.nextInt();
				r[i] = in.nextInt();
			}

			// solve
			int[] cs = new int[90001];
			for (int i = 1; i <= d; i++) {
				for (int j = i+d; j < 90001; j+=d) {
					cs[j] = cs[j-d] + move(p[j].x, p[j].y, p[j-d].x, p[j-d].y);
				}
			}
			for (int i = 0; i < q; i++) {
				out.println(cs[r[i]] - cs[l[i]]);
			}

		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class Point {
		int x;
		int y;
		Point (int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
	static int move (int x, int y, int i, int j) {
		int abs = 0;
		abs = Math.abs(x-i) + Math.abs(y-j);
		return abs;
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}
}


Measured memory_bytes: 47784
from functools import lru_cache

n = int(input())
@lru_cache(maxsize=None)
def func(n):
  if n < 6:
    return n
  a = []
  b = 6
  while(b<=n):
    a.append(b)
    b*=6
  b = 9
  while(b<=n):
    a.append(b)
    b*=9
  ret = n
  a.sort(reverse=True)
  for i in a:
    ret = min(ret,1+func(n-i))
  return ret
print(func(n))

Measured memory_bytes: 12028
s = list(input())
N = len(s)

for i in range(N - 1):
    if s[i] == s[i + 1]:
        print (i + 1, i + 2)
        exit()
for i in range(N - 2):
    if s[i] == s[i + 2]:
        print (i + 1, i + 3)
        exit()
print (-1, -1)

Measured memory_bytes: 3956
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node{int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
    if (u == NIL) return;
    D[u] = d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if (T[u].left != NIL){
        h1 = setHeight(T[u].left) + 1;
    }
    if (T[u].right != NIL){
        h2 = setHeight(T[u].right) + 1;
    }
    return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
    if (T[u].parent == NIL) return NIL;
    if (T[T[u].parent].left != u && T[T[u].parent].left != NIL)
        return T[T[u].parent].left;
    if (T[T[u].parent].right != u && T[T[u].parent].right != NIL)
        return T[T[u].parent].right;
    return NIL;
}

void print(int u){
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibling(u));
    int deg = 0;
    if (T[u].left != NIL) deg++;
    if (T[u].right != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);

    if (T[u].parent == NIL){
        printf("root\n");
    }else if (T[u].left == NIL && T[u].right == NIL){
        printf("leaf\n");
    }else{
        printf("internal node\n");
    }
}

int main(){
    int v, l, r, root=0;
    scanf("%d", &n);

    for (int i=0; i<n; i++) T[i].parent = NIL;

    for (int i=0; i<n; i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if (l != NIL) T[l].parent = v;
        if (r != NIL) T[r].parent = v;
    }
    
    for (int i=0; i<n; i++){
        if (T[i].parent == NIL){
            root = i;
        }
    }

    setDepth(root, 0);
    setHeight(root);

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

    return 0;
    
}

Measured memory_bytes: 1048
#include<cstdio>

int main(void){
    int n;
    int a[200];
    int result = 0;

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

    while(true){
        for(int i = 0; i < n; i++){
            if(a[i] % 2 == 0){
                a[i] /= 2;
            }else{
                goto exitloop;
            }
        }
        result++;
    }
    exitloop:

    printf("%d\n", result);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  size_t n, m;
  cin >> n >> m;

  set<size_t> a, b;
  for(size_t u, v; m; --m)
  {
    cin >> u >> v;
    -- u; --v;
    if(v == 0 || v == n - 1) swap(u, v);
    if(u == 0)
    {
      if(b.count(v))
      {
        cout << "POSSIBLE";
        return 0;
      }
      a.insert(v);
    }
    else if (u == n - 1)
    {
      if(a.count(v))
      {
        cout << "POSSIBLE";
        return 0;
      }
      b.insert(v);
    }
  }

  cout << "IMPOSSIBLE";
  return EXIT_SUCCESS;
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        
        while (true) {
            int h = scanner.nextInt();
            int w = scanner.nextInt();
            
            if (h==0 && w==0) {
                break;
            }
            
            for (int i=0; i<h; i++) {
                for (int j=0; j<w; j++) {
                    if ( 0 < i && i < (h-1) && 0 < j && j < (w-1) ) {
                        sb.append(".");
                    } else {
                        sb.append("#");
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
            
        }
        System.out.print(sb);
        
    }
    
}


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

int main(){
	string s;
	cin >> s;
	for(int i = (int)s.size() - 2; i >= 0; i -= 2) {
		int n = i / 2;
		bool flag = true;
		for(int j = 0; j < n; j++) {
			if(s[j] != s[j + n]) {
				flag = false;
				break;
			}
		}
		if(flag) {
			printf("%d\n", i);
			break;
		}
	}
}


Measured memory_bytes: 256
using System;
namespace ITP1_5_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string[] S = Console.ReadLine().Split();
                int H = int.Parse(S[0]);
                int W = int.Parse(S[1]);
                int i;
                int j;
                if(H == 0 && W == 0)
                {
                    break;
                }
                for(i = 0; i < H; i++)
                {
                    for(j = 0; j < W; j++)
                    {
                        if(j == 0 || j == W - 1 || i == 0 || i == H - 1)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}


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

using namespace std;

int main()
{
    int n,m,c,a[10000],b[10000],i,s,k=0;;
    cin>>n>>m>>c;
    for(i=0; i<m; i++)
    {
        cin>>b[i];
    }
    while(n--)
    {
            s=0;
        for(i=0; i<m; i++)
        {
            cin>>a[i];
            s=s+a[i]*b[i];
        }
        s=s+c;
        if(s>0)
                k++;
    }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import heapq

array_pqr = list(map(int,input().split()))

if not ( 1 <= array_pqr[0] <= 100 and 1 <= array_pqr[1] <= 100 and 1 <= array_pqr[2] <= 100 ): sys.exit()

print(sum(heapq.nsmallest(2,array_pqr)))

Measured memory_bytes: 8944
#bがaの末尾にあうかチェック
def check(a, b):
    a = list(a)
    b = list(b)
    while b and a[-len(b):] != b:
        b.pop(-1)
    return len(b)
N = int(input())
A = input()
B = input()
print(N*2-check(A, B))

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    int A, B, C;
    cin >> A >> B >> C;

    int flg = 0;
    if(A == B){
        flg++;
    }
    if(B == C){
        flg++;
    }
    if(C == A){
        flg++;
    }

    if(flg != 1){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as C
import Data.List

main = do
    [n,k] <- unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine
    h <- U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

    let dp = U.constructN n (\dp_ ->
            if U.null dp_ then 0
                else let !i = U.length dp_
                         !hi = h U.! i
                         f = U.slice (max 0 (i-k)) (min i k)
                         !refh = f h
                         !refd = f dp_
                    in U.minimum (
                        U.zipWith (\dc hc -> dc + abs(hi - hc)) refd refh
                        )
            )

    print $ U.last dp

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  int ans = 0;
  if (m1 + 1 == m2) {
    if (m1 == 2) {
      if (d1 == 28 && d2 == 1) {
        ans = 1;
      }
    } else if (m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11) {
      if (d1 == 30 && d2 == 1) {
        ans = 1;
      }
    } else {
      if (d1 == 31 && d2 == 1) {
        ans = 1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;

const ll MAX_N=131072;

int bit[MAX_N*2-1];
ll n;
vector<int> G[1000010];
vector<vector<int>> used(1000010,vector<int>(3,0));
int main(){
  int N,K;cin>>N>>K;
  if (((N-1)*(N-2))/2<K){
    cout<<-1<<endl;
    return 0;
  }
  int k=((N-1)*(N-2))/2-K;
  cout<<N-1+k<<endl;
  rep(i,N-1) cout<<1<<" "<<i+2<<endl;
  for(int i=2;i<=N;++i){
    for(int j=i+1;j<=N;++j){
      if (k==0) return 0;
      k-=1;
      cout<<i<<" "<<j<<endl;
    }
  }
}


Measured memory_bytes: 78464
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

int main() {
    int N;
    cin >> N;
    bool ok = true;
    int low = -1;
    int high = -1;
    cin >> low;
    int lownum = 1;
    int highnum = 0;
    for (int i = 1; i < N; i++) {
        int num;
        cin >> num;
        if (num == low) {
            lownum++;
        } else {
            if (num == low + 1) {
                high = low + 1;
                highnum++;
            } else if (num == low - 1) {
                if (high == -1) {
                    high = low;
                    highnum = lownum;
                    low = low - 1;
                    lownum = 1;
                } else {
                    ok = false;
                    break;
                }
            } else {
                ok = false;
                break;
            }
        }
    }
    if (ok) {
        if (high == -1) {
            if (low != N - 1 && low > N / 2) {
                ok = false;
            }
        } else {
            int colorlow = lownum + 1;
            int colorhigh = lownum + (highnum / 2);
            if (high < colorlow || high > colorhigh) {
                ok = false;
            }
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
from collections import defaultdict as ddic, Counter, deque
import heapq, bisect, itertools
MOD = 10 ** 9 + 7

def solve(N, A):
    from fractions import gcd
    g  = A[0]
    for x in A:
        g=  gcd(g,x)
    if g > 1:
        return "not coprime"

    seen = set()
    for x in A:
        saw = set()
        while x % 2 == 0:
            x //= 2
            saw.add(2)
        d = 3
        while d*d <= x:
            while x%d == 0:
                saw.add(d)
                x //= d
            d += 2
        if x > 1:
            saw.add(x)

        for p in saw:
            if p in seen:
                return "setwise coprime"
        seen |= saw

    return "pairwise coprime"

N= rri()
A = rrm()

print solve(N, A)


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

int main(int argc, char const *argv[])
{
	std::string text;
	std::string word;
	std::cin >> word;
	//convert query word to lower case
	std::string temp;
	for(char c : word){
		if((int)c >= (int)'a'){
			temp.push_back(c);
		}else{
			temp.push_back((char)((int)c-(int)'A'+(int)'a'));
		}
	}
	word = temp;
	temp.clear();
	int count = 0;
	while(std::cin >> text){
		if(text.compare("END_OF_TEXT") == 0){
			break;
		}
		temp.clear();
		for(char c : text){
			if((int)c >= (int)'a'){
				temp.push_back(c);
			}else{
				temp.push_back((char)((int)c - (int)'A' + (int)'a'));
			}
		}
		text = temp;
	if(text.compare(word) == 0){
			count ++;
		}
	}
	std::cout << count << std::endl;
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
const int P = 1e9 + 7;
int dp[3005][3005][2];

int main() {
  if(fopen("input.txt","r")) {
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  }

  int N, M; scanf("%d%d", &N, &M);
  for(int i = 1;i <= N; ++i)
    dp[0][i][0] = 1;
  dp[0][0][1] = 1;
  for(int i = 0;i < M; ++i) {
    for(int j = 0;j <= N; ++j) {
      for(int k = 0;k < 2; ++k) {
	if(!dp[i][j][k]) continue;
	if(j) {
	  (dp[i+1][j-1][k|(j==1)] += dp[i][j][k]) %= P;
	  (dp[i+1][j][k|(j==1)] += dp[i][j][k]) %= P;
	}
	if(N-j) {
	  (dp[i+1][j+1][k] += dp[i][j][k]) %= P;
	  (dp[i+1][j][k] += dp[i][j][k]) %= P;
	}
      }
    }
  }

  int ans = 0;
  for(int i = 0;i <= N; ++i)
    (ans += dp[M][i][1]) %= P;
  printf("%d", ans);
  
  return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
using namespace std;

int main(void)
{
    long long int a,b,ans;
    cin>>a>>b;
    ans=a*b;

    if(a==1 || b == 1)
    {
        cout << 1;
        return 0;
    }

    if(ans & 1)
        cout << (ans+1)/2;
    else
        cout<<ans/2;
    return 0;
}

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

using namespace std;

long N;
int C;

int main() {
#ifdef __APPLE__
    freopen("input0.txt", "r", stdin);
#endif
    cin >> N >> C;

//    long s[100000] = {0};
//    long t[100000] = {0};
//    long c[100000] = {0};
    vector<long> s;
    vector<long> t;
    vector<long> c;

    long si, ti, ci;

    for (int i = 0; i < N; ++i) {
        cin >> si >> ti >> ci;
        s.push_back(si);
        t.push_back(ti);
        c.push_back(ci);
    }



    vector<vector<int>> channel_record((unsigned long)C+1);
    for (int i = 0; i < C+1; ++i) {
        channel_record[i].resize(100001);
    }

    for (int i = 0; i < N; ++i) {
        ++channel_record[c[i]][s[i]];
        --channel_record[c[i]][t[i]];
    }

    int max_required_machines = 0;
    int required_machines = 0;
    for (int time = 0; time < 100001; ++time) {
        for (int channel = 1; channel < C+1; ++channel) {
            if (channel_record[channel][time] == 1) ++required_machines;
        }
        max_required_machines = max(max_required_machines, required_machines);
        for (int channel = 1; channel < C+1; ++channel) {
            if (channel_record[channel][time] == -1) --required_machines;
        }
    }
    cout << max_required_machines << endl;

    return 0;
}

Measured memory_bytes: 14688
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes";
    else cout<<"No";
}

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

int main() {
    ll h;
    int count=0;
    ll ans=1;
    
    cin >> h;
    
    while(h > 0){
        h = h/2;
        count++;
    }
    
    rep(i, count){
        ans *= 2;
    }
    
    cout << ans-1 << endl;
    
    return 0;
}




Measured memory_bytes: 256
N,Q=map(int,input().split())
A=[int(i) for i in input().split()]
X=[int(input()) for i in range(Q)]
if N%2==0:
    ta=N//2
    ao=N//2
else:
    ta=N//2+1
    ao=N//2
L=[0]*(N+1)
M0=[0]*(ta+1)#0,2,4,6...acucsum
M1=[0]*(ao+1)#1,3,5,...accsum
for i in range(N):
    L[i+1]=L[i]+A[i]
for i in range(ta):
    M0[i+1]=M0[i]+A[i*2]
for i in range(ao):
    M1[i+1]=M1[i]+A[i*2+1]

def shin(z):
    ma=N-1
    mi=0
    while ma-mi>1:
        mid=(ma+mi)//2
        if check(mid,z):
            ma=mid
        else:
            mi=mid
    #print(ma)


    nowta = ma
    get = N - 1 - ma + 1  # takahashigets
    ans = 0
    if get == ta:
        ans = L[N] - L[nowta]
    else:
        ans = L[N] - L[nowta]
        nowao = nowta - get - 1
        if nowao % 2 == 1:
            ans += M1[nowao // 2 + 1]

        else:
            ans += M0[nowao // 2 + 1]
    print(ans)

def check(x,z):
    p=(N-1)-x+1
    #print(p)
    if x-p+1<0:
        return False
    if abs(z-A[x-p+1])<=abs(z-A[x]):
        return True
    else:
        return False
for x in X:
    shin(x)



Measured memory_bytes: 81516
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

const ll MOD=1e9+7;
int main(){
    int n;
    ll k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    ll x=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            if(a[j]>a[i]) x++;
        }
    }
    ll piyo=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            if(a[i]!=a[j]) piyo++;
        }
    }
    ll res=piyo%MOD*(k*(k-1)/2%MOD)%MOD;
    res+=x*k%MOD;
    res%=MOD;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
// Aizu Vol-1 0183: Black-and-White
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char *gets(char *);
char buf[100], *p;

int main()
{
	int r, c, d;
	int tab[3][3];

	while (1) {
		for (r = 0; r < 3; r++) {
			gets(p = buf);
			while (isspace(*p)) p++;
			if (*p == '0') return 0;
			for (c = 0; c < 3; c++) {
				if (*p == 'b') d = 1;
				else if (*p == 'w') d = -1;
				else d = 0;
				tab[r][c] = d;
				p++;
			}
		}
		for (r = 0; r < 3; r++) {
			d = 0;
			for (c = 0; c < 3; c++) d += tab[r][c];
			if (d == 3 || d == -3) goto END;
		}
		for (c = 0; c < 3; c++) {
			d = 0;
			for (r = 0; r < 3; r++) d += tab[r][c];
			if (d == 3 || d == -3) goto END;
		}
		d = tab[0][0] + tab[1][1] + tab[2][2];
		if (d == 3 || d == -3) goto END;
		d = tab[0][2] + tab[1][1] + tab[2][0];

END: 	if (d == 3) putchar('b');
		else if (d == -3) putchar('w');
		else putchar('N'), putchar('A');
		putchar('\n');
	}
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    
    for(int i=0;i<n;i++) cin >> a[i];
    
    int max_num = 0;
    ll count=0;
    for(int i=0;i<n;i++){
        max_num = max(max_num , a[i]);
        ll temp = max_num;
        count += abs(temp-a[i]);
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3976
package main
import (
    "fmt"
)

func main(){
  var N int
  fmt.Scan(&N)
  var L []int
  var temp int
  var maxL = 0
  var maxi = 0
  for i:=0;i<N;i++{
    fmt.Scan(&temp)
    if maxL < temp{
      maxL = temp
      maxi = i
    }
    L = append(L,temp)
  }
  var sum=0
  for i:=0;i<N;i++{
    if i == maxi {
      continue;
    }
    sum += L[i]
  }

  if sum > maxL{
    fmt.Println("Yes")
  }else{
    fmt.Println("No")
  }

}


Measured memory_bytes: 512
N = int(input())
S = input()

l = 0
r = S.count("E", 1, len(S))
ans = l + r
for i in range(1, len(S)):
    if S[i] == "E":
        r -= 1
    if S[i - 1] == "W":
        l += 1

    ans = ans if ans <= l + r else l + r

print(ans)

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;
}


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

using namespace std;
typedef long long ll;

ll a[3];
int main(){
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+2);
    if (a[0] %2==0 || a[1] % 2==0 || a[2] % 2==0) {
                cout << 0 << endl;
    } else {

        cout << min(a[0]*a[1],min(a[1]*a[2],a[0]*a[2])) << endl;
    }
}


Measured memory_bytes: 256
import io.StdIn.readLine


object Main {
  def main(args: Array[String]): Unit = {
    val n = readLine().toInt
    val s = readLine()
    val t = readLine()

    for (i <- (0 to n).reverse) {
      if (s.slice(n - i, n) == t.slice(0, i)) {
        println(2 * n - i)
        return
      }
    }
  }
}


Measured memory_bytes: 21428
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <unordered_map>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=r-1;i>=(int)(l);--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using ll=long long;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
//int read(){int a;scanf("%lld",&a);return a;}

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int inf = TEN(18)*3 + 10;
const int mod = TEN(9) + 7;

int N, M, L;

int E[303][303];
int d1[303][303];
int d2[303][303];

signed main()
{
	cin >> N >> M >> L;

	rep(i, N) rep(j, N) {
		d1[i][j]=i==j?0:inf;
		d2[i][j]=i==j?0:inf;
	}

	rep(i, M) {
		int a,b,c;
		cin>>a>>b>>c;
		--a,--b;
		d1[a][b] = d1[b][a] = c;
	}

	rep(k,N)rep(i,N)rep(j,N) {
		chmin(d1[i][j], d1[i][k] + d1[k][j]);
	}

	rep(i, N) rep(j, i) {
		if (d1[i][j] <= L) {
			d2[i][j] = d2[j][i] = 1;
		}
	}

	rep(k, N) rep(i, N) rep(j, N) {
		chmin(d2[i][j], d2[i][k] + d2[k][j]);
	}

	int q; cin >> q;
	rep(_, q) {
		int s, t; cin >> s >> t;
		--s, --t;
		if (d2[s][t] == inf) puts("-1");
		else printf("%lld\n", d2[s][t] - 1);
	}
}


Measured memory_bytes: 1920
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()

machines = []

for i in range(N):
    X,L=two_int()
    minL=max(1,X-L)
    maxL=X+L
    machines.append([X,L, minL, maxL])



machines = sorted(machines,key=lambda x:x[3])

output=[[0,0,0,0]]
for m in machines:
    if output[-1][3] <= m[2]:
        output.append(m)

print(len(output)-1)

Measured memory_bytes: 29984
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn get_vec_by_lines<T : FromStr>(n : usize) -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for _i in 0..n {
        let x : T = get_one();
        v.push(x);
    }
    return v;
}

fn main() {
    let n : usize = get_one();
    let mut fs = Vec::new();
    for _i in 0..n {
        let v : Vec<i32> = get_vec();
        fs.push(v);
    }
    let mut ps = Vec::new();
    for _i in 0..n {
        let v : Vec<i32> = get_vec();
        ps.push(v);
    }
    let mut ans = -1 * 100 * 10_i32.pow(7) - 500;
    for i in 1..1024 {
        let mut src = i;
        let mut bits = vec!(0;10);
        for j in 0..10 {
            bits[j] = src & 1;
            src = src >> 1;
        }
        let mut score = 0;
        for j in 0..n {
            let mut open = 0;
            for k in 0..10 {
                if bits[k] == 1 && fs[j][k] == 1 {
                    open += 1;
                }
            }
            score += ps[j][open];
        }
        ans = std::cmp::max(ans, score);
    }
    println!("{}", ans);
}


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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,int>>
#define pb push_back
#define mod 1000000007
using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

ll dp[3005][3005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    ll a[n];
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = n; i > 0; i--) {
        for (int j = i; j <= n; j++) {
            if (i == j) dp[i][j] = a[i];
            else dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
        }
    }
    cout << dp[1][n] << " ";
    return 0;
}


ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

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


Measured memory_bytes: 70016
Q, H, S, D = map(int, input().split())
N = int(input()) * 4
L = [[8*Q, 1, Q], [4*H, 2, H], [2*S, 4, S], [D, 8, D]]
L.sort()
ans = 0
for l in L:
  s, t = N // l[1], N % l[1]
  ans += s * l[2]
  N = t
print(ans)

Measured memory_bytes: 9064
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main() {
 map<char, int> data;
 for(auto c = 'a'; c <= 'z'; c++) {
    data[c] = 0;
 }
 string str;
 while(cin >> str) { 
  for(string::iterator it = str.begin(); str.end() != it; ++it) {
    char c = *it;
    if(c >= 'A' && c <= 'Z') {
      c = (char)(c + 32);
      data[c] += 1;
    } else if (c >= 'a' && c <= 'z') {
      data[c] += 1;
    }
  }
 }
 for(auto it = data.begin(); it != data.end(); ++it ){ 
  cout << it->first << " : " << it->second << endl;
  }

}

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

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(Q);
  for(int i=0; i<Q; i++){
    cin >> A.at(i);
  }

  vector<int> score(N, K);
  for(int a : A){
    score.at(a - 1)++;
  }
  
  for(int &s : score){
    s -= Q;
  }

  for(int s : score){
    if(s > 0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1408
import java.util.Scanner;
public class Main {
private static Scanner s = new Scanner(System.in);
private static int n = s.nextInt();
static int a,b;
static int[] m = new int[8];
static boolean[] col = new boolean[8];
static boolean[] dpos = new boolean[2*8-1];
static boolean[] dneg = new boolean[2*8-1];
public static void main(String[] args) {
	for(int i = 0;i < 8;i++) {
		m[i] = -1;
	}
	for(int i = 0;i < n;i++) {
		a = s.nextInt();
		b = s.nextInt();
		m[a] = b;
		col[b] = dpos[a+b]  = dneg[a - b + 7] = true;
	}
	putQ(0);
}


static void putQ(int i) {
	if(i == 8) {
		print();
		return;
	}

	if(m[i] != -1) putQ(i+1);
	for(int j = 0;j < 8;j++) {
		if(m[i] != -1 || col[j] || dpos[i+j] || dneg[i - j + 7]) continue;

		m[i] = j;
		col[j] = dpos[i+j] = dneg[i - j + 7] = true;
		putQ(i+1);
		m[i] = -1;
		col[j] = dpos[i+j] = dneg[i - j + 7] = false;
	}
}
static void print(){
	for(int i = 0; i < 8;i++) {
		for(int j = 0;j < 8;j++) {
			if(m[i] == j) {
				System.out.print("Q");
			}else {
				System.out.print(".");
			}
		}
		System.out.println();
	}
}
}


Measured memory_bytes: 26316
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;

static const long long MOD = 1000000007;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

void solve(long long S) {
	vector<modll> dp(S + 1, 0);
	for (LL j = 3; j <= S; ++j) {
		dp[j] = 1;
	}
	modll ans = dp[S];
	for (LL i = 1; i <= S / 3; ++i) {
		vector<modll> next(S + 1, 0);
		for (LL j = 3; j <= S - 3; ++j) {
			for (LL k = 3; j + k <= S; ++k) {
				next[j + k] += dp[k];
			}
		}
		dp = next;
		ans += next[S];
	}
	cout << ans << endl;
}

int main() {
    long long S;
	std::cin >> S;
	solve(S);
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        double n;
        cin>>n;
        double ans=(n*2)*3.14159;
        cout<<ans;
    }
}



Measured memory_bytes: 3800
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int N, A;
	cin >> N >> A;
	if (N % 500 <= A) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256