akhauriyash/Code-Regression huggingface dataset:
// AOJ 1311: Test Case Tweaking
// 2018.1.13 bal4u

#include <stdio.h>
#include <string.h>

#define QMAX 100000
typedef struct { int t, s, d; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t, int d)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t, que[i].d = d;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

int to[101][101], dt[101][101], hi[101];
char used[101][101];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int dijkstra(int n, int c, int start, int goal)
{
	int i, s, t, d, e, t2, ans;

	memset(used, 0, sizeof(used));
	qsize = 0;
	ans = n;
	enq(start, 0, 0);
	while (qsize) {
		s = que[0].s, t = que[0].t, d = que[0].d, deq();
		if (s == goal) {
			if (d < ans) ans = d;
			continue;
		}
		if (used[s][d]) continue;
		used[s][d] = 1;
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i];
			t2 = t+dt[s][i];
			if (d < ans) enq(e, t, d+1);
			if (t2 <= c) enq(e, t2, d);
		}
	}
	return ans;
}

int main()
{
	int n, m, c, f, k;
	
	while (n = in()) {
		m = in(), c = in();
		memset(hi, 0, sizeof(hi));

		while (m--) {
			f = in()-1, k = hi[f]++;
			to[f][k] = in()-1, dt[f][k] = in();
		}
		printf("%d\n", dijkstra(n, c, 0, n-1));
	}
	return 0;
}


Measured memory_bytes: 2408
import operator

func = {'+':operator.add, '-':operator.sub, '*':operator.mul}

stack  = []
for symbol in input().split():
    if symbol.isdigit():
        stack.append(int(symbol))
    else:
        a = stack.pop()
        b = stack.pop()
        stack.append(func[symbol](b, a))
        
print(stack[0])

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define se second
#define endl "\n"
#define pii pair<int, int>
#define vi vector<int> 
#define vvi vector<vi>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define ALL(c) (c).begin(),()c.end() 

#define PI 3.14159265358979323846
const int N = 2e5 + 10;
const int INF=2e9;

int MOD=1e9+7;
int cnt;


void solve() {
	int n=5,k;
	vector<int> v(n);
	
	for(int i=0;i<n;i++)
	     cin>>v[i];
	     
	     cin>>k;
	     
	     for(int i=0;i<v.size();i++){
			    for(int j=i+1;j<v.size();j++) {
					   if(v[j]-v[i]>k) {
						      ++cnt;
						      break;
						   }		    
					}
			 }
			 
			 if(cnt==0) 
				   cout<<"Yay!";
				   
				 
			else 
			     cout<<":( ";	 
	    
	
	  
	 
		     
	}   
	   

int32_t main() {
  cool;
  int t = 1;
  while (t--)
	solve();

  return 0;
}


Measured memory_bytes: 256
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

X = int(input())
v = 100

cnt = 0
while v<X:
    v = int(v*1.01)
    cnt += 1


print(cnt)




Measured memory_bytes: 9496
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final long MOD = (long)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		String s = sc.next();
		String prefix = "";
		String postfix = "";
		int count = 0;
		
		
		for (char c: s.toCharArray()) {
			if (c == ')') {
				if (count == 0) {
					prefix += "(";
				} else {
					count -= 1;
				}
			} else {
				count++;
			}
		}
		
		if (count == 0) {
			// 全部匹配，加上prefix就可以
			System.out.println(prefix + s);
		} else {
			// count 比0大代表有沒匹配到的）
			postfix = nTimesChar(')', count);
			System.out.println(prefix + s + postfix);
		}
	}
	
	private static String nTimesChar(char c, int t) {
		String res = "";
		for (int i = 0; i < t; i++) {
			res += c;
		}
		return res;
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 22996
#include "iostream"
#include "vector"
#include "iomanip"
#include "algorithm"
#include "vector"
#include "cmath"

typedef struct {
	int s;
	int c;
}Rest;

int main() {
	int n, m;
	std::cin >> n;
	std::cin >> m;

	std::vector<Rest> rest(m);
	for (int i = 0; i < m; ++i) {
		std::cin >> rest[i].s;
		std::cin >> rest[i].c;
	}

	std::vector<int>ans_rest(n + 1, -1);
	int ans = 0;
	for (int i = 0; i < m; ++i) {
		if (rest[i].s == 1 && rest[i].c == 0 && n != 1)
			ans = -1;
		if (ans_rest[rest[i].s] == -1)
			ans_rest[rest[i].s] = rest[i].c;
		else
			if (ans_rest[rest[i].s] != rest[i].c)
				ans = -1;
	}

	if (ans != -1) {
		for (int i = 1; i <= n; ++i)
			if (ans_rest[i] != -1)
				ans += ans_rest[i] * pow(10, n - i);
		if (ans_rest[1] == -1 && n != 1)
			ans += pow(10, n - 1);
	}

	std::cout << ans;
}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
info=[]
for i in range(n):
    x,y,a=map(int,input().split())
    info.append([x,y,a])
top,down,left,right=h,0,0,w
def calc(x,y,a):
    global top,down,left,right
    if a==1:
        if left<x:
            left=x
    elif a==2:
        if x<right:
            right=x
    elif a==3:
        if down<y:
            down=y
    else:
        if y<top:
            top=y
for i in range(n):
    calc(info[i][0],info[i][1],info[i][2])
    if top<=down:
        top,down=0,0
        break
    if right<=left:
        right,left=0,0
        break
    #print(right)
    #print(left)
print((top-down)*(right-left))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll 	long long
#define pb push_back
#define mp make_pair
using namespace std;

int main(){

ll n,m,d=0,e=0;
cin>>n>>m;

 d=n*m;

if(d==n || d==m)
e=1;
else if(d%2)
 e=(d+1)/2;
else
 e=d/2;

cout<<e<<endl;
    return 0;
}

Measured memory_bytes: 3620
def main():
    N, K = map(int, input().split())
    P = [(v + 1) / 2 for v in map(int, input().split())]

    ans = tmp = sum(P[0:K])
    for i in range(N - K):
        tmp = tmp - P[i] + P[i + K]
        ans = max(ans, tmp)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23524
#include<iostream>
#include<algorithm>
#include<cstring>
#include<set>
#include<vector>
#include<queue>
#include<cmath>
#include<memory.h>
#include<ctime>
#include<cstdio>

using namespace std;

int main()
{
	string s;
	cin>>s;
	string tmp=s;
	reverse(s.begin(),s.end());
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='b')
		{
			s[i]='d';
		}			
		else 		
		{
			if(s[i]=='d')
			{
				s[i]='b';
			}
			else 
			{
				if(s[i]=='q')
				{
					s[i]='p';
				}			
				else 
				{
					if(s[i]=='p')
					{
						s[i]='q';
					}			
				}				
			}			
		}		
	}
	if(s==tmp)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 512
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

A = LI()

print("bust" if sum(A) >= 22 else "win")


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i,m) cin >> x.at(i);
    sort(x.begin(), x.end());
    if (m <= n) {
        cout << 0 << endl;
        return 0;    
    }
    
    int ans = x.at(m-1) - x.at(0);
    vector<int> distance(m-1);
    rep(i,m-1) {
        distance.at(i) = x.at(i+1) - x.at(i);
    }
    sort(distance.rbegin(), distance.rend());
    rep(i,n-1) ans -= distance.at(i);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3880
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define pp pair<ll,ll>
#define vi vector<int>
#define vvi vector<vi>
#define vb vector<bool>
#define vvb vector<vb>

using namespace std;

int dfs(int x,vvi& graph,vi& dp){
    
    if(dp[x]!=-1) return dp[x];
    
    int count=0;
    for(int e:graph[x]){
        count=max(count,dfs(e,graph,dp)+1);
    }
    return dp[x]=count;
}

void longestpath(){
    int n,m,a,b;
    cin>>n>>m;
    vector<vector<int>> graph(n+1,vector<int>());
    while(m--){
        cin>>a>>b;
        graph[a].push_back(b);
    }
    vi dp(n+1,-1);
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,dfs(i,graph,dp));
    }
    cout<<ans;
}

int main(){
  longestpath();
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(5);
  for(int i=0;i<5;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<5;i++){
    if(a.at(i)==0){
      cout<<i+1<<endl;
    }
  }
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forN(i, n) for(int i = 0; i <n ; ++i)
#define endl "\n"
#define noob (main)
typedef long long ll;
using namespace  std;
typedef vector<int> vi;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const int N = 2e5 +5 ;
vi primes(1,2);
void sieve(){
    vi m(N+1,0);
    for(int i = 4; i<N; i+=2)m[i]=1;
    for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
    for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}
bool isPrime(ll x){
    if(x==1)return 0;
    for(auto i:primes){
        if(i*i>x)return 1;
        if(x%i==0)return 0;
    }
    return 1;
}

int noob(){
    fastIO;
    int n;
    cin>>n;
    int ans = 0;
    while(n--){
        int a , b;
        cin>>a>>b;
        if(a==b){
            ans++;
        }
        else if(a!=b){
            ans = 0;
        }
        if(ans==3){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define in cin>>
#define out cout<<
#define change endl

int main()
{
   int n;
    in n;
    int k=n/1000;
    int r=n%1000;
    if(r==0) out 0;
    else out 1000*(k+1)-n;

}

Measured memory_bytes: 3588
n,k = map(int,input().split())
a = list(map(int,input().split()))
already = ["1"]
set = {"1"}
now = 1

for i in range(n):
    now = str(a[int(now)-1])
    if now in set:
        break
    else:
        already.append(now)
        set.add(now)


ind = already.index(now)
k -= ind
cycle = already[ind:]

if k <= 0:
    print(already[k+ind])
else:
    now = (k+1) % len(cycle)
    print(cycle[now-1])

Measured memory_bytes: 102512
import java.util.Scanner;

/**
 * C - Traveling Salesman around Lake
 * 1 周 K メートルの円形の湖があり、その周りに N 軒の家があります。
 * i 番目の家は、湖の北端から時計回りに Ai メートルの位置にあります。
 * 家の間の移動は、湖の周りに沿ってのみ行えます。
 * いずれかの家から出発して N 軒すべての家を訪ねるための最短移動距離を求めてください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 湖の円周の長さ
        int k = sc.nextInt();
        // 周りの家の数
        int n = sc.nextInt();
        // 家の間のそれぞれの距離
        int[] a = new int[n];
        for( int i = 0; i < n; i++ ) {
            a[i] = sc.nextInt();
        }

        int max = k - a[a.length - 1];
        int result = 0;
        for( int i = 1; i < n; i++ ) {
//            System.out.println("a["+ i +"]:" +a[i]);
//            System.out.println("a["+ (i-1) +"]:" +a[i -1]);
            result += a[i] - a[i - 1];
            if( max < a[i] - a[i - 1] ) {
                max = a[i] - a[i - 1];
            }
        }

        System.out.println( result > k - max ?  k - max : result );

        sc.close();
    }
}

Measured memory_bytes: 78120
import java.util.Scanner;

public class Main{
    public static void main(final String[] args) {
 Scanner sc = new Scanner(System.in);
 
for(int k=0;;k++){

 int H=sc.nextInt();
 int W=sc.nextInt();
 if(H==0&&W==0){
break;
 }
 for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
System.out.print("#");
 }
 System.out.println("");
}
System.out.println();
}

 sc.close();
    }
}


Measured memory_bytes: 33004
#include <cstdio>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

ll dp[60][2600];

int main(void) {
  int n;
  int avg;
  scanf("%d%d", &n, &avg);

  dp[0][0] = 1;
  REP(i, n) {
    int v;
    scanf("%d", &v);
    for(int j = i; j >= 0; --j) {
      for(int k = 2500; k >= 0; --k) {
        dp[j+1][k+v] += dp[j][k];
      }
    }
  }

  ll res = 0;
  for(int i = 1; i <= n; ++i) {
    res += dp[i][i*avg];
  }
  printf("%lld\n", res);
  
  return 0;
}


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

int main(){
  string S;
  int ans, x = 0;
  cin >> S;
  while (x == 0) {
    S.pop_back();
    for (int i = 0 ; i < S.size()/2 ; i++) {
      if (S.at(i) != S.at(S.size()/2 + i)) {
        x = 0;
        break;
      }
      else {
        x = 1;
      }
    }
  }
  ans = S.size() / 2 * 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math
 
def calc(x, y):
    s = math.fabs((x[1]-x[0])*(y[2]-y[0]) - (x[2]-x[0])*(y[1]-y[0]))/2
    a = ((x[2]-x[1])**2 + (y[2]-y[1])**2)**0.5
    b = ((x[0]-x[2])**2 + (y[0]-y[2])**2)**0.5
    c = ((x[1]-x[0])**2 + (y[1]-y[0])**2)**0.5
    r = a*b*c/(4*s)
 
    a = [2*(x[1]-x[0]), 2*(x[2]-x[0])]
    b = [2*(y[1]-y[0]), 2*(y[2]-y[0])]
    c = [x[0]**2 - x[1]**2 + y[0]**2 -y[1]**2, x[0]**2 - x[2]**2 + y[0]**2 -y[2]**2]
    x = (b[0]*c[1]-b[1]*c[0])/(a[0]*b[1]-a[1]*b[0])
    y = (c[0]*a[1]-c[1]*a[0])/(a[0]*b[1]-a[1]*b[0])
 
    return [x,y,r]
 
for i in range(int(input())):
    list = [float(l) for l in raw_input().split()]
    x,y = [list[0::2],list[1::2]]
 
    ans = calc(x,y)
 
    print "%.3f %.3f %.3f" % (ans[0],ans[1],ans[2])

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

int main() {
  int n;
  cin >> n;
  int a[n + 1];
  int b[n];
  for (int i = 0; i < n + 1; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    // i 人目の勇者が i 番目の街で討伐
    int i_attack = min(b[i], a[i]);
    ans += i_attack;
    a[i] -= i_attack;
    b[i] = max(0, b[i] - i_attack);
    // i 人目の勇者が i+1 番目の街で討伐
    int ii_attack = min(b[i], a[i + 1]);
    ans += ii_attack;
    a[i + 1] -= ii_attack;
  }

  cout << ans << endl;
}


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

int main(){
  int a[3];
  for(int i=0;i<3;i++){
  	cin>>a[i];
  }
  sort(a,a+3);
  cout<<a[1]-a[0]+a[2]-a[1]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W; cin >> H >> W;
  string Q;
  for (int i=0;i<W+2;i++) cout << "#";
  cout << endl;
  for (int j=0;j<H;j++){
    cin >> Q;
    cout << "#" << Q << "#" << endl;
  }
  for (int i=0;i<W+2;i++) cout << "#";
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin >> n >> m;
    pair<ll,ll> students[n];
    pair<ll,ll> checkpoint[m];
    rep(i,n) {
        ll a,b;
        cin >> a >> b;
        pair<ll, ll> p = make_pair(a,b);
        students[i] = p;
    }
    rep(i,m) {
        ll c,d;
        cin >> c >> d;
        pair<ll, ll> p = make_pair(c,d);
        checkpoint[i] = p;
    }
    rep(i,n)
    {
        // tyoten students[i].first, students[i].second
        int index = inf;
        ll min_num = INF;
        rep(j,m)
        {
            ll kyori = abs(students[i].first-checkpoint[j].first)+abs(students[i].second-checkpoint[j].second);
            if (kyori < min_num)
            {
                min_num = kyori;
                index = j;
            }
        }
        cout << index+1 << endl;
    }

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Map<Long, Long> m = new HashMap<>();

        for (int n = 0; n < N; n++) {
            Long a = in.nextLong();

            if (m.containsKey(a)) {
                m.put(a, m.get(a) + 1);
            } else {
                m.put(a, 1L);
            }
        }

        long res = 0;
        for (long k : m.keySet()) {
            long v = m.get(k);

            if (k > v) {
                res += v;
            } else {
                res += v - k;
            }
        }

        System.out.println(res);
    }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

#endif

int main(void)
{
	string s;  cin >> s;
	vector<bool> ans(200, false);

	sort(all(s));
	rep(i, 0, size(s))
		ans[(ll)s[i]] = true;

	ll c = 0;
	rep(i, (ll)'a', (ll)'z'+1)
	{
		if (ans[i] == true)
			c++;
	}

	if (c == ((ll)'z' - (ll)'a' + 1))
	{
		cout << "None";
		return 0;
	}

	rep(i, (ll)'a', (ll)'z' + 1)
	{
		if (ans[i] == false)
		{
			cout << (char)(i);
			return 0;
		}
	}

	return 0;
}


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

using namespace std;
int a[110000];
int main()
{
    int s=0,n,k;
    scanf("%d %d",&n,&k);
    int i;
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    int l;l=n;
    while(l>1)
    {
        l=l-k+1;
        s++;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-10
#define PB push_back
#define fi first
#define se second
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
typedef vector<int> vi;
int ans[1000001];
ll mod_pow(ll x, ll n ,ll mod){
	if(n == 0) return 1;
	ll res = mod_pow(x*x%mod,n/2,mod);
	if(n & 1) res = res * x % mod;
	return res;
}
void makeHammingNumbers(){
	rep(i,1000000){
		rep(j,13){
			if(mod_pow(60,j,i+1)==0){
				ans[i+1] = 1;
				break;
			}
		}
	}
	return ;
}
int main(){
	makeHammingNumbers();
	reps(i,1,1000000){
		ans[i+1] += ans[i];
	}
	int m;
	while(scanf("%d",&m),m){
		int n;
		scanf("%d",&n);
		printf("%d\n",ans[n]-ans[m-1]);
	}
	return 0;
}

Measured memory_bytes: 5092
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;
const ll mod=998244353;
const ll inv=(mod+1)/2;

int n, m;

ll dziel(ll a, ll b)
{
	ll wyk=mod-2;
	while(wyk)
	{
		if (wyk&1)
			a=(a*b)%mod;
		b=(b*b)%mod;
		wyk>>=1;
	}
	return a;
}

vll raz(vll wek)
{
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<m; j++)
		{
			if (!(j&(1<<i)))
			{
				ll a=wek[j];
				ll b=wek[j^(1<<i)];
				wek[j]=(a+b)%mod;
				wek[j^(1<<i)]=(a-b+mod)%mod;
			}
		}
	}
	return wek;
}

vll dwa(vll wek)
{
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<m; j++)
		{
			if (!(j&(1<<i)))
			{
				ll a=wek[j];
				ll b=wek[j^(1<<i)];
				wek[j]=(a+b)%mod;
				wek[j^(1<<i)]=(a-b+mod)%mod;
				wek[j]=(wek[j]*inv)%mod;
				wek[j^(1<<i)]=(wek[j^(1<<i)]*inv)%mod;
			}
		}
	}
	return wek;
}

vll mno(vll a, vll b)
{
	for (int i=0; i<m; i++)
		a[i]=(a[i]*b[i])%mod;
	return a;
}

vll dziel(vll a, vll b)
{
	for (int i=0; i<m; i++)
		a[i]=dziel(a[i], b[i])%mod;
	return a;
}

vll dod(vll a, vll b)
{
	for (int i=0; i<m; i++)
		a[i]=(a[i]+b[i])%mod;
	return a;
}

vll odj(vll a, vll b)
{
	for (int i=0; i<m; i++)
		a[i]=(a[i]-b[i]+mod)%mod;
	return a;
}

int main()
{
	scanf("%d", &n);
	m=(1<<n);
	vll in(m);
	ll s=0;
	for (ll &i : in)
	{
		scanf("%lld", &i);
		s+=i;
	}
	for (ll &i : in)
		i=dziel(i, s);
	in[0]=(in[0]-1+mod)%mod;
	vll trz(m);
	trz[0]=m;
	for (ll &i : trz)
		i=(i-1+mod)%mod;
	
	vll wez=dwa(dziel(raz(trz), raz(in)));
	for (int i=0; i<m; i++)
		printf("%lld\n", (wez[i]-wez[0]+mod)%mod);
	return 0;
}


Measured memory_bytes: 8956
#include "iostream"
#include <vector>
#include <array>

std::array<std::string, 4> DIV_STR_LIST = {"dream", "dreamer", "erase", "eraser"};

int main()
{
    std::string text;
    std::cin >> text;

    /* 後方一致を楽に行うため、反転 */
    std::reverse(text.begin(), text.end());
    for (auto& dividString : DIV_STR_LIST) {
        std::reverse(dividString.begin(), dividString.end());
    }

    bool isOK = false;
    while(!text.empty()) {
        isOK = false;
        /* 何れかの文字列に一致すればそれを削除 */
        for (const auto& dividString : DIV_STR_LIST) {
            if (text.compare(0, dividString.size(), dividString) == 0) {
                text = text.substr(dividString.size());
                isOK = true;
                break;
            }
        }

        if (isOK == false) {
            break;
        }
    }

    if (isOK) {
        std::cout << "YES" << std::endl;
    }
    else {
        std::cout << "NO" << std::endl;
    }

    return 0;
}



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

int64_t ruijyo (int x, int a) {
  int64_t ans = 1;
  if (a == 0) {
    return 1;
  }
  else {
    for (int i = 0; i < a; i++) {
      ans *= x;
    }
  return ans;
  }
}

int main() {
  int64_t h;
  cin >> h;

  int64_t min = 0;
  int tmp = 0;
  for (int i = 0; i < 50; i++) {
    if ((ruijyo(2, i) <= h ) && (h < ruijyo(2, i+1))) {
      tmp = i;
      break;
    }
  }
  for (int j = 0; j < tmp + 1; j++) {
    min +=ruijyo(2,j);
    //cout << min << endl;
  }
  cout << min << endl;
}
  
      

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

using namespace std;

vector <vector <char>> a;
vector <vector <int>> d;
vector <vector <bool>> tf;
const int INF = 1000;

int main() {
	int h, w;
	cin >> h >> w;
	a.resize(h);
	for (int i = 0; i < h; i++)
		a[i].resize(w);
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> a[i][j];
	int ans = 0;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#')
				continue;
			d.resize(0);
			d.resize(h);
			for (int y = 0; y < h; y++)
				d[y].resize(w, INF);
			tf.resize(0);
			tf.resize(h);
			for (int y = 0; y < h; y++)
				tf[y].resize(w);
			d[i][j] = 0;
			queue <pair <int, int>> q;
			q.push({ i, j });
			tf[i][j] = true;
			while (!q.empty()) {
				pair <int, int> v = q.front();
				q.pop();
				int y = v.first;
				int x = v.second;
				if (y > 0 && !tf[y - 1][x] && a[y - 1][x] == '.') {
					q.push({ y - 1, x });
					tf[y - 1][x] = true;
					d[y - 1][x] = min(d[y - 1][x], d[y][x] + 1);
				}
				if (y < h - 1 && !tf[y + 1][x] && a[y + 1][x] == '.') {
					q.push({ y + 1, x });
					tf[y + 1][x] = true;
					d[y + 1][x] = min(d[y + 1][x], d[y][x] + 1);
				}
				if (x > 0 && !tf[y][x - 1] && a[y][x - 1] == '.') {
					q.push({ y, x - 1 });
					tf[y][x - 1] = true;
					d[y][x - 1] = min(d[y][x - 1], d[y][x] + 1);
				}
				if (x < w - 1 && !tf[y][x + 1] && a[y][x + 1] == '.') {
					q.push({ y, x + 1 });
					tf[y][x + 1] = true;
					d[y][x + 1] = min(d[y][x + 1], d[y][x] + 1);
				}
			}
			for (int y = 0; y < h; y++) 
				for (int x = 0; x < w; x++) 
					if (d[y][x] != INF)
						ans = max(d[y][x], ans);
		}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
const ll mod =   1e9+7;
ll dp[5000];
int main()
{  fast
ll n;
cin>>n;
if(n<3){
	cout<<0;
	return 0;
	
}
dp[3]=1;
for(int i=4;i<=n;i++){
	dp[i]=1;
	for(int j=3;j<=i-3;j++){
		dp[i]+=dp[j];dp[i]%=mod;
	}
}
cout<<dp[n];
}

Measured memory_bytes: 3640
K,N=(int(x) for x in input().split())
A = list(map(int, input().split()))
A.sort()

for i in range(N):
    A.append(A[i] + K)

result = 10000000
for i in range(N):
    temp = A[i+N-1] - A[i]
    if temp < result:
        result = temp
print(result)

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int n=read();
	vi dp(n,0);
	REP(i,n){
		int p=read()-1;
		int k=p>0?dp[p-1]:0;
		dp[p]=k+1;
	}
	print(n-*max_element(ALL(dp)));
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
using namespace std;

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

		cin >> n >> a >> b;
		d = n % (a + b);
	if (d >= a) {
		d = a;
	}
	c = n / (a + b) * a + d;

	cout << c;

}

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

using namespace std;

#define ll long long
#define fr(i,n) for(int i=0; i<n; ++i)
#define frr(i,n) for(int i=n; i>=0; --i)

int main(){

    int n;
    cin>>n;
    vector<vector<int>> A(n, vector<int>(3));
    fr(i, n) cin>>A[i][0]>>A[i][1]>>A[i][2];
    vector<vector<int>> dp(2, vector<int>(3));
    dp[0][0]=A[0][0];dp[0][1]=A[0][1];dp[0][2]=A[0][2];
    for(int i=1; i<n; i++){
        // for a
        dp[i%2][0]=A[i][0]+max(dp[(i-1)%2][1], dp[(i-1)%2][2]);
        dp[i%2][1]=A[i][1]+max(dp[(i-1)%2][0], dp[(i-1)%2][2]);
        dp[i%2][2]=A[i][2]+max(dp[(i-1)%2][0], dp[(i-1)%2][1]);
    }
    cout<<max(dp[(n-1)%2][0], max(dp[(n-1)%2][1], dp[(n-1)%2][2]));
    return 0;
}

Measured memory_bytes: 8696
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b;
		cin >> a >> b;
		dump(a + b);
	}
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
      	int y = sc.nextInt();
      	int p =1;
      
      	for(int i=0; i<x+1; i++){         
          int u =i*2 + (x-i)*4;
          if(u==y){
            System.out.print("Yes");
            p =0;
            break;
          }
        }
        
      	if(p==1){
        	System.out.print("No");
        }
       
      
	}
}

Measured memory_bytes: 35732
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,q;
    cin>>n;
    vector<int> a(n,0);
    rep(i,n) cin>>a.at(i);
    cin>>q;
    vector<int> m(q);
    int x;
    rep(i,q){
        cin>>x;
        m[i]=x;
    }
    vector<bool> ans(40001,false);
    for(int tmp = 0;tmp< (1<<n); tmp++){
        bitset<20> s(tmp);
        int cnt=0;
        rep(i,n){
            if(s.test(i)) cnt+=a[i];
        }
        ans[cnt]=true;
    }
    rep(i,q){
        if(ans[m[i]]) cout<<"yes"<<'\n';
        else cout<<"no"<<'\n';
    }
}


Measured memory_bytes: 3232
#import<iostream>
#define a(k,x) j<<k-__builtin_clzll(x)
long long A,B,C,D,i,j=1;main(){std::cin>>A>>B;if(A^B){C=(a(64,A^B))-1;A&=C;B&=C;i=++C>>1;B=(B-i)?(a(64,B-i))-1:0;C=C-A-(A>B)*(A-1-B);std::cout<<C;}else puts("1");}

Measured memory_bytes: 256
require 'set'
require 'prime'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

wa = [0]
i = 1
x = 0
while x <= 40
  x += i
  wa[i] = x
  i += 1
end

ans = 0
p = 2

ans = 0
Prime.prime_division(N).each do |pr, num|
  sousa = wa.find_index { |x| x > num } - 1
  ans += sousa
end

puts ans





Measured memory_bytes: 14448
def main():
    N = int(input())
    A = list(map(int, input().split(" ")))
    zero = 0
    neg = 0
    m = float("inf")
    for i in range(N):
        if A[i] == 0:
            zero += 1
        if A[i] < 0:
            neg += 1
        A[i] = abs(A[i])
        m = min(m, A[i])

    neg = neg % 2 
    if neg == 0:
        result = sum(A)
    else:
        if zero:
            result = sum(A)
        else:
            result = sum(A) - 2*m
    print(result)
    return 

if __name__ == "__main__":
    main()


Measured memory_bytes: 14468
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int H = input.nextInt();
        int W = input.nextInt();
        
        while (H != 0 && W != 0) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
                        System.out.print("#");
                    }
                    else {
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
            
            H = input.nextInt();
            W = input.nextInt();
        }
    }
}


Measured memory_bytes: 32148
#include<iostream>
using namespace std;
int main()
{
 int Time;
 int h,m,s;

 cin >> Time;

 h = Time/3600;
 m = (Time % 3600)/60;
 s = (Time % 3600) % 60;

 cout << h << ":" << m << ":" << s << endl;
 return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int D; cin >> D;
    vector<int> C(26 + 1);
    for (int i = 1; i <= 26; i++) scanf("%d", &C[i]);
    vector<vector<int>> S(D + 1, vector<int>(26 + 1));
    for (int i = 1; i <= D; i++) {
        for (int j = 1; j <= 26; j++) scanf("%d", &S[i][j]);
    }

    vector<int> last(26 + 1);
    for (int d = 1; d <= D; d++) {
        int ans;
        ll grd = 0;
        for (int t = 1; t <= 26; t++) {
            ll sum = 0;
            sum += (ll)S[d][t];
            int bef = last[t];
            last[t] = d;
            for (int i = 1; i <= 26; i++) sum -= (ll)C[i] * (d - last[i]);
            if (chmax(grd, sum)) ans = t;
            last[t] = bef;
        }
        last[ans] = d;
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 3804
n = int(input())
a = [int(input()) for _ in range(n)]

m = max(a[0], a[1])
mm = min(a[0], a[1])
for i in range(2, n):
    if a[i] >= m:
        mm = m
        m = a[i]
    elif a[i] > mm:
        mm = a[i]

for i in range(n):
    if a[i] == m:
        print(mm)
    else:
        print(m)


Measured memory_bytes: 12512
btl :: Int -> Int -> Int -> Int -> String
btl a b c d | c <= 0 ="Yes"
            | a <= 0 = "No"
            | otherwise = btl (a-d) b (c-b) d

main :: IO ()
main = do
    [a,b,c,d] <- map read <$> (words <$> getLine) :: IO [Int]
    putStrLn (btl a b c d)


Measured memory_bytes: 3916
N, M = map(int, input().split())
A = [None for i in range(M)]
B = [None for i in range(M)]
for i in range(M):
    A[i], B[i] = map(int, input().split())

s = []
past = [1]
for i, a in enumerate(A):
    if a == past[-1] and not B[i] in past:
        s.append(past+[B[i]])
for i, b in enumerate(B):
    if b == past[-1] and not A[i] in past:
        s.append(past+[A[i]])
num_paths = 0
while s:
    past = s.pop()
    if len(past) == N:
        num_paths += 1
        continue
    for i, a in enumerate(A):
        if a == past[-1] and not B[i] in past:
            s.append(past+[B[i]])
    for i, b in enumerate(B):
        if b == past[-1] and not A[i] in past:
            s.append(past+[A[i]])

print(num_paths)

Measured memory_bytes: 3064
#include <iostream>
int main(void){
    double xa1,xa2,ya1,ya2,xb1,xb2,yb1,yb2;
    while(std::cin>>xa1>>ya1>>xa2>>ya2>>xb1>>yb1>>xb2>>yb2){
        if(xa1<=xb2&&xb1<=xa2&&ya1<=yb2&&yb1<=ya2)std::cout<<"YES\n";
        else std::cout<<"NO\n";
    }
    return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<math.h>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<string>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main()
{
	int n,a,b,ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		ans+=abs(a-b)+1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 2147483647;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

const int	MAX_N = 200010;

int N;
int dat[2*MAX_N-1];

//?????????
void init(int n_)
{
	N=1;
	while(N<n_) N*=2;
	rep(i, 2*N-1) dat[i]=INF;
}

//k????????????(0-indexed)???a?????´??°
void update(int k, int a)
{
	k+=N-1;
	dat[k]=a;
	while(k>0)
	{
		k=(k-1)/2;
		dat[k]=min(dat[k*2+1], dat[k*2+2]);
	}
}

//[a, b)???????°????????±???????
//??????k???[l, r)?????????
int query_(int a, int b, int k, int l, int r)
{
	if(r<=a || b<=l) return INF;
	else if(a<=l && r<=b) return dat[k];
	else
	{
		int vl=query_(a, b, k*2+1, l, (l+r)/2);
		int vr=query_(a, b, k*2+2, (l+r)/2, r);
		return min(vl, vr);
	} 
}

int query(int a, int b)
{
	return query_(a, b, 0, 0, N);
}



int main()
{
	int n, q;
	cin >> n >> q;
	init(n);
	int com, x, y;
	while(cin >> com >> x >> y)
	{
		if(com==0) update(x, y);
		else cout << query(x, y+1) << endl;
	}
	return 0;
}

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

int main(){
    int w,h,x,y,r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    printf("%s\n",((x>=r && x+r<=w) && (y>=r && y+r<=h))?"Yes":"No");
    return 0;
}


Measured memory_bytes: 3164
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


/* bellmanford begin*/
struct edge {
	ll from, to, cost;
};

class bellmanford 
{
private:
	long long vertex;	// 頂点数
	long long inf = 1LL << 60;
	vector<edge> e;	// 辺
	vector<long long> distance;	// 最短距離
public:
	void init(long long n);	// nは頂点の数
	void add_edge(long long from, long long to, long long cost);	// 頂点fromから頂点toに辺を張る
	bool run(long long s);		// sは開始地点。返り値がfalseのとき負の閉路あり
	ll get_distance(long long v);	// 頂点vへの距離を返す
};

void bellmanford::init(long long n) {
	vertex = n;
}

void bellmanford::add_edge(long long from, long long to, long long cost) {
	e.push_back({ from, to, cost });
}

bool bellmanford::run(long long s) {
	distance = vector<long long>(vertex, inf);
	distance[s] = 0;	//開始点の距離は0

	for (long long i = 0; i < vertex; i++) {
		for (auto es : e) {
			if (distance[es.from] != inf && distance[es.to] > distance[es.from] + es.cost) {
				distance[es.to] = distance[es.from] + es.cost;
				if (i == vertex - 1) {
					//return false;
					distance[es.to] = -inf;
				}
			}
		}
	}
	return true;
}

long long bellmanford::get_distance(long long v) {
	return distance[v];
}
/* bellmanford end*/

int main()
{
	ll n, m;

	cin >> n >> m;

	bellmanford bell;
	bell.init(n);

	REP(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;

		bell.add_edge(a, b, -c);
	}

	bell.run(0);

	if (bell.get_distance(n - 1) > -(1LL << 60)) {
		cout << -bell.get_distance(n - 1) << endl;
	}
	else {
		cout << "inf" << endl;
	}
}

Measured memory_bytes: 384
#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()
{
   char s[3];
   cin >> s;

   if(s[0] == s[1] && s[1]== s[2])
   {
       cout << "No" << endl;
   }
   else
   {
       cout << "Yes" << endl;
   }
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;

int main()
{
  int n,m,h,k;
  while(true)
    {
      cin >> n >> m >> h >> k;
      if(n+m+h+k == 0)
	break;
      vector<int> s,now;
      s.resize(n),now.resize(n);
      for(int i=0;i<n;i++)
	cin >> s[i],now[i] = i;
      vector<P> ab,edge;

      ab.resize(m),edge.resize(m);
      for(int i=0;i<m;i++)
	{
	  cin >> ab[i].S >> ab[i].F;
	  edge[i] = P(-1,-1);
	  ab[i].S--;
	}
	  sort(ab.begin(),ab.end());


      for(int i=0;i<m;i++)
	{
	  edge[i] = P(now[ab[i].S],now[ab[i].S+1]);
	  swap(now[ab[i].S],now[ab[i].S+1]);
	}
      int sum = 0;
      map<int,bool> exist;
      vector<int> new_pos;
      new_pos.resize(n);
      for(int i=0;i<n;i++) 
	new_pos[now[i]] = i;

      for(int i=0;i<k;i++)
	sum += s[new_pos[i]],exist[i] = true;
 
      
      int ans = sum;
      for(int i=0;i<m;i++)
	{
	  int new_sum = sum;
     
	  if((exist[edge[i].F] && exist[edge[i].S]) || (!exist[edge[i].F] && !exist[edge[i].S]))
	    continue;

	  
	  if(!exist[edge[i].F])
	    {
	      new_sum -= s[new_pos[edge[i].S]];
	      new_sum += s[new_pos[edge[i].F]];
	    }
	  else if(!exist[edge[i].S])
	    {
	      new_sum -= s[new_pos[edge[i].F]];
	      new_sum += s[new_pos[edge[i].S]];
	    } 
	  
	  ans = min(ans,new_sum);

	}
      cout << ans << endl;

    }

  return 0;
}

Measured memory_bytes: 2640
import fractions
def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  flip = 0
  for i in range(n):
    if a[i] <0:
      a[i] *= -1
      flip += 1
  if flip %2 == 0:
   print(sum(a))
  else:
   print(sum(a)-2*min(a))
solve()

Measured memory_bytes: 16436