akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{     

    static void InsertionSort(int[] data, int n, int g)
    {
        for(int i = g; i < n; i++)
        {
            int v = data[i];
            int j = i - g;
            while (j >= 0 && data[j] > v)
            {
                data[j + g] = data[j];
                j -= g;
                cnt++;
            }
            data[j + g] = v;
        }
    }

    static void ShellSort(int[] data, int n, List<int> g)
    {
        for(int h = 1; ;)
        {
            if(h > n)
            {
                break;
            }
            g.Add(h);
            h = 3 * h + 1;
        }

        for(int i = g.Count - 1; i >= 0; i--)
        {
            InsertionSort(data, n, g[i]);
        }

    }

    static int cnt;

    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] data = new int[n];
        List<int> g = new List<int>();
        cnt = 0;

        for (int i = 0; i < n; i++)
        {
            data[i] = int.Parse(Console.ReadLine());
        }

        ShellSort(data, n, g);

        Console.WriteLine(g.Count);        
        for(int i = g.Count - 1; i >= 0; i--)
        {
            if(i != 0)
            {
                Console.Write(g[i] + " ");
            }
            else
            {
                Console.WriteLine(g[i]);
            }         
        }
        Console.WriteLine(cnt);
        
        foreach(var s in data)
        {
            Console.WriteLine(s);
        }

    }
}


Measured memory_bytes: 23276
#include <functional>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
using namespace std;
 
#define pii pair<int, int>
#define rank asdf
 
const int mod = (int)1e9 + 7;

int n;
vector<pii> g[22];
int type[22];

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for(int i = 0, a; i < n; ++i){
        cin >> a;
        for(int j = 0, x, y; j < a; ++j){
            cin >> x >> y;
            x--;
            g[i].push_back({x, y});
        }
    }
    int ans = 0;
    for(int mask = 0; mask < (1 << n); ++mask){
        memset(type, -1, sizeof type);
        bool ok = 1;
        int cnt = 0;
        for(int i = 0; i < n; ++i){
            if(mask & (1 << i)) type[i] = 1;
            else type[i] = 0;
        }
        for(int i = 0; i < n && ok; ++i){
            if(mask & (1 << i)){
                cnt++;
                for(auto x : g[i]){
                    if(type[x.first] != x.second){
                        ok = 0;
                        break;
                    }
                }
            }
        }
        if(ok) ans = max(ans, cnt);
    }
    cout << ans << endl;
}

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


void solve(long long a, long long b, long long h){
	cout << (a+b)*h/2 << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long h;
    scanf("%lld",&h);
    solve(a, b, h);
    return 0;
}


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

using namespace std;
typedef long long ll;

string s;

ll Sum(int pre, int now, ll sum) {
	ll ans = 0;
	for (int i = 0; i < now - pre; i++)
		ans += (s[now - i] - '0')*ll(pow(10, i));
	if (now == s.size() - 1)
		return ans + sum;
	return Sum(pre, now + 1, sum) + Sum(now, now + 1, sum + ans);
}

int main(void) {
	cin >> s;
	cout << Sum(-1, 0, 0) << "\n";
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		int[] p = Arrays.stream(sc.nextLine().split(" ")).mapToInt(s -> Integer.parseInt(s)).toArray();

		int miss = 0;
		for (int i = 0; i < N; i++) {
			if (p[i] != i + 1) {
				miss += 1;
			}
		}
		if (miss == 0 || miss == 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 26964
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll MOD = 1000000007LL;

ll dp[22][1 << 21];

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

  dp[0][0] = 1;
  for(int i = 0; i < N; i++){
    for(int msk = 0; msk < (1 << N); msk++){
      if(dp[i][msk] != 0LL){
        for(int j = 0; j < N; j++){
          if(!(msk & (1 << j)) && a[i][j]){
            dp[i + 1][msk | (1 << j)] += dp[i][msk];
            dp[i + 1][msk | (1 << j)] %= MOD;
          }
        }
      }
    }
  }

  cout << dp[N][(1 << N) - 1] << endl;
  return 0;
}


Measured memory_bytes: 309504
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	ll sum = 0;
	for (int i = 0; i <= s.size(); i++) {
		for (int j = i + 1; j <= s.size(); j++) {
			ll p = stoll(s.substr(i, j - i));
			int o = i - 1, k = s.size() - j - 1;
			if (o < 0) o = 0; if (k < 0) k = 0;
			sum += p * (1LL << (o + k));
		}
	}
	cout << sum << endl;
 	return 0;
}

Measured memory_bytes: 256
///
// File:  d.go
// Author: ymiyamoto
//
// Created on Sat Apr 14 22:13:52 2018
//
package main

import (
	"fmt"
	"sort"
)

var n int
var a []int

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func main() {
	fmt.Scan(&n)
	a = make([]int, n)

	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)

	max := a[len(a)-1]
	min := 1 << 30
	var mid int
	for i := range a {
		if abs(2*a[i]-max) < min {
			mid = a[i]
			min = abs(2*a[i] - max)
		}
	}

	fmt.Println(max, mid)
}


Measured memory_bytes: 5504
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[6];
    int i;
    scanf("%d%d%d%d%d",&a[1],&a[2],&a[3],&a[4],&a[5]);
    for(i=1;i<=5;i++){
        if(a[i]==0)
            break;
    }
    printf("%d\n",i);
    return 0;
}


Measured memory_bytes: 1676
import sys
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
s=a[n-1]
if s==0:
    print(0)
else:
    for i in range(0,n-1):
        s*=a[i]
        if s>10**18:
            print(-1)
            sys.exit()
    print(s)


Measured memory_bytes: 21792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using Graph = vector<vector<int>>;
using ll = long long;


int main() {
    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<char>> c(h,vector<char> (w));
    rep(i,h){
        rep(j,w){
            cin>>c[i][j];
        }
    }
    int ans=0;
    rep(i,1<<h){
        rep(p,1<<w){
            vector<vector<char>> cc(h,vector<char> (w));
          cc=c;
            rep(j,h){
                if(i>>j&1){
                    rep(k,w){
                        cc[j][k]='r';
                    }
                }
            }
            rep(q,w){
                if(p>>q&1){
                    rep(r,h){
                        cc[r][q]='r';
                    }
                }
            }
            int count=0;
            rep(x,h){
                rep(y,w){
                    if(cc[x][y]=='#'){
                        count++;
                    }
                }
            }
            if(count==k){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

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

    multiset<int> st = {0, 0, 0};

    int mod = 1e9 + 7;
    int count = 1;
    for(int i=0; i<n; i++){
        int num = st.count(a[i]);
        count = (count * num) % mod;
        if(num != 0){
            auto itr = st.find(a[i]);
            st.insert(*itr + 1);
            st.erase(itr);
        }
        else{
            cout << 0 << endl;
            return 0;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 4032
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
using namespace std;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}
int moji(char i){
  if(i=='a'){
    return 1;
  }
  if(i=='b'){
    return 2;
  }
  if(i=='c'){
    return 3;
  }
  if(i=='d'){
    return 4;
  }
  if(i=='e'){
    return 5;
  }
  if(i=='f'){
    return 6;
  }
  if(i=='g'){
    return 7;
  }
  if(i=='h'){
    return 8;
  }
  if(i=='i'){
    return 9;
  }
  if(i=='j'){
    return 10;
  }
  if(i=='k'){
    return 11;
  }
  if(i=='l'){
    return 12;
  }
  if(i=='m'){
    return 13;
  }
  if(i=='n'){
    return 14;
  }
  if(i=='o'){
    return 15;
  }
  if(i=='p'){
    return 16;
  }
  if(i=='q'){
    return 17;
  }
  if(i=='r'){
    return 18;
  }
  if(i=='s'){
    return 19;
  }
  if(i=='t'){
    return 20;
  }
  if(i=='u'){
    return 21;
  }
  if(i=='v'){
    return 22;
  }
  if(i=='w'){
    return 23;
  }
  if(i=='x'){
    return 24;
  }
  if(i=='y'){
    return 25;
  }
  if(i=='z'){
    return 26;
  } 
  return 100;
  
}





int main() {
  string s;
  cin>>s;
  int point,sum;
  point=0;
  sum=0;
  for(int i=0;i<s.size();i++){
    if(sum==0){
      if(s.at(i)=='g'){
        sum++;
      }else{
        sum++;
        point--;
      }
    }else{
      if(s.at(i)=='g'){
        point++;
        sum--;
      }else{
        sum--;
      }
    }
  }
  cout<<point<<endl;







  

  
  
  


  
  


  

  




  
  
}


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

int main(){
  vector<char> s(3);
  for(int i=0;i<3;i++){
    cin >> s.at(i);
  }
  sort(s.begin(),s.end());
  if(s.at(0)=='a'&&s.at(1)=='b'&&s.at(2)=='c'){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

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

 int v[n];
 int w[n];

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

 int DP[n+1][W+1];

 for(int j=0;j<=W;j++){
	DP[0][j]=0;
 }

 for(int i=1;i<=n;i++){
	for(int j=0;j<=W;j++){
		if(j<w[i-1]){
			DP[i][j]=DP[i-1][j];
		}else{
			if(DP[i-1][j]>DP[i-1][j-w[i-1]]+v[i-1]){
				DP[i][j]=DP[i-1][j];
			}else{
				DP[i][j]=DP[i-1][j-w[i-1]]+v[i-1];
			}
		}
	}
 }
 cout<<DP[n][W]<<endl;
return 0;
}

Measured memory_bytes: 7000
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int r,c;
	while(1){
		cin>>r>>c;
		if(r+c==0) break;
		o((r*c%2?"no":"yes"));
	}
}

Measured memory_bytes: 1152
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;


#define INF (1ll<<60)

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

vector<vector<int>> G;
typedef pair<int,int> pii;
int main(int argc, char const *argv[]) {
  int h,w,k;cin>>h>>w>>k;
  vector<string> ss(h);
  // G=vector<vector<int>>(n);
  for(int i=0;i<h;++i)cin>>ss[i];
  int s,t;
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      if(ss[i][j]=='S'){
        s=i;
        t=j;
      }
    }
  }
  vector<vector<int>> dist(h,vector<int>(w,-1));
  queue<pii> que;
  que.push(pii(s,t));
  int res=1<<30;
  dist[s][t]=0;
  res=min(res,s);
  res=min(res,h-1-s);
  res=min(res,t);
  res=min(res,w-1-t);
  while(!que.empty()){
    pii u=que.front();
    que.pop();
    res=min(res,u.first);
    res=min(res,h-1-u.first);
    res=min(res,u.second);
    res=min(res,w-1-u.second);
    vector<pii> tmp;
    if(u.first>0)tmp.push_back(pii(u.first-1,u.second));
    if(u.second>0)tmp.push_back(pii(u.first,u.second-1));
    if(u.first<h-1)tmp.push_back(pii(u.first+1,u.second));
    if(u.second<w-1)tmp.push_back(pii(u.first,u.second+1));
    for(pii v:tmp){
      if(dist[v.first][v.second]==-1&&ss[v.first][v.second]=='.'){
        dist[v.first][v.second]=dist[u.first][u.second]+1;
        if(dist[v.first][v.second]<=k)que.push(v);
      }
    }
  }
  cout<<(1+(res+k-1)/k)<<endl;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
string a[1005];
int dp[1005][1005];
int mod=1e9+7;
int main(){
cin>>n>>m;
dp[1][1]=1;
for(int i=1;n>=i;i++)
{
	cin>>a[i];
	a[i]='1'+a[i];
	for(int j=1;m>=j;j++)
	{
		if(a[i][j]=='#')
			continue;
		if(j!=1 and a[i][j-1]=='.')
			dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
		if(i!=1 and a[i-1][j]=='.')
			dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
	}
}
cout<<dp[n][m];

return 0;
}


Measured memory_bytes: 5248
#include <iostream>

using namespace std;

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

int main(){
	int T;
	cin >> T;
	while(T--){
		int ng[20][20][20][20] = {};
		int gx, gy;
		cin >> gx >> gy;
		int p;
		cin >> p;
		rep(i, p){
			int x1, y1, x2, y2;
			cin >> x1 >> y1 >> x2 >> y2;
			ng[y1][x1][y2][x2] = 1;
			ng[y2][x2][y1][x1] = 1;
		}
		int dp[20][20] = {};
		dp[0][0] = 1;
		rep(i, gy+1){
			rep(j, gx+1){
				if(!ng[i][j][i+1][j]) dp[i+1][j] += dp[i][j];
				if(!ng[i][j][i][j+1]) dp[i][j+1] += dp[i][j];
			}
		}
		if(dp[gy][gx] == 0) cout << "Miserable Hokusai!" << endl;
		else cout << dp[gy][gx] << endl;

	}

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int MAX=2e5+7,MOD=1e9 + 7;
void solve(){
    int n,m;cin>>n>>m;
    vector<int>g[n+5];
    int h[n+5];
    for(int i=1;i<=n;i++)cin>>h[i];
    for(int i=1;i<=m;i++){
        int u,v;cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int res=0;
    for(int i=1;i<=n;i++){
            int bad=0;
            for(int v:g[i]){
                if(h[i]<=h[v]){
                    bad=1;
                    break;
                }
            }
            if(bad==0)res++;
    }
    cout<<res<<endl;

}
int main (){
    int t=1;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 9152
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

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

#define MAX_N 1000000
#define INF 1000000

int A[MAX_N];

int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;

  ll cnt[MAX_N];
  fill(cnt, cnt + MAX_N, 0);
  
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    cnt[ A[i] ]++;
  }

  ll total_comb = 0;
  
  for (int i = 0; i < MAX_N; i++) {

    if(cnt[i] != 0) {
      ll n = cnt[i];
      total_comb += n * (n-1) / 2;
    }

  }

  //cout << "total_comb = " << total_comb << endl;
  
  for (int i = 0; i < N; i++) {
    cout << total_comb - ( cnt[ A[i] ] - 1 ) << endl;
  }
  
  return 0;
  
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[3];
		int b[] = new int[3];

		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		int n[] = new int[4];

		for (int i = 0; i < 3; i++) {
			for (int j = 1; j <= 4; j++) {
				if (a[i]== j) {
					n[j-1]++;
				}
				if (b[i]==j) {
					n[j-1]++;
				}
			}
		}

		Arrays.sort(n);
		if (n[3] >= 3) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int a,b;
    cin >> a >> b;
    if (a < 6)cout << 0 << endl;
    else if (a < 13) {
        cout << b / 2 << endl;
    }
    else cout << b << endl;
}

Measured memory_bytes: 384
from itertools import product
A, B, Q = map(int, input().split())
S, T, X = [], [], []

for _ in range(A):
  S.append(int(input()))
  
for _ in range(B):
  T.append(int(input()))

for _ in range(Q):
  X.append(int(input()))
  
Xs = sorted(X)

pos = 0
sl, tl = -1e18, -1e18
sr, tr = S[0], T[0]
si, ti, xi = 0, 0, 0 # index

XQ = {} # key=X,value=(x,sl,sr,tl,tr)を格納

for _ in range(int(5e5)):
  pos = min(sr,tr,Xs[xi]) 
  if pos == sr:
    sl = sr
    si += 1
    sr = S[si] if si < A else 1e18
  elif pos == tr:
    tl = tr
    ti += 1
    tr = T[ti] if ti < B else 1e18
  else:
    XQ[Xs[xi]] = [Xs[xi], sl, sr, tl, tr]
    xi += 1
    if xi >= Q:
      break

for i in range(Q):
  x, sl, sr, tl, tr = XQ[X[i]]
  sl, sr, tl, tr = sl-x, sr-x, tl-x, tr-x
  ans = 1e18
  ans = min(ans, abs(sl) + abs(sl-tl))
  ans = min(ans, abs(sl) + abs(sl-tr))
  ans = min(ans, abs(sr) + abs(sr-tl))
  ans = min(ans, abs(sr) + abs(sr-tr))
  ans = min(ans, abs(tl) + abs(tl-sl))
  ans = min(ans, abs(tl) + abs(tl-sr))
  ans = min(ans, abs(tr) + abs(tr-sl))
  ans = min(ans, abs(tr) + abs(tr-sr))
  print(ans)

Measured memory_bytes: 34548
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
ll nCr(ll n, ll r){
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
  ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
  return ret;
}

int main(void){
  int n,k;cin>>n>>k;
  string s;
  cin>>s;
  ll ans = 0;
  rep(i,s.size()-1){
    if(s[i] == s[i+1]){
      ans++;
    }
  }
  cout<<min((ll)s.size()-1, ans+2*k)<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long n;
long p[] = {1,
    10,
    100,
    1000,
    10000,
    100000,
    1000000,
    10000000,
    100000000,
    1000000000,
    10000000000,
};

std::vector<long> list[12][11];//[dig][top]

int main(){
    scanf("%ld", &n);
    for(int i = 0; i < 10; i++){
        list[0][i].push_back(i);
    }
    for(int dig = 1; dig <= 10; dig++){
        for(int top = 0; top < 10; top++){
            for(long d = -1; d <= 1; d++){
                if(0 <= top + d && top + d < 10){
                    for(long ind = 0; ind < list[dig-1][top+d].size(); ind++){
                        long vis = list[dig-1][top+d][ind];
                        list[dig][top].push_back(top * p[dig] + vis);
                    }
                }
            }
        }
    }
    std::set<long> st;
    for(int dig = 0; dig <= 10; dig++){
        for(int top = 0; top < 10; top++){
            for(int ind = 0; ind < list[dig][top].size(); ind++){
                st.insert(list[dig][top][ind]);
            }
        }
    }
    auto ita = st.begin();
    for(int i = 0; i < n; i++){
        //printf("%ld\n", *ita);
        ita++;
    }
    printf("%ld\n", *ita);
}


Measured memory_bytes: 32760
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;

void main() {
    int x = readln.chomp.to!(int);
    int[1001] arr;

    for (int i = 1; i <= x; i++) {
        for (int j = 2; j <= 100; j++) {
            int t = pow(i, j);
            if (t <= x) {
                arr[i] = max(arr[i], t);
            }
            else {
                break;
            }
        }
        arr[i] = max(arr[i - 1], arr[i]);
    }

    writeln(arr[x]);
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[23]:


import math
import itertools


# In[27]:


N = int(input())


# In[28]:


for i in range(1,N+1):
#     print("f(%s)"%i)
    ans = 0
    for x in range(1,int(math.sqrt(i))+1):
        if i - x**2 - x > 0:
            for y in range(x,int(math.sqrt(i-x**2-x))+1):
                if i - x**2 - x - y**2 - y - x*y > 0:
                    for z in range(y,int(math.sqrt(i-x**2-x-y**2-y-x*y)+1)):
                        if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                            if x==y and y==z:
                                ans += 1
                            elif x==y:
                                ans += 3
                            elif y==z:
                                ans += 3
                            else:
                                ans += 6
    print(ans)


# In[ ]:






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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s;
    cin>>s;
    int n=s.size();
    int ans=0;
    for(int bg = 0; bg < n; bg++)
    {
        for(int en = bg; en < n; en++)
        {
            bool ok=true;
            for(int i = bg; i <= en; i++)
            {
                if(s[i]!='A' && s[i]!='T' && s[i]!='G' && s[i]!='C')
                {
                    ok=false;
                    break;
                }
            }
            if(ok)
            {
                ans=max(ans,(en-bg+1));
            }
        }
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    vector<int> num(3);
    rep(i, 3)
    {
        cin >> num[i];
    }
    sort(all(num));
    cout << num[0] + num[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int a[100005];
int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	ll sum = 0;
	for (int i = 0; i < k; i++) {
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n;
  cin >> n;
  int max = 0;
  rep(i, n) {
    int h;
    cin >> h;

    if (max > h) {
      cout << "No";
      return 0;
    }

    if (max < h) {
      max = h - 1;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
q = []
heapq.heapify(q)
heapq.heapify(ab)
total = 0
for i in range(m, -1, -1):
    while True:
        if len(ab) != 0:
            p = heapq.heappop(ab)
            if p[0] + i <= m:
                heapq.heappush(q, -p[1])
            else:
                heapq.heappush(ab, p)
                break
        else:
            break
    if len(q) != 0:
        p = heapq.heappop(q)
        total += -p
print(total)


Measured memory_bytes: 27884
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;



const long max_comb=300;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(long a, long b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(long a, long b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(long i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}



ll dp[205][100005];

int main(int argc, char* argv[])
{
    long n, x;
    scanf("%ld%ld", &n, &x);

    vector<long> s(n);
    long i,j;
    for(i=0; i<n; i++) {
        scanf("%ld", &s[i]);
    }
    sort(s.rbegin(), s.rend());

    pre_comb();

    dp[0][x]=1;
    for(i=0; i<n; i++) {
        for(j=0; j<=x; j++) {
            if(dp[i][j]) {
                ll tmp = minv(n-i);
                dp[i+1][j] = (dp[i+1][j] + (dp[i][j]* (1+MOD-tmp)))%MOD;
                dp[i+1][j%s[i]] = (dp[i+1][j%s[i]] + dp[i][j]* tmp)%MOD;
            }
        }
    }

    ll ans=0;
    for(i=0; i<s[n-1]; i++) {
        ans = (ans + i*dp[n][i])%MOD;
    }
    ans = (ans * perm(n,n))%MOD;
    printf("%lld\n", ans);

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  using tsii=tuple<string,int,int>;
  vector<tsii> vec(N);
  for(int i=0;i<N;i++){
    int P;
    string S;
    cin >> S >> P;
    vec.at(i)=make_tuple(S,100-P,i);
  }
  sort(vec.begin(),vec.end());
  for(tsii i:vec)
    cout << get<2>(i)+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)9e18;

int main() {
	int N;
	cin >> N;
	string S1, S2;
	cin >> S1;
	cin >> S2;
	ll count = 1LL;
	if (S1[0] == S2[0]) {
		count *= 3;
		FOR(i,1,N) {
			if (S1[i] == S2[i]) {
				if (S1[i - 1] == S2[i - 1]) {
					count *= 2;
					count %= MOD;
				}
			}
			else {
				if (S1[i - 1] == S2[i - 1]) {
					count *= 2;
					count %= MOD;
					i++;
				}
				else {
					count *= 3;
					count %= MOD;
					i++;
				}
			}
		}
	}
	else {
		count *= 6;
		FOR(i, 2, N) {
			if (S1[i] == S2[i]) {
				if (S1[i - 1] == S2[i - 1]) {
					count *= 2;
					count %= MOD;
				}
			}
			else {
				if (S1[i - 1] == S2[i - 1]) {
					count *= 2;
					count %= MOD;
					i++;
				}
				else {
					count *= 3;
					count %= MOD;
					i++;
				}
			}
		}
	}
	cout << count << endl;	
	return 0;
}


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

int main(){
  vector<string> S(3);
  repeat(i,0,3) cin >>S[i];
  
  int i = 0;
  char ans;
  while(true){
    if (S[i].size()==0){
      ans = 'A'+i;
      break;
    }
    char front = S[i][0];
    S[i].erase(0,1);
    i = front - 'a';
  }

  cout <<ans<< endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
 
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
   
using namespace std;
   
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
   
static const double EPS = 1e-8;
   
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

P calc(int lhs,int rhs){
  int sum = lhs + rhs;
  int carry = 0;
  int cost = 0;
  for(int i = 0; i < 9; i++){
    cost += (lhs % 10) * (rhs % 10) + carry;
    carry = (lhs % 10 + rhs % 10 + carry >= 10 ? 1 : 0);
    lhs /= 10;
    rhs /= 10;
  }
  return P(sum,cost);
}

int main(){
  int N;
  while(~scanf("%d",&N)){
    vector<int> numbers;
    for(int i = 0; i < N; i++){
      int number;
      scanf("%d",&number);
      numbers.push_back(number);
    }
    P dp[301][301];
    for(int i = 0; i < numbers.size(); i++) {
      dp[i][i].first = numbers[i];
      dp[i][i].second = 0;
    }

    int sum = 0;
    for(int d = 1; d < numbers.size(); d++){
      for(int i = 0; i < numbers.size() - d; i++){
        int j = i + d;
        dp[i][j].second = INF;
        for(int k = i; k < j; k++){
          P tmp = calc(dp[i][k].first,dp[k+1][j].first);
          dp[i][j].first = tmp.first;
          dp[i][j].second = min(dp[i][j].second,
                                tmp.second + dp[i][k].second + dp[k+1][j].second);
        }
      }
    }

    cout << dp[0][numbers.size()-1].second << endl;
    // printf("%d\n",res);
  }
}

Measured memory_bytes: 1936
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll x, y, z;
	cin >> x >> y >> z;

	cout << z<<" " << x<<" " << y << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    int l[112];
    for (int i = 0; i < n;i++){
        cin >> l[i];
    }
    int d[112];
    d[0] = 0;
    int res = 0;
    for (int i = 1; i <= n;i++){
        d[i] = d[i - 1] + l[i - 1];
        if(d[i]<=x)
            res++;
    }
    cout << res + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
# question 2
A, B = input().split()

# question 2
a_org = int(A)
a = int(A)
b = int(B)
i = 1

while True:
  if b == 1:
    i = 0
    break
  
  if a >= b:
    break
    
  i += 1
  a += (a_org-1)
  
print(i)

Measured memory_bytes: 2940
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------
struct unionfind{
    vector<int> rank,parent,size;
    int independent_tree;
    int N;
    
    unionfind(int n){
        N=n;
        for(int i=0;i<n;i++){
            rank.push_back(1);
            parent.push_back(i);
            size.push_back(1);
            independent_tree=N;
        }
    }
    int getroot(int x){
        if(parent[x]==x)
            return x;
        return parent[x]=getroot(parent[x]);
    }
    bool issame(int a,int b){
        return getroot(a)==getroot(b);
    }
    void unite(int a,int b){
        a=getroot(a);
        b=getroot(b);
        if(a==b)
            return;
        else if(rank[a]>rank[b]){
            parent[b]=a;
            size[a]+=size[b];
        }
        else if(rank[a]==rank[b]){
            parent[b]=a;
            rank[a]++;
            size[a]+=size[b];
        }
        else{
            parent[a]=b;
            size[b]+=size[a];
        }
    }
};
ll n,m;
vector<ll>ans;
vector<pair<ll,ll> >e;
//---------------------------------------------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        a--;b--;
        e.push_back(make_pair(a,b));
    }
    reverse(e.begin(),e.end());
    ll remin=n*(n-1)/2;
    unionfind uf(n);
    for(int i=0;i<m;i++){
        ans.push_back(remin);
        if(!uf.issame(e[i].first,e[i].second)){
            remin-=uf.size[uf.getroot(e[i].first)]*uf.size[uf.getroot(e[i].second)];
            uf.unite(e[i].first,e[i].second);
        }
    }
    reverse(ans.begin(),ans.end());
    for(int i=0;i<m;i++)
        cout<<ans[i]<<endl;
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 6000
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

string str;
int memo[20][20];
int calc(int left, int right) {
  if (left < 0 || right >= (int)str.size()) { return 3; }
  if (memo[left][right] != -1) { return memo[left][right]; }
  int ret = 0;
  if ((str[left] == '(' && str[right] == ')') ||
      (str[left] == ')' && str[right] == '(') ||
      (str[left] == '[' && str[right] == ']') ||
      (str[left] == ']' && str[right] == '[') ||
      (str[left] == '{' && str[right] == '}') ||
      (str[left] == '}' && str[right] == '{')) {
    ret = 2 + calc(left - 1, right + 1);
  }
  ret = max(ret, calc(left - 1, right));
  ret = max(ret, calc(left, right + 1));
  return memo[left][right] = ret;
}

int main() {
  while (cin >> str) {
    MEMSET(memo, -1);
    int center;
    REP(i, str.size()) { if (str[i] == 'w') { center = i; } }
    printf("%d\n", calc(center - 2, center + 2));
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){
	int n = 0, k = 0;
	scanf("%d",&n);
	for(int i = 1; i <= 9; i++ ){
		if(n / i < 10 && n % i == 0){
			k = 1;
			break;
		}
	}
	if(k == 1){
		printf("Yes");
	}
	else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
def valid_month?(a)
  a != 0 && a <= 12
end

S = gets.chomp.to_i
a = S / 100
b = S % 100

if valid_month?(a)
  if valid_month?(b)
    puts "AMBIGUOUS"
  else
    puts "MMYY"
  end
else
  if valid_month?(b)
    puts "YYMM"
  else
    puts "NA"
  end
end



Measured memory_bytes: 1788
N,*f = map(int, open(0).read().split())
ab = [f[i] - f[i+N] for i in range(N)]
c = 0
d = 0
for x in ab:
    if x < 0:
        c += abs(x) // 2
    elif x > 0:
        d += x
if c >= d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 11232
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

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


signed main(){
  int n;cin>>n;pair<string, pair<int,int>> p[110];
  rep(i,n){
    cin>>p[i].first>>p[i].second.first;
    p[i].second.first *= -1;
    p[i].second.second = i+1;
  }
  sort(p,p+n);
  rep(i,n){
    cout << p[i].second.second << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace _0001
{
    class Program
    {
        const int OUTPUT_NUMBER = 3;
        const int MAX_NUMBER = 10;
        static void Main(string[] args)
        {
           List<int> sampleDate = new List<int>();

           for (int i = 0; i < MAX_NUMBER; i++)
           {
               sampleDate.Add(int.Parse(Console.ReadLine()));
           }

          List<int> sortedDate = sampleDate.OrderByDescending(i=>i).ToList();

          for (int count = 0; count < OUTPUT_NUMBER; count++)
           {
               Console.WriteLine("{0}", sortedDate[count]);
           }
        }
    }
}

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(a <= 5) cout << 0 << '\n';
    else if(a >= 13) cout << b << '\n';
    else cout << b/2 << '\n';
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, a;
    cin >> n >> a;
    cout << n*n - a << "\n";
    
    return 0;
}

Measured memory_bytes: 256
<?php

//[$target] = explode(' ', trim(fgets(STDIN))); えぇ…PHP7.xじゃないの…
list($target) = explode(' ', trim(fgets(STDIN)));
$target = (int) $target;
$numList = array_map('intval', explode(' ', trim(fgets(STDIN))));

// $target = 50000;
// $numList = array_map('intval', explode(' ', '1 92 1377 3168 7095 1170 1809 5046 3225 1054 4016 142 108 6430 3970 48 8416 4909 114 6968'));

rsort($numList);
array_pop($numList); // 1
$min = end($numList);
$fail = [];

function search($rest, $count) {
	global $numList, $min, $out, $fail;

	if (isset($fail[$rest])) {
		if ($fail[$rest] + $count < $out) {
			$out = $fail[$rest] + $count;
		}
		return;
	}

	if ($rest < $min) {
		if ($count + $rest < $out) {
			$out = $count + $rest;
		}
		return;
	}

	for ($i = 0; isset($numList[$i]); ++$i) {
		if ($rest < $numList[$i]) {
			continue;
		}
		search($rest - $numList[$i], $count + 1);
	}
}

for ($i = 1; $i <= $target; ++$i) {
	$out = 10000;
	search($i, 0);
	$fail[$i] = $out;
}

echo $fail[$target] . "\n";



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

const int MAX = 100;

int main(){
    int a, b;
    cin >> a >> b;

    cout << max(a + b, max(a - b, a*b)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int c;
    if(s[0]==s[1]&&s[1]==s[2])c=0;
    else if(s[1]==s[2]&&s[2]==s[3])c=1;
    else c=2;
    if(c==0||c==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

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

    vector<long> T(N);
    for (int i = 0; i < N; i++)
    {
        cin >> T[i];
    }
    sort(T.begin(), T.end());

    int result = 0;
    for (int i = 0; i < N;)
    {
        result++;
        int t = i;
        while (i - t + 1  <= C && T[i] - T[t] <= K && i < N)
            i++;
    }
    cout << result << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

ll gcd(ll x, ll y)
{
	return (y ? gcd(y, x % y) : x);
}

int main()
{
	ll a, b;
	cin >> a >> b;

	printf("%lld", a * b / gcd(a, b));


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

int N;

// comb(n,2)
ll choose2(ll n)
{
  if (n <= 1) return 0;
  return n * (n - 1) / 2;
}

int main()
{
  cin >> N;
  vector<int> A(N);
  // multimap<int,int> m;
  // multiset<int> st;
  map<int,int> m;  // 値とその個数

  REP(i,0,N) {
    cin >> A[i];
    m[A[i]]++;
  }

  ll total = 0;
  for (auto it = m.begin(); it != m.end(); ++it) {
    total += choose2(it->second);
  }

  REP(k,0,N) {
    ll ans = total - choose2(m[A[k]]) + choose2(m[A[k]]-1);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 8320