akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var a = consoleReader.ReadLineInt32();
            var b = consoleReader.ReadLineInt32();
            var c = consoleReader.ReadLineInt32();
            var d = consoleReader.ReadLineInt32();
            var e = consoleReader.ReadLineInt32();
            var k = consoleReader.ReadLineInt32();


            return e - a <= k ? "Yay!" : ":(";
        }

        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader)
        {
            this.consoleReader = consoleReader;
        }
        static void Main() => Console.WriteLine(new Program().Calc());
    }

    public class ConsoleReader
    {
        public virtual string ReadLine() => Console.ReadLine();
        public int ReadLineInt32() => int.Parse(ReadLine());
        public long ReadLineInt64() => long.Parse(ReadLine());
        public ulong ReadLineUInt64() => ulong.Parse(ReadLine());
        public double ReadLineDouble() => double.Parse(ReadLine());
        public string[] ReadLineSplit() => ReadLine().Split().ToArray();
        public int[] ReadLineSplitInt32() => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public long[] ReadLineSplitInt64() => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public ulong[] ReadLineSplitUInt64() => ReadLine().Split().Select(s => ulong.Parse(s)).ToArray();
        public double[] ReadLineSplitDouble() => ReadLine().Split().Select(s => double.Parse(s)).ToArray();

        public IEnumerable<string> RepeatReadLines(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLine();
        }
        public IEnumerable<int> RepeatReadLinesInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineInt32();
        }
        public IEnumerable<string[]> RepeatReadLinesSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineSplit();
        }
    }
    static class DicExt
    {
        public static V GetOrDefault<K, V>(this Dictionary<K, V> dic, K key)
        {
            V val;
            return dic.TryGetValue(key, out val) ? val : default(V);
        }
    }
}


Measured memory_bytes: 11092
a=[]
mv=10
for i in range(5):
    n=input()
    if n[-1]!='0':
        mv=min(mv,int(n[-1]))
    a.append(int(n))

mvb=True
ans=0
t=0
for i in range(5):
    if str(a[i])[-1]==str(mv) and mvb:
        mvb=False
        t=a[i]
        continue
    ans+=a[i]
    while ans%10!=0:
        ans+=1
print(ans+t)

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

// a quote from http://www.igaris.com/math/c.pdf

#define MOD (1000000000+7)

long long C[1001][1001];

long long power( long long x, int n )
{
	if( n == 0 ) {
		return 1;
	}
	if( n % 2 ) {
		return x * power( x, n - 1 ) % MOD;
	}
	else {
		return power( x * x % MOD, n / 2 );
	}
}

long long ifac( long long x )
{
	long long f = 1;
	while( x > 1 ) {
		f *= power( x, MOD - 2 );
		f %= MOD;
		x--;
	}
	return f;
}

int main()
{
	int n, k;
	cin >> n >> k;

	// Pascal's triangle for combination
	C[0][0] = 1;
	for( int i = 1; i < 1001; i++ ) {
		for( int j = 0; j <= i; j++ ) {
			if( j == 0 || j == i ) {
				C[i][j] = C[i - 1][0];
			}
			else {
				C[i][j] = ( C[i - 1][j - 1] + C[i - 1][j] ) % MOD;
			}
		}
	}

	long long ans = 0;
	if( n <= k ) {
		ans = 1;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 10032
n,m = map(int,input().split())
stores = list()
cost = 0

for i in range(n):
    stores.append(list(map(int,input().split())))

stores = sorted(stores, key=lambda x: x[0])

for store in stores:
    if store[1] <= m:
        cost += store[0] * store[1]
        m -= store[1]
    else:
        cost += store[0] * m
        m -= store[1]
        if m <= 0:
            break

print(cost)

Measured memory_bytes: 29792
import java.util.Scanner;
import java.util.Arrays;

class Main {
  public static void main(String[] args) {
  	
  	final int N = 10;
  	int[] a = new int[N];
  	
  	Scanner sc = new Scanner(System.in);
  	
  	for(int i = 0; i < N; ++i) {
	  	a[i] = sc.nextInt();
  	}
  	
  	Arrays.sort(a);
  	
  	for(int i = 0; i < 3; ++i) {
  		System.out.println(a[N - i - 1]);
  	}
  }
}

Measured memory_bytes: 26288
#include <bits/stdc++.h>
#define ll long long
#define MOD 998244353
using namespace std;

ll mypow(ll b, ll e) {
  ll o = 1;
  while(e) {
    if(e & 1) o = o * b % MOD;
    e >>= 1;
    b = b * b % MOD;
  }
  return o;
}

int main() {
  int n, d, m = 0;
  ll o = 1;
  scanf("%d", &n);
  vector<int> num(n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &d);
    if(!i && d) o = 0;
    m = max(m, d);
    num[d]++;
  }
  if(num[0] != 1) o = 0;
  for(int i = 1; i <= m; i++) { o = o * mypow(num[i - 1], num[i]) % MOD; }
  printf("%lld\n", o);
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;  cin >> s >> t;
    vector<int> p(26, -1), q(26, -1);
    rep(i, s.size()) {
      int a = s[i] - 'a';
      int b = t[i] - 'a';
      if (p[a] != -1 || q[b] != -1) {
        if (p[a] != b || q[b] != a) {
          cout << "No" << '\n';
          return 0;
        }
      }
      p[a] = b;
      q[b] = a;
    }
    cout << "Yes" << '\n';

    return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,0,1,-1,1,-1,0,1};
//int dy[]= {1,1,1,0,0,-1,-1,-1};






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int a,b,c;
    cin >> a >> b;
    c=abs(a-b);
    if(c & 1)cout << "IMPOSSIBLE";
    else cout << (a+b)/2;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    long long N,a,b;
    // スペース区切りの整数の入力
    cin >> N >> a >> b ;
    long long q=N/(a+b);
    long long r=N%(a+b);
    if ( r > a ){
        // 出力
        cout << (q+1)*a << endl;
    } else {
        // 出力
        cout << q*a+r << endl;
    }
    return 0;
}

Measured memory_bytes: 256
include3 :: Int -> Bool
include3 x
    | x == 0    = False
    | otherwise = if x `mod` 10 == 3 then True else include3 $ x `div` 10

solve :: Int -> String
solve n = " " ++ (unwords $ map show $ filter (\x -> x `mod` 3 == 0 || include3 x) [1 .. n])

main :: IO ()
main = readLn >>= putStrLn . solve

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

using namespace std;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

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

	int res = 0;
	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j < n; ++j){
			res += d[i] * d[j];
		}
	}

	cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    if(x*2==w && y*2== h){
        printf("%0.9f",(double)w*h/2 );
        cout <<" 1" << endl;
    }else {
        printf("%0.9f",(double)w*h/2 );
        cout << " 0" << endl;
    }
    return 0;
}

Measured memory_bytes: 3740
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int n;
int main()
{
	fast;
	cin>>n;
    cout<<int (sqrt(n))*int (sqrt(n))<<endl;
    return 0;
}

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

using namespace std;

char n[10];

int main(void)
{
	scanf("%s", n);
	
	if(n[0] == '7' || n[1] == '7' || n[2] == '7')
		printf("Yes");
	else
		printf("No");
	
	return 0;
}

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

typedef long long ll;

int main() {
    ll n; cin >> n;
    ll a[5];
    fore(i, 0, 5) cin >> a[i];
    sort(a, a + 5);
    cout << 5 + (n - 1) / a[0] << endl;
    return 0;
}

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

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

#define loop(i, n) for(int i = 0;i < n;i++)
#define IINF 2e9
#define MOD 1e9+7

int main(void){

    ll a;
    long double b;
    cin >> a >> b;

    long double ans = a * b;


    cout << (ll)ans << endl;

    return 0;
}

Measured memory_bytes: 3728
import math
a,b = map(int,input().split())
a_min = math.ceil(a / 0.08)
a_max = math.floor((a + 1) / 0.08) - 1
b_min = math.ceil(b / 0.1)
b_max = math.floor((b + 1) / 0.1) - 1
 
if a_max < b_min or b_max < a_min:
  print('-1')
else:
  result = b_min if a_min <= b_min else a_min
  print(result)


Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
int main(){
  int i,N,ans;
  double A,T,H[100000],S[100000],subm=99999;
  scanf("%d",&N);
  scanf("%lf %lf",&T,&A );
  for(i=1;i<N+1;i++){
  scanf("%lf",&H[i] );
  S[i]=T-H[i]*0.006;
  S[i]=fabs(A-S[i]);
  if(S[i]<subm){
  subm=S[i];
  ans=i;
}
}
printf("%d",ans);
}




Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();

		n = n.replace("1", "a");
		n = n.replace("9", "1");
		n = n.replace("a", "9");

		System.out.println(n);
	}
}


Measured memory_bytes: 22868
import bisect
import collections
N,M = map(int, input().split())
q = [[int(j) for j in input().split()] for i in range(M)]
li = collections.defaultdict(list)

for i,j in sorted(q):
    li[i].append(j)

for p,y in q:
    z = bisect.bisect(li[p],y)
    print("{:0=6}".format(p) + "{:0=6}".format(z))

Measured memory_bytes: 43012
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N;
    cin >> N;
    struct Match {
        ll a;
        ll b;
        Match(ll x, ll y) {
            a = min(x, y);
            b = max(x, y);
        }
        static bool comp(Match lhs, Match rhs) {
            return lhs.a < rhs.a || (lhs.a == rhs.a && lhs.b < rhs.b);
        }
    };
    vector<vector<Match>> matches(N);
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N-1; j++) {
            ll A;
            cin >> A;
            A--;
            matches[i].push_back(Match(i, A));
        }
    }
    set<Match, decltype(&Match::comp)> hoped_one(&Match::comp);
    set<Match, decltype(&Match::comp)> hoped_two(&Match::comp);
    for (ll i = 0; i < N; i++) {
        Match m = matches[i].back();
        if (hoped_one.find(m) == hoped_one.end()) {
            hoped_one.insert(m);
        } else {
            hoped_one.erase(m);
            hoped_two.insert(m);
        }
    }
    ll day = 1;
    while (true) {
        set<Match, decltype(&Match::comp)> today = move(hoped_two);
        while (!today.empty()) {
            Match m = *today.begin();
            today.erase(m);
            for (ll i : {m.a, m.b}) {
                matches[i].pop_back();
                if (!matches[i].empty()) {
                    Match n = matches[i].back();
                    if (hoped_one.find(n) == hoped_one.end()) {
                        hoped_one.insert(n);
                    } else {
                        hoped_one.erase(n);
                        hoped_two.insert(n);
                    }
                }
            }
        }
        if (hoped_two.empty()) {
            if (hoped_one.empty()) {
                cout << day << endl;
                return 0;
            } else {
                cout << -1 << endl;
                return 0;
            }
        }
        day++;
    }
}



Measured memory_bytes: 16384
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

constexpr int INF = (1 << 30);

string a, b, c;

void input(void) { cin >> a >> b >> c; }

vector<int> merge_ab(20001, 1), merge_bc(20001, 1), merge_ca(20001, 1);

void build(void) {
	auto judge = [](char c1, char c2) {
		return (c1 == '?' || c2 == '?' || c1 == c2);
	};
	for (int i = 0; i < (int)a.size(); ++i)
		for (int j = 0; j < (int)b.size(); ++j)
			merge_ab[i - j + 10000] &= judge(a[i], b[j]);
	for (int i = 0; i < (int)b.size(); ++i)
		for (int j = 0; j < (int)c.size(); ++j)
			merge_bc[i - j + 10000] &= judge(b[i], c[j]);
	for (int i = 0; i < (int)c.size(); ++i)
		for (int j = 0; j < (int)a.size(); ++j)
			merge_ca[i - j + 10000] &= judge(c[i], a[j]);
}

int main(void) {
	input(); build();
	int res = INF;
	for (int b_st = -5000; b_st <= 5000; ++b_st) {
		if (!merge_ab[b_st + 10000]) continue;
		for (int c_st = -5000; c_st <= 5000; ++c_st) {
			bool ok = merge_bc[c_st - b_st + 10000] && merge_ca[-c_st + 10000];
			if (!ok) continue;
			int r = max({ (int)a.size(), (int)b.size() + b_st, (int)c.size() + c_st });
			int l = min({ 0, b_st, c_st });
			res = min(res, r - l);
		}
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;

int main() {
	long long int x, y;
	cin >> x >> y;
	vector<int> v;
	while (x <= y) {
		v.push_back(1);
		x *=2;
	}

	cout << v.size() << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
		 static ArrayList<HashMap<Integer, Integer>> w = new ArrayList<HashMap<Integer, Integer>>();
		 static long a_dist[];
		 static int[][] c;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);

	        int N = sc.nextInt();
	        a_dist = new long[N];
	        for(long i=0;i<N;i++)list.add(new ArrayList<Integer>());
	        for(int i = 0; i < N; i++)w.add(new HashMap<Integer, Integer>());
	        for(long i=0;i<N-1;i++) {
	        	int ai = sc.nextInt()-1;
	        	int bi = sc.nextInt()-1;
	        	int ci = sc.nextInt();
	        	list.get(ai).add(bi);
	        	list.get(bi).add(ai);
	        	w.get(ai).put(bi,ci);
	        	w.get(bi).put(ai,ci);
	        }
	        
	        int Q = sc.nextInt();
	        int K = sc.nextInt();
	        StringBuffer ans= new StringBuffer();
	        dfs(K-1,0,-1);
	        for(long i=0;i<Q;i++) {
	        	int x = sc.nextInt()-1;
	        	int y = sc.nextInt()-1;
	        	ans.append(a_dist[x]+a_dist[y]);
	        	ans.append("\n");
	        }
	        
	        
	        
	        System.out.println(ans);
	        

	    }
	    
		static void dfs(int now, long cnt, int parent) {
			a_dist[now]=cnt;
			for(int i=0;i<list.get(now).size();i++) {
				int next = list.get(now).get(i);
				int d = w.get(now).get(next);
				if(next == parent)continue;
				dfs(next, cnt+d, now);
			}
		}
	    

	}
	

Measured memory_bytes: 219336
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
int main() {
    long long mny=100,x , ans=0;
    cin >> x;
    while(mny<x){
        mny*=1.01;
        ans++;
    }


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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,C,K,ans=1;
  cin >>N >>C >>K;
  vector<int> A(N,0);
  for(int i=0; i<N; i++){
    int t;
    cin >>t;
    A[i]=t;
  }
  sort(A.begin(), A.end());
  int z=0;
  for(int i=0; i<N; i++){
    if(A[i]-A[z]>K || i-z>=C){
      ans++;
      z=i;
    }
//   cout<<"i:"<<i<<" A[i]:"<<A[i]<<" A[z]"<<A[z]<<" ans:"<<ans<<endl;
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)
#define Mod 1000000007
typedef long long ll;
int n, k;
int a[100005], memo[100005];
int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	//write; read;
#endif 
	memset(memo, 0, sizeof memo);
	cin >> n >> k;
	for (int i = 1; i <=n; i++)
		cin >> a[i];

	for(int i=1;i<=k;i++)
		for (int j = 1; j <= n; j++)
		{
			if (i - a[j] >= 0 && memo[i - a[j]] == 0)memo[i] = 1;
		}
	
	
	if (memo[k])cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

class NumTh{
	static long Choose(long n, long k) {
		long res = 1;
		for(long i = n; i >= n - k + 1; i--) {
			res *= i;
			res /= k - n + i;
		}
		return res;
	}
}

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), P = sc.nextInt();
		long Even = 0, Odd = 0;
		for(int i = 0; i < N; i++) {
			int A = sc.nextInt();
			if(A % 2 ==0) Even++;
			else Odd++;
		}
		if(Odd == 0) {
			if(P == 0) System.out.println((long)1 << Even);
			else System.out.println(0);
		}else System.out.println((long)1 << (long)(N - 1));
	}
}

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

typedef long long  LL;
const int N=300010;
int n,m,t[N],q[N];
LL a[N],sum[N],l[N],r[N],f[N];

void calc(LL *f)
{
	LL sum=0;
	for (int i=1,top=0,pos=0; i<=n; i++)
		{
			sum+=t[i],pos=min(pos+1,top);
			while ((pos)&&(a[q[pos]]-1LL*q[pos]*i<a[q[pos-1]]-1LL*q[pos-1]*i))  pos--;
			f[i]=max(f[i-1],a[q[pos]]-1LL*q[pos]*i+1LL*i*(i+1)/2-sum);
			a[i]=f[i]+1LL*i*(i-1)/2+sum;
			while ((top)&&((a[i]-a[q[top]])*(q[top]-q[top-1])-(a[q[top]]-a[q[top-1]])*(i-q[top])>=0))  top--;
			q[++top]=i;
		}
}

void solve(int L,int R,int ty)
{
	if (L==R)  {f[L]=max(f[L],l[L-1]+r[L+1]+1-t[L]);  return;}
	int mid=(L+R-ty)>>1,top=0;  LL mx=-1LL<<60;
	solve(L,mid,ty),solve(mid+1,R,ty);
	for (int i=L-1; i<=mid; i++)
		{
			a[i]=l[i]+sum[i]+1LL*i*(i-1)/2;
			while ((top>1)&&((a[i]-a[q[top]])*(q[top]-q[top-1])-(a[q[top]]-a[q[top-1]])*(i-q[top])>=0))  top--;
			q[++top]=i;
		}
	for (int i=R,pos=1; i>mid; i--)
		{
			while ((pos<top)&&(a[q[pos]]-1LL*q[pos]*i<a[q[pos+1]]-1LL*q[pos+1]*i))  pos++;
			mx=max(mx,a[q[pos]]-1LL*q[pos]*i+1LL*i*(i+1)/2-sum[i]+r[i+1]);
			f[i]=max(f[i],mx);
		}
}

void work()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)  scanf("%d",&t[i]),f[i]=-1LL<<60;
	calc(l),reverse(t+1,t+n+1);
	calc(r),reverse(t+1,t+n+1),reverse(r+1,r+n+1);
	for (int i=1; i<=n; i++)  sum[i]=sum[i-1]+t[i];
	solve(1,n,0);
	reverse(t+1,t+n+1),reverse(f+1,f+n+1);
	reverse(l+1,l+n+1),reverse(r+1,r+n+1),swap(l,r);
	for (int i=1; i<=n; i++)  sum[i]=sum[i-1]+t[i];
	solve(1,n,1);
	reverse(t+1,t+n+1),reverse(f+1,f+n+1);
	swap(l,r),reverse(l+1,l+n+1),reverse(r+1,r+n+1);
	scanf("%d",&m);
	for (int i=1,p,x; i<=m; i++)
		scanf("%d %d",&p,&x),printf("%lld\n",max(l[p-1]+r[p+1],f[p]+t[p]-x));
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 16000
//Brick Break

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
const int inf = 2147483647;

int main (){
    int n;cin>>n;
    int a=0;
    rep(i,0,n){
        int c;cin>>c;
        if(c==1&&a==0)a=1;
        if(c==a)a++;
    }
    if(a==0){
        cout<<-1<<endl;
        return 0;
    }
    cout << n-a+1 << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
list($N, $D) = sscanf(trim(fgets(STDIN)), "%d %d");
$c = 0;
for ($i = 0; $i < $N; $i++) {
    list($X, $Y) = sscanf(trim(fgets(STDIN)), "%d %d");
    if(sqrt($X**2+$Y**2) <= $D) $c++;
}
print($c);

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int cal[18][1<<18];
int dp[1<<18][50];

int a[20],b[20];

int main(){
	int n;cin>>n;
	rep(i,n)scanf("%d",&a[i]),a[i]--;
	rep(i,n)scanf("%d",&b[i]),b[i]--;
	rep(i,n)rep(j,1<<n){
		rep(k,n){
			if(k>i&&(j>>k&1))cal[i][j]++;
			if(k<i&&!(j>>k&1))cal[i][j]++;
		}
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	rep(i,1<<n)rep(j,50){
		if(dp[i][j]==INF)continue;
		rep(k,n){
			if(i>>k&1)continue;
			int o=cal[k][i]%2;
			int D=(o==0?a[k]:b[k]);
			if(j>D)continue;
			dp[i|1<<k][D]=min(dp[i|1<<k][D],dp[i][j]+cal[k][i]);
		}
	}
	int Min=INF;
	rep(i,50){
		Min=min(Min,dp[(1<<n)-1][i]);
	}
	if(Min==INF)puts("-1");
	else cout<<Min/2<<endl;
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    long long X = 2, Y = 1 , Z = 1;
    for(int i = 2; i <= N; i++) {
        Z = Y + X;
        X = Y;
        Y = Z;
    }
    cout << Z << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  string S;
  cin >> S;
  map <char, ll> mp;
  rep(i,S.size()){
    char C = S[i];
    mp[C]++;
  }
  char X = 'a';
  rep(i,26){
    if(mp[X] == 0){
      cout << X;
      return 0;
    }
    X++;
  }
  cout << "None";
}

Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <algorithm>

using ull = unsigned long long;

int main() {
  size_t N, M;

  std::cin >> N >> M;

  std::vector<std::pair<ull, size_t>> table;
  table.reserve(N);

  for (size_t i=0; i<N; i++) {
    ull a;
    size_t b;
    std::cin >> a >> b;
    table.emplace_back(a, b);
  }

  std::sort(table.begin(), table.end());

  ull ans = 0;
  size_t cnt = M;

  for (auto p: table) {
    auto a = p.first;
    auto b = p.second;

    ans += a * std::min(b, cnt);

    if (b >= cnt) break;

    cnt -= b;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
    public static int n;
    public static int A[];
    public static int q;
    public static int M[];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        A = new int[n+1];
        for(int i=0;i<n;i++){
            A[i]= sc.nextInt();
        }
        q = sc.nextInt();
        M = new int[q+1];
        for(int i=0;i<q;i++){
            M[i]= sc.nextInt();
        }
        for(int i=0;i<q;i++){
            if(dfs(0,0,M[i])) System.out.println("yes");
            else System.out.println("no");            
        }
        sc.close();
    }

    private static boolean  dfs(int i,int sum,int ans){
        if (i==n) return sum == ans;
        if(dfs(i+1,sum,ans)) return true;
        if(dfs(i+1,sum+A[i],ans)) return true;
        return false;
    }
}


Measured memory_bytes: 26936
N,A,B,C = map(int, input().split())
l = [int(input()) for _ in range(N)]

def dfs(cur, a,b,c):
  if cur == N:
    return(abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else float("INF"))
  ret0 = dfs(cur+1, a,b,c)
  ret1 = dfs(cur+1, a+l[cur],b,c) + 10
  ret2 = dfs(cur+1, a,b+l[cur],c) + 10
  ret3 = dfs(cur+1, a,b,c+l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
import sys

a = sys.stdin.readlines()
for i in range(len(a)):
	b = a[i].split()
	m =int(b[0])
	f =int(b[1])
	r =int(b[2])
	if m*f < 0 :
		print "F"
	elif m==-1 and f==-1 and r==-1:
		break
	else:
		if m+f >= 80:
			print "A"
		elif 80 > m+f >=65:
			print "B"
		elif 65 > m+f >=50:
			print "C"
		elif 50 > m+f >=30 and r < 50:
			print "D"
		elif 50 > m+f >=30 and r >= 50:	
			print "C"
		elif 30 > m+f:
			print "F"

Measured memory_bytes: 6468
#include <stdio.h>

void Process(int A[ ], int n){
	int i;
	for(i=0;i<n-1;i++)
		printf("%d ",A[i]);
	printf("%d\n",A[i]);
}

void InsertionSort(int A[ ], int n){
	int i,j,v;
	for(i=1;i<n;i++){
		v = A[i];
		j = i - 1;
		while(j>=0 && A[j]>v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		Process(A, n);

	}
}



int main(void){
	int i,N;
	scanf("%d",&N);
	int A[100];
	for(i=0;i<N;i++)
		scanf("%d",&A[i]);
	Process(A, N);
	InsertionSort(A, N);
	
	
	return 0;


}

Measured memory_bytes: 1768
using System;

namespace AOJ
{
    class DrawingLots
    {
        public static void Main()
        {
            int lines = int.Parse(Console.ReadLine());
            int vlines = int.Parse(Console.ReadLine());

            // あみだくじの初期化
            int[] answer = new int[lines + 1];
            for (int i = 1; i <= lines; i++) { answer[i] = i; }
            // あみだくじ実行
            for (int i = 0; i < vlines; i++)
            {
                var input = Console.ReadLine().Trim().Split(',');
                int a = int.Parse(input[0]);
                int b = int.Parse(input[1]);
                // 位置を入れ替える
                int tmp = answer[a];
                answer[a] = answer[b];
                answer[b] = tmp;
            }

            for (int i = 1; i <= lines; i++) { Console.WriteLine(answer[i]); }
        }
    }
}

Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int a,b;
  char op;
  int res=0;
  cin >> a>>op>>b;

  if(op=='+') res=a+b;
  else res=a-b;

  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            int n = in.nextInt();
            in.nextLine();
            int[] num = new int[n];
            for(int i=0;i<n;i++){
                num[i] = in.nextInt();
            }
            Arrays.sort(num);                                        //排序
            if(n==0 || n==1)
                System.out.println(0);
            if(n == 2)
                System.out.println(num[1]-num[0]);
            boolean b  = false;
            if(n>2) b  = true;
            int start = 1;
            int end = n-2;
            int max = num[n-1];
            int min = num[0];
            long abs = num[n-1]-num[0];
            while(start <= end){
                if(start == end){                              //最后剩下1个元素的情况
                    abs += Math.max(Math.abs(num[start]-min),Math.abs(num[start]-max));
                    break;
                }
                int maxt = num[end];
                int mint = num[start];
                abs += Math.abs(min-maxt);
                abs += Math.abs(max-mint);
                min = mint;
                max = maxt;
                start++;
                end--;
            }
            if(b)
            System.out.println(abs);
        }
    }
}


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

int main() {

    int n, k;
    cin >> n >> k;
    k--;
    int arr[n];
    for (int i=0; i<n; i++) {
        cin >> arr[i];
    }
    sort(arr, arr+n);
    int mx = INT_MAX;
    for (int i=0; i<n-k; i++) {
        mx = min(mx, abs(arr[i]-arr[i+k]));
    }
    cout << mx;

}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
const int MAXS = 20;
const int MAXW = 3;
const char* W[] = {
  "Sunny", "Cloudy", "Rainy"
};
char S[MAXS];

int solve() {
  for (int i = 0; i < MAXW; ++i) {
    if (strcmp(S, W[i]) == 0) {
      return (i + 1) % MAXW;
    }
  }
  return 0;
}

int main() {
  scanf(" %s", S);
  puts(W[solve()]);
  return 0;
}

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

int main(){

  ll y = 2019;
  ll l, r;
  cin >> l >> r;

  ll minmin = 2019;
  
  vector<ll> m;
  for(ll i=0; i<2019*2; i++){
    if(l+i > r){
      break;
    }
    m.push_back((l+i)%y);
  }
  
  for(ll i=0; i<m.size(); i++){
  	for(ll j=i; j<m.size(); j++){
      if(i == j){
      	continue;
      }
      ll mulmod = (m[i] * m[j]) % y;
      minmin = min(mulmod, minmin);
    }
  }
  
  cout << minmin << endl;
   
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

const (
	// 初期バッファサイズ
	initialBufSize = 10000
	// バッファサイズの最大値。Scannerは必要に応じこのサイズまでバッファを大きくして各行をスキャンする。
	// この値がinitialBufSize以下の場合、Scannerはバッファの拡張を一切行わず与えられた初期バッファのみを使う。
	maxBufSize = 1000000
)

func main() {

	var wtr = bufio.NewWriter(os.Stdout)
	var sc = bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)

	var A, B, M int
	sc.Scan()
	temp := strings.Split(sc.Text(), " ")
	A, _ = strconv.Atoi(temp[0])
	B, _ = strconv.Atoi(temp[1])
	M, _ = strconv.Atoi(temp[2])

	a := make([]int, A)
	b := make([]int, B)

	amin := math.MaxInt64
	bmin := math.MaxInt64

	sc.Scan()
	for i, s := range strings.Split(sc.Text(), " ") {
		a[i], _ = strconv.Atoi(s)
		if a[i] < amin {
			amin = a[i]
		}
	}
	sc.Scan()
	for i, s := range strings.Split(sc.Text(), " ") {
		b[i], _ = strconv.Atoi(s)
		if b[i] < bmin {
			bmin = b[i]
		}
	}

	min := amin + bmin

	for j := 0; j < M; j++ {
		sc.Scan()
		temp := strings.Split(sc.Text(), " ")
		//fmt.Println(temp)
		x, _ := strconv.Atoi(temp[0])
		y, _ := strconv.Atoi(temp[1])
		c, _ := strconv.Atoi(temp[2])
		t := a[x-1] + b[y-1] - c
		if t < min {
			min = t
		}
	}

	fmt.Fprintln(wtr, min)
	_ = wtr.Flush()
}


Measured memory_bytes: 13372
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}

int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string N,M;
	//int ans = 1;
	//ll ans = 10000000000000000000ll;
	cin >> N;
	bool ans = false;
	for (int i = 0; i < N.size(); i++)
	{
		if (N.at(i) == '7')
		{
			ans = true;
		}
	}
	if (ans)cout << "Yes" << endl;
		else cout << "No" << endl;
	/*int N;
	cin >> N;
	vector<int> data(N);
	ll sum = 0;
	for (int i = 0; i < N; i++)
	{
		data[i] = i+1;
		if ((data[i] % 3 == 0) && (data[i] % 5 == 0))
		{
			data[i] = 0;
		}
		else if(data[i]%3 == 0)
		{
			data[i] = 0;
		}
		else if (data[i] % 5 == 0)
		{
			data[i] = 0;
		}
		sum += data[i];
			 
	}
	cout << sum << endl;*/

	return 0;

	


}


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

int main() {
  int n, k, s;
  cin >> n >> k >> s;
  
  if(s != 1000000000) {
    if(n != k) {
      for(int i=0; i<k; i++) {
        cout << s << " ";
      }
      for(int i=k; i<n; i++) {
        if(i == n - 1) {
          cout << 1000000000 << endl;
        }
        else {
          cout << 1000000000 << " ";
        }
      }
    }
    else {
      for(int i=0; i<n; i++) {
        if(i == n - 1) {
          cout << s << endl;
        }
        else {
          cout << s << " ";
        }
      }
    }
  }
  else {
    if(n != k) {
      for(int i=0; i<k; i++) {
        cout << 1000000000 << " ";
      }
      for(int i=k; i<n; i++) {
        if(i == n - 1) {
          cout << 1 << endl;
        }
        else {
          cout << 1 << " ";
        }
      }
    }
    else {
      for(int i=0; i<n; i++) {
        if(i == n - 1) {
          cout << 1000000000 << endl;
        }
        else {
          cout << 1000000000 << " ";
        }
      }
    }
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
long long N, K;
const int MOD = 1000000007;
long long dp[101][110000] = {};
long long S[110000] = {};
long long num[110000];

int solve() {
    int M = 0;
    for(int i=1; i<=N;) {
        int j = N / i;
        if(i <= j) {
            num[M++] = 1; 
            ++i;
        } else {
            num[M++] = N / j - i + 1;
            i = N / j + 1;
        }
    }

    dp[0][0] = 1;
    for(int k=0; k<K; ++k) {
        memset(S, 0, sizeof(S));
        for(int j=0; j<M; ++j) S[j + 1] = (S[j] + dp[k][j]) % MOD;
        for(int j=0; j<M; ++j) dp[k + 1][j] = (S[M - j] * num[j]) % MOD;
    }

    int res = 0;
    for(int j=0; j<=M; ++j) res = (res + dp[K][j]) % MOD;
    return res;
}

int main() {
    cin >> N >> K;
    cout << solve() << endl;
}

Measured memory_bytes: 87680
ma = lambda : map(int,input().split())
ni = lambda : int(input())
import math
ceil = math.ceil
n = ni()
csf = []
for i in range(n-1):
    csf.append(tuple(ma()))
for i in range(n-1):
    ans = csf[i][1] + csf[i][0]
    for j in range(i+1,n-1):
        if ans<=csf[j][1]:
            ans =csf[j][1]+csf[j][0]
        else:
            ans = ceil(ans/csf[j][2])*csf[j][2] +csf[j][0]
    print(ans)
print(0)


Measured memory_bytes: 3188
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

    int h,a;
    cin >> h >> a;

    cout << (h+a-1)/a << endl;
    
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc153.contest.atcoder.jp/tasks/abc153_b

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

static int N, M, visit[100000] = {}, DP[100000] = {}, ANS = 0;
static vector<int> V[100000];

int Next(int X) {
	if (visit[X] == 1) return DP[X];
	visit[X] = 1;
	int RET = 0;
	for (int Y : V[X]) {
		RET = max(RET, Next(Y) + 1);
	}
	return DP[X] = RET;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int X, Y;
		cin >> X >> Y;
		X--, Y--;
		V[X].push_back(Y);
	}
	for (int i = 0; i < N; i++) ANS = max(ANS, Next(i));
	cout << ANS << endl;
}

Measured memory_bytes: 8576
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
  
using namespace std;

#define pi 3.141592653589793

bool canalldel(char g[31][31], int h, int w, int n)
{
	char nowg[31][31];
	bool candel[31][31];
	bool isend = true;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			nowg[i][j] = g[i][j];
			candel[i][j] = false;
		}
	}
	for(int i = 0; i < w; i++){
		for(int j = h - 1; j >= 0; j--){
			int dropnum = 0;
			while(nowg[j - dropnum][i] == '.' && j - dropnum >= 0){
				dropnum++;
			}
			if(dropnum == j + 1 || dropnum == 0) continue;
			nowg[j][i] = nowg[j - dropnum][i];
			nowg[j - dropnum][i] = '.';
		}
	}
	for(int i = 0 ; i < h; i++){
		for(int j = 0; j < w; j++){
			int samemasnum = 1;
			if(nowg[i][j] == '.') continue;
			while(i + samemasnum < h && nowg[i][j] == nowg[i + samemasnum][j]){
				samemasnum++;
			}
			if(samemasnum >= n){
				for(int k = 0; k < samemasnum; k++){
					candel[i + k][j] = true;
				}
				isend = false;
			}
			samemasnum = 1;
			while(j + samemasnum < w && nowg[i][j] == nowg[i][j + samemasnum]){
				samemasnum++;
			}
			if(samemasnum >= n){
				for(int k = 0; k < samemasnum; k++){
					candel[i][j + k] = true;
				}
				isend = false;
			}
		}
	}
	if(isend) return false;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(candel[i][j]) nowg[i][j] = '.'; 
		}
	}
	isend = true;
	for(int i = 0; i < w; i++){
		for(int j = h - 1; j >= 0; j--){
			int dropnum = 0;
			if(nowg[j][i] != '.') isend = false;
		}
	}
	if(isend) return true;
	else return canalldel(nowg, h, w, n);
}

void solve(char g[31][31], int h, int w, int n)
{
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w - 1; j++){
			if(g[i][j] != g[i][j + 1]){
				swap(g[i][j], g[i][j + 1]);
				if(canalldel(g, h, w, n)){
					cout << "YES" << endl;
					return;
				}
				swap(g[i][j], g[i][j + 1]);
			}
		}
	}
	cout << "NO" << endl;
	return;
}

int main()
{
	int h, w, n;
	char game[31][31];
	cin >> h >> w >> n;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> game[i][j];
		}
	}
	solve(game, h, w, n);
	return 0;
}

Measured memory_bytes: 1220
s = gets.chomp.chars
q = gets.to_i
querys = q.times.map{gets.chomp.split}
rev_cnt = 0
querys.each do |t,f,c|
  if t == "1"
    rev_cnt += 1
  else
    if rev_cnt.even?
      if f == "1"
        s.unshift(c)
      else
        s.push(c)
      end
    else
      if f == "1"
        s.push(c)
      else
        s.unshift(c)
      end
    end
  end
end
if rev_cnt.odd?
  s.reverse!
end
puts s.join

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

int main(void) {
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0, j = S.length()-1; i <= j; i++, j--) {
		if (S[i] != S[j]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*author : Sparsh Sinha */
#include "bits/stdc++.h"
using namespace std;
int main(){
       string s;
       cin >> s;
       for(int i = 0; i < (int) s.length(); i++){
           if(s[i] == '7'){
               cout << "Yes\n";
               return 0;
           }
       }
       cout << "No\n";
}

Measured memory_bytes: 3624
n,m=map(int,input().split())
d=dict()
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6+10
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
for i in range(1,int(m**0.5)+1):
  cnt=0
  while m%(i+1)==0:
    cnt+=1
    m//=(i+1)
  if cnt>0:
    if i+1 not in d:
      d[i+1]=cnt
    else:
      d[i+1]+=cnt
if m>1:
  if m not in d:
    d[m]=1
  else:
    d[m]+=1
d=list(d.items())
ans=1
for p,root in d:
  ans*=cmb(root+n-1,n-1,mod)
  ans%=mod
print(ans%mod)

Measured memory_bytes: 128724
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
typedef long long LL; 
const LL INF = 1e16; 
const int MAX_N = 55; 
const int MAX_V = 2e5 + 5; 
struct Graph { int to, next; } e[MAX_N << 1]; 
int fir[MAX_N], e_cnt; 
void clearGraph() { memset(fir, -1, sizeof(fir)); e_cnt = 0; } 
void Add_Edge(int u, int v) { e[e_cnt] = (Graph){v, fir[u]}, fir[u] = e_cnt++; } 

struct node { LL val, wei; bool op; } a[MAX_N]; 
bool operator < (const node &l, const node &r) 
    { return 1ll * l.val * r.wei > 1ll * l.wei * r.val; } 
int N, X, D; 
void dfs(int x) { 
	for (int i = fir[x]; ~i; i = e[i].next) { 
		int v = e[i].to; 
		dfs(v); 
		a[x].val += a[v].val; 
		a[x].wei += a[v].wei; 
	} 
} 
int V, lim;
LL f[MAX_V]; 
void ins(LL w, LL v) { 
	for (int i = V; i >= v; i--) 
        f[i] = min(f[i], f[i - v] + w); 
} 
void add(node p) { 
	int t = lim; 
	for (int i = 0; 1 << i <= t; i++) 
		ins(p.wei * (1 << i), p.val * (1 << i)), t -= 1 << i; 
	if (t) ins(p.wei * t, p.val * t); 
} 
int main () { 
	clearGraph(); 
	scanf("%d %d %d", &N, &X, &D); 
	scanf("%lld", &a[1].wei), a[1].val = 1, a[1].op = 1; 
	for (int i = 2; i <= N; i++) { 
		int w, fa; scanf("%d %d", &w, &fa); 
		a[i].wei = w, a[i].val = 1, Add_Edge(fa, i); 
	} 
	dfs(1); 
	lim = min(N, D); 
	V = N * N * N; 
	for (int i = 0; i <= V; i++) f[i] = INF; 
	f[0] = 0; 
	for (int i = 1; i <= N; i++) add(a[i]); 
	sort(&a[1], &a[N + 1]); 
	while (!a[N].op) --N; 
	LL ans = 0; 
	for (int i = 0; i <= V; i++) { 
		if (f[i] > X) continue; 
		LL val = i, wei = f[i]; 
		for (int j = 1; j < N; j++) { 
			LL cnt = min(1ll * D - lim, (X - wei) / a[j].wei); 
			val += cnt * a[j].val, wei += cnt * a[j].wei; 
		} 
		LL cnt = (X - wei) / a[N].wei; 
		ans = max(ans, val + cnt * a[N].val); 
	} 
	printf("%lld\n", ans); 
    return 0; 
} 

Measured memory_bytes: 1280
N, K = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
dp = [0] * N

for i in range(1, N):
    L = []
    for j in range(max(0, i-K), i):
        L.append(dp[j] + abs(H[i] - H[j]))
    dp[i] = min(L)
print(dp[-1])

Measured memory_bytes: 52448
import java.util.*

fun main(args: Array<String>) {
    val (W, H, N) = readLine()!!.split(" ").map{it.toInt()}
    val st = Array(H + 2) { TreeSet<Int>() }

    for (i in 1..N) {
        val (x, y) = readLine()!!.split(" ").map{it.toInt()}
        st[y].add(x)
    }

    for (i in 1 .. H + 1) {
        st[i].add(W + 1)
    }

    var x = 1
    var y = 1
    var res = W
    while(x <= W) {
        res = Math.min(res, (st[y].higher(x) ?: res + 1) - 1)
        x++
        if (y < H && !st[y + 1].contains(x)) {
            y++
        }
    }

    println(res)
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <limits>
#include <iomanip>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class AAtCoderBeginnerContest999 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string n;in>>n;
	    rep(i,3){
	        out<<((n[i]=='1') ? 9 : 1);
	    }
	}
};


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


Measured memory_bytes: 3168
import numpy as np

H,W = map(int,input().split())
A = []
for i in range(H):
    A.append([0 if i == "#" else H+W for i in list(input())])
A = np.array(A)

for i in range(H-1):
  A[i+1, :] = np.minimum(A[i, :] + 1, A[i+1, :])
for i in range(H-1,0,-1):
  A[i-1,:] = np.minimum(A[i,:]+1,A[i-1,:])
for i in range(W-1):
  A[:,i+1] = np.minimum(A[:,i]+1,A[:,i+1])
for i in range(W-1,0,-1):
  A[:,i-1] = np.minimum(A[:,i]+1,A[:,i-1])
print(np.max(A))

Measured memory_bytes: 63032
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
using namespace std;
const int SIZE=5*1e5;
const int INF=1<<30;
LL A[SIZE],B[SIZE],C[SIZE],D[SIZE];
string s;
LL calc(LL a,LL b){
	return min(min(a+b,24-(a+b)),abs(a-b));
}
int solve(){
	int N;
	LL last=0,minium=INF;
	cin >> N;
	FOR(i,1,N+1){
		cin >> D[i];
		minium=min(minium,D[i]);
		if(D[i]==0) return 0;
		C[D[i]]++;
		if(C[D[i]]>=3) return 0;
	}
	if(C[12]==2) return 0;
	bool now=0;
	FOR(i,1,12+1){
		if(C[i]==2){
			B[i]=1;
			B[24-i]=1;
		}
		else if(C[i]==1){
			if(now){
				B[i]=1;
			}else{
				B[24-i]=1;
			}
			now^=true;
		}
	}
	FOR(i,1,48){
		if(B[i%24]){
			minium=min(minium,abs(last-i));
			last=i;
		}
	}
	return minium;
}
int main(){
 	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 4352
coins = list(map(int, input().split()))
for i in range(len(coins)):
    current_coin = coins[i]
    if i == 0:
        coins[i] = current_coin * 1
    elif i == 1:
        coins[i] = current_coin * 5
    elif i == 2:
        coins[i] = current_coin * 10
    elif i == 3:
        coins[i] = current_coin * 50
    elif i == 4:
        coins[i] = current_coin * 100
    elif i == 5:
        coins[i] = current_coin * 500

if sum(coins) >= 1000:
    print('1')
else:
    print('0')

Measured memory_bytes: 7732