akhauriyash/Code-Regression huggingface dataset:
alpha=['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
N=int(input())
S=input()
st=""
for s in S:
    index=alpha.index(s)
    if N+index>=len(alpha)-1:
        st = st + alpha[N + index-len(alpha)]
    else:

        st=st+alpha[N+index]
print(st)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;

  cout << s[0] << s[1] << s[2] << s[3] << " " << s[4] << s[5] << s[6] << s[7] << s[8] <<s[9] <<s[10] << s[11] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

typedef priority_queue<int, vector<int>, greater<int>> priority_queue_asc;

int main() {
    int N, K;
    cin >> N >> K;

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

    int ans = 1;
    int cnt = K;
    while (cnt < N) {
        cnt += K - 1;
        ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define ll long long
#define INF 2000000000
#define INF2 2000000000000000000
 
using namespace std;

int main() {
    
    IOS;

    ll n,x,m;
    cin >> n >> x >> m;
    ll arr[m + 5];
    arr[0] = x;
    map<ll, int>s;
    s[x] = 0;
    if(n <= m + 4) {
    	ll sum = x;
    	for(int i = 1; i < n; i++) {
    		arr[i] = (arr[i - 1] * arr[i - 1])%m;
    		sum += arr[i];
    	}
    	cout << sum;
    	return 0;
    }

    n--;
    ll tot = x;
    int startPos;
    int len;
    for(int i = 1; i <= m + 3; i++) {
   		arr[i] = (arr[i - 1] * arr[i - 1])%m;
   		if(s.find(arr[i]) != s.end()) {
   			startPos = s[arr[i]];
   			len = i - startPos;
   			break;
   		}
   		tot += arr[i];
   		s[arr[i]] = i;
   		n--;	
    }
    ll sum = 0;
	for(int j = startPos; j <= startPos + len - 1; j++)
   		sum += arr[j];
   	tot += (n/len) * sum;
   	n %= len;
   	for(int j = startPos; j <= startPos + n - 1; j++)
   		tot += arr[j];
   	cout << tot;

}

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

int main() {
  int n;
  cin>>n;
  set<string> dict;
  for (int i = 0; i < n ; i++) {
    string ope, word;
    cin>>ope>>word;
    if(ope=="insert")dict.insert(word);
    else cout<<(dict.count(word) ? "yes" : "no")<<endl;
  }
}



Measured memory_bytes: 32164
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String
    }

    match &*s {
        "Sunny" => println!("Cloudy"),
        "Cloudy" => println!("Rainy"),
        "Rainy" => println!("Sunny"),
        _ => println!("Error"),
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

struct edge {int to; ll cost; };
const int MAX_N = 1e5 + 100;
vector<edge> tree[MAX_N];
int N;
ll d[MAX_N];
bool col[MAX_N];

void tansaku(int cur){
    REP(i, 0, tree[cur].size()){
        int t = tree[cur][i].to;
        ll c = tree[cur][i].cost;
        if(d[t] == 0) { d[t] = d[cur] + c; tansaku(t); }
    }
}

int main()
{
    scanf("%d", &N);
    REP(i,0,N-1) {
        int u, v; ll w;
        scanf("%d %d %lld", &u, &v, &w);
        --u, --v;
        tree[u].push_back((edge){v, w});
        tree[v].push_back((edge){u, w});
    }
    d[0] = 0;
    tansaku(0);
    col[0] = true;
    REP(i, 1, N) if(d[i]%2) col[i] = false; else col[i] = true;
    REP(i,0,N) if(col[i]) printf("1\n"); else printf("0\n");
    return 0;
}

Measured memory_bytes: 10240
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
  	vector<int> A = igets(3);
  	sort(A.begin(),A.end());
  	int temp=A[0],ans=0;
	if(temp==A[1]) ans++; else temp = A[1];
  	if(temp==A[2]) ans++;
    cout << 3-ans << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
/*FUNC*/
//各桁の和
int EDSum(ll number){
    int ans=0;
    while(1){
        ans += number % 10;
        number /= 10;
        if(number == 0) break;
    }
    return ans;
}

//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

ll nPr(ll n,ll r) {
    ll ans=1;
    r=n-r;
    while(n!=r) {
        ans*=n;
        --n;
    }
    return ans;
}

ll nE(ll n) {
    return nPr(n,n);
}

ll nCr(ll n,ll r) {
    if(r==0)return -1;
    else{
        if(0!=n-r&&n-r<r)r=n-r;
        return nPr(n,r)/nE(r);
    }
}


Measured memory_bytes: 256
/*
	W A  自动机
		  --InterestingLSY
*/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define pb push_back
#define mp make_pair
#define INF 9999999
#define LINF 9999999999999999
#define SINF "%"
#define uint unsigned int
#define msn(a,v) memset(a,v,sizeof(a))
#define ms(a) msn(a,0)
#define NONE -1
#define ll long long
#define uchar unsigned char
#define sint short int
#define usint unsigned sint
#define xsize(a) sizeof(a)/1024/1024
#define fr(aaaaa,bbbbb) for(aaaaa = 1;aaaaa <= bbbbb;aaaaa++)
#define frr(aaaaa,bbbbb,ccccc) for(aaaaa = ccccc;aaaaa <= bbbbb;aaaaa++)
using namespace std;
#define MAXN 5100
 
int n,k;
ll data[MAXN];
 
int main(){
	//freopen("D.txt","r",stdin);
	
	scanf("%d %d",&n,&k);
	for(int i = 1;i <= n;i++)
		scanf("%lld",&data[i]);
	
	sort(data+1,data+n+1);
	
	int ans = 0;
	ll sum = (ll)0;
	for(int i = n;i >= 1;i--){
		if(sum + (ll)data[i] < k){
			sum += (ll)data[i];
			ans++;
			//cout << i << endl;
		}
		else ans = 0;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		final char[][] button = {
				{},
				{'.',',','!','?',' '},
				{'a','b','c'},
				{'d','e','f'},
				{'g','h','i'},
				{'j','k','l'},
				{'m','n','o'},
				{'p','q','r','s'},
				{'t','u','v'},
				{'w','x','y','z'}
		};
		int n = stdIn.nextInt();
		for(int j=0;j<n;j++){
			String[] key =  stdIn.next().split("0");
			for(int i=0;i<key.length;i++){
				if(key[i].length()<1){
					continue;
				}
				char[] tmp = key[i].toCharArray();
				int num = tmp[tmp.length-1]-'0';
				int times = key[i].length();
				int pos = times%(button[num].length)-1;
				if(pos<0){
					pos = button[num].length-1;
				}
				System.out.print(button[num][pos]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
from math import *
def g(x):
    y = (int((1000 * abs(x)) * 2 + 1) // 2) / 1000
    if x < 0:
        y *= -1
    return y
'''
def f(x):
    a = (x[2] - x[4]) * (x[1] - x[3]) - (x[0] - x[2]) * (x[3] - x[5])
    b = (x[0] - x[2]) * (x[4] - x[0]) - (x[5] - x[1]) * (x[1] - x[3])
    l = 0.5 * b / a
    X = 0.5 * x[2] + 0.5 * x[4] + l * (x[3] - x[5])
    Y = 0.5 * x[3] + 0.5 * x[5] + l * (x[4] - x[2])
    R = sqrt((X - x[0]) ** 2 + (Y - x[1]) ** 2)
    X = g(X)
    Y = g(Y)
    R = g(R)
    print("{0:.3f} {1:.3f} {2:.3f}".format(X, Y, R))
'''
def f(x):
    x1, y1, x2, y2, x3, y3 = x
    X1 = x1 - x3
    Y1 = y1 - y3
    X2 = x2 - x3
    Y2 = y2 - y3
    k  = (X2 ** 2 + Y2 ** 2 -X1 * X2 - Y1 * Y2) / (2 * (X2 * Y1 - X1 * Y2))
    X  = X1 / 2 + k * Y1 + x3
    Y  = Y1 / 2 - k * X1 + y3
    R = sqrt((X - x1) ** 2 + (Y - y1) ** 2)
    X = g(X)
    Y = g(Y)
    R = g(R)
    print("{0:.3f} {1:.3f} {2:.3f}".format(X, Y, R))

n = int(input())
a = []
for _ in range(n):
    a.append(list((map(float, input().split()))))
for i in a:
    f(i)



Measured memory_bytes: 5704
#include <iostream>
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

/*---------------------------------------------------*/

int H, W;
char s[55][55];

bool check(int y, int x){
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i], ny = y + dy[i];
    if(0 <= nx && nx < W && 0 <= ny && ny < H && s[ny][nx] == '#')return true;
  }
  return false;
}

int main(){

  cin >> H >> W;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> s[i][j];
    }
  }

  bool ok = true;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(s[i][j] == '#'){
	if(!check(i, j)) ok = false;
      }
    }
  }

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define in(n) ll a[n];  for (i=0;i<n;i++)   cin>>a[i]
#define inb(n) ll b[n]; for (i=0;i<n;i++)   cin>>b[i]
#define op(n) for(i=0;i<n;i++)  cout<<a[i]<<" ";  cout<<endl;

#define ini ll n,i,j,k,l,m,o,p,s=0,su=0,s1=0,s2=0,d,x,y,z,r,q
#define te ll t;cin>>t;while(t--)

#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define min4(a,b,c,d) min(min3(a,b,c),d)
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define maxa(a,n) (*max_element(a,a+n))
#define maxv(v) (*max_element(v.begin(),v.end())
#define mina(a,n) (*min_element(a,a+n))
#define minv(v) (*min_element(v.begin(),v.end())
#define sot(v) sort(v.begin(),v.end())

#define ct(v,k) count(v.begin(),v.end(),k)
#define pb(a) push_back(a)




#define fo(j,n) for(i=j;i<n;i++)

#define itr(v) for(auto it=v.begin();it!=v.end();it++) 


#define fi it->first
#define sc it->second

using namespace std;

typedef long long int ll;
typedef long double db;

const ll  mod=(ll )1e9+7;

   ll gcd(ll a,ll b) { if(a%b==0) return b; return gcd(b,a%b); }
   ll ab(ll a){if(a<0) return -1*a;return a;}   
   ll cei(ll a,ll b){ if(a==0) return 0;return ((a-1)/b)+1;}  // postive values only
   ll flo(ll a,ll b){return a/b;}
   ll lc(ll a,ll b){return ((a*b)/gcd(a,b));}


ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}



ll modInverse(ll a, ll m) { return power(a, m-2, m); }


void fastscan(ll &number)
{ 
    bool negative = false; 
     register ll c; number = 0; c = getchar(); 
    if (c=='-') 
    { 
        negative = true; 
        c = getchar(); 
    }
    
    for (; (c>47 && c<58); 
    c=getchar()) number = number *10 + c - 48; 
    if (negative)  number *= -1;   
}

inline vector<string> tokenize(string To_change,string delimiter)
{
    size_t pos = 0;
    string token;
    vector<string> changed;
    while ((pos = To_change.find(delimiter)) != string::npos) 
    {
        token = To_change.substr(0, pos);
        //cout << token << endl;
        changed.push_back(token);
        To_change.erase(0, pos + delimiter.length());
    }
    //cout << To_change << endl;
    changed.push_back(To_change);
    
    for(int i=0;i<(int)changed.size();i++)cout<<changed[i]<<endl;
    return changed;
}



/*
bool prime[1000001]; 
void Sieve(ll n){memset(prime, true, sizeof(prime));for (ll p=2; p*p<=n; p++) if (prime[p] == true) { for (ll i=p*p; i<=n; i += p)prime[i] = false;} prime[0]=false; prime[1]=false;}



ll fac[100001]; 
void ncrmodp(ll n, ll r, ll p){fac[0] = 1; for (ll i=1 ; i<=n; i++) fac[i] = fac[i-1]*i%p;} 
ll getncrmod(ll n,ll r,ll p){if (r==0) return 1;return (fac[n]* modInverse(fac[r], p) % p * modInverse(fac[n-r], p) % p) % p; }
*/ 

// function to print the divisors
  


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ini;
    cin>>n;
    cout<<3LL*n*n;
        
        
    return 0;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra


def main():
    import heapq
    import sys
    input = sys.stdin.buffer.readline
    N, M, L = map(int, input().split())

    G = [[-1]*N for i in range(N)]

    for i in range(M):
        A, B, C = map(int, input().split())
        A -= 1
        B -= 1
        G[A][B] = C
        G[B][A] = C
    g = csgraph_from_dense(G, null_value=-1)
    D = dijkstra(g)
    G2 = [[-1]*N for i in range(N)]
    for i in range(N):
        for j in range(N):
            if D[i][j] >= 0 and D[i][j] <= L:
                G2[i][j] = 1

    g2 = csgraph_from_dense(G2, null_value=-1)
    D = dijkstra(g2)


    Q = int(input())
    for _ in range(Q):
        s, t = map(int, input().split())
        s -= 1
        t -= 1
        if D[s][t] <= N**2:
            print(int(D[s][t])-1)
        else:
            print(-1)


main()


Measured memory_bytes: 44212
n,w = map(int,input().split())
dp = [[0]*(w+1) for _ in range(n+1)]

for i in range(n):
    a,b = map(int,input().split())
    for j in range(w+1):
        if b > j:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j] , dp[i][j-b] + a)
            
print(dp[n][w])


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

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    int sl = s.length();
    int tl = t.length();

    static long long dp[3000+1][3000+1];
    for(int i=1;i<3000+1;i++){
        dp[i][0] = 0;
        dp[0][i] = 0;
    }
    for(int i=1;i<sl+1;i++){
        for(int j=1;j<tl+1;j++){
            if(s[i-1]==t[j-1])
                dp[i][j] = max({dp[i-1][j],dp[i][j-1],dp[i-1][j-1]+1});
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }

    string ans = "";
    int i=sl,j=tl;
    while(i>0 && j>0){
        if(dp[i-1][j] == dp[i][j])
            i--;
        else if(dp[i][j-1] == dp[i][j])
            j--;
        else{
            ans = s[i-1] + ans;
            i--;
            j--;
        }
    }

    // cout << dp[sl][tl];
    cout << ans;

    return 0;
}

Measured memory_bytes: 70656
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int p = sc.nextInt(), q = sc.nextInt(), r = sc.nextInt();
   	int res = 0;
    if (p < q){
      res += p + Math.min(q,r);
    } else {
   		res += q + Math.min(p,r);
    }
    System.out.println(res);
  }
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

int N;
__int128 T[1010], A[1010];

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}



bool check(int i,__int128 y,__int128 pt,__int128 pa) {
  y = y * A[i];
  __int128 x = T[i] * y / A[i];
  return x >= pt && y >= pa;
}

void compute() {
  __int128 x = T[0];
  __int128 y = A[0];
  REP(i,1,N) {
    __int128 L = 0, R = 1000000000000000000;
    while( L + 1 < R ){
      __int128 M = ( L + R ) / 2;
      if( check(i,M,x,y) ) R = M;
      else                 L = M;
    }
    __int128 v;
    if( check(i,L,x,y) ) {
      v = L;
    } else if( check(i,(L+R)/2,x,y) ) {
      v = ( L + R ) / 2;
    } else {
      v = R;
    }
    y = v * A[i];
    x = T[i] * y / A[i];
  }
  
  cout << x + y << endl;
}

int main() {
  cin >> N;
  rep(i,N) {
    int a,b;
    cin >> a >> b;
    T[i] = a, A[i] = b;
  }
  compute();
  return 0;
}


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

using namespace std;

int main() {

    string S; cin >> S;

    int min_diff = 1000;

    for (int i = 0; i < S.length() - 2; ++i) {
        string num;
        num = S.substr(i, 3);
        int diff;
        diff = abs(stoi(num) - 753);

        min_diff = min(min_diff, diff);
    }

    cout << min_diff << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i,cnt;
  char ox[3];
  cnt=0;
  scanf("%s",ox);
  for(i=0;i<3;i++){
    if(ox[i]=='o'){
      cnt++;
    }
  }
  printf("%d\n",700+100*cnt);
  return 0;
}


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

d_li = []
for i in range(n):
    line = list(map(int, input().split()))
    d_li.append(line)

count = 0
for i in range(n):
    if d_li[i][0] == d_li[i][1]:
        count += 1
    else:
        count = 0
    
    if count == 3:
        msg = "Yes"
        break
    else:
        msg = "No"

print(msg)


Measured memory_bytes: 62424
N = int(input())
L = list(map(int, input().split()))
sort_L = sorted(L)
count = 0

for i in range(N - 2):
  a = sort_L[i]
  for j in range(i + 1,N - 1):
    b = sort_L[j]
    for k in range(j + 1,N):
      c = sort_L[k]
      if (a != b) and (b != c) and (a != c) and (abs(a-b) < c < (a + b)):
        count = count + 1
      
print(count)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N;cin>>N;
    map<int,int>memo;
    REPS(i,N){
        int C=i;
        for(int j=2;j<=sqrt(C);j++){
            while(C%j==0){
                memo[j]++;
                C/=j;
            }
        }
        if(C!=1)memo[C]++;
    }
    int c74=0,c24=0,c14=0,c4=0,c2=0;
    for(auto v:memo){
        if(v.second>=74)c74++;
        if(v.second>=24)c24++;
        if(v.second>=14)c14++;
        if(v.second>=4)c4++;
        if(v.second>=2)c2++;
    }
    int ans=c74+c24*(c2-1)+c14*(c4-1)+c4*(c4-1)*(c2-2)/2;
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int a = x1 - x2, b = y1 - y2;
	cout << x2 + b << " " << y2 - a << " " << x1 + b << " " << y1 - a << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
const int mod=1e9+7;
char c[1005][1005];
int dp[1005][1005];
int n,m;

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		scanf("%s",c[i]);
	}
	for(int i=0;i<n;i++)
	{
		if(c[i][0]=='#') break;
		dp[i][0]=1;
	}
	for(int j=0;j<m;j++)
	{
		if(c[0][j]=='#') break;
		dp[0][j]=1;
	}
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<m;j++)
		{
			if(c[i][j]=='#') dp[i][j]=0;else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		}
	}
	cout<<dp[n-1][m-1]<<endl;
	return 0;
}

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

using namespace std;

// int jumps(int n, int N, int a[],int dp[]) {
//     int x,y;
//     x = y = INT_MAX;
//     if(n == N) return 0;
//     else if(dp[n] != 0) return dp[n];
//     else {
//         if(n+1 <= N) x = jumps(n+1,N,a,dp) + abs(a[n] - a[n+1]);
//         if(n+2 <= N) y = jumps(n+2,N,a,dp) + abs(a[n] - a[n+2]);
//         dp[n] = min(x,y);
//         return dp[n];
//     }
// }

int jumps(int N, int a[],int k) {
    int x,y;
    int dp[N+1] = {0}; 
    for(int i=2; i<=N; i++) {
        x = y = INT_MAX;
        for(int j=1; j<=k; j++) {
            if(i-j>=1) x = dp[i-j] + abs(a[i] - a[i-j]);
            y = min(x,y); 
        }
        dp[i] = y;
    }
    return dp[N];
}

int main() {
    int N,k;
    cin>>N>>k;
    int a[N+1]; 
    for(int i=1; i<=N; i++) cin>>a[i];
    cout<<jumps(N,a,k);
    return 0;
}

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

size_t GetNumber(size_t N){
    if( N==10
     || N==100
     || N==1000
     || N==1000
     || N==10000
     || N==100000
    ){
        return 10;
    }

    size_t n = 0;
    while(N>=10){
        n += N%10;
        N /=10;
    }
    n += N%10;

    return n;
}

int main()
{
    size_t N;
    cin >> N;
    auto n = GetNumber(N);
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
double dist(ii a, ii b){
	double ans= pow(a.first-b.first,2) + pow(a.second-b.second,2);
	return sqrt(ans);
}
int main(){
	int n, div=1; cin>>n; 
	vector<ii>p(n);
	for(int i=0;i<n;i++){
		cin>>p[i].first>>p[i].second;
		div *= n-i;
	}
	double ans=0.0, cur;
	sort(p.begin(),p.end());
	do{
		for(int i=0;i<n-1;i++) {
			cur = dist(p[i], p[i+1]);
			ans+=cur;
		}
	}while(next_permutation(p.begin(),p.end()));
	ans /= div;
	cout<<setprecision(9)<<fixed<<ans<<endl;
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  sort(s.begin(), s.end());

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

  return 0;
}

Measured memory_bytes: 3640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	k := intScanner()
	as := intSliceScanner(k)
	if as[k-1] != 2 {
		fmt.Println(-1)
	} else {
		x := 2
		y := 3
		f := true
		for i := k - 2; i >= 0; i-- {
			p := (x + as[i] - 1) / as[i]
			q := y / as[i]
			if p*as[i] > y || q*as[i]+as[i]-1 < x {
				f = false
			} else {
				x = p * as[i]
				y = q*as[i] + as[i] - 1
			}
		}
		if f {
			fmt.Println(x, y)
		} else {
			fmt.Println(-1)
		}
	}
}


Measured memory_bytes: 4208
import std.algorithm, std.conv, std.range, std.stdio, std.string;

const mod = 10 ^^ 9 + 7;
alias mint = FactorRing!mod;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto a = readln.split.to!(int[]);
  a.sort();

  auto check()
  {
    auto b = a;
    if (n % 2 == 1) {
      if (b[0] != 0) return false;
      b = b[1..$];
    }
    foreach (i, bi; b)
      if (bi != i/2 * 2 + 2 - (n % 2 == 0)) return false;

    return true;
  }

  if (!check)
    writeln(0);
  else
    writeln(repeatedSquare(mint(2), n/2));
}

T repeatedSquare(T, alias pred = "a * b", U)(T a, U n)
{
  return repeatedSquare(a, n, T(1));
}

T repeatedSquare(T, alias pred = "a * b", U)(T a, U n, T init)
{
  import std.functional;
  alias predFun = binaryFun!pred;

  if (n == 0) return init;

  auto r = init;
  while (n > 0) {
    if ((n & 1) == 1)
      r = predFun(r, a);
    a = predFun(a, a);
    n >>= 1;
  }

  return r;
}

struct FactorRing(int m, bool pos = false)
{
  version(BigEndian) {
    union { long vl; struct { int vi2; int vi; } }
  } else {
    union { long vl; int vi; }
  }

  @property int toInt() { return vi; }
  alias toInt this;

  this(int v) { vi = v; }
  this(int v, bool runMod) { vi = runMod ? mod(v) : v; }
  this(long v) { vi = mod(v); }

  ref FactorRing!(m, pos) opAssign(int v) { vi = v; return this; }

  pure auto mod(int v) const
  {
    static if (pos) return v % m;
    else return (v % m + m) % m;
  }

  pure auto mod(long v) const
  {
    static if (pos) return cast(int)(v % m);
    else return cast(int)((v % m + m) % m);
  }

  static if (m < int.max / 2) {
    pure auto opBinary(string op: "+")(int rhs) const { return FactorRing!(m, pos)(mod(vi + rhs)); }
    pure auto opBinary(string op: "-")(int rhs) const { return FactorRing!(m, pos)(mod(vi - rhs)); }
  } else {
    pure auto opBinary(string op: "+")(int rhs) const { return FactorRing!(m, pos)(mod(vl + rhs)); }
    pure auto opBinary(string op: "-")(int rhs) const { return FactorRing!(m, pos)(mod(vl - rhs)); }
  }
  pure auto opBinary(string op: "*")(int rhs) const { return FactorRing!(m, pos)(mod(vl * rhs)); }

  pure auto opBinary(string op)(FactorRing!(m, pos) rhs) const
    if (op == "+" || op == "-" || op == "*") { return opBinary!op(rhs.vi); }

  static if (m < int.max / 2) {
    auto opOpAssign(string op: "+")(int rhs) { vi = mod(vi + rhs); }
    auto opOpAssign(string op: "-")(int rhs) { vi = mod(vi - rhs); }
  } else {
    auto opOpAssign(string op: "+")(int rhs) { vi = mod(vl + rhs); }
    auto opOpAssign(string op: "-")(int rhs) { vi = mod(vl - rhs); }
  }
  auto opOpAssign(string op: "*")(int rhs) { vi = mod(vl * rhs); }

  auto opOpAssign(string op)(FactorRing!(m, pos) rhs)
    if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(rhs.vi); }
}


Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
#define int long long int
//int dp[300006];
int dp[102][102*500];
int32_t main(){
    string s,t;
    cin>>s>>t;
    string ans="Yes";
    map<char,char>c1,c2;
    for(int i=0;i<s.size();i++){
        if(c1.count(s[i])){
            if(c1[s[i]]!=t[i]){
               // cout<<"No"<<endl;
                //return 0;
                ans="No";
                break;
            }
        }
        if(c2.count(t[i])){
            if(c2[t[i]]!=s[i]){
                ans="No";
                break;
            }
        }
        
        c1[s[i]]=t[i];
        c2[t[i]]=s[i];
    }
    cout<<ans<<endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int n,m;cin>>n>>m;
    vii a(n);
    rep(i,n){
        cin>>a[i].F>>a[i].S;
    }
    sort(all(a));
    deque<int>A,B;
    rep(i,n){
        A.PB(a[i].F);
        B.PB(a[i].S);
    }
    rep(i,n){
    }
    priority_queue<int>q;
    int d=1;
    ll ans=0;
    while(d<=m){
        int x=A.front();
        while(x==d&&!A.empty()){
            A.pop_front();
            int y=B.front();
            B.pop_front();
            q.push(y);
            x=A.front();
        }
        if(!q.empty()){
        int v=q.top();
        q.pop();
        ans+=v;}
        d++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2464
#奇数だから一個仲間外れにできるとの神(ki..sh..ak..i)の啓示

n = int(input())
a = [int(i) for i in input().split()]
w = [] #逆向きの答え
s = sum(a)/2
k = n//2
#w(n-1)を求める
a_odd = [a[2*i] for i in range(0,k)]
w.append(s-sum(a_odd))
for i in reversed(range(n-1)):
  w.append(a[i]-w[-1])
w.reverse()
for i in range(n):
  print(int(2*w[i]), end=" ")

Measured memory_bytes: 14092
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n+1), b(m+1);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < m; ++i) {
        scanf("%d", &b[i]);
    }
    a[n] = -1, b[m] = -1;
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());
    if(a.size() != n+1 || b.size() != m+1 || a[n] != n*m || b[m] != n*m){
        puts("0");
        return 0;
    }
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    ll ans = 1, p = 0, q = 0, c = 0;
    for (int j = n*m; j >= 1; --j) {
        while(a[p+1] >= j) p++;
        while(b[q+1] >= j) q++;
        if(a[p] == j && b[q] == j) {}
        else if(a[p] == j){
            (ans *= q+1) %= MOD;
        }else if(b[q] == j){
            (ans *= p+1) %= MOD;
        }else {
            (ans *= ((p+1)*(q+1)-c)) %= MOD;
        }
        c++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import Counter

N, K = sys.stdin.readline().split()
K = int(K)
line = sys.stdin.readline()
A = map(int, line.strip().split())
D = Counter(A)
diff = len(D) - K

if diff <= 0:
    print(0)
else:
    print( sum( i[1] for i in D.most_common()[-1*diff:]) )


Measured memory_bytes: 42760
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, A, B = map(int, readline().split())
H = [int(readline()) for _ in range(N)]


def C(T):
    """
    T回爆発させて、魔物全滅できるか
    """
    damage = B * T
    cnt = 0
    for h in H:
        h -= damage
        if h <= 0:
            continue
        cnt += (h + (A - B) - 1) // (A - B)
        if cnt > T:
            return False
    return cnt <= T


left = 0
right = 10 ** 18
while right - left > 1:
    mid = (right + left) // 2
    if C(mid):
        right = mid
    else:
        left = mid

ans = right
print(ans)


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

int main(){
    ll x; cin >> x;

    ll limit = 119;
    loop(a, -limit, limit)loop(b, -limit, limit){
        ll a5 = a*a*a*a*a;
        ll b5 = b*b*b*b*b;
        if((a5 - b5) == x) {
            cout << a << ' ' << b << endl;
            return 0;
        }
    }

    return 0;
}

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

int main() {
  int N, W;
  cin>>N>>W;

  vector<long long> v[4];

  long long w1, v1;
  cin>>w1>>v1;
  v[0].push_back(v1);
  for (int i=0; i<N-1; i++) {
    long long wi, vi;
    cin>>wi>>vi;
    v[wi - w1].push_back(vi);
  }
  for (int i=0; i<4; i++) {
    sort(v[i].begin(), v[i].end());
    reverse(v[i].begin(), v[i].end());
  }
  vector<long long> acc[4];
  for (int i=0; i<4; i++) {
    acc[i].push_back(0);
    for (int j=1; j<=v[i].size(); j++) {
      acc[i].push_back(v[i][j-1] + acc[i][j-1]);
    }
  }
  long long ans = 0;
  for (int i=0; i<acc[0].size(); i++) {
    long long tmp_w = w1 * i;
    if (tmp_w > W) {
      break;
    }
    for (int j=0; j<acc[1].size(); j++) {
      long long tmp_w2 = tmp_w + (w1 + 1) * j;
      if (tmp_w2  > W) {
        break;
      }
      for (int k=0; k<acc[2].size(); k++) {
        long long tmp_w3 = tmp_w2 + (w1 + 2) * k;
        if (tmp_w3 > W) {
          break;
        }
        int l = 0;
        if (W - tmp_w3 > 0) {
          l = min((W - tmp_w3) / (w1 + 3), (long long)acc[3].size() - 1);
        }
        ans = max(ans, acc[0][i] + acc[1][j] + acc[2][k] + acc[3][l]);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
class Factorials:
    def __init__(self, n, mod):
        self.mod = mod

        # self.fac[i] ≡ i! (factorial:階乗)
        self.fac = [1]
        num = 1
        for i in range(1, n+1):
            num *= i
            num %= mod
            self.fac.append(num)

        # self.rec[i] ≡ 1 / i! (reciprocal:逆数)
        num = pow(num, mod-2, mod)
        self.rec = [1 for i in range(n+1)]
        self.rec[n] = num
        for i in range(n-1, 0, -1):
            num *= i + 1
            num %= mod
            self.rec[i] = num

    # comb(n, r) ≡ nCr
    def comb(self, n, r):
        return self.fac[n] * self.rec[r] * self.rec[n - r] % self.mod
    
    # perm(n, r) ≡ nPr
    def perm(self, n, r):
        return self.fac[n] * self.rec[n-r] % self.mod

def main():
    n, m = map(int, input().split())
    mod = 10**9 + 7

    f = Factorials(m, mod)

    ans = 0
    for i in range(n+1):
        if i % 2 == 0:
            ans += f.comb(n, i) * f.perm(m, i) * f.perm(m-i, n-i) * f.perm(m-i, n-i) % mod
        else:
            ans -= f.comb(n, i) * f.perm(m, i) * f.perm(m-i, n-i) * f.perm(m-i, n-i) % mod
        ans %= mod

    print(ans)

main()

Measured memory_bytes: 48372
import java.util.Scanner;

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

		if(A.length()>B.length()) {
			int diff=A.length()-B.length();
			for(int i=0; i<diff; i++) {
				B="0"+B;
			}
		}
		else if(A.length()<B.length()) {
			int diff=B.length()-A.length();
			for(int i=0; i<diff; i++) {
				A="0"+A;
			}
		}

		for(int i=0; i<A.length(); i++) {
			int AA=Integer.parseInt(A.charAt(i)+"");
			int BB=Integer.parseInt(B.charAt(i)+"");

			if(AA>BB) {
				System.out.println("GREATER");
				System.exit(0);
			}

			else if(AA<BB) {
				System.out.println("LESS");
				System.exit(0);
			}
		}
		System.out.println("EQUAL");
	}
}

Measured memory_bytes: 23124
#include <iostream>

using namespace std;

int main()
{
    int n, q, s[10010], t[510], cnt=0;
    cin>>n;
    for (int i=0; i<n; i++) cin>>s[i];
    cin>>q;
    for (int i=0; i<q; i++) cin>>t[i];
    for (int i=0; i<q; i++)
    {
        for (int j=0; j<n; j++)
        {
            if (s[j]==t[i])
            {
                cnt++;
                break;
            }
        }
    }
    cout<<cnt<<'\n';
    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define dd(x) cout<<#x<<" = "<<x<<" "
#define de(x) cout<<#x<<" = "<<x<<endl
#define sz(x) int(x.size())
#define All(x) x.begin(),x.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef priority_queue<int> pq;
const int maxn=1e5+10,mod=1e9+7,INF=0x3f3f3f3f;
char s[maxn];
ll f[maxn][20];
int n;
ll dfs(int pos,int val){
	if (f[pos][val]!=-1)
		return f[pos][val];
	if (pos>=n)
		return val==5;
	ll tmp=0;
	if (s[pos]!='?')
		tmp=dfs(pos+1,(val*10+(s[pos]-'0'))%13);
	else{
		for (int i=0;i<=9;++i)
			tmp=(tmp+dfs(pos+1,(val*10+i)%13))%mod;
	}
	f[pos][val]=tmp;
	return tmp;
}
int main()
{
	scanf("%s",s);
	n=strlen(s);
	memset(f,-1,sizeof(f));
	cout<<dfs(0,0);
	return 0;
}

Measured memory_bytes: 23808
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <iterator>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ff first
#define ss second
#define END "\n"
#define pb push_back
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<ii> vii;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////
int main()
{
    ll n, W, w, v, ans;
    cin >> n >> W;
    vector<ll> dp(W + 1, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> w >> v;
        for (int j = W - w; j >= 0; --j)
        {
            dp[j + w] = max(dp[j + w], dp[j] + v);
        }
        //for (i = 0; i < W; ++)
    }
    ans = 0;
    for (int i = 0; i <= W; i++)
    ans = max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<pair<int,int> > v;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		v.push_back(make_pair(x, 1));
	}
	for(int i = 1; i < n; i++){
		if(v[i].first < v[i-1].first){
			for(int j = 0; v[i-j] < v[i-j-1] && i-j >= 0; j++){
				if(v[i-j-1].second > 0){
					v[i-j-1].first--;
					v[i-j-1].second--;
				}
				if(v[i-j].first < v[i-j-1].first){
					cout << "No" << endl;
					return 0;
				}
				if(v[i-j-1].first >= v[i-j-2].first){
					break;
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1400
//
// Created by rajshah9914 on 05/04/20.
//

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,a[100000];
    cin>>n>>m;
    int s=0;
    for(int i=0;i<n;i++)
        cin>>a[i],s+=a[i];
    sort(a,a+n);
//    int x=s/(4*m);
int c=0;
    for(int i=0;i<n;i++)
    {
        if(4*m*a[i]>=s)
            c++;
        if(c==m)
            break;
    }
    if(c<m)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;

int main(){
    cin.tie(0);
    int i,N;
    char s[100000];
    cin >> s;
    N=strlen(s);
    for (i=0;i<N;i++){
        if(i%2 == 0){
            cout << s[i];
        }
    }
    return 0;
}

Measured memory_bytes: 384
import math
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]
tot = 0

for i in range(n):
  for j in range(n):
    tot += math.sqrt((a[i][0]-a[j][0])**2 + (a[i][1]-a[j][1])**2)
    
print(tot/n)

Measured memory_bytes: 9120
use std::io::Read;
use std::cmp::*;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let h: usize = it.next().unwrap().parse().unwrap();
    let w: usize = it.next().unwrap().parse().unwrap();
    let mut dp = vec![0; w + 1];
    let mut ans = 0;
    for _ in 0..h {
        let mut next = vec![0; w + 1];
        for i in 1..(w + 1) {
            let a: usize = it.next().unwrap().parse().unwrap();
            if a == 0 {
                next[i] = min(next[i - 1], min(dp[i], dp[i - 1])) + 1;
                ans = max(next[i], ans);
            }
        }
        dp = next;
    }
    ans *= ans;
    println!("{}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 10112
#include <bits/stdc++.h>
#define debug(x) cout << #x << " -> " << x << endl
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


void testcase(){
	int n,k,a[200005];
	cin >> n >> k;
	for(int i{0};i < n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	ll ans = 0;
	for(int i{0};i < k;i++){
		ans += (ll)a[i];
	}
	cout << ans << "\n";
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


Measured memory_bytes: 3664
import math
from collections import deque
def main():
    h,w = tuple([int(t)for t in input().split()])

    s = [['.']*(w+1)]

    s.extend(([list('.'+input()) for _ in range(h)]))

    dp = [[0]*(w+1) for _ in range(h+1)]

    for i in range(h):
        if s[i+1][1] == '.':
            dp[i+1][1] = dp[i][1]
        else:
            if s[i][1]=='.':
                dp[i+1][1] = dp[i][1]+1
            else:
                dp[i+1][1] = dp[i][1]

    for j in range(w):
        if s[1][j+1] == '.':
            dp[1][j+1] = dp[1][j]
        else:
            if s[1][j]=='.':
                dp[1][j+1] = dp[1][j]+1
            else:
                dp[1][j+1] = dp[1][j]

    for i in range(1,h):
        for j in range(1,w):
            if s[i+1][j+1] == '.':
                dp[i+1][j+1] = min(dp[i][j+1],dp[i+1][j])
            else:
                if s[i][j+1] == '.':
                    if s[i+1][j] == '.':
                        dp[i+1][j+1] = min(dp[i][j+1],dp[i+1][j])+1
                    else:
                        dp[i+1][j+1] = min(dp[i][j+1]+1,dp[i+1][j])
                else:
                    if s[i+1][j] == '.':
                        dp[i+1][j+1] = min(dp[i][j+1],dp[i+1][j]+1)
                    else:
                        dp[i+1][j+1] = min(dp[i][j+1],dp[i+1][j])

    print(dp[-1][-1])
if __name__ == "__main__":
    main()

Measured memory_bytes: 3532
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	long long n,k;cin>>n>>k;
  cout << min(n%k,k-(n%k)) << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
lists = list(input().split())
ave_sum = 0
for i in lists:
  ave_sum = ave_sum + int(i)
ave = round(ave_sum / N)
nijyo = 0
for i in lists:
  nijyo = nijyo + (int(i) - ave) ** 2
print(str(nijyo))

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];
//平方根　= sqrt




void solve() {
  int n,d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i,n) {
    rep(j,d) cin >> x[i][j];
  }

  int ans =0;
  rep(i,n)rep(j,i) { // j<i
    int sq =0;
    rep(k,d) {
      int diff = x[i][k] - x[j][k];
      sq += diff * diff;
    }
    int s = sqrt(sq) + 0.5; // 1.9999....
    if (s*s == sq) ans++;
  }
  cout << ans << endl;
  return ;

}

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


Measured memory_bytes: 256