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

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define clr(arr, key) memset(arr, key, sizeof arr)
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define infinity (1 << 28)
#define LL long long
#define PI acos(-1)
#define gcd(a, b) __gcd(a, b)
#define CF ios_base::sync_with_stdio(0);cin.tie(0);
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define all(v) v.begin(), v.end()
#define no_of_ones __builtin_popcount // __builtin_popcountll for LL
#define SZ(v) (int)(v.size())
#define eps 1e-7

//int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int col[4] = {1, 0, -1, 0};
//int row[4] = {0, 1, 0, -1};
//int months[13] = {0, ,31,28,31,30,31,30,31,31,30,31,30,31};

using namespace std;

struct point{int x, y; point () {} point(int a, int b) {x = a, y = b;}};
template <class T> T sqr(T a){return a * a;}
template <class T> T power(T n, T p) { T res = 1; for(int i = 0; i < p; i++) res *= n; return res;}
template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}    // distance between a and b
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}
template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}
//LL bigmod(LL B,LL P,LL M){LL R=1; while(P>0)  {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
struct fast{fast(){ios_base::sync_with_stdio(0);cin.tie(0);}}cincout;

#define MAX 100010
/***********************************THE GRASS IS ALWAYS GREENER ON THE OTHER SIDE***********************************/

int main()
{
    // in;
    LL a, b, c, k;
    cin >> a >> b >> c >> k;
    LL res = 0;
    if(a <= k){
        k -= a;
        res += a;
    }else{
        cout << k;
        return 0;
    }
    k -= b;
    if(k <= 0){
        cout << res;
        return 0;
    }
    res -= k;
    cout << res;
    return 0;
}


Measured memory_bytes: 3648
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PI acos(-1)

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  int scan;
  ll  n;
  ll  answer;

  scan = scanf("%lld", &n);
  answer = 0;
  for (ll k = 1; k <= n; k++) {
    answer += ((n / k) * (n / k + 1) / 2) * k;
  }
  printf("%lld", answer);
  return (0);
}


Measured memory_bytes: 1736
h, w = map(int, input().split())
s = [[c for c in input()] for _ in range(h)]

dx = [-1, 0, 1, -1, 1, -1, 0, 1]
dy = [-1, -1, -1, 0, 0, 1, 1, 1]

def count_bom(i, j):
    count = 0

    for k in range(8):
        cx = j + dx[k]
        cy = i + dy[k]

        if (cx < 0 or cx >= w):
            continue
        if (cy < 0 or cy >= h):
            continue
        count += check(s[cy][cx])

    return count

def check(symbol):
    if (symbol == "#"):
        return 1
    else:
        return 0

def main():
    ans = [[0 for _ in range(w)] for _ in range(h)]

    for i in range(h):
        for j in range(w):
            if (s[i][j] == "."):
                ans[i][j] = count_bom(i, j)
            else:
                ans[i][j] = "#"

    for a in ans:
        for b in a:
            print(b, end="")
        print()

if __name__ == '__main__':
    main()

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

int n, m, dp[60000], b[100];
//dp[i]=j 为凑够i元需要j个硬币

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

	memset(dp, 60000, sizeof(dp));
	dp[0] = 0;

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

	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3316
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#拡張ユークリッドとかしらないので、オイラー関数でmodの逆元計算して無理やり通します。
def gcd(a,b):
    if a==0:
        return b
    return gcd(b%a,a)
a,b = LI()
g = gcd(a,b)
a//=g
b//=g
if b == 1:
    print(0,1)
    quit()
if b < 4:
    f = b-1
else:
    p = []
    x = 2
    m = b
    while x**2 <= b:
        if not m%x:
            p.append(x)
            while not m%x:
                m//=x
        x += 1
    if m != 1:p.append(m)
    f = b
    for i in p:
        f *= (1-1/i)
    f = int(f)
x_ = pow(a,f-1,b)
y_ = (1-a*x_)//b
ans = [x_,y_,abs(x_)+abs(y_)]
for i in range(-100,100):
    s = -b*i+x_
    t = a*i+y_
    m = abs(s)+abs(t)
    if m < ans[2]:
        ans = [s,t,m]
    elif m == ans[2] and s <= t:
        ans = [s,t,m]
print(ans[0],ans[1])



Measured memory_bytes: 8236
//
// Created by ?????°?????? on 2016/06/21.
//

#include <iostream>
#include <string>
using namespace std;

void solve(string T,string P){
    int size = T.size() - P.size() +1;
    for (int i = 0; i < size ; ++i) {
        if(T[i] == P[0])
        {
            bool isSame = true;
            for (int j = 0; j < P.size() ; ++j) {
                if( T[i+j] != P[j]) {
                    isSame = false;
                    break;
                }
            }
            if(isSame){
                cout << i << endl;
            }
        }
    }
}

int main(){
    string T,P;
    cin >> T >> P;
    solve(T,P);
    return 0;
}

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

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

    int even_no = (int)ceil(k / 2);
    int odd_no = k - even_no;
    cout << odd_no * even_no << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,a,n) for(ll i=a;i<n;i++)
#define ford(i,a,n) for(ll i=n-1;i>=a;i--)
#define testc  ll ts;\
               cin>>ts;\
               while(ts--)
#define arn ll n;\
            cin>>n;\
            ll a[n];\
            forr(i,0,n)cin>>a[i];\
               
#define arr(a,n) ll a[n];\
                 forr(i,0,n)cin>>a[i];\
 
#define sss <<" "<<
#define nnn <<"\n"
#define nl cout<<"\n";
using namespace std;
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,ctr=0,ans=0;
    string s;
    cin>>n;
    cin>>s;
    forr(i,0,n){
        if(s[i]=='R')ctr++;
    }
    forr(i,0,ctr){
        if(s[i]=='W')ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int N; cin >> N;
	vector<long long>sum(N + 1);
	for (int i = 0; i < N; i++) {
		int n; cin >> n;
		sum[i + 1] = sum[i] + n;
	}

	long long m = 1e18;
	for (int i = 1; i < N; i++) {
		m = min(m, abs(sum[N] - sum[i] - sum[i]));
	}
	cout << m << endl;

	return 0;
}



Measured memory_bytes: 1792
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(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;

const int MOD = 1e9 + 7;
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a%b);
}


int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, 0, n) {
        cin >> a[i];
    }

    int g = a[0];
    rep(i, 1, n) {
        g = gcd(g, a[i]);
    }

    sort(a.begin(), a.end());

    if (k % g || k > a.back()) {
        cout << "IMPOSSIBLE" << endl;
    }
    else {
        cout << "POSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(int(input())):
    
    x = input()
    if x == 'AC':
        AC += 1
    elif x == 'WA':
        WA +=1
    elif x == 'TLE':
        TLE += 1
    else:
        RE += 1
print("AC x {}".format(AC))    
print("WA x {}".format(WA))    
print("TLE x {}".format(TLE))    
print("RE x {}".format(RE))    




Measured memory_bytes: 9044
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str = Console.ReadLine ().Split (' ');

            for (int i = 0; i < 5; i++)
            {
                if (str[i] == "0")
                {
                    Console.WriteLine (i + 1);
                    return;
                }
            }
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 25964
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if (j*i == n){
                cout << "Yes" << endl;
                exit(0);
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;
string s, t;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> s >> t;
	int S = s.length(), T = t.length();
	int dp[S + 1][T + 1];
	for(int i = 0; i <= S; ++i){
		for(int j = 0; j <= T; ++j){
			if(i == 0 || j == 0){
				dp[i][j] = 0;
				continue;
			}
			if(s[i - 1] == t[j - 1]){
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	vector<char> ans;
	ans.clear();
	int i = S, j = T;
	while(i > 0 && j > 0){
		if(s[i - 1] == t[j - 1]){
			ans.push_back(s[i - 1]);
			i--; j--;
		}
		else{
			if(dp[i - 1][j] > dp[i][j - 1]){
				i--;
			}
			else
				j--;
		}
	}

	reverse(all(ans));

	for(char c: ans)
		cout << c;

	return 0;
}

Measured memory_bytes: 38772
S = input()
max = 0
cnt = 0
for s in S:
    if s == 'A' or s == 'T' or s == 'G' or s == 'C':
        cnt += 1
    else:
        if max < cnt:
            max = cnt
        cnt = 0
if max < cnt:
    max = cnt
print(max)

Measured memory_bytes: 3060
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
fn main() {
    input! {
        mut a: isize, b: isize, mut c: isize, d: isize
    }

    let mut turn = 0;
    while a > 0 && c > 0 {
        if turn%2 ==  0 {
            c -= b;
        } else {
            a -= d;
        }
        turn += 1;
    }
    if a <= 0 {
        println!("No");
    } else {
        println!("Yes");
    }
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL (vec)(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t make_tuple
#define eb emplace_back
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define cont const auto
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
#define PQ priority_queue
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  VL a(n);
  rep(i,n)cin>>a[i];

  int res=INF;
  rep(i,n){
    int x=0,y=0;
    rep(j,i)x+=a[j];
    for(int j=i;j<n;++j)y+=a[j];
    chmin(res,abs(x-y));
  }
  out(res);
  
  
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#define MAX_N 1000

using namespace std;

typedef pair<int, int> P;
int n, T, a;
double result = 1e9;
double tmp[MAX_N];
int heights[MAX_N];

int solve() {
	int ans  = 0;
  scanf("%d", &n);
  scanf("%d %d", &T, &a);
  for(int i = 0; i < n; i++) {
    scanf("%d", &heights[i]);
  }
  for(int i = 0; i < n; i++) {
    tmp[i] = T - (heights[i] * 0.006);
  }
  for(int i = 0; i < n; i++) {
    if(result > abs(a - tmp[i])) {
      result = abs(a - tmp[i]);
      ans = (i + 1);
    }
  }
  printf("%d\n", ans);
}

int main(int args, char* argv[]) {
  solve();
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

char S[SIZE];

int main(){
  ll M;
  int N;

  scanf("%lld%s", &M, S);

  N = strlen(S);

  ll sum[10] = {};

  for(int i=0; i<N; i++) {
    for(int j=0; j<10; j++) sum[j] = sum[j]*10 % mod;

    sum[S[i]-'0']++;
  }

  int per[10];

  iota(per, per+10, 0);

  bool ok = false;

  do{
    ll v = 0;

    if (per[S[0]-'0'] == 0 && N != 1) continue;

    for(int i=0; i<10; i++) {
      v = (v + sum[i] * per[i]) % mod;
    }

    if (v == M) {
      ok = true;
      break;
    }

  }while(next_permutation(per, per+10));

  if (ok) {
    for(int i=0; i<N; i++)
      printf("%d", per[S[i]-'0']);
    puts("");
  } else {
    puts("-1");
  }

  return 0;
}



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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

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

    int n=t.length();
    rep(i, n) if(t[i]=='?') t[i]='D';

    cout << t << endl;
    return 0;
}


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

int main() {
  int x, y, z;
  int n, m;
  cin >> n >> m >> x >> y;

  int xArray[n];
  int yArray[m];

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

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

  for( int i = 1; i < n; i++ ) {
    int v = xArray[i];
    int j = i - 1;
    while ( j >= 0 && xArray[j] > v ) {
     xArray[j+1] = xArray[j];
     j--;
    }
    xArray[j+1] = v;
  }

  for( int i = 1; i < m; i++ ) {
    int v = yArray[i];
    int j = i - 1;
    while ( j >= 0 && yArray[j] > v ) {
     yArray[j+1] = yArray[j];
     j--;
    }
    yArray[j+1] = v;
  }

  for ( int z = x+1; z <= y; z++ ) {
    if(xArray[n-1] < z && yArray[0] >= z ) {
      if( xArray[n-1] < yArray[0] ) {
        cout << "No War" << endl;
        return 0;
      }
    }
  }

  cout << "War" << endl;


  return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

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

    // YYMM
    bool isYYMM = true;
    if (S.substr(2, 2) < "01" || "12" < S.substr(2, 2)) {
        isYYMM = false;
    }


    // MMYY
    bool isMMYY = true;
    if (S.substr(0, 2) < "01" || "12" < S.substr(0, 2)) {
        isMMYY = false;
    }

    if(isYYMM && isMMYY) {
        cout << "AMBIGUOUS" << endl;
    } else if(isYYMM) {
        cout << "YYMM" << endl;
    } else if(isMMYY) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 200100;
const int mod = 1e9 + 7;

int add(int x, int y) {
  x += y;
  if (x >= mod)
    x -= mod;
  return x;
}

int mul(ll x, ll y) {
  return x * y % mod;
}

int sub(int x, int y) {
  x -= y;
  if (x < 0)
    x += mod;
  return x;
}

int f[M], r[M];

void pre() {
  f[0] = 1;
  for (int i = 1; i < M; ++i)
    f[i] = mul(i, f[i - 1]);

  r[1] = 1;
  for (int i = 2; i < M; ++i) {
    int bon = sub(0, mod / i);
    bon = mul(bon, r[mod % i]);
    r[i] = bon;
  }

  r[0] = 1;
  for (int i = 1; i < M; ++i)
    r[i] = mul(r[i], r[i - 1]);
}

int binom(int n, int k) {
  if (n < 0 || k < 0 || n < k)
    return 0;

  int ans = f[n];
  ans = mul(ans, r[k]);
  ans = mul(ans, r[n - k]);
  
  return ans;
}

int h, w, a, b;

void read() {
  cin >> h >> w >> a >> b;
}


void kill() {
  int ans = 0;
  for (int x = 0; x < h - a; ++x) {
    int bon = mul(binom(b - 1 + x, x), binom((h - x - 1) + (w - b - 1), (w - b - 1)));
    ans = add(ans, bon);
  }
  cout << ans << endl;
}

int main() {
  pre();
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}


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

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

    int nowmin = 1000000;
    int count = 0;
    for(int i =0;i<n;i++){
        int k;
        cin >> k;
        if(nowmin > k){
            count++;
            nowmin = k;
        }
    }
    cout << count;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
answered = [0] * n
ans = 0
pena = 0
for _ in range(m):
    p, s = input().split()
    pidx = int(p) - 1
    if answered[pidx] == -1:
        continue
    if s == "AC":
        ans += 1
        pena += answered[pidx]
        answered[pidx] = -1
    else:
        answered[pidx] += 1
print("{} {}".format(ans, pena))


Measured memory_bytes: 3828
from fractions import gcd
A,B,C,D = map(int, input().split())

c_div=B//C
d_div=B//D
dc_div=B//((C*D)//gcd(C,D))

not_div1 = B-(d_div+c_div-dc_div)

A =A-1
c_div=A//C
d_div=A//D
dc_div=A//((C*D)//gcd(C,D))

not_div2 = A-(d_div+c_div-dc_div)

print(not_div1-not_div2)

Measured memory_bytes: 66156
N = int(input())
src = [input().split() for i in range(2)]

A = []
for row in src:
    A.append(list(row))

max_count = 0
for i in range(N):
    x = 0
    y = 0
    count = int(A[x][y])
    for j in range(N):
        if i==j:
            x += 1
            count += int(A[x][y])
        else:
            y += 1
            count += int(A[x][y])
    if max_count <= count:
        max_count = count
print(max_count)

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

int main( ){
  int m,f,b;
  cin>>m>>f>>b;
  if(m>=b){cout<<0<<endl;
  }else if(m<b && m+f>=b){cout<<b-m<<endl;
  }else if(m<b && m+f<b){cout<<"NA"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
//#define int long long
using namespace std;

int a[30];
bool vis[30];

signed main()
{
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s.size()!=26){
		cout<<s;
		for(int i=0;i<s.size();i++) vis[s[i]-'a'+1]=1;
		for(int i=1;i<=26;i++){
			if(!vis[i]){
				cout<<char('a'+i-1)<<endl;
				return 0;
			}
		}
	}
	else{
		for(int i=s.size()-1;i>=1;i--){
			if(s[i-1]>s[i]) continue;
			else{
				int pos=s.size()-1;
				for(int j=i;j<=s.size()-1;j++){
					if(s[j]>s[i-1]) pos=j;
				} 
				cout<<s.substr(0,i-1)<<s[pos]<<endl;
				return 0;
			}
		}
		cout<<-1<<endl;
	}
	return 0;
}
//bfghijklmnopqrstuvwxyzdeca

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())

first, second = sorted(A,reverse=True)[:2]
for i in range(N):
    if A[i] == first:
        print(second)
    else:
        print(first)

Measured memory_bytes: 13284
package main

import "fmt"

// 2018-08-03T23:14:25+0800
// 2018-08-03T23:24:36+0800
// 2018-08-03T23:54:09+0800 # @see https://arc063.contest.atcoder.jp/submissions/2939452
// 2018-08-04T00:02:23+0800 # @see https://arc063.contest.atcoder.jp/submissions/2939465
// 2018-08-04T00:23:32+0800
func main() {
	var N, T int
	fmt.Scanf("%d%d", &N, &T)
	A := make([]int, N)
	pa := make([]int, N)
	pb := make([]int, N)
	fmt.Scanf("%d", &A[0])
	pa[0] = A[0]
	for i := 1; i < N; i++ {
		fmt.Scanf("%d", &A[i])
		if A[i] < pa[i-1] {
			pa[i] = A[i]
		} else {
			pa[i] = pa[i-1]
		}
	}
	pb[N-1] = A[N-1]
	for i := N - 2; i >= 0; i-- {
		if A[i] > pb[i+1] {
			pb[i] = A[i]
		} else {
			pb[i] = pb[i+1]
		}
	}
	t := 0
	max := -1
	// (1, 5), (2, 6)
	out := make(map[int]map[int]bool)
	for i := 1; i < N; i++ {
		t = pb[i] - pa[i-1]
		if t >= max {
			max = t
			if out[t] == nil {
				out[t] = make(map[int]bool)
			}
			out[t][pb[i]] = true
		}
	}
	fmt.Println(len(out[max]))
}

func main1() {
	var N, T int
	fmt.Scanf("%d%d", &N, &T)
	A := make([]int, N)
	AA := make([]int, N)
	iAA := 0
	fmt.Scanf("%d", &A[0])
	AA[0] = A[0]
	iAA++
	inc := true
	for i := 1; i < N; i++ {
		fmt.Scanf("%d", &A[i])
		if i == 1 {
			inc = A[1] > A[0]
		}
		if (inc && A[i] < A[i-1]) || (!inc && A[i] > A[i-1]) {
			AA[iAA] = A[i-1]
			iAA ++
			inc = !inc
		}
	}
	AA[iAA] = A[N-1]
	iAA ++
	A = AA
	N = iAA
	pa := make([]int, N)
	pb := make([]int, N)
	pa[0] = A[0]
	for i := 1; i < N; i++ {
		if A[i] < pa[i-1] {
			pa[i] = A[i]
		} else {
			pa[i] = pa[i-1]
		}
	}
	pb[N-1] = A[N-1]
	for i := N - 2; i >= 0; i-- {
		if A[i] > pb[i+1] {
			pb[i] = A[i]
		} else {
			pb[i] = pb[i+1]
		}
	}
	out := 0
	t := 0
	max := -1
	end := -1
	for i := 1; i < N; i++ {
		t = pb[i] - pa[i-1]
		if t > max && end != pb[i] {
			max = t
			end = pb[i]
			out = 1
		} else if t == max {
			out++
		}
	}
	fmt.Println(out)
}

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

int main()
{
  typedef long long ll;
  ll A, B, K;
  cin >> A >> B >> K;
  if (A < K)
  {
    B -= (K - A);
    cout << 0 << " " << ((B < 0) ? 0 : B);
  }
  else
    cout << A - K << " " << B;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll gcd (ll a,ll b){
    return b ? gcd(b,a%b) : a;
}
main(){
    int T;
    cin >> T;
    rep(i,0,T){
        ll A,B,C,D;
        cin >> A >> B >> C >> D;
        if(A < B || B > D){
            cout << "No" << endl;
            continue;
        }
        if(B <= C + 1){
            cout << "Yes" << endl;
            continue;
        }
        if(D == B){
            if(A % B <= C)cout << "Yes" << endl;
            else          cout << "No" << endl;
            continue;
        }
        ll g = gcd(D - B, D);
        //cout << A % g + D - g << endl;
        if(C + D - B >= A % g + D - g){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }

        /*
        int cnt = 0,num = A;
        
        while(1){
            
            if(num < B){
                cout << "No" << endl;
                break;
            }
            num -= B;
            if(num <= C)num += D;
            if(num == A){
                cout << "Yes" << endl;
                cout << "loop:" << cnt << endl;
                break;
            }
            cnt++;
        }
        */
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<string> S(N); for (auto &s : S) cin >> s;
    vector<tuple<int, int, int>> up, notup;
    for (int i = 0; i < N; i++) {
        int lv = 0, mi = 0;
        for (int c : S[i]) {
            if (c == '(') {
                lv++;
            } else {
                lv--;
                mi = min(mi, lv);
            }
        }
        if (lv > 0) {
            up.emplace_back(-mi, mi, lv);
        } else {
            notup.emplace_back(mi - lv, mi, lv);
        }
    }
    sort(begin(up), end(up));
    sort(begin(notup), end(notup));
    int curr = 0;
    bool ans = true;
    for (auto& tup : up) {
        int dummy, mi, lv; tie(dummy, mi, lv) = tup;
        if (curr + mi < 0) ans = false;
        curr += lv;
    }
    for (auto& tup : notup) {
        int dummy, mi, lv; tie(dummy, mi, lv) = tup;
        if (curr + mi < 0) ans = false;
        curr += lv;
    }
    if (curr != 0) ans = false;
    cout << (ans ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 46336
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int n,k,x,y,isblack,checker[2001][2001];
char c;

int main(){
    I(n); I(k);
    REP(i,n){
        scanf("%d %d %c", &x, &y, &c);
        isblack = (c=='B');
        x %= (2*k);
        if (x>=k) {x -= k; isblack ^= 1;}
        y %= (2*k);
        if (y>=k) {y -= k; isblack ^= 1;}

        if(isblack) {
            checker[0][0]++;
            checker[x][0]--;
            checker[0][y]--;
            checker[x][y]++;
            checker[x][y]++;
            checker[x][k]--;
            checker[k][y]--;
            checker[k][k]++;
        } else {
            checker[0][y]++;
            checker[0][k]--;
            checker[x][y]--;
            checker[x][k]++;
            checker[x][0]++;
            checker[k][0]--;
            checker[x][y]--;
            checker[k][y]++;
        }
    }

    REP(i,k) REP(j,k) checker[i][j+1] += checker[i][j];
    REP(i,k) REP(j,k) checker[i+1][j] += checker[i][j];
    int mini = n;
    int maxi = 0;
    REP(i,k) { REP(j,k){
        mini = min(mini,checker[i][j]);
        maxi = max(maxi,checker[i][j]);
    } }
    cout << max(maxi,n-mini) << endl;
}


Measured memory_bytes: 8448
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ll x, ll y, ll a, ll b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( int k = 0; k < n; k++ ){ cout << a[k] << " ";} cerr << "\n"; }

int main(){
	FASTIO;
	ll a, b; cin >> a >> b;
	cout << lcm(a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static int n;
    static long x;
    static long[] a;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        x = sc.nextInt();
        a = new long[n];
        long ans = 0;
        long diff = 0;

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n - 1; i++) {
            diff = a[i] + a[i+1] - x;
            if (diff > 0) {
                a[i+1] -= Math.min(a[i+1], diff);
                ans += diff;

            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 50600
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#define maxn 400010
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define IL inline
#define ss system
using namespace std;

int a[maxn], n;
template <class T> void read(T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch))
    fl |= ch == '-', ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  if (a[n - 1] <= 0) {
    int ans = a[n];
    for (int i = 1; i <= n - 1; i++) {
      ans -= a[i];
    }
    cout << ans << endl;
    for (int i = 1; i <= n - 1; i++) {
      cout << a[n] << " " << a[i] << endl, a[n] -= a[i];
    }
    return 0;
  }
  int pos = n - 1;
  for (int i = n - 1; i; i--) {
    if (a[i] > 0)
      pos = i;
  }
  if (pos == 1)
    pos++;
  int ans = 0;
  for (int i = 1; i < pos; i++) {
    ans -= a[i];
  }
  for (int i = pos; i <= n; i++) {
    ans += a[i];
  }
  cout << ans << endl;
  for (int i = pos; i <= n - 1; i++) {
    cout << a[1] << " " << a[i] << endl, a[1] -= a[i];
  }
  for (int i = 1; i < pos; i++) {
    cout << a[n] << " " << a[i] << endl, a[n] -= a[i];
  }
  return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int n,k,q;
int f[1000000];
cin >> n >> k >> q;
for(int i=1;i<=n;i++){
   f[i]=0;
}
for(int i=1;i<=q;i++){
    int x;
    cin >>x;
    f[x]++;
}
for(int i=1;i<=n;i++){
    if((q-f[i])>=k)
    cout << "No" << endl;
    else
    cout << "Yes" << endl;
}
    return 0;
}


Measured memory_bytes: 2944
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n = inp[0]
a = inp
ans = 0
mae = 0
a.each do |d|
  ans += [mae-d,0].max
  mae = [mae,d].max
end
p ans


Measured memory_bytes: 30088
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
struct Corr{
    int y;
    int x;
    int length;
};
vector<int> dy={0,0,-1,1};
vector<int> dx={-1,1,0,0};

int bfs(vector<vector<char>> &s,queue<Corr> q,int g_y, int g_x, int h, int w){
    vector<vector<char>> s2=s;
    int y,x,length=0;
    while(!q.empty()){
        Corr now = q.front();
        q.pop();
        y=now.y;
        x=now.x;
        length=now.length;
        if(y==g_y&&x==g_x) return length;
        for(int i=0; i<4; i++){
            Corr next = {y+dy[i],x+dx[i],length+1};
            if(0<=next.y && next.y<h && 0<=next.x && next.x<w && s2[next.y][next.x]=='.'){
                s2[next.y][next.x] = '#';
                q.push(next);
            }
        }
    }
    return 0;
}
int main() {
    int h,w;
    cin>>h>>w;
    vector<vector<char>> s(h,vector<char>(w));
    for(int i=0; i<h; i++) for(int j=0; j<w; j++) cin>>s[i][j];
    int ans=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            for(int k=0; k<h; k++){
                for(int l=0; l<w; l++){
                    if(i==k&&j==l) continue;
                    if(s[i][j]=='#'||s[k][l]=='#') continue;
                    //cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;
                    queue<Corr> q;
                    Corr start = {i,j,0};
                    q.emplace(start);
                    ans=max(ans,bfs(s,q,k,l,h,w));
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(),x.end()
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
using namespace std; 

const int N=1e6+560; 

int n,res;

int f(int n,int k){
	//printf("f(%d,%d)\n",n,k); 
	if(n<k)return 0; 
	if(n%k==0)return n/k;
	int l=k*(n/k),z=n/k+1;
	//printf("l=%d,z=%d,w=%d\n",l,z,((-l+z)%z+n%z+z)%z); 
	return f(min(l+((-l+z)%z+n%z+z)%z,n-z),k); 
}

int g(int n,int k){
	
	//printf("g(%d,%d)\n",n,k); 
	if(n<k)return 0; 
	if(n%k==0)return n/k;
	return f(n-n/k-1,k); 
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);  
#endif
	cin>>n;
	rep(i,1,n){
		int a,k;
		cin>>a>>k;
		res^=f(a,k); 
		//printf("%d,%d\n",f(a,k),g(a,k)); 
	}
	puts(!res?"Aoki":"Takahashi");
	return 0; 
}


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

using namespace std;
typedef long long ll;
const int N = 200010;
int _w;

int n, a[N];

int main() {
	_w = scanf( "%d", &n );
	for( int i = 1; i <= n; ++i ) {
		_w = scanf( "%d", a+i );
		a[i] -= i;
	}
	sort(a+1, a+n+1);
	ll b = a[(1+n)/2];
	ll s = 0;
	for( int i = 1; i <= n; ++i )
		s += abs(b - a[i]);
	printf( "%lld\n", s );
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String lineNum = sc.nextLine();
        int N = Integer.parseInt(lineNum.split(" ")[0]);
        int M = Integer.parseInt(lineNum.split(" ")[1]);
        int[] Pz = new int[M];
        String[] Sz = new String[M];

        for (int m = 0; m < M; m++){
            String line = sc.nextLine();
            Pz[m] = Integer.parseInt(line.split(" ")[0]);
            Sz[m] = line.split(" ")[1];
        }

        String[] problems = new String[N];
        String[] answeredProblems = new String[N];
        for (int m = 0; m < M; m++){
            if ("AC".equals(Sz[m])){
                answeredProblems[Pz[m] - 1] = "AC";
            }
        }

        int waNum = 0;
        int acNum = 0;

        for (int m = 0; m < M; m++){
            if (!("AC".equals(answeredProblems[Pz[m] - 1]))){
                continue;
            }

//            System.out.println(problems[Pz[m] - 1] +" "+ Sz[m]);
            if ((!("AC".equals(problems[Pz[m] - 1]))) && ("WA".equals(Sz[m]))){
                waNum++;
            }
            if ((!("AC".equals(problems[Pz[m] - 1]))) && ("AC".equals(Sz[m]))) {
                acNum++;
            }
            if ("AC".equals(Sz[m])){
                problems[Pz[m] - 1] = "AC";
            }

        }

//        for (int n = 0; n < N; n++){
//            System.out.println(problems[n]);
//        }

        System.out.println(acNum+" "+waNum);

    }
}



Measured memory_bytes: 66976
#include<bits/stdc++.h>
using namespace std;
int main()
{ios_base::sync_with_stdio(false);
//cin.tie(NULL);
   long long int n,sum=0,curr_sum=0,ans=0,t;
   cin>>n;
   for(long long int i=2;i<=n;i++)
    for(long long int j=1;j<=n;j++)
    for(long long int k=1;k<=n;k++)
   {
       t=__gcd(i,j);t=__gcd(t,k);
       ans+=t;
   }
   ans+=(n*n);
   cout<<ans<<endl;
}


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

long long T[2], A[2], B[2];
long long sp[2];

int main(){
    cin >> T[0] >> T[1];
    cin >> A[0] >> A[1];
    cin >> B[0] >> B[1];

    sp[0] = T[0] * (A[0] - B[0]);
    sp[1] = T[1] * (A[1] - B[1]);

    if(sp[0] + sp[1] == 0){
        cout << "infinity" << endl;
        return 0;
    }

    if(sp[0] / abs(sp[0]) * sp[1] > 0){
        cout << 0 << endl;
    }else if(abs(sp[0]) > abs(sp[1])){
        cout << 0 << endl;
    }else{
        sp[0] = abs(sp[0]);
        sp[1] = abs(sp[1]);
        long long n = sp[0] / (sp[1] - sp[0]);
        long long ret = 2 * n + 1;
        if(sp[0] % (sp[1] - sp[0]) == 0){
            ret--;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}




//overflowするときは1を返す
int is_mul_overflow(long long a, long long b) {
	float mul_log;

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

	mul_log = log10f(a) + log10f(b);


	if (mul_log > 18.0) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {

	int X, N;

	int p[120],ans,ab;

	cin >> X >> N;

	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}

	ab = 1000;

	for (int i = 0; i < 200; i++) {
		int is_include = 0;
		for (int j = 0; j < N; j++) {
			if (p[j] == i) {
				is_include = 1;
			}
		}
		if (is_include == 0 && abs(X - i) < ab) {
			ans = i;
			ab = abs(X - i);
		}
	}

	cout << ans << endl;

	cin >> ans;

	return 0;


}

Measured memory_bytes: 3652
def SixDigit(x):
    while len(x) < 6:
        x = '0' + x
    return x
        
n, m = map(int, input().split())
l = []
for i in range(m):
    p, y = map(int, input().split())
    l.append([p, y, i])
l.sort()

count = 1
ans = [[l[0][2], l[0][0], count]]
for j in range(1, m):
    if l[j][0] == l[j-1][0]:
        count += 1
        ans.append([l[j][2], l[j][0], count])
    elif l[j][0] != l[j-1][0]:
        count = 1
        ans.append([l[j][2], l[j][0], count])
    
ans.sort()
for k in range(m):
    print(SixDigit(str(ans[k][1]))+SixDigit(str(ans[k][2])))

Measured memory_bytes: 37836
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

string s;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
   cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
    cin>>s;
    int n=(int)s.length();
    int g=0,p=0;
    int ans=0;
    for(int i=0;i<n;i++){
    	if(s[i]=='p'){
    		if(g>p){
    			p++;
    		}else {
    			g++;
    			ans-=1;
    		}
    	}else{
    		if(g>p){
    			p++;
    			ans++;
    		}else{
    			g++;
    		}
    	}
    }
    cout<<ans<<"\n";
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Measured memory_bytes: 512
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        998244353
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ll n;cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)cin>>a[i];
	if(a[0]!=0)return cout<<"0",0;
	sort(a,a+n);
	for(ll i=1;i<n;i++){
		if(a[i]==0)return cout<<"0",0;
	}
	for(ll i=1;i<n;i++){
		if(a[i-1]==a[i]);
		else if(a[i-1]+1==a[i]);
		else return cout<<"0",0;
	}
	ll f[n+1]={0};
	for(ll i=0;i<n;i++){
		f[a[i]]++;
	}
	ll ans=1;
	for(ll i=1;i<n;i++){
		ans=ans*f[a[i]-1]%hell;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int cnt;
int n,m;

void dfs(vector<vector<int>> &g, int v, int c,vector<bool> seen){
  seen[v] = true; //vを訪問済みにする
  if (c == n){
    cnt++; //もし到達ノード数が全てのノード数と一致していたらcountする。
    return;
  }
  //vに繋がっている next_vを探索する。
  for (auto next_v : g[v]){
    if (seen[next_v]) continue; //もしすでにnext_vが探索済みであったら、skip
    dfs(g, next_v, c+1,seen); //もしそうでなければ再帰的に探索
  }
}

int main() {
  cin >> n >> m;
  
  vector<vector<int>> g(n);
  cnt = 0;
  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  
  vector<bool> seen(n, false); //全頂点をfalse、つまり未訪問で初期化。
  dfs(g,0,1,seen);
  
  cout << cnt;
  return 0;
}

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (int i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (int i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int was[mxn];

int f (int x) {
	if (x & 1) return x * 3 + 1;
	else return x / 2;
}
int a[N];

int main () {               
    cin >> a[1];
    was[a[1]] = 1;
    for (int i = 2; ; i ++) {
    	a[i] = f(a[i - 1]);
    	if (was[a[i]]) {
    		cout << i;
    		exit(0);
    	}
    	was[a[i]] = 1;
    }
    return Accepted;
}

// Coded By OB

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

#define ll long long
#define pb push_back

void solve()
{
    ll a,b,c;
    cin>>a>>b>>c;
    
    
    ll d = c-a-b;
    if(c-a-b>0 && 4*a*b<d*d) cout << "Yes" << endl; 
    else cout << "No" << endl;
    
    
}



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

Measured memory_bytes: 256
module prime_factorization
  implicit none
  integer :: num, p(1000)
contains
  subroutine prime_factor(n,f,m)
    implicit none
    integer, intent(in) :: n
    integer, intent(inout) :: f(:), m
    integer :: i, k, x, y
    m = 0
    f = 0
    k = 1
    x = n
    do
      y = x
      do i = k, num
        if (mod(x,p(i)).eq.0) then
          m = m+1
          f(m) = p(i)
          k = i
          x = x/p(i)
          exit
        end if
      end do
      if (x.eq.1) exit
      if (x.eq.y) then
        m = m+1
        f(m) = x
        exit
      end if
    end do
    return
  end subroutine prime_factor
  subroutine primes(n)
    implicit none
    integer, intent(in) :: n
    integer :: i, j
    logical :: s(n)
    s = .false.
    s(1) = .true.
    do i = 1, n
      if (s(i)) cycle
      do j = 2*i, n, i
        s(j) = .true.
      end do
    end do
    num = 0
    p = 0
    do i = 1, n
      if (i*i.gt.n) exit
      if (s(i)) cycle
      num = num+1
      p(num) = i
    end do
    return
  end subroutine primes
end module prime_factorization
program factors_of_factorial
  use prime_factorization
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer(8) :: cnt(1000) = 0_8, m = 1_8
  integer :: n, i, j, s, f(50) = 0
  read(*,*) n
  call primes(n)
  do i = 2, n
    call prime_factor(i,f,s)
    do j = 1, s
      cnt(f(j)) = cnt(f(j))+1_8
    end do
  end do
  do i = 1, n
    m = mod(m*(cnt(i)+1_8),md)
  end do
  write(*,'(i0)') m
  stop
end program factors_of_factorial

Measured memory_bytes: 256