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

using namespace std;

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

    int n;
    cin >> n;
    for (int a = 1; a <= 9; ++a) {
        for (int b = 1; b <= 9; ++b) {
            if (a * b == n) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>

using namespace std;


int main() {

	int n;
	cin >> n;

	int d[101];

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

	int bucket[101] = { 0 };

	for (int i = 0; i < n; i++) {
		bucket[d[i]]++;
	}
	
	int ans = 0;

	for (int i = 1; i <= 100; i++) {
		if (bucket[i]) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

  int w=0, h=0, x=0, y=0;

  cin >> w >> h >> x >> y;

  int ans=0;
  if((w == (2*x)) && (h == (2*y))){
    ans = 1;
  }

  printf("%lf %d\n", double(w)*double(h)/2, ans);
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

#+++++
		
def main():
	s = input()
	aa = lambda c : 1 if c == 'o' else 0
	ret = sum([aa(c) for c in s])*100+700
	
	print(ret)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3060
object Main extends App{
  import scala.io.StdIn._
  val Array(n,m) = readLine().split(" ").map(_.toLong)
  var Array(l,r) = readLine().split(" ").map(_.toLong)
  var flag = true
  for (i <- 1L until(m)){
    val Array(ll,rr) = readLine().split(" ").map(_.toLong)
    if(flag){
      if(l <= ll && r >= ll || ll <= l && rr >= l) {
      l = Math.max(l,ll)
      r = Math.min(r,rr)
      }else {
        flag = false
      }
    }
  }
  println(if(flag)r - l + 1 else 0)
}

Measured memory_bytes: 58084
#include<bits/stdc++.h>
using namespace std;
long long int steps(long long int a,long long int b)
{
  return a-1 + b-1;
}
int main()
{
 long long int n,ans=(long int)1e18;
  cin>>n;
  for(long long int i=1;i*i<=n;i++)
    if(n%i==0)
      ans = min(steps(n/i,i),ans);
  
  cout<<ans<<"\n";
  
 return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int[] Num = new int[11];
		Scanner n=new Scanner(System.in);
			for (int i = 0; i < 10;i++){
				Num[i]=n.nextInt();
		}
			for (int a=9;a>=0;a--){
				for (int b=0;b<a;b++){
						if (Num[b]<Num[b+1]){
						Num[10]=Num[b];
						Num[b]=Num[b+1];
						Num[b+1]=Num[10];
						}
				}
				}
		System.out.println(Num[0]);
		System.out.println(Num[1]);
		System.out.println(Num[2]);
	}	
}

Measured memory_bytes: 17168
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define inf 1<<29
#define MAX 101
using namespace std;

int a,b,h,w,t,s,p,P[12];
string dungeon[MAX];
int grid[MAX][MAX];
pair<char,int> S[1001];
int Steps[1001];
int dp[1001][(1<<12)];
int X[4]={0,1,0,-1};
int Y[4]={-1,0,1,0};

int f(char c){
  if(c=='U')return 0;
  if(c=='R')return 1;
  if(c=='D')return 2;
  return 3;
}

int main()
{
  while(1){
    cin>>a>>b;
    if(a+b==0)break;
    cin>>h>>w;
    for(int i=0;i<h;i++){
      cin>>dungeon[i];
    }
    cin>>t;
    map<char,int> T;
    for(int i=0;i<t;i++){
      char t1;
      int t2;
      cin>>t1>>t2;
      T[t1]=t2;
    }
    cin>>s;
    for(int i=0;i<s;i++)cin>>S[i].f>>S[i].s;
    cin>>p;
    for(int i=0;i<p;i++)cin>>P[i];

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)grid[i][j]=T[dungeon[i][j]];
    }
    int ni=0,nj=0,c=0;
    Steps[c++]=0;
    for(int i=0;i<s;i++){
      int muki=f(S[i].f);
      for(int j=0;j<S[i].s;j++){
	ni+=Y[muki];
	nj+=X[muki];
	Steps[c++]=grid[ni][nj];
      }
    }
    for(int i=0;i<c;i++){
      for(int j=0;j<(1<<p);j++)dp[i][j]=0;
    }
    for(int i=0;i<(1<<p);i++)dp[0][i]=a;
    for(int step=1;step<c;step++){
      for(int i=0;i<(1<<p);i++){
	if(dp[step-1][i]==0)continue;
	for(int j=0;j<p;j++){
	  if((i>>j)%2==0)continue;
	  int nhp=min(dp[step-1][i]+P[j],b);
	  dp[step][i-(1<<j)]=max(dp[step][i-(1<<j)],
				 max(0,nhp-Steps[step]));
	}
	dp[step][i]=max(dp[step][i],dp[step-1][i]-Steps[step]);
      }
    }
    bool flag=false;
    for(int i=0;i<(1<<p);i++){
      if(0<dp[c-1][i])flag=true;
    }
    if(flag)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 17288
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>
#define SIZE 100005
#define MOD 1000000007

using namespace std;

class A500YenCoins {
public:
    static void solve(std::istream& cin, std::ostream& cout) {
        int64_t k, x;
        cin >> k >> x;
        if (500*k >= x ){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
};


int main() {
    A500YenCoins solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int s,t,n,ans=0;
    cin>>n;
    vector<long long int> av,bv;
    for(int i=0;i<n;i++){
        cin>>s>>t;
        av.push_back(s);
        bv.push_back(t);
    }
    for(int i=n-1;i>=0;i--){
            ans+=(bv[i]-(av[i]+ans)%bv[i])%(bv[i]);
    }
    cout<<ans<<endl;
    
}


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

int main() 
{
    set<string> s;
    int n; 
    char ord[10], moji[15];
    scanf("%d", &n);
    while (n--)
    {
        scanf("%s %s", ord, moji);
        if (ord[0] == 'i') s.insert(moji);
        else printf(s.find(moji) != s.end() ? "yes\n" : "no\n");
    }
}


Measured memory_bytes: 29120
import sys
import datetime

def main():
    ans = 0.0

    _ = sys.stdin.readline()
    for line in sys.stdin:
        line = line.rstrip()
        lst = line.split()

        x = float(lst[0])
        u = lst[1]

        if u == 'JPY':
            ans += x
        elif u == 'BTC':
            ans += x * 380000.0
        else:
            pass

    print(ans)

    return 0

if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 3440
#include <stdio.h>

int main(){
  int n, m, p[1001], i, j, max, sum;
  while(scanf("%d%d", &n, &m) && n && m){
    for(i = 0; i < n; ++i) scanf("%d", p + i);
    for(i = 0; i < n; ++i){
      max = i;
      for(j = i + 1; j < n; ++j)
        if(p[max] < p[j]) max = j;
      if(max != i)
        p[max] += p[i], p[i] = p[max] - p[i], p[max] -= p[i];
    }
    sum = 0;
    for(i = 0; i < n; ++i)
      if((i + 1) % m != 0)
        sum += p[i];
    printf("%d\n", sum);
  }
  return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
int32_t main(){
    
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    while(b <= a){
    	// cout << a  << " " << b << endl;
    	k--;
    	b = b*2;
    }
    while(c <= b){
    	// cout << c  << " " << b << endl;
    	k--;
    	// cout << "kkk" << k << endl;
    	c = c * 2;
    }
    if(k < 0){
    	cout << "No" << endl;
    } else {
    	cout << "Yes" << endl;
    }
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
	unsigned long int R, G, B, N, count = 0, startR, startG, startB;

    cin >> R >> G >> B >> N;
    
    startR = N / R;
    
    for(int i = startR ; i >= 0 ; i--){
        int startG = (N - R * i) / G;
        for(int j = startG ; j >= 0 ; j --){
            int startB = (N - R * i - G * j) / B;
            for(int k = startB ; k >= 0 ; k--){
                if((N - R * i - G * j - B * k) == 0){
                    count++;
                    break;
                }
            }
        }
    }
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
  	string ans="Impossible";
  	if(a%3==0||b%3==0||(a+b)%3==0) ans="Possible";
  	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import random
import copy
import time
def evaluateSatisfaction(d, c, s, ans):
    score = 0
    last = [-1 for i in range(26)]
        
    for i in range(d):
        
        score += s[i][ans[i]]
        last[ans[i]] = i
        for j in range(26):
            if j != ans[i] or True:
                score -= c[j]*(i - last[j])
    return score
    
def valuationFunction(d,c,s,contestType,day,last):
    las = copy.copy(last)
    las[contestType] = day
    gain = s[day][contestType]
    lost = 0
    for i in range(10):
        for j in range(26):
            lost += c[j]*(i - las[j])
    return gain - lost

def Input():
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for i in range(d)]
    #s[3][25] =   contest(25+1) of day(3+1)
    return d, c, s

def evolution(d, c, s, ans):
    score_before = evaluateSatisfaction(d, c, s, ans)
    ans_after = copy.copy(ans)
    x = random.randint(0,(d-1)-6)
    idx1 = x
    idx2 = x+random.randint(1,5)
    
    tmp = ans_after[idx1]
    ans_after[idx1] = ans_after[idx2]
    ans_after[idx2] = tmp

    score_after = evaluateSatisfaction(d,c,s,ans_after)

    if score_after > score_before:
        return ans_after
    else:
        return ans

if __name__ == "__main__":
    
    d, c, s = Input()
    
    #print("val =", evaluateSatisfaction(d, c, s, [1, 17, 13, 14, 13]))

    #calc start
    t1 = time.time()
    ans = [0 for i in range(d)]
    last = [-1 for i in range(26)]
    for i in range(d):
        evalValueList = [0 for j in range(26)]
        for j in range(26):
            evalValueList[j] = valuationFunction(d, c, s, j,i,last)

        max_idx = 0
        max = evalValueList[0]

        for j in range(26):
            if (max < evalValueList[j]):
                max_idx = j
                max = evalValueList[j]
        
        ans[i] = max_idx
        last[ans[i]] = i


    
    #ans = [1, 2, 3, 4, 5]
    t2 = time.time()
    while(float(t2-t1) < 1.8):
        ans = evolution(d, c, s, ans)
        #print("ans = ",evaluateSatisfaction(d,c,s,ans))
        t2 = time.time()
    for x in ans:
        print(x + 1)
    #print(evaluateSatisfaction(d,c,s,ans))

Measured memory_bytes: 9884
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

	ll l,r;	
	cin>>l>>r;

	if(r-l>2019)
	{
		cout<<0<<endl;
		return 0;
	}

	ll res=3000;
	for(ll i=l;i<r;i++)
		for(ll j=i+1;j<=r;j++)
			res=min(res,i*j%2019);

	cout<<res<<endl;

	return 0;
}

Measured memory_bytes: 256
s = input()
k = int(input())

flag = True
for i in range(len(s) - 1):
    if s[i] != s[i + 1]:
        flag = False
        break
if flag == True:
    print(len(s) * k // 2)
else:
    seq = []
    num = 1
    for i in range(len(s) - 1):
        if s[i] == s[i + 1]:
            num += 1
        else:
            seq.append(num)
            num = 1
    seq.append(num)
    count = 0
    if s[len(s) - 1] == s[0]:
        for i in range(len(seq) - 2):
            count += ((seq[i + 1] // 2) * k)
        count += (((seq[0] + seq[len(seq) - 1]) // 2) * (k - 1))
        count += (seq[0] // 2)
        count += (seq[len(seq) - 1] // 2)
    else:
        for i in seq:
            count += (i // 2) * k
    print(count)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

 
int main(){
    int n, m, k;
    cin >> n >> m >> k;
    bool f = false;

    //ヨコにi行、縦にj行塗った場合を考える
    rep(i,n+1){
        rep(j, m+1){
            int black = i * m + j * ((n-i) - i);
            if(black == k){
                f = true;
                break;
            }
        }
    }
    if(f) cout << "Yes" << ln;
    else cout << "No" << ln;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int>h(n);
  rep(i,n) cin >> h[i];
  vector<bool>seen(n,false);
  vector<vector<int>>data(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    if(h[a] < h[b]){
      seen[a] = true;
    }
    else if(h[a] > h[b]){
      seen[b] = true;
    }
    else{
      seen[a] = true;
      seen[b] = true;
    }
  }
  int ans = 0;
  rep(i,n){
    if(!seen[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5896
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		execute5_1();
	}
	
	private static void execute5_1() {
		try (Scanner sc = new Scanner(System.in)) {
			long H = sc.nextLong();
			
			long pw=0;
			long ans = 1;
			while(H>1) {
				pw++;
				ans += (long) (Math.pow(2, pw));
				H=H/2;
			}
		
		
		System.out.println(ans);
		}
		
	}
}

Measured memory_bytes: 22736
#!/usr/bin/env python3
n = int(input())
c = [0] * (n + 1)
for i in range(1, n + 1):
    for j in range(1, n // i + 1):
        c[j * i] += 1
print(sum(c[i] == 8 for i in range(1, n + 1, 2)))


Measured memory_bytes: 64060
def main():
    n = int(input())
    abc = [list(map(int,input().split())) for i in range(n)]

    dp = [[0] * 3 for _ in range(n)]

    dp[0][0] = abc[0][0]
    dp[0][1] = abc[0][1]
    dp[0][2] = abc[0][2]

    for i in range(n-1):
        today = dp[i]
        tomorrow = abc[i+1]
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                dp[i+1][j] = max(dp[i+1][j], today[k] + tomorrow[j])

    print(max(dp[n-1]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 74328
while True :
    n, x = map(int, input().split())
    if n == x == 0 :
        break
    ans = 0
    for i in range(1, n - 1) :
        for j in range(i + 1, n) :
            if j < x - i - j <= n :
                ans += 1
    print(ans)


Measured memory_bytes: 5596
#テストファイルで実行する時
import sys
if sys.platform =='ios':
	sys.stdin=open('input_file.txt')
	
n = int(input())
l=[list(map(int,input().split())) for i in range(2)]

maxl = 0

for i in range(n):
	a = sum(l[0][:i+1]) + sum(l[1][i:])
	if a > maxl:
		maxl = a

print(maxl)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int t;
	int b;
  cin>>t>>b;
  if(t==1 or b==1){
   cout<<1;
    exit(0);
  }
  int val = t*b;
  if(val&1==1){
    cout<<((val/2)+1);
  }else{
    cout<<val/2;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ar              array
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("ip1.txt", "r", stdin);
	freopen("op1.txt", "w", stdout);
#endif
}
bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b);
int gcd(int a, int b) ;
int prime(int n);
int power(int x, int y);
int lcm(int a, int b);
int32_t main()
{
	k_007();
	char c;
	cin >> c;
	int ans = c + 1;

	cout << (char)ans << endl;

}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int prime(int n) {
	int flag = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {flag = 0; break;}
	}
	return flag;
}
int power(int x, int y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
	else
		return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

Measured memory_bytes: 3536
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
typedef long long LL;
#define MAX 105

using namespace std;

int p[MAX];

int find_num(int m)
{
	for(int i = 0;i < MAX;i++)
	{
		if(p[i] == m)
			return 1;
	}
	return 0;
}

int main()
{
	int x,n;
	int a,b;
	cin >> x >> n;
	for(int i = 0;i < n;i++)
	{
		scanf("%d",&p[i]);
	}
	for(int j = x;j >= 0;j--)
	{
		if(!find_num(j))
		{
			a = j;
			break;
		}
	}
	for(int j = x+1;;j++)
	{
		if(!find_num(j))
		{
			b = j;
			break;
		}
	}
	if(abs(a-x) > abs(b-x))
		cout << b << endl;
	else
		cout << a << endl;
	
	return 0;
}

Measured memory_bytes: 3772
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC {
    class Program {
        static void Main(string[] args) {
            string zip = Console.ReadLine();
            if (zip.Substring(0, 1) != zip.Substring(1, 1) && zip.Substring(1, 1) != zip.Substring(2, 1)
                && zip.Substring(0, 1) != zip.Substring(2, 1)) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }
}


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

class Program
{
    private int N;
    private int[]A,B;
    
    private void Scan()
    {
        N=int.Parse(Console.ReadLine());
        A=new int[N];
        B=new int[N];
        for(int i=0;i<N;i++)
        {
            var l=Console.ReadLine().Split(' ');
            A[i]=int.Parse(l[0]);
            B[i]=int.Parse(l[1]);
        }
    }
    
    private void Calc()
    {
        int max=-1;
        int ans=0;
        for(int i=0;i<N;i++)
        {
            if(max<A[i])
            {
                ans=A[i]+B[i];
                max=A[i];
            }
        }
        Console.WriteLine(ans);
    }
    
    public void Solve()
    {
        Scan();
        Calc();
    }
    
    static void Main()
    {
        new Program().Solve();
    }
}

Measured memory_bytes: 15808
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        int maxa=-1;
        int mina=2001;
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
            if(maxa<a[i]){
                maxa=a[i];
            }
            if(mina>a[i]){
                mina=a[i];
            }
        }
        int min=2001;
        for(int i=mina;i<=maxa;i++){
            int max=-1;
            for(int j=0;j<n;j++){
                if(max<Math.abs(i-a[j])){
                    max=Math.abs(i-a[j]);
                }
            }
            if(min>max){
                min=max;
            }
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 30100
import math
def koch(a, p1, p2):
    if a == 0:
        return
     
    v = [p2[0] - p1[0], p2[1] - p1[1]]
    s = [p1[0] + v[0] / 3, p1[1] + v[1] / 3]
    t = [p1[0] + 2 * v[0] / 3, p1[1] + 2 * v[1] / 3]
    u = [p1[0] + v[0] / 2 - v[1] * math.sqrt(3) / 6, p1[1] + v[1] / 2 + v[0] * math.sqrt(3) / 6]
 
    koch(a-1,p1,s)
    print(" ".join(map(str, s)))
    koch(a-1,s,u)
    print(" ".join(map(str, u)))
    koch(a-1,u,t)
    print(" ".join(map(str, t)))
    koch(a-1,t,p2)
 
n = int(input())
print("0 0")
koch(n, [0, 0], [100, 0])
print("100 0")


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int a, b;
    cin>> a>> b;
    a--;
    b--;

    cout <<( (b+a-1)/a);
    nl;



    return 0;
}




Measured memory_bytes: 3640
#include<stdio.h>

int main(){
  int i,x,n,p[10],max=0,total=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for(i=0;i<n;i++){
    if(max<=p[i]){
      max=p[i];
      x=i;
    }
  }
  p[x]=p[x]/2;
  for(i=0;i<n;i++){
    total+=p[i];
  }
  printf("%d",total);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  bool ok = false;
  if(s.size() >= 4 && s.substr(0, 4) == "YAKI") {
    ok = true;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int k;
   cin>>k;
   if(k==1)
   {
       cout<<1<<endl;
       return 0;
   }
   if(k%2==0 || k%5==0)
   {
       cout<<-1<<endl;
       return 0;
   }
   int ans=0;
   for(int i=1;i<1e7;i++)
   {
       ans*=10;
       ans+=7;
       ans%=k;
       if(ans==0)
       {
           cout<<i<<endl;
           return 0;
       }
   }
   cout<<-1<<endl;

}


Measured memory_bytes: 3664
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=55;

int N;
pair<int,int> P[MAXN];
bool vis[MAXN];

int solve(int p,int q)
{
	memset(vis,0,sizeof vis);
	int ret=0;
	for(int i=1;i<=N;i++)
	{
		if(vis[i])
			continue;
		int u=i,v;
		for(;;)
		{
			v=lower_bound(P+1,P+N,make_pair(P[u].first+p,P[u].second+q))-P;
			if(P[v].first!=P[u].first+p||P[v].second!=P[u].second+q)
				break;
			vis[v]=true;
			u=v;
		}
		ret++;
	}
	return ret;
}

int main()
{
	scanf("%d",&N);
	if(N==1)
	{
		printf("1\n");
		return 0;
	}
	for(int i=1;i<=N;i++)
		scanf("%d%d",&P[i].first,&P[i].second);
	sort(P+1,P+N+1);
	int ans=0x3F3F3F3F;
	for(int i=1;i<=N;i++)
		for(int j=i+1;j<=N;j++)
		{
			int p=P[j].first-P[i].first,q=P[j].second-P[i].second;
			ans=min(ans,solve(p,q));
		}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>

const int MaxN = 400 + 5;
const long long INF = 0x7F7F7F7F7F7F7F7F;

int N;
int A[MaxN];
long long Pre[MaxN];
long long Dp[MaxN][MaxN];
bool Vis[MaxN][MaxN];

template <typename Typ>
inline Typ min(Typ x, Typ y) { return x < y ? x : y; }

void init() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
}

long long dfs(int l, int r) {
  if (Vis[l][r] == true) return Dp[l][r];
  Vis[l][r] = true;
  if (l == r) return Dp[l][r] = 0;
  Dp[l][r] = INF;
  for (int k = l; k < r; ++k)
    Dp[l][r] = min(Dp[l][r], dfs(l, k) + dfs(k + 1, r) + Pre[r] - Pre[l - 1]);
  return Dp[l][r];
}

void solve() {
  for (int i = 1; i <= N; ++i) Pre[i] = Pre[i - 1] + A[i];
  printf("%lld\n", dfs(1, N));
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
constexpr int INF = 100100100;
using ld = long double;

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

using namespace std;

template<typename T>
T power(typename std::common_type<T>::type a, int n) {
  T ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans *= a;
    }
    a = a * a;
    n >>= 1;
  }
  return ans;
}

int natlog(int a, int b, int c) {
  int n = 0, x = a;
  while (x < c) {
    ++n; x *= b;
  }
  return n;
}

int main() {
  cout << fixed << setprecision(10);
  int N, K;
  cin >> N >> K;
  ld ans = 0;
  FOR(p, 1, N) {
    int n = natlog(p, 2, K);
    auto const prob = power<ld>(0.5, n) / N;
    ans += prob;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char a[30],b[30],c[30];
	int m,n,i;
	scanf("%s %s",&a,&b);
	scanf("%d %d",&m,&n);
	scanf("%s",&c);
	if(a[0]==c[0]&&a[1]==c[1])
		printf("%d %d",m-1,n);
	if(b[0]==c[0]&&b[1]==c[1])
		printf("%d %d",m,n-1);
    return 0;
}


Measured memory_bytes: 128
// template version 1.9

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
const int INF=1e18;
const int MOD=1e9+7;
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int v(int a, int b, int k, int i){
  int l, r;
  l = (i>=a ? i+1 : i);
  r = (k>=b ? k+1 : k);
  if (r>=b){
    r -= i-1;
    if (r<=b) r--;
  }
  else{
    r -= i-1;
  }
  return l*r;
}

int query_max(int a, int b, int k){
  if (a>b) swap(a,b);
  if (k<a) return false;
  int left = 1;
  int right = 3e9+50;
  auto isright = [&](int i) {  // v[i-1] <= v[i] -> left
    if (v(a,b,k,i)-v(a,b,k,i-1)>=0) return false;
    else return true;
  };
  while (right-left>1){
    int mid = (right+left)/2;
    if (isright(mid)) { right = mid;}
    else{ left = mid; }
  }
  return v(a, b, k, right-1);
}

int query(int a, int b){
  int left = 0;
  int right = 3e9+50;
  auto isright = [&](int k) {  // right : k人以上にできない。
    if (query_max(a, b, k) < a*b) return false;
    else return true;
  };
  while (right-left>1){
    int mid = (right+left)/2;
    if (isright(mid)) { right = mid;}
    else{ left = mid; }
  }
  dump(right);
  return right - 1;
}

int solve(){
  int q;cin>>q;
  // rep(i, 1, 10) dump(v(1, 4, 9, i));
  rep(i, 1, 5)dump(query_max(1, 4, i));
  // dump(query(4, 8));
  rep(i,q){
    int a,b;cin>>a>>b;
    cout << query(a, b) << endl;
  }
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

int main() {
  long long luca[87];
  luca[0] = 2;
  luca[1] = 1;
  for ( int i = 2; i <= 86; i++ ) { luca[i] = luca[i-1] + luca[i-2]; }

  int n;
  cin >> n;
  cout << luca[n] << endl;
  return 0;
}


Measured memory_bytes: 3632
/*Author : Yuvraj Singh
 * Patience is Power
 * 
 * */
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const long long mod = 1e9 + 7;
#define ar array
void solve(){
	ll n; cin>>n;
	ll dp[]={-mod,mod,-mod,mod};
	for(int i=0;i<n;i++){
		ll x,y; cin>>x>>y;
		dp[0]=max(dp[0],x+y);
		dp[1]=min(dp[1],x+y);
		dp[2]=max(dp[2],x-y);
		dp[3]=min(dp[3],x-y);
	}
	ll mx = dp[0]-dp[1];
	ll mi = dp[2]-dp[3];
	ll ans = max(mx,mi);
	cout<<ans<<"\n";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	//int t; cin>>t;
	//while(t--)
		solve();
		
    return 0;
}



Measured memory_bytes: 3616
//In the name of Allah the Most Merciful
//Astagfirullahil laji Rabbi Minkulli Jamio Watubi elai
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define MX 10000008
#define cs int t;cin>>t;while(t--)
int i,j,k;
int r,s;
main()
{
   int a,b,c;cin>>a>>b>>c;if(a+b+c>=22)cout<<"bust"<<endl;else cout<<"win"<<endl;
}


Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int n; cin >> n;
    vector<ll> A(n), B(n);
    rep(i, n) cin >> A[i];
    ll num = 0; int res = 0;
    vector<ll> margin;
    rep(i, n){
        cin >> B[i];
        if(A[i] < B[i]){
            num += B[i] - A[i];
            res++;
        }
        else margin.push_back(A[i] - B[i]);    
    }
    sort(all(margin), greater<ll>());
    ll p = 0;
    for(ll m: margin){
        if(p >= num) break;
        p += m; res++;
    }
    if(p < num) res = -1;
    cout << res << ln;
}


Measured memory_bytes: 2936
import math

n = int(input())
arr = [0] * n

for x in range(1,500):
    for y in range(1,500):
        for z in range(1,501):
            ans = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if ans <= n:
                arr[ans - 1] += 1

for i in range(n):
    print(arr[i])

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

/*
int gcd(int x, int y){
    int r = x % y;
    return r ? gcd(y, r) : y;
}
*/

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

    int n;
    cin >> n;
    
    int a, ans = 0;
    REP(i, n){
        cin >> a;
        ans += a;
    }

    cout << ans - n << endl;

    return 0;
}

Measured memory_bytes: 256
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

const int maxN = 33;
int food[maxN];
int N, M;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	while (scanf("%d%d", &N, &M) == 2) {
		memset(food, 0, sizeof(food));
		for (int i = 0; i < N; i++) {
			int K; scanf("%d", &K);
			for (int i = 0; i < K; i++) {
				int t; scanf("%d", &t);
				food[t]++;
			}
		}
		int ans = 0;
		for (int i = 1; i <= M; i++) if (food[i] == N) ans++;
		cout << ans << endl;
	}

	return 0;
}
/*
    input:
    output:
    modeling:
    methods:
    complexity:
    summary:
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<40)
#define mod 998244353
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

int main(){
	ll n,A;cin>>n>>A;
	vector<ll> a(n+1);
	rep(i,n+1) if(i!=0) cin>>a[i];

	vector<vector<vector<ll>>> dp(55,vector<vector<ll>>(55,vector<ll>(3000,0)));//i番目まで選べるとき 要素をk個選んでいるとき　和をjにする方法数
	dp[0][0][0]=1;

	rep(i,n+1){//i番目まで選べる
		rep(j,n+1){//選ぶ個数
			rep(k,3000){//和
				if(i==0 && j==0 && k==0) continue;

				if(i>=1 && k-a[i]<0) dp[i][j][k]=dp[i-1][j][k];//i番目を選ばないとき
				else if(i>=1 && j>=1 && k-a[i]>=0) dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-a[i]];//i番目を選択する
				else dp[i][j][k]=0;
			}
		}
	}

	ll ans=0;
	rep(i,n+1){
		if(i==0) continue;
		ans+=dp[n][i][i*A];
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 72576
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

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

#define io ios_base::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
#define mod 1000000007
#define pii pair<int, int>
#define PI 2*acos(0.0)

ll gcd(ll a, ll b)
{
    return b? gcd(b, a%b):a;
}

int main()
{
    io;
    ll po[200005] = {1};
    for(int i = 1; i< 200005; i++)
        po[i] = po[i-1]*2%mod;
    ll ans = -1, n;
    cin>>n;
    map<pair<ll, ll> , pair<int, int> > cnt;
    while(n--)
    {
        ll x, y;
        cin>>x>>y;
        if( !x && !y)
        {
            ans++;
            continue;
        }
        if(pair<ll, ll> (x, y) < pair<ll, ll> (0LL, 0LL))
        {
            x = -x;
            y = -y;
        }
        ll g = gcd(abs(x), abs(y));
        x/= g; y /= g;
        if(y > 0LL)
            cnt[{x, y}].first++;
        else
            cnt[{-y, x}].second++;
    }
    ll res = 1;
    for(auto p: cnt)
        res = res*(po[p.second.first] + po[p.second.second] - 1)%mod;
    cout<< (ans+res+mod)%mod;
    return 0;
}

Measured memory_bytes: 17620
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int [n];
        int max = 0;
        int min = 101;
        for(int i = 0; i < n; i++){
            x[i] = sc.nextInt();
            if(max < x[i]){
                max = x[i];
            }
            if(min > x[i]){
                min = x[i];
            }
        }
        int res = Integer.MAX_VALUE;
        for(int i = min; i <= max; i++){
            int sum = 0;
            for(int j = 0; j < n; j++){
                sum += Math.pow(x[j] - i, 2);
            }
            if(res > sum){
                res = sum;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 22356
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long long
#define ll long long

int main()
{
  string s;
  cin>>s;

  if (s=="") cout<<"No"<<endl;
  else {
    size_t pos=s.find("hi");
    while (pos==0) {
      s=s.substr(2,s.length()-2);
      pos = s.find("hi");
    }
    if (s.length()==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }


  return 0;
}




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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int h = ri();
	int w = ri();
	int k = ri();
	int sx = ri() - 1, sy = ri() - 1;
	int gx = ri() - 1, gy = ri() - 1;
	std::string map[h];
	for (auto &i : map) std::cin >> i;
	
	int dist[h][w];
	for (auto &i : dist) for (auto &j : i) j = 1000000000;
	dist[sx][sy] = 0;
	std::queue<std::pair<int, int> > que;
	que.push({sx, sy});
	
	std::set<int> r0[h], r1[w];
	for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) if (i != sx || j != sy) r0[i].insert(j), r1[j].insert(i);
	
	while (que.size()) {
		auto i = que.front();
		que.pop();
		
		// std::cerr << "!" << i.first << " " << i.second << " " << dist[i.first][i.second] << std::endl;
		
		auto itr = r0[i.first].lower_bound(i.second);
		for (; itr != r0[i.first].begin(); ) {
			int y = *std::prev(itr);
			if (map[i.first][y] == '@' || i.second - y > k) break;
			r0[i.first].erase(std::prev(itr));
			r1[y].erase(i.first);
			dist[i.first][y] = dist[i.first][i.second] + 1;
			que.push({i.first, y});
		}
		for (auto j = itr; j != r0[i.first].end(); ) {
			int y = *j;
			if (map[i.first][y] == '@' || y - i.second > k) break;
			r0[i.first].erase(j++);
			r1[y].erase(i.first);
			dist[i.first][y] = dist[i.first][i.second] + 1;
			que.push({i.first, y});
		}
		itr = r1[i.second].lower_bound(i.first);
		for (; itr != r1[i.second].begin(); ) {
			int x = *std::prev(itr);
			if (map[x][i.second] == '@' || i.first - x > k) break;
			r0[x].erase(i.second);
			r1[i.second].erase(std::prev(itr));
			dist[x][i.second] = dist[i.first][i.second] + 1;
			que.push({x, i.second});
		}
		for (auto j = itr; j != r1[i.second].end(); ) {
			int x = *j;
			if (map[x][i.second] == '@' || x - i.first > k) break;
			r0[x].erase(i.second);
			r1[i.second].erase(j++);
			dist[x][i.second] = dist[i.first][i.second] + 1;
			que.push({x, i.second});
		}
	}
	printf("%d\n", dist[gx][gy] == 1000000000 ? -1 : dist[gx][gy]);
	
	return 0;
}


Measured memory_bytes: 148956
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

int n, a[MAXN];

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    int g = a[1];
    FOR(i,2,n) g = gcd(g, a[i]);
    cout << g;
    return 0;
}

Measured memory_bytes: 640
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

int n, x ;

signed main(){
	scanf("%d", &n) ;
	rep(i, 1, n) {
		scanf("%d", &x) ;
		if (x % 2) PRINT("first") ;
	}
	PRINT("second") ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define ALL(x)          (x).begin(), (x).end()
#define rALL(x)         (x).rbegin(), (x).rend()
#define REP(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rREP(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define FOR(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/

bool judge(ll &x){
    if(x < 2) return false;
    else return true; 
}

/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/
    bool rev = false;
    string s; cin >> s;
    int q; cin >> q;

    string front = "", back = "";
    REP(i, q){
        int t; cin >> t;
        if(t == 1){
            rev ^= 1;
        }
        else if(t == 2){
            int f; cin >> f;
            if(f == 1 && !rev){
                char c; cin >> c;
                front += c;
            }
            if(f == 1 && rev){
                char c; cin >> c;
                back += c;
            }
            if(f == 2 && !rev){
                char c; cin >> c;
                back += c;
            }
            if(f == 2 && rev){
                char c; cin >> c;
                front += c;
            }
        }
    }

    if(rev){
        s += back;
        reverse(ALL(s));
        s += front;
        cout << s << endl;
        return 0;
    }
    else{
        s += back;
        reverse(ALL(s));
        s += front;
        reverse(ALL(s));
        cout << s << endl;
        return 0;
    }

return 0;
}

Measured memory_bytes: 4176
// Aizu 0362: Trampoline
// 2017.9.29 bal4u@uu

#include <stdio.h>

#define MAX 300005
int d[MAX+2];

int main()
{
	int n, i, j, a, k;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", d+i);
	for (k = j = i = 0; i < n-1; i++) {
		a = j + d[i];
		if (a > k) k = a;
		j += 10;
		if (k < j) { puts("no"); return 0; }
	}
	for (k = j = (n-1)*10, i = n-1; i > 0; i--) {
		a = j - d[i];
		if (a < k) k = a;
		j -= 10;
		if (j < k) { puts("no"); return 0; }
	}
	puts("yes");
	return 0;
}

Measured memory_bytes: 2868