akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n, m;
  cin >> n >> m;
  cout << (n > m? "No": "Yes") << endl;
  return 0;
}


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

int main(){
  ll n,k;
  cin>>n>>k;
  ll p[5005],c[5005];
  rep(i,n){
    cin>>p[i];
    p[i]--;
  }
  rep(i,n){
    cin>>c[i];
  }

  vector<P> cycle_cost(n,{-2,0});
  rep(st,n){
    if(cycle_cost[st].first!=-2) continue;
    ll now=p[st];
    ll score=c[st],cnt=1;
    while(now!=st){
      score+=c[now];
      cnt++;
      now=p[now];
    }
    if(score<0) score=-1;
    rep(i,cnt){
      cycle_cost[now].first=score;
      cycle_cost[now].second=cnt;
      now=p[now];
    }
  }

  /*
  for(auto x:cycle_cost){
    cout<<x.first<<' '<<x.second<<endl;
  }
  */
  
  ll ans=-1e18;
  rep(st,n){
    ll now=st;
    ll score=0;
    ll cnt=0;
    if(cycle_cost[now].first<0){
      rep(i,cycle_cost[st].second){
	if(cnt>=k) break;
	now=p[now];
	score+=c[now];
	ans=max(score,ans);
	cnt++;
      }
    }
    else{
      ans=max(cycle_cost[st].first*(k/cycle_cost[st].second),ans);
      rep(i,cycle_cost[st].second){
	if(cnt>=k) break;
	now=p[now];
	score+=c[now];
	cnt++;
	ll ma=score;
	ma+=cycle_cost[st].first*((k-cnt)/cycle_cost[st].second);
	ans=max(ma,ans);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  double sum=0;
  for (int i=0;i<N;i++){
    double x;
    string u;
    cin >> x >> u;
    if (u=="JPY"){
      sum+=x;
    }
    else {
      sum+=x*380000;
    }
  }
  cout << fixed << setprecision(5);
  cout << sum << endl;
}

Measured memory_bytes: 256
N,A,B,C,D = map(int,input().split())
S = input()
A_start = True
if C < D:
  space1 = S[A-1:D]
  if ('##' in space1) != True:
    print('Yes')
  else:
    print('No')
else:
  space1 = S[A-1:C]
  space2 = S[B-2:D+1]
  if ('##' in space1) != True and ('...' in space2) == True:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 9380
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void)
{
    int i, a, k, b;
    scanf("%d%d%d", &k, &a, &b);
    for (i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            printf("OK\n");
            return 0;
        }
    }
    printf("NG\n");
    return 0;
}

Measured memory_bytes: 1664
from collections import deque

H, W = map(int, input().split())
S = [list(input().rstrip('\n') ) for _ in range(H)]

moves = [[-1,0], [1,0], [0,-1], [0,1]]



min_val = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            continue
        todo = deque([[i,j]])
        
        shortest = [[-10e+10 for _ in range(W)] for _ in range(H)]
        shortest[i][j] = 0
        
        while len(todo) > 0:
            checking = todo.popleft()
            for move in moves:
                if checking[0] + move[0] >= 0 and checking[0] + move[0] < H and checking[1] + move[1] >= 0 and checking[1] + move[1] < W:
                    if shortest[checking[0]+move[0]][checking[1]+move[1]] == -10e+10 and S[checking[0]+move[0]][checking[1]+move[1]] == ".":
                        shortest[checking[0]+move[0]][checking[1]+move[1]] = shortest[checking[0]][checking[1]]+1
                        todo.append([checking[0]+move[0],checking[1]+move[1]])
        if min_val < max([max(row) for row in shortest]):
            min_val = max([max(row) for row in shortest])
print(min_val)

Measured memory_bytes: 3316
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
using std::vector;
using std::sort;
vector<int> item(100);
int main(){
    int N,M,sum;
    sum = 0;
    cin >> N >> M;
    for(int i=0;i<N;i++){
        cin >> item[i];
        sum += item[i];
    }
    
    sort(item.begin(),item.begin()+N);
    double c;
    c = sum/4.0/M;
    int flag = 0;
    for(int i=N-1;i>N-1-M;i--){
        if(double(item[i])<c){
            flag = 1;
            break;
        }
    }


    if(flag){
        cout << "No";
    }else{
        cout <<"Yes";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B;
  if(A>B){
    C=A+A-1;
  }
  else if(A<B){
    C=B+B-1;
  }
  else if(A=B){
    C=A+B;
  }
  cout << C << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H, W; string s[509];
int main() {
	cin >> H >> W;
	for(int i = 0; i < H; i++) {
		cin >> s[i];
		for(int j = 0; j < W; j++) {
			cout << (j != W - 1 && (s[i][j] == '#' || j == 0 || i % 2 == 0) ? '#' : '.');
		}
		cout << endl;
	}
	cout << endl;
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			cout << (j != 0 && (s[i][j] == '#' || j == W - 1 || i % 2 == 1) ? '#' : '.');
		}
		cout << endl;
	}
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  int i,j,n,m,work,p[10001],sum=0,k;
  
  while(1){
    scanf("%d %d",&n,&m);
    if(n==0&&m==0) break;
    
    for(i=0;i<n;i++){
      scanf("%d",&p[i]);
      sum+=p[i];
    }
    
    for(i=0;i<n;i++){
      for(j=0;j<n-1;j++){
	if(p[j]<p[j+1]){
	  work = p[j];
	  p[j] = p[j+1];
	  p[j+1] = work;
	}
      }
    }
    
    for(i=1,k=1;i<=n;i++){
      if(i==k*m){
	k++;
	sum-=p[i-1];
      }
    }
    
    printf("%d\n",sum);
    sum = 0;
  }
    
  

  return 0;
}

Measured memory_bytes: 608
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N = inp()
D, X = inlist()
A = []
K = [0] * N
for i in range(N):
    A.append(inp())


for i in range(N):
    for d in range(D):
        eaten_at = d*A[i] + 1
        if eaten_at <= D:
            K[i] += 1
print(sum(K)+X)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

int n, m, c[30];
#define INF 1000000;

int main(){
	int dp[30][50010];

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

	dp[0][0] = 0;
	for(int i = 1;i <= n;i++){
		dp[0][i] = INF;
	}

	for(int i = 0;i < m;i++){
		for(int j = 0;j <= n;j++){
			if(j < c[i]){
				dp[i + 1][j] = dp[i][j];
			} else {
				dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - c[i]] + 1);
			}
		}
	}

	cout << dp[m][n] << endl;

	return 0;
}

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

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

    if(S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import bisect


input = sys.stdin.readline

def main():
    N = int(input())
    L = sorted(map(int, input().strip().split()))

    bleft = bisect.bisect_left
    bright = bisect.bisect
    ans = 0

    for i, a in enumerate(L):
        if i > N-2:
            break
        for j, b in enumerate(L):
            if j > N-1:
                break
            if j <= i:
                continue
            c_right = bleft(L[j+1:], a+b)
            ans += c_right
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 53024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

int main(){
    ll N; cin >> N;
    vector<ll> a(N);
    REP(i,N) cin >> a[i];

    sort(a.begin(),a.end());
    // check
    if(N % 2 == 0){
        for(int i = 0; i < N; i += 2){
            if(a[i] != a[i+1]){
                cout << 0 << endl;
                return 0;
            }
        }
     } else {
        if(a[0] != 0){
            cout << 0 << endl;
            return 0;
        }
        for(int i = 1; i < N; i += 2){
            if(a[i] != a[i+1]){
                cout << 0 << endl;
                return 0;
            }
        }
     }
    //
    ll ans = 1;
    REP(i,N/2){
        ans *= 2;
        if(ans > MOD) ans -= MOD;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
  long long N, A, B;
  
  cin >> N >> A >> B;
  
  if (A == 0) {
    cout << 0 << endl;
    
    return 0;
  }
  
  long long a = N / (A + B);
  long long b = N - a * (A + B);
  
  if (b >= A) {
    cout << (a * A + A) << endl;
  } else {
    cout << (a * A + b) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
import os
import math


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, D = list(map(int, sys.stdin.readline().split()))
    look = 2 * D + 1
    print(math.ceil(N / look))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int long long
#define P make_pair
#define F first
#define S second
signed main(void){
    int n,m,ans,p,w;
    ans=0;
    string s;
    cin>>n>>m;
    if(m==n)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;

}


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

char s[2333];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> s + 1;
	int len = strlen(s + 1);
	if(s[len] == 's') s[len + 1] = 'e', s[len + 2] = 's';
	else s[len + 1] = 's';
	cout << s + 1;

}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;

namespace Beautiful_Strings
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var w = Console.ReadLine().ToCharArray();
            var countdict = new Dictionary<char, int>();
            for (int i = 0; i < w.Length; i++)
            {
                if (!countdict.ContainsKey(w[i]))
                {
                    countdict.Add(w[i], 0);
                }
                countdict[w[i]]++;
            }

            if (IsBeautifulStrings(countdict))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        private static bool IsBeautifulStrings(Dictionary<char, int> countdict)
        {
            var keys = countdict.Keys;
            foreach (var keyValuePair in countdict)
            {
                int count = keyValuePair.Value;
                if (count % 2 != 0)
                {
                    return false;
                }
            }
            return true;
        }
    }
}


Measured memory_bytes: 13152
from math import sqrt
from itertools import permutations

def dist(x0,y0,x1,y1):
  return sqrt((x0-x1)**2+(y0-y1)**2)

N=int(input())
x,y=[],[]
for _ in range(N):
  x_tmp,y_tmp=list(map(int,input().split()))
  x.append(x_tmp)
  y.append(y_tmp)
ls=list(permutations(list(range(N)),N))
ans=0
for l in ls:
  idx=0
  while idx+1<len(l):
    ans+=dist(x[l[idx]],y[l[idx]],x[l[idx+1]],y[l[idx+1]])
    idx+=1
print(ans/len(ls))


Measured memory_bytes: 13808
N, K = map(int, input().split())
p = list(map(int, input().split()))
SUM_P=sum(p[0:K])
all_sum_p=[SUM_P]
for i in range(N-K):
    SUM_P=SUM_P-p[i]+p[i+K]
    all_sum_p.append(SUM_P)
print((max(all_sum_p)+K)/2)

Measured memory_bytes: 24548
#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;
  int n = s.size();
  vector<int> a(26);
  rep(i, n) a[(int)(s[i] - 'a')]++;
  bool frag = false;
  rep(i, n) if (a[i]>1) frag = true;
  if (frag) cout<<"no"<<endl;
  else cout<<"yes"<<endl;
}


Measured memory_bytes: 256
#  --*-coding:utf-8-*--

def f(N, A):
    ps = sorted(filter(lambda x: x>= 0, A))
    ns = sorted(filter(lambda x: x<0, A))

    if len(ps) == 0:
        ps.append(ns.pop())
    elif len(ns) == 0:
        ns.append(ps.pop(0))

    m = 0
    ops = []

    if len(ps) == 1:
        m = ps[0]

        for x in ns:
            ops.append(str(m) + ' ' + str(x))
            m -= x

    elif len(ns) == 1:
        m = ns[0]

        for x in ps[:-1]:
            ops.append(str(m) + ' ' + str(x))
            m -= x

        ops.append(str(ps[-1]) + ' ' + str(m))
        m = ps[-1] - m

    else:
        p0 = ps.pop()
        n0 = ns.pop()
        
        for x in ns:
            ops.append(str(p0) + ' ' + str(x))
            p0 -= x

        for x in ps:
            ops.append(str(n0) + ' ' + str(x))
            n0 -= x

        ops.append(str(p0) + ' ' + str(n0))
        m = p0 - n0
        
    print(m)
    for op in ops:
        print(op)
    


def main():
    N = int(input())
    A = list(map(int, input().split()))

    f(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 17856
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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; }
ll mod_pow(ll x,ll n){
	ll res = 1;
	while(n > 0){
		if(n & 1){
			res = res * x % mod;
		}
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

int main(){
	ll n;cin>>n;
	if(n == 1){
		cout << 0 << endl;
		return 0;
	}
	ll ans = mod_pow(10,n);
	ans = (ans + mod_pow(8,n))% mod;
	if(ans < 0){
		ans += mod;
	}
	ans = (ans - 2 * mod_pow(9,n))% mod;
	if(ans<0){
		ans += mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

#define MAX_VALUE 9223372036854775807

int solve() {
	ll h, w;
	cin >> h >> w;

	vector<vector<ll>> values(h, vector<ll>(w));
	ll v;
	REPD(i, 0, h) REPD(j, 0, w) {
		cin >> v;
		values[i][j] = v;
	}
	REPD(i, 0, h) REPD(j, 0, w) {
		cin >> v;
		values[i][j] = abs(values[i][j] - v);
	}

	vector<vector<vector<bool>>> dps(h, vector<vector<bool>>(w, vector<bool>(80 * 80 * 2 + 1)));
	dps[0][0][values[0][0]] = true;
	REPD(i, 0, h) REPD(j, 0, w) {
		if (i > 0) {
			REPD(k, 0, 80 * 80 * 1) {
				if (dps[i - 1][j][k]) {
					dps[i][j][abs(k + values[i][j])] = true;
					dps[i][j][abs(k - values[i][j])] = true;
				}
			}
		}
		if (j > 0) {
			REPD(k, 0, 80 * 80 * 1) {
				if (dps[i][j - 1][k]) {
					dps[i][j][abs(k + values[i][j])] = true;
					dps[i][j][abs(k - values[i][j])] = true;
				}
			}
		}
	}

	REPD(i, 0, 80 * 80 * 2 + 1) if (dps[h - 1][w - 1][i]) RET(i);

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


Measured memory_bytes: 13936
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let h: usize = read();
    let w: usize = read();
    let n: usize = read();
    let s: Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();
    let mut color: Vec<Vec<u32>> = (0..h).map(|_| (0..w).map(|_| 0).collect()).collect();

    let mut now = 0;
    for i in 0..h {
        for j in 0..w {
            if s[i][j] == '#' {
                now += 1;
                color[i][j] = now;
            }
        }

        let mut c = 0;
        for j in 0..w {
            if c > 0 && color[i][j] == 0 {
                color[i][j] = c;
            } else if color[i][j] > 0 {
                c = color[i][j];
            }
        }

        c = 0;
        for j in 0..w {
             if color[i][j] > 0 {
                 c = color[i][j];
                 break;
             }
        }

        if c > 0 {
            for j in 0..w {
                if color[i][j] > 0 {
                    break;
                }
                color[i][j] = c;
            }
        }
    }

    for j in 0..w {
        let mut c = 0;
        for i in 0..h {
            if c > 0 && color[i][j] == 0 {
                color[i][j] = c;
            } else if color[i][j] > 0 {
                c = color[i][j];
            }
        }

        c = 0;
        for i in 0..h {
            if color[i][j] > 0 {
                c = color[i][j];
                break;
            }
        }

        for i in 0..h {
            if color[i][j] > 0 {
                break;
            }
            color[i][j] = c;
        }
    }

    for i in 0..h {
        for j in 0..w {
            if j == w - 1 {
                println!("{}", color[i][j]);
            } else {
                print!("{} ", color[i][j]);
            }
        }
    }
}


Measured memory_bytes: 2860
open System 
open System.Text

type Explicit =          
    static member inline ($) (_:int32, _:Explicit) = int
    static member inline ($) (_:int64, _:Explicit) = int64

let inline convert (value:'a): 'b = 
    (Unchecked.defaultof<'b> $ Unchecked.defaultof<Explicit>) value

let inline fromInt (x: int): 'a = convert x

module NumericLiteralG =
    let inline FromZero(): 'a = LanguagePrimitives.GenericZero
    let inline FromOne(): 'a = LanguagePrimitives.GenericOne
    let inline FromInt32 (n: int): 'a = fromInt n

let R() = Console.ReadLine()

let f (x: char): char =
    ['A' .. 'Z']
    |> List.contains x 
    |> function 
    | true -> 'A'
    | _ -> 'a'
 
let α = char <| R()

f α
|> printfn "%c" 

Measured memory_bytes: 29712
n = gets.to_i
data = n.times.map { gets.strip.split.map(&:to_i) }

def is_reachable(current, next_data)
    # 次の地点までのマンハッタン距離
    tc, xc, yc = current
    tn, xn, yn = next_data
    dist = (xc - xn).abs + (yc - yn).abs

    # 最短距離でも間に合わない
    return false if dist > tn - tc

    # 行ったり来たりでちょうど到着できるか
    (dist - (tn - tc)).even?
end

current = [0, 0, 0]
data.each do |d|
    unless is_reachable(current, d)
        puts 'No'
        exit 0
    end
    current = d
end

puts 'Yes'

Measured memory_bytes: 9468
#include <iostream>

using namespace std;

int main()
{
	//std::cout << "Hello World!\n";

	int N, a, b;
	cin >> N >> a >> b;

	//cout << a << "," << b << "," << c;

	int max = a;
	if (b < a) {
		max = b;
	}

	int min = 0;
	if (N < a + b) {

		min = a + b - N;
	}
	cout << max << " " << min;

}

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

int main(void){
 int N,M;
 cin >> N >> M;

 const int nmmax=50;
 char A[nmmax][nmmax],B[nmmax][nmmax];


 for(int y=0;y<N;++y){
 for(int x=0;x<N;++x){
 cin >> A[y][x];
 }
 }

 for(int y=0;y<M;++y){
 for(int x=0;x<M;++x){
 cin >> B[y][x];
 }
 }

 bool exist=false;

 for(int ly=0;ly<N;++ly){
 for(int lx=0;lx<N;++lx){
 if(ly+M-1>=N or lx+M-1>=N) continue;

 bool match=true;
 for(int y=0;y<M;++y){
 for(int x=0;x<M;++x){
 if(A[ly+y][lx+x]!=B[y][x]) match=false;
 }
 }
 if(match) exist=true;
 }
 }

 if(exist)
 cout << "Yes" << endl;
 else
 cout << "No" << endl;

 return 0;
 }

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
odd, four = 0, 0
for i in range(N):
  if A[i] % 4 == 0:
    four += 1
  else:
    if A[i] % 2 == 1:
      odd += 1
if four < odd and four + odd < N:
  print('No')
elif odd - four > 1 and four + odd == N:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 14252
import sys
iN = int(input())
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
aData.sort(key=lambda x:x[2],reverse=True)

for cx in range(0,101) :
    for cy in range(0,101) :
        aH = []
        uH = False
        bF = True
        for x,y,z in aData :
            d = abs(x-cx)+abs(y-cy)
            if z > 0 :
                aH.append( z + d )
            else :
                if aH[0] > d:
                    bF = False
                if uH :
                    uH = min(uH,d)
                else :
                    uH = d
        for i in range(1,len(aH)) :
            if aH[0] != aH[i] :
                bF = False
        if uH :
            if uH < aH[0] :
                bF = False
        if bF :
            print(cx,cy,aH[0])
            exit()


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

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long sum = 0;
        for(int i=0; i<n; i++) {
            a[i] = sc.nextLong()-i+n;
            sum+=a[i];
        }
        Arrays.sort(a);
        System.out.println(calc(n, a, a[n/2]));
    }

    static long calc (long n, long[]a, long d) {
        long sum = 0;
        for(int i=0; i<n; i++) {
            sum += Math.abs(a[i] - d);
        }
        return sum;
    }

}


Measured memory_bytes: 90052
X, N = map(int, input().split())
p = list(map(int, input().split()))

if N == 0:
    print(X)
else:
    p = sorted(p)
    for i in range(0, 100):
        if X-i not in p:
            print(X-i)
            break
        elif X+i not in p:
            print(X+i)
            break

Measured memory_bytes: 9188
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
S = 0
prev = -2
for i in range(n):
    now = a[i]
    S += b[now - 1]
    if now - prev == 1:
        S += c[prev - 1]
    prev = now

print(S)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=1e5+5;
ll inf=1e15;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        ll ar[n+1];
        for(int i=1;i<=n;i++)
        {
            cin>>ar[i];
        }
        bool dp[k+1];
        memset(dp,false,sizeof(dp));
        for(int i=1;i<=n;i++)
            dp[ar[i]]=true;
        for(int i=1;i<=k;i++)
        {
            for(int j=n;j>=1;j--)
            {
                if(i-ar[j]>=0)
                {
                    if(dp[i-ar[j]]==false)
                        dp[i]=true;
                }
            }
            // cout<<dp[i]<<" ";
        }
        if(dp[k])
        {
            cout<<"First"<<endl;
        }
        else
        {
            cout<<"Second"<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, m, v, t, l[5005], r[5005];
long long dp[5005][5005], a[5005], ans;
P b[205][5005];
int main(){
	scanf("%d%d", &n, &m);
	rep(i,n-1){
		scanf("%lld", a+i+1);
		a[i+1] += a[i];
	}
	rep(i,n) rep(j,m){
		scanf("%d", &v);
		b[j][i] = P(v,i);
	}
	rep(i,m){
		sort(b[i], b[i]+n);
		rep(i,n){
			l[i] = i-1;
			r[i] = i+1;
		}
		rep(j,n){
			tie(v, t) = b[i][j];
			dp[t][l[t]+1] += v;
			dp[t][t+1] -= v;
			dp[r[t]][l[t]+1] -= v;
			dp[r[t]][t+1] += v;
			if(t) r[l[t]] = r[t];
			if(t != n-1) l[r[t]] = l[t];
		}
	}
	rep(i,n) rep(j,n) dp[i][j+1] += dp[i][j];
	rep(j,n) rep(i,n){
		dp[i+1][j] += dp[i][j];
		if(i >= j) ans = max(ans, dp[i][j]-a[i]+a[j]);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 203904
import java.util.Scanner;

public class Main {
	long count = 0;

	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		StringBuilder builder = new StringBuilder();
		int[] A = new int[n];
		int[] B = new int[n];
		int K = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			A[i] = scanner.nextInt();
			K = Math.max(K, A[i]);
		}
		CountingSort(A, B, K);
		builder.append(B[0]);
		for (int i = 1; i < n; i++) {
			builder.append(' ').append(B[i]);
		}
		System.out.println(builder);
	}

	private void CountingSort(int[] a, int[] b, int k) {
		int[] C = new int[k + 1];
		for (int i = 0; i < a.length; i++)
			C[a[i]]++;

		for (int i = 1; i <= k; i++)
			C[i] += C[i - 1];

		for (int i = a.length - 1; i >= 0; i--) {
			C[a[i]]--;
			b[C[a[i]]] = a[i];

		}
	}
}

Measured memory_bytes: 561292
N,M = map(int,input().split())
ans = 0

def retCard(n,m):
    global ans
    # 特殊パターン対応
    if n == 1 and m == 1:
        ans = 1
        return 0
    if n == 2 and m == 2:
        ans = 0
        return 0
    if n == 1 or m == 1:
        ans = max(n,m) - 2
        return 0
    # 通常パターン
    ans = (n - 2) * (m - 2)
    return 0

retCard(N,M)
print(ans)

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

using namespace std;

int main(void) {
  string s;
  long long k;
  cin >> s >> k;
  k--;

  long long tmp = -1;
  string value;
  for(int i = 0; i < s.length(); i++) {
    if(s[i] != '1') {
      tmp = i;
      value.push_back(s[i]);
      break;
    }
  }

  if(k < tmp || tmp == -1) {
    cout << "1" << endl;
  }
  else {
    cout << value << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
count2 = 0
count4 = 0
for i in range(n):
    #２の倍数だが４の倍数でない
    if a[i]%2 == 0 and a[i]%4 != 0:
        count2 += 1
    #４の倍数
    elif a[i]%4 == 0:
        count4 += 1

if count4 != 0:
    count4 = count4*2

if count2 >= 2:
    count4 += count2-1

if count4 >= n-1:
    print("Yes")
else:
    print("No")

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

//highlight color RGB = [70,70,70]
#define asll unsigned long long
#define ll long long
#define ld long double
#define imt int
#define pii pair<int,int>
#define st first
#define nd second
#define kj <<" "<<
#define kjb <<" ";
#define dg <<","<<
#define ml <<endl;
#define co cout<<
#define ter cout<<endl;
#define sibi cout<<"TES"<<endl;
#define tes(x) cout<<"TES "<<x<<endl;
#define psbk(x) push_back(x);
#define For(x,a,b) for(int x=(a);x<(b);x++)
#define FOR(x,n) for(int x=0;x<(n);x++)
#define kera(x,m) for( int i = 0;i < m ; i++ ){ cout<<"x["<< i <<"] =" kj x[i] ml}
#define kpr(x) cout<<"("<<x.st dg x.nd <<")" ml
#define kkor(p) cout<<"("<<p.x dg p.y <<")" ml

asll M=1e9+7;
int n,m,tc;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(0);
	srand(time(0));
	int d,t,s;
	cin>>d>>t>>s;
	//co t*s kj d ml
	if(t*s>=d){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No" ml
	}
}


Measured memory_bytes: 3616
int main(void){
    int count=0;
    int x,y;
    int a,b,c;
    
    while(1){
    
    scanf("%d %d",&x,&y);
    if(x==0 ){
        break;
    }
    
    for(a=1;a<=x;a++){
        for(b=1+a;b<=x;b++){
            for(c=1+b;c<=x;c++){
                if(a+b+c == y){
                    count++;
                }
            }
        }
    }
    printf("%d\n",count);
    count=0;
    }
}


Measured memory_bytes: 2068
#include <stdio.h>
int main()
{
	int n,m;
	while(scanf("%d%d", &n, &m)!=EOF){
		for(int i = m/n; i >= 1; i--){
			if(m % i == 0) {
				printf("%d\n",i); 
				break;
			}
		}
	}
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int i, N;
	long double x, sum = 0.0;
	char u[4];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%Lf %s", &x, u);
		if (u[0] == 'B') sum += x * 380000.0;
		else sum += x;
	}
	printf("%Lf\n", sum);
	fflush(stdout);
	return 0;
}

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

#define count_ones __builtin_popcountl
#define all(a) a.begin(), a.end()
#define gcd(a, b) __gcd(a, b)
#define lca(a, b) a / __gcd(a, b) * b
typedef long long ll;
typedef long long ld;
using namespace std;

int main() {
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    for (ll i = 9; i >= 1; i--) {
        if (n % i == 0) {
            n /= i;
            break;
        }
    }

    cout << (n <= 9 ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
/**
 * 
 */
 
/**
 * @author kawakami
 *
 */
class Main {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner as = new Scanner(System.in);
         
        String T ="";
        String P ="";
        String TT = "";
         
        int point = 0;
        int hyouj = 0;
         
        T = as.next();
        P = as.next();
         
        TT = T;
         
        while(point != -1){
             
            point = T.indexOf(P);
            if(point != -1){
             
                T = T.substring(point+1);
                hyouj = (TT.length()-T.length())-1;
                System.out.println(String.valueOf(hyouj));
                 
            }
        }
 
    }
 
}

Measured memory_bytes: 26272
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //?§????
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

signed main() {
	int n, m;
	
	scanf("%d %d", &n, &m);
	vector<vector<int>> g(n);
	vector<int> inc(n);
		REP(i, m) {
			int a, b;
			scnaf("%d %d", &a, &b);
			a--; b--;
			g[b].push_back(a);
			inc[a]++;
		}

		queue<int> que;
		bool f = 0;
		REP(i, n) {
			if (!inc[i])
				que.push(i);
		}
		vector<int> ans;
		while (que.size()) {
			if (que.size() > 1)
				f = 1;
			int cur = que.front();
			que.pop();
			ans.push_back(cur+1);
			for(auto itr : g[cur]) {
				inc[itr]--;
				if (!inc[itr]) {
					que.push(itr);
				}
			}
		}
		for (int i = ans.size() - 1; 0 <= i; i--) {
			printf("%d\n", ans[i]);
		}
		printf("%d\n", f);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define rreps(i, a, b) for (int i = (a - 1); i >= (b); i++)

#define all(v) (v).begin(), (v).end();
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    vector<int> dp(n);

    rep(i, n)
        cin >> h[i];

    dp[1] = abs(h[1] - h[0]);

    reps(i, 2, n) {
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
    }

    cout << dp[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define maxn 100005

bool solve(int tx,int ty,int x,int y,int t)
{
    int quick=abs(tx-x)+abs(ty-y);
    if(t<quick) return false;
    else if((t-quick)%2==0) return true;
    else return false;
}

int main()
{
//    freopen("Traveling.in","r",stdin);
//    freopen("Traveling.out","w",stdout);
    
    int n;
    scanf("%d",&n);
    int t,x,y,tt=0,tx=0,ty=0;
    bool key=true;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(!solve(tx,ty,x,y,t-tt)) {key=false; break;}
        tt=t;tx=x;ty=y;
    }
    
    if(key) printf("Yes");
    else printf("No");
    return 0;
} 


Measured memory_bytes: 128
#include <stdio.h>

typedef struct {
	int key, id;
} data;

void merge_sort(data x[], int n)
{
	static data y[300001] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, H, W, M;
	data d[300001], h[300001], w[300001];
	scanf("%d %d %d", &H, &W, &M);
	for (i = 0; i < H; i++) {
		h[i].key = 0;
		h[i].id = i + 1;
	}
	for (i = 0; i < W; i++) {
		w[i].key = 0;
		w[i].id = i + 1;
	}
	for (i = 0; i < M; i++) {
		scanf("%d %d", &(d[i].key), &(d[i].id));
		h[d[i].key - 1].key++;
		w[d[i].id - 1].key++;
	}
	merge_sort(h, H);
	merge_sort(w, W);
	
	int j, l[300001], r[300001], tmp;
	merge_sort(d, M);
	for (i = 0; i < M; i++) {
		l[d[i].key] = i;
		tmp = d[i].key;
		for (j = i; j < M && d[j].key == tmp; j++) {
			d[j].key ^= d[j].id;
			d[j].id ^= d[j].key;
			d[j].key ^= d[j].id;
		}
		merge_sort(&(d[i]), j - i);
		r[d[i].id] = j - 1;
		i = j - 1;
	}
	
	int L, R;
	for (i = H - 1; i >= 0 && h[i].key == h[H-1].key; i--) {
		for (j = W - 1; j >= 0 && w[j].key == w[W-1].key; j--) {
			L = l[h[i].id];
			R = r[h[i].id];
			while (L < R) {
				if (d[(L+R)/2].key < w[j].id) L = (L + R) / 2 + 1;
				else R = (L + R) / 2;
			}
			if (d[L].key != w[j].id) break;
		}
		if (j >= 0 && w[j].key == w[W-1].key) break;
	}
	if (i >= 0 && h[i].key == h[H-1].key) printf("%d\n", h[H-1].key + w[W-1].key);
	else printf("%d\n", h[H-1].key + w[W-1].key - 1);
	fflush(stdout);
	return 0;
}

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

int main(){
    using namespace std;
    long A, B;
    cin >> A >> B;
    long ans{0};
    if(A < B)swap(A, B);
    ans += A;
    --A;
    if(A < B)swap(A, B);
    ans += A;
    --A;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from math import gcd
#import numpy as np
#import math
from fractions import Fraction
import itertools

input=sys.stdin.readline
def main():
  ans=1
  mod=1000000007
  n0=0
  na=nb=0
  n=int(input())
  d={}

  for i in range(n):
      a,b=map(int,input().split())
      if b==0 and a==0:
          n0+=1
      elif b==0:
          nb+=1
      elif a==0:
          na+=1
      else:
          g=gcd(a,b)
          if b<0:
            a*=-1
            b*=-1
          s=(a//g,b//g)
          if s not in d:
              d[s]=1
          else:
              d[s]+=1
  for k,v in d.items():
      a,b=k
      if a>0:
        if (-b,a) in d:
            if d[(a,b)]!=-1:
                ans*=pow(2,d[(-b, a)])-1+pow(2,d[(a,b)])-1+1
                ans=ans%mod
                d[(-b,a)]=-1
        else:
            ans*=pow(2,d[(a,b)])
            ans=ans%mod
            
      else:
        if (b,-a) in d:
            if d[(a,b)]!=-1:
                ans*=pow(2,d[(b, -a)])-1+pow(2,d[(a,b)])-1+1
                ans=ans%mod
                d[(b,-a)]=-1
        else:
            ans*=pow(2,d[(a,b)])
            ans=ans%mod
  ans*=pow(2,na)-1+pow(2,nb)-1+1
  print((ans-1+n0)%mod)

if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef Larra
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int N;
  cin>>N;
  map<ll, int> cnt;
  ll b = 0LL,h = 0LL;
  for(int i = 0; i < N; i++){
    ll x;
    cin>>x;
    if(cnt.count(x) == 0)
      cnt[x] = 1;
    else
      cnt[x]++;
  }
  for(auto& x : cnt){
      if(x.second >= 2 && x.first > b){
        b = x.first;
      }
  }
  if(cnt.count(b))
    cnt[b] -= 2;
  for(auto& x : cnt){
      if(x.second >= 2 && x.first > h){
        h = x.first;
      }
  }
  if(cnt.count(h))
    cnt[h] -=2;
  ll area = b*h;
  cout<<area<<"\n";
}


Measured memory_bytes: 6528
#include <stdio.h>

int main(){
    int man[10] = {0};
    int i;
    int a = 0;
    int max = 0;
    int counter = 0;
    for (i = 0; i < 10; i++) {
        scanf("%d",&man[i]);
    }
    while (counter < 3) {
        for (i = counter; i < 10; i++) {
            if (i == counter) {
                max = man[i];
            }
            else {
                if (max < man[i]) {
                    max = man[i];
                }
            }
        }
        for (i = counter; i < 10; i++) {
            if (man[i] == max){
                a = man[counter];
                man[counter] = max;
                man[i] = a;
            }
        }
        counter++;
    }
    for (i = 0; i < 3; i++) {
        printf("%d\n",man[i]);
    }
    return 0;
}

Measured memory_bytes: 600
n = int(input())

ans = n
for i in range(n + 1):
    cnt = 0
    t = i
    while t > 0:
        cnt += t % 6
        t //= 6
    j = n - i
    while j > 0:
        cnt += j % 9
        j //= 9
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//turn on extra precision
//#pragma GCC target("fpmath=387")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define watch(x) cout << (#x) << " is : " << (x) << newl

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
vi dirx = {0,0,1,-1};
vi diry = {1,-1,0,0};
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122) return char(x-32);
    if( 65 <= int(x) && int(x) <= 90) return x;
    return -1;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122) return x;
    if( 65 <= int(x) && int(x) <= 90) return char(x+32);
    return -1;
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57) return int(x-'0');
    if(97 <= int(x) && int(x) <= 122) return int(x-96);
    if(65 <= int(x) && int(x) <= 90) return int(x-64);
    return -1;
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1 = {l1,r1};
    pii p2 = {l2,r2};
    if(p1>p2)swap(p1,p2);
    return (p2.fi <= p1.se);
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1%MOD;
    else if(num2==1)return num1%MOD;
    else{
        ll temp = quickpow (num1,num2>>1LL,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2&1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
bool ok[1000010];
int main(){

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int ans = -1;
    int res = 0;
    int k; cin >> k;
    int i = 0;
    while(!ok[res]){
        ++i;
        ok[res] = true;
        res *= 10;
        res += 7;
        res %= k;
        if(res == 0) {ans = i; break;}
    }

    cout << ans << newl;

    return 0;
}


Measured memory_bytes: 4620
#!/usr/bin/env python3

n, l = list(map(int, input().split()))

max_ = l+n-1
min_ = l

# print(min_, max_)
if max_ >= 0 and min_ <= 0:
    print((max_+min_)*(max_-min_+1)//2)
elif max_ <= 0:
    max_ -= 1
    print((max_+min_)*(max_-min_+1)//2)
else:
    min_ += 1
    print((max_+min_)*(max_-min_+1)//2)


Measured memory_bytes: 3060
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
using namespace std;
#define ln '\n'

#define ll long long int

ll n,m,a,b,t,i,j,d,cs=0,counT=1,k,ans=0,l=0,sum1=0,sum=0,Max,Min,num;
char ch;
int main()
{
    string s ;
    cin >> s;
    deque<char>vc(s.begin(),s.end());
    cin >> m ;
    while(m--)
    {
        cin >> a ;
        if(a==1)
            counT++;
        else
        {
            cin >> b ;
            cin >> ch ;
            if(counT%2==0)
            {
                if(b==1)
                    vc.push_back(ch);
                else
                    vc.push_front(ch);
            }
            else
            {
                if(b==1)
                   vc.push_front(ch);
                else
                     vc.push_back(ch); ;
            }
        }
    }
if(counT%2==0)
    reverse(vc.begin(),vc.end());
for(auto it : vc)
    cout << it ;
cout << ln ;

/// Comment the debugger section
}




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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        br.close();
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        if (k==1) System.out.println(0);
        else System.out.println(n-k);
    }
}

Measured memory_bytes: 21460
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>
 
using namespace std;
 
const int MAXN = 100005;
 
int n;
int a[MAXN];
 
bool check()
{
	for (int i = 1;i <= n;i++)
		if (a[i] == 1)
		{
			int sum = 0;
			for (int j = 1;j <= n;j++)
				sum ^= (a[j] - 1);
			return ~sum & 1;
		}
	int cnt = 0;
	for (int i = 1;i <= n;i++)
		cnt += (a[i] & 1);
	int step = ((n - cnt) & 1);
	if (cnt > 1 && !step)
		return 1;
	if (cnt >= 1 && step)
		return 0;
	for (int i = 1;i <= n;i++)
		if (a[i] & 1)
			a[i]--;
	int g = 0;
	for (int i = 1;i <= n;i++)
		g = __gcd(g,a[i]);
	for (int i = 1;i <= n;i++)
		a[i] /= g;
	return check() ^ 1;
}
 
int main()
{
//	freopen("input.txt","r",stdin);
//	freopen("output1.txt","w",stdout);
	scanf("%d",&n);
	for (int i = 1;i <= n;i++)
		scanf("%d",&a[i]);
	if (n == 1)
	{
		puts((a[1] & 1) ? "Second" : "First");
		return 0;
	}
	puts(check() ? "Second" : "First");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,m;
bool fl;

vector<vi> solve(int n) {
	//H W=2^n-1
	if(n==1) return {{1}};
	auto tmp=solve(n-1);
	int len=(1<<n)-1,len2=(1<<(n-1))-1;
	vector<vi> ret(len);
	for(int i=0;i<len;i++) ret[i].resize(len);
	for(int i=0;i<len2;i++)
		for(int j=0;j<len2;j++) ret[i][j]=ret[i+len2+1][j]=ret[i][j+len2+1]=ret[i+len2+1][j+len2+1]=tmp[i][j];
	ret[len2][len2]=1;return ret;
}

int main() {
	cin>>n>>m;
	if(n<m) fl=1,swap(n,m);
	auto ans=solve(n);
	if(!fl) {
		for(int i=0;i<(1<<n)-1;i++,cout<<'\n')
			for(int j=0;j<(1<<m)-1;j++) cout<<ans[i][j];
	}
	else {
		for(int i=0;i<(1<<m)-1;i++,cout<<'\n')
			for(int j=0;j<(1<<n)-1;j++) cout<<ans[j][i];
	}
	return 0;
}


Measured memory_bytes: 6400
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n,t=0,x=0,y=0,tt,xx,yy;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&tt,&xx,&yy);
		if((tt-t)<abs(x-xx)+abs(y-yy)||(tt-t+x-xx+y-yy)%2){
			printf("No\n");
			return 0;
		}
		t=tt;
		x=xx;
		y=yy;
	}
	printf("Yes\n");
}

Measured memory_bytes: 128
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int N,H,W;
    cin>>N>>H>>W;
    
    cout<<(N-H+1)*(N-W+1)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Set<Integer> set = new HashSet<Integer>();
		for(int i = 0; i < 3; i++) {
			set.add(sc.nextInt());
		}
		sc.close();
		System.out.println(set.size());
	}
}

Measured memory_bytes: 21972
A = list(reversed(input()))
B = list(reversed(input()))
C = list(reversed(input()))

turn = 'a'

for i in range(300):
    if turn == 'a':
        if len(A) == 0:
            print('A')
            exit()
        turn = A.pop()
    elif turn == 'b':
        if len(B) == 0:
            print('B')
            exit()
        turn = B.pop()
    else:
        if len(C) == 0:
            print('C')
            exit()
        turn = C.pop()

Measured memory_bytes: 3064