akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

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

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}
void check(long long a,long long b,long long c,long long d){
    long long same=a;
    a = a-b;
    while(same != a && a >= 0){
        cout << a << endl ;
        if(a <= c){
            a += d;
            if(a == same){
                cout << "Yes" << endl;
                return;
            }
        }
        a = a-b ;
    }

    if(a<0)
        cout << "No" << endl;
    return;
}


int main(int argc, const char * argv[]) {
    
    // source code
    int a,b,k;

    a = inputValue();
    b = inputValue();
    k = inputValue();
    int flg = 0;
    int i = 0;
    while(i<k){

        if(a % 2 != 0){
            a=a-1;
        }
        b = b + a/2;
        a = a/2;
        i++;
        if(i>=k) break;

        if(b % 2 !=0){
                b = b-1;
            }
        a = a + b/2;
        b = b/2;
        i++;

    }

    cout << a <<" " << b << endl;
}

Measured memory_bytes: 256
//>>>>>>>>>>>>>>>>>>>>>>>>>>JAI BAJRANG BALI<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<//
//😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😝😝😝😝😝😝😝😝😝😝😝😝😝😂😂😂😂😂😂😂😜😜😜😜😜😜😜😜😜😜😜
#define HARSH_JUDGE
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define db(x)                   cout<<#x<<"="<<x<<'\n'
#define db2(x,y)                 cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define setbits(x)      __builtin_popcountll(x)
#define str string
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n;i>=a;i--)
#define cases   long long t;cin>>t;while(t--)
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define ff first
#define ss second
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define sp(x,y)         fixed<<setprecision(y)<<x
#define nl '\n'
#define sz(x) ((int)(x).size())
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
const ll N = 1e5 + 5;
#define printall(a) fo(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;



typedef vector<int> vi;
typedef map<ll, ll> mll;
typedef set<int> si;
typedef unordered_set<int> usi;
typedef map<ll, int> mli;
typedef map<char, int> mci;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;

bool cmp(const pair<ll, ll>& a, const pair<ll, ll>& b)
{

	return a.ss < b.ss;
}

// >>>>>>>>>>>>>>>>>>>>>>>>>>TOR DE DUSHMAN KI NALI<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<//

void solve()
{


	ll n;
	cin >> n;
	ll a[n + 1], dp[n + 1] = {0};
	fo(i, 1, n + 1)cin >> a[i];
	dp[1] = 0, dp[2] = abs(a[2] - a[1]);
	fo(i, 3, n + 1)
	{
		dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1], dp[i - 2] + abs(a[i] - a[i - 2]));
	}
	cout << dp[n];


	return;
}

int main()
{	fio
#ifndef HARSH_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
#endif
	ll t = 1;
	// cin >> t;
	// clock_t timest = clock();
	// cerr << "[Executes in " << (double)(clock() - timest) / CLOCKS_PER_SEC << "s]" << endl;
	while (t--)
	{
		solve();

	}
}

Measured memory_bytes: 5188
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<math.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n,m;
	cin>>n>>m;
	if(n<=10){
		cout<<m+100*(10-n);
	}
	else
		cout<<m;
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  string S;
  IN(S);

  string s_pre = "";
  ll pos = 0;
  ll ans = 0;
  while(pos<S.size()){
    string tmp = "";
    while(true){
      tmp += S[pos];
      if(s_pre != tmp){
        s_pre = tmp;
        ans++;
        break;
      }
      pos++;
      if(pos>=S.size()) break;
    }
    pos++;
    if(pos>=S.size()) break;
  }

  OUT(ans);

  return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lec11D
{
    public class Element
    {
        public int id;
        public List<int> fri_list;
        public int group;

        public Element()
        {
            fri_list = new List<int>();
            group = -1;
        }

    }
    class Program
    { 
       static  Element[] arr;

        static void Main(string[] args)
        {

            //setting part

            string [] num_inp = Console.ReadLine().Split(' ');
            var n = int.Parse(num_inp[0]);
            var m = int.Parse(num_inp[1]);

             arr = new Element[n];

            for (int i = 0; i < n; i++)
            {
                arr[i] = new Element
                {
                    id = i
                };
            }

            //input part

            for (int i = 0; i < m; i++)
            {
                string[] fri_inp = (Console.ReadLine()).Split(' ');
                var s = int.Parse(fri_inp[0]);
                var t = int.Parse(fri_inp[1]);

                arr[s].fri_list.Add(t);
                arr[t].fri_list.Add(s);
            }

            Adjust();

            //quetion part

            int q = int.Parse(Console.ReadLine());

            for (int i = 0; i < q; i++)
            {
                string[] q_inp = (Console.ReadLine()).Split(' ');
                var s = int.Parse(q_inp[0]);
                var t = int.Parse(q_inp[1]);
                if (arr[s].group == arr[t].group)
                {
                    Console.WriteLine("yes");
                }
                else
                {
                    Console.WriteLine("no");
                }
            }

            Console.ReadLine();
        }

        static void Adjust()
        {
            var g = 1;
            foreach (var i in arr)
            {
                if (i.group == -1)
                {
                    DFS(i,g);
                    g++;
                }
            }
        }

        static void DFS(Element t,int g)
        {
            t.group = g;
            Stack<int> stk = new Stack<int>();
            stk.Push(t.id);
       
            while ( stk.Count != 0)
            {
                int tag = stk.Pop();
                foreach(int next in arr[tag].fri_list)
                {
                    if (arr[next].group == -1)
                    {
                        stk.Push(next);
                        arr[next].group = g;
                    }
                }
            }
        }
    }
}




Measured memory_bytes: 33760
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    A, B, C = map(int, readline().split())
    if (A == B != C) or (B == C != A) or (C == A != B):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ans = s.matches("^A??KIHA??BA??RA??$") ? "YES" : "NO";
		System.out.println(ans);
	}
}


Measured memory_bytes: 22868
import sys

n, *x = map(int, sys.stdin.read().split())

def main():
    a = sorted(x)
    l = a[n//2-1]; r = a[n//2]
    for i in range(n):
        print(l if x[i] >= r else r)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 25052
use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        hs: [i64; n],
        paths: [(usize, usize); m],
    }
    let ex = paths
        .iter()
        .flat_map(|(a, b)| {
            if hs[*a - 1] < hs[*b - 1] {
                vec![*a]
            } else if hs[*a - 1] == hs[*b - 1] {
                vec![*a, *b]
            } else {
                vec![*b]
            }
        })
        .collect::<std::collections::HashSet<_>>()
        .len();
    println!("{}", n - ex);
}


Measured memory_bytes: 7540
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

N = int(input())
P = list(map(int,input().split()))

P.append(0) # 番兵

count = 0
for i in range(N):
    if P[i] == i+1:
        x = P[i]
        P[i] = P[i+1]
        P[i+1] = x
        count += 1

print(count)

Measured memory_bytes: 14388
#include<bits/stdc++.h>
using namespace std;
int n,k,a[222222];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1; i<=n; i++){
		int x;
		scanf("%d",&x);
		a[x]++;
	}
	sort(a+1,a+n+1);
	int res = n;
	for(int i=1; i<=k; i++)
		res -= a[n+1-i];
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 1024
#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()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	string s; cin >> s;
	
	int l=s.size();
	
	string s1="",s2="";
	
	int c1=0,c2=0;
	
	if(l%2==0){
		while(s1.size()<l){
			s1.push_back('0'); s1.push_back('1');
			s2.push_back('1'); s2.push_back('0');
		}
		
		rep(i,l){
			if(s[i]!=s1[i]) c1++;
			if(s[i]!=s2[i]) c2++;
		}
		
		cout << min(c1,c2) << endl;
		return 0;
	}
	else{
		
		s1.push_back('1');
		s2.push_back('0');
		
		while(s1.size()<l){
			s1.push_back('0'); s1.push_back('1');
			s2.push_back('1'); s2.push_back('0');
		}
		
		rep(i,l){
			if(s[i]!=s1[i]) c1++;
			if(s[i]!=s2[i]) c2++;
		}
		//cout << s1 << endl << s2 << endl;
		cout << min(c1,c2) << endl;
		return 0;
	}
	
	return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

/*
struct edge {
    int from, to, cost;
    edge(int from, int to, int cost): from(from), to(to), cost(cost) {}
    edge(int to, int cost) {
        edge(0, to, cost);
    }
    edge() {
        edge(0,0,0);
    }
};
*/

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL x;
    cin >> x;
    int n = x / 100;
    RREP(i,1,n+1) {
        int rem = x - n * 100;
        if (rem <= 5 * n) {
            cout << 1 << endl;
            return;
        }
    }
    cout << 0 << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 2000009
#define ll long long
#define ld long double
#define ff first
#define ss second
#define inf 1000000005
#define mod 1000000007
using namespace std;
ll n, a[100009][5], dp[100009][5];
int main() {
    //ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i][1]>>a[i][2]>>a[i][3];
    }
    dp[1][1] = a[1][1];
    dp[1][2] = a[1][2];
    dp[1][3] = a[1][3];
    for(int i=2;i<=n;i++) {
        for(int j=1;j<=3;j++) {
            for(int k=1;k<=3;k++) {
                    if(k == j)
                    continue;
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
            }
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<max(dp[n][1], max(dp[n][2], dp[n][3]));
}


Measured memory_bytes: 11380
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
unsigned ll maxGCD(unsigned ll N, unsigned ll P)
{

    unsigned ll ans = 1;
    unordered_map<unsigned ll, unsigned ll> prime_factors;
    for (unsigned ll i = 2; i * i <= P; i++) {

        while (P % i == 0) {

            prime_factors[i]++;

            P /= i;
        }
    }

    if (P != 1)
        prime_factors[P]++;
    for (auto v : prime_factors)
        ans *= pow(v.first, v.second / N);

    return ans;
}
int main()
{
    unsigned ll N,P;
    cin>>N>>P;

    cout << maxGCD(N, P)<<'\n';

    return 0;
}


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

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

using namespace std;

int main() {
    int n,i,ans=0,count=0;
    cin>>n;
    int s[n],c[n]={0};
    rep(i,n){
    	cin>>s[i];
    }
    sort(s,s+n);
    rep(i,n){
    	ans=ans+s[i];
    	c[i]=s[i]%10;
    	count=count+c[i];
    }
    if(count%10==0){
    	rep(i,n){
    		if(c[i]!=0){
    			ans=ans-s[i];
    			break;
    		}
    	}
    }
    if(ans%10==0){
    	ans=0;
    }
    cout<<ans<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <valarray>

#include<cassert>//assert();
//#include <random>//xAOJ
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
/////////
using namespace::std;
/////////
/////////

void solve(){
	int N,M;
	cin >> N >> M;
	int a,b,c;
	vector< vector<int> > org = vector<vector<int>>(M,vector<int>(3,0));
	vector< vector<int> > path = vector<vector<int>>(N,vector<int>(N,9999999));
	for(int cou=0;cou<N;cou++){
		path[cou][cou] = 0;
	}
	for(int cou=0;cou<M;cou++){
		cin >> a >> b >> c;
		--a;--b;
		org[cou][0] = a;
		org[cou][1] = b;
		org[cou][2] = c;
		path[a][b] = c;
		path[b][a] = c;
	}
	//わーしゃるふろいと
	for(int k=0;k<N;++k){//中継点
		for(int i=0;i<N;++i){//始点
			for(int j=0;j<N;++j){//終点
				path[i][j] = min(path[i][j],path[i][k]+path[k][j] );
				path[j][i] = path[i][j];
			}
		}
	}
	vector<vector<int>>::iterator itr,end;
	itr = org.begin();
	end = org.end();
	int count = 0;
	for(;itr != end;itr++){
		if( path[(*itr)[0]][(*itr)[1]] < (*itr)[2] ){
			++count;
		}
	}

	cout << count << endl;
}

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(16);//
	
	solve();
	
	return 0;
}


Measured memory_bytes: 384
n, k = map(int, input().split())
a = list(map(int, input().split()))
history = []
mark = set()

pos = 0
cnt = 0
while pos not in mark and cnt < k:
  history.append(pos)
  mark.add(pos)
  pos = a[pos] - 1
  cnt += 1

if cnt == k:
  print(pos + 1)
else:
  cnt_before = history.index(pos)
  print(history[cnt_before + (k - cnt_before) % (cnt - cnt_before)] + 1)

Measured memory_bytes: 35264
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

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

using namespace std;


double getE(int n, int m){
	vector<int> num(m);
	vector<double> p(m);
	double psum = 0;
	rep(j, m){
		cin >> num[j] >> p[j];
		psum += p[j];
	}
	double ex = 0;
	rep(j, m){
		ex += num[j]*p[j]/psum;
	}
	return ex;
}


int main(){
	int t;
	cin >> t;
	double best = 0;
	rep(i, t){
		int n, m;
		cin >> n >> m;
		best = max(best, getE(n, m));
	}
	int p, q;
	cin >> p >> q;
	cout << (best-getE(p, q)>1e-7?"YES":"NO") << endl;


	return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Edge{
	Edge(int arg_to,int arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	int to,cost;
};


struct Info{
	Info(int arg_node_id,int arg_depth){
		node_id = arg_node_id;
		depth = arg_depth;
	}
	bool operator<(const struct Info &arg) const{
		return depth < arg.depth;
	}

	int node_id,depth;
};

int *depth_table,*parent,*max_dist;
vector<Edge> G[100000];

void calcDepth(int node_id,int depth,int parent_id){
	depth_table[node_id] = depth;
	parent[node_id] = parent_id;
	for(int i = 0; i < G[node_id].size(); i++){
		if(G[node_id][i].to == parent_id)continue;
		calcDepth(G[node_id][i].to,depth+1,node_id);
	}
}

int main(){

	int N;
	scanf("%d",&N);

	depth_table = new int[N];
	parent = new int[N];
	max_dist = new int[N];

	for(int i = 0; i < N; i++)max_dist[i] = -1;

	int from,to,cost;
	for(int loop = 0; loop < N-1; loop++){
		scanf("%d %d %d",&from,&to,&cost);
		G[from].push_back(Edge(to,cost));
		G[to].push_back(Edge(from,cost));
	}

	calcDepth(0,0,-1);

	priority_queue<Info> Q;

	for(int i = 0; i < N; i++){
		Q.push(Info(i,depth_table[i]));
	}

	int ans = 0;
	int max1,max2;

	while(!Q.empty()){

		max1 = 0,max2 = 0;

		for(int i = 0; i < G[Q.top().node_id].size(); i++){
			if(G[Q.top().node_id][i].to == parent[Q.top().node_id])continue;

			if(max1 < max_dist[G[Q.top().node_id][i].to] + G[Q.top().node_id][i].cost){
				max2 = max1;
				max1 = max_dist[G[Q.top().node_id][i].to] + G[Q.top().node_id][i].cost;
			}else if(max2 < max_dist[G[Q.top().node_id][i].to] + G[Q.top().node_id][i].cost){
				max2 = max_dist[G[Q.top().node_id][i].to] + G[Q.top().node_id][i].cost;
			}
		}
		ans = max(ans,max1+max2);
		max_dist[Q.top().node_id] = max1;
		Q.pop();
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 15156
import sys
from collections import deque


def input():
    return sys.stdin.readline()[:-1]


def solve():
    N, P = map(int, input().split())
    S = input()
    if (10 % P == 0):
        ans = 0
        for i in range(N):
            if int(S[N - i - 1]) % P == 0:
                ans += N - i
        return ans
    ten = 1
    cur = 0
    val = [0] * P
    val[cur] += 1
    for i in range(N):
        cur = (cur + int(S[N - i - 1]) * ten) % P
        ten *= 10
        ten %= P  # ある数XがPで割れるならXを10倍したものもPで割れるはずなので.
        val[cur] += 1
    ans = 0
    for p in range(P):
        ans += val[p] * (val[p] - 1) // 2
    return ans


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3880
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <iterator>
#include <cmath>
using namespace std;

#define rep(i, n)       rep2 (i, 0, n)
#define rep2(i, m, n)   for (int i = m; i < (int)(n); ++i)
#define all(c)          (c).begin(), (c).end()

class Node
{
private:
    string  m_id;
    double  m_sim;
public:
    bool    is_leaf;
    Node    *lch, *rch;
    void    init() { m_id.clear(); m_sim = -1.0; }
    string  id();
    string  to_str() const;
    int     parse(const string &str, int idx = 0);
    void    insert(set<string> &s);
    double  sim();
    void    norm(bool is_left = true);
};

int used;
Node buf[300];

string Node::id()
{
    if (!m_id.empty()) return m_id;
    if (is_leaf) return m_id = "10";
    string l = lch->id(), r = rch->id();
    if (l > r) swap(l, r);
    return m_id = "1" + l + r + "0";
}

string Node::to_str() const
{
    if (is_leaf) return "x";
    return "(" + lch->to_str() + " " + rch->to_str() + ")";
}

int Node::parse(const string &str, int idx)
{
    if (str[idx] == 'x') {
        is_leaf = true;
        ++idx;
    } else {
        is_leaf = false;
        lch = buf + used++;
        rch = buf + used++;
        ++idx;
        idx = lch->parse(str, idx);
        ++idx;
        idx = rch->parse(str, idx);
        ++idx;
    }
    return idx;
}

void Node::insert(set<string> &s)
{
    s.insert(id());
    if (!is_leaf) {
        lch->insert(s);
        rch->insert(s);
    }
}

double Node::sim()
{
    if (m_sim != -1.0) return m_sim;
    if (is_leaf) return m_sim = 0.0;
    set<string> left, right;
    vector<string> uni, inter;
    lch->insert(left);
    rch->insert(right);
    set_union(all(left), all(right), back_inserter(uni));
    set_intersection(all(left), all(right), back_inserter(inter));
    return m_sim = (double)inter.size() / uni.size();
}

// return true if lhs is strictly more asymmetrical than rhs
bool cmp(Node &lhs, Node &rhs)
{
    if (lhs.is_leaf && rhs.is_leaf) return false;
    double l = lhs.sim(), r = rhs.sim();
    if (abs(l - r) > 1e-9) return l < r;
    Node *la = lhs.lch, *lb = lhs.rch;
    Node *ra = rhs.lch, *rb = rhs.rch;
    if (!cmp(*la, *lb)) swap(la, lb);
    if (!cmp(*ra, *rb)) swap(ra, rb);
    if (cmp(*la, *ra)) return true;
    if (cmp(*ra, *la)) return false;
    if (cmp(*lb, *rb)) return true;
    return false;
}

void Node::norm(bool is_left)
{
    if (is_leaf) return;
    if (is_left ^ cmp(*lch, *rch)) swap(lch, rch);
    lch->norm(true);
    rch->norm(false);
}

int main()
{
    string str;
    while (getline(cin, str) && str != "0") {
        used = 0;
        rep (i, 300) buf[i].init();
        Node &node = buf[used++];
        node.parse(str);
        node.norm();
        cout << node.to_str() << endl;
    }
}

Measured memory_bytes: 1244
N = int(input())

c = 0
for i in range(N):
    v = N - i
    c += v * (v+1) // 2

for i in range(N-1):
    u, v = map(int, input().split())
    if u > v:
        u, v = v, u

    c -= (N - v + 1) * u

print(c)

Measured memory_bytes: 74464
iN = int(input())
aX = [int(_) for _ in input().split()]

aXs = sorted(enumerate(aX),key=lambda x:x[1])

iMu  = iN//2
iMd  = iN//2 -1

iMuV = aXs[iMu][1]
iMdV = aXs[iMd][1]

if iMuV == iMdV:
    print("\n".join([str(iMuV)]*iN))
else:
    print("\n".join(map(str,map(lambda x: iMuV if aX[x] < iMuV else iMdV ,range(iN)))))


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

def main():
    L = int(input())

    N = 0
    e = []

    d = L
    k = 0
    while 0 < d:
        d = int(d / 2)
        k += 1
        if 2 <= k:
            e.append((k - 1, k, 0))
            e.append((k - 1, k, 2 ** (k - 2)))

    N = k

    d = L
    k = 0
    s = []
    while 1 < d:
        d, m = int(d / 2), d % 2
        if m == 1:
            s.append(k)
        k += 1

    a = 2 ** (N - 1)
    for i in range(len(s) - 1, -1, -1):
        k = s[i]
        e.append((k + 1, N, a))
        a += 2 ** k


    print('{} {}'.format(N, len(e)))
    for v in e:
        print('{} {} {}'.format(v[0], v[1], v[2]))

if __name__ == '__main__':
    main()



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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    char a,b;
    cin >>a>>b;

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout<<ans<<endl;
    if(a == b)cout << "H" <<endl;
    else cout << "D" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define MAX_N 100000 * 2 + 16
using namespace std;
int W,H;
bool vis[105][105];
char G[105][105];
int dx[]={ 1,-1, 0, 0};
int dy[]={ 0, 0,-1, 1};
 
void dfs(int x,int y,char c)
{
    G[x][y] = '.';
    for(int i = 0;i<4;i++)
    {
        int nx = x+dx[i], ny = y+dy[i];
        if(nx>0 && nx<=H && ny>0 && ny<=W && G[nx][ny] == c)
            dfs(nx,ny,c);
    }
}
 
int main()
{
    while(cin>>H>>W) // H高度，W宽度
    {
        if (W==0 && H==0) break;
        memset(G,0,sizeof(G));
 
        for(int i =1;i<=H;i++)
            for(int j = 1; j<=W;j++)
                cin>>G[i][j];
        int sum = 0;
        for(int i = 1; i<=H;i++)
        {
            for(int j = 1; j<=W;j++)
            {
                if (G[i][j] != '.')
                {
                    dfs(i,j,G[i][j]);
                    sum++;
                }
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}



Measured memory_bytes: 3596
#ifdef ConanYu
#include "E:\yuzining\code\local.hpp"
#else
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie();
  Main();
  return 0;
}
#endif

void Main() {
  string s; cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

ll modpow(ll b, ll i){
  ll s=1;
  while(i){
    if(i%2) s=(s*b)%MOD;
    b=(b*b)%MOD; i/=2;
  }
  return s;
}

void solve(){
  int n; cin >>n;
  cout <<(modpow(10,n)-2*modpow(9,n)+modpow(8,n)+2*MOD)%MOD;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3648
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
typedef long long LL;
const int N=1000005,mod=1000000007;
int n,f[N],g[N],ans;

void inc(int &x,LL y)
{
	x=(x+y)%mod;
}

int main()
{
	scanf("%d",&n);
	f[0]=1;
	rep(i,0,n)
	{
		if(i) inc(g[i],g[i-1]),inc(f[i],g[i]);
		if(i==n) inc(ans,f[i]);
		else if(i==n-1) inc(ans,(LL)f[i]*(n-1));
		else inc(ans,(LL)f[i]*(n-1)%mod*(n-1));
		inc(f[i+1],f[i]);
		
		if(i<=n-2)
		{
			int x=max(1,n-i-2);
			if(2<=x) inc(g[i+3],f[i]),inc(g[n],-f[i]);
			inc(f[n],(LL)f[i]*(n-x));
		}
	}
	printf("%d\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 7936
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main(){
	int n, l;
	std::cin >> n >> l;

	std::vector<std::string> s(n);
	for(int i = 0; i < n; ++i){
		std::cin >> s.at(i);
	}

	std::sort(std::begin(s), std::end(s));
	
	std::string os = "";
	for(auto str : s){
		os += str;
	}

	std::cout << os << std::endl;

	return 0;
}



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

class Prgram
{
    static void Main()
    {
        int[] alp = new int[26];

        string str;

        while ((str = Console.ReadLine()) != null)
        {
           
            char[] chaan = new char[str.Length];
            chaan = str.ToCharArray();

            for (int i = 0; i < chaan.GetLength(0); i++)
            {
                chaan[i] = char.ToLower(chaan[i]);
            }



            for (int i = 0; i < chaan.GetLength(0); i++)
            {
                if (('a' <= chaan[i]) && ('z' >= chaan[i]))
                {
                    alp[chaan[i] - 'a']++;
                }
            }
        }

        for (int i = 0; i < 26; i++)
        {
            char choon = (char)('a' + i);
            Console.WriteLine("{0} : {1}", choon, alp[i]);
        }
    }

   

 
    
}

Measured memory_bytes: 9156
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		char x=s[i]+n;
		if(x>90)
			x-=26;
		cout<<x;
		
	}
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}






Measured memory_bytes: 3644
q = gets.to_i
abs = []
for i in 1..q
  abs << gets.split.map(&:to_i)
end
for ab in abs
  a = ab[0]
  b = ab[1]
  ab = a * b
  s = Math.sqrt(ab).to_i
  t = 2 * (s - 1)
  t += 1 if a == b
  t += 1 if s * (s + 1) < ab
  t -= 1 if s * s == ab
  puts t
end

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

#define inm (int)10e9
using namespace std;
int main()
{	
	int ans=0, i, j, k;
	int s, a[10000]={0};
	cin >> s;

	for (i = 1; i < inm/1000;i++){
		if(i==1){
			a[i] = s;
		}
		else{
			if(a[i-1]%2){
				a[i] = 3 * a[i - 1] + 1;
			}
			else{
				a[i] = a[i - 1] / 2;
			}
		}
		
		for (j = 1; j < i;j++){
			if(a[j]==a[i]){
				cout << i << endl;
				return 0;
			}
		}
	}
		return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String args[]){
		Main app = new Main();
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int count = 0;
			String word = scan.nextLine();
			int num = Integer.parseInt(scan.nextLine());
			for(int i=0;i<num;i++){
				count += app.searchRing(word,scan);
			}
			System.out.println(count);
		}
	}
	
	public int searchRing(String word,Scanner scan){
		String ring = scan.nextLine();
		int ringLen = ring.length();
		int wordLen = word.length();
		for(int i=0;i<ringLen;i++){
			String str = new String();
			if(i+wordLen > ringLen){
				str = ring.substring(i,ringLen);
				str += ring.substring(0,wordLen-str.length());
				if(str.equals(word)){
					return 1;
				}
			}else{
				str = ring.substring(i,i+wordLen);
				if(str.equals(word)){
					return 1;
				}
			}
		}
		return 0;
	}
}

Measured memory_bytes: 17488
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))
print('Yes' if sum(B)-sum(A) >= sum(max(0,(b-a+1)//2) for a,b in zip(A,B)) else 'No')



Measured memory_bytes: 4596
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = list(input())
T = list(input())

border_U = 0
border_D = H + 1
border_L = 0
border_R = W + 1

res = "YES"

for i in reversed(range(1, N)):

    # Takahashi's turn
    if S[i] == "U":
        border_U += 1
    elif S[i] == "D":
        border_D -= 1
    elif S[i] == "L":
        border_L += 1
    elif S[i] == "R":
        border_R -= 1

    # mate in the middle
    if border_U >= border_D - 1 or border_L >= border_R - 1:
        res = "NO"

    # Aoki's turn
    if T[i - 1] == "U":
        border_D += 1
    elif T[i - 1] == "D":
        border_U -= 1
    elif T[i - 1] == "L":
        border_R += 1
    elif T[i - 1] == "R":
        border_L -= 1

    # sanitize
    border_U = max(border_U, 0)
    border_D = min(border_D, H + 1)
    border_L = max(border_L, 0)
    border_R = min(border_R, W + 1)

# Takahashi's final turn
if S[0] == "U":
    border_U += 1
elif S[0] == "D":
    border_D -= 1
elif S[0] == "L":
    border_L += 1
elif S[0] == "R":
    border_R -= 1

if sr <= border_U:
    res = "NO"
elif sr >= border_D:
    res = "NO"
elif sc <= border_L:
    res = "NO"
elif sc >= border_R:
    res = "NO"

print(res)


Measured memory_bytes: 72648
import numpy as np
H,W = map(int,input().split())
H += -1
W += -1
import sys
ma = [[c for c in l.strip()] for l in sys.stdin]
ya = []
for s in ma:
  ya.extend(s)
count = ya.count(".")
ma = np.array(ma,"U10")
ma[0][0] = 1
que = []
que.append([0,0])
while len(que) > 0:
  y,x = que.pop(0)
  if y == H and x == W:
    break
  score = ma[y][x]
  try:
    if y != 0:
      y1 = ma[y-1][x] 
  except:
    pass
  try:
    y2 = ma[y+1][x]
  except:
    pass
  try:
    if x != 0:
      x1 = ma[y][x-1]
  except:
    pass
  try:
    x2 = ma[y][x+1] 
  except:
    pass
  try:
    if y1 == ".":
      ma[y-1][x] = str(int(score) + 1)
      que.append([y-1, x])
  except:
    pass
  try:
    if y2 == ".":
      ma[y+1][x] = str(int(score) + 1)
      que.append([y+1, x])
  except:
    pass
  try:
    if x1 == ".":
      ma[y][x-1] = str(int(score) + 1)
      que.append([y, x-1])
  except:
    pass
  try:
    if x2 == ".":
      ma[y][x+1] = str(int(score) + 1)
      que.append([y, x+1])
  except:
    pass
  x1 = 999
  x2 = 999
  y1 = 999
  y2 = 999
if ma[H][W] == ".":
  print(-1)
else:
  ten = int(ma[H][W])
  print(count - ten)

Measured memory_bytes: 12548
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t int64;

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

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


class D {
	int n, m, q;
	static const int MAX_M{ 200001 };
	static const int MAX_N{ 501 };

public:
	D()
	{
		cin >> n >> m >> q;
	}

	// O(n^2 + qn)
	void solve_cumulative()
	{
		int l, r;
		int x[MAX_N][MAX_N], cum[MAX_N][MAX_N];
		memset(cum, 0, sizeof cum);
		memset(x, 0, sizeof x);


		REP(i, m)
		{
			cin >> l >> r;
			++x[l][r];
		}

		// O(n^2)
		REP(i, n)
			REP(j, n)
		{
			cum[i + 1][j + 1] = cum[i + 1][j] + x[i + 1][j + 1];
		}

		// O(qn)
		REP(i, q) // q loops
		{
			cin >> l >> r;
			int sum{ 0 };

			for (int j{ l }; j <= r; j++) // n loops
				sum += cum[j][r] - cum[j][l - 1];

			cout << sum << endl;
		}

		// end solution solve_cumulative
	}

	// O(n^2 + q)
	void solve_2Dcumulative()
	{
		int l, r;
		int cum[MAX_N][MAX_N];
		memset(cum, 0, sizeof cum);

		REP(i, m)
		{
			cin >> l >> r;
			++cum[l][r];
		}

		// O(n^2)
		REP(i, n)
			REP(j, n)
			cum[i + 1][j + 1] += cum[i + 1][j];
		// O(n^2)
		
		REP(i, n)
			REP(j, n)
			cum[i + 1][j + 1] += cum[i][j + 1];

		// O(q)
		REP(i, q)
		{
			cin >> l >> r;

			int ans{ cum[r][r] + cum[l - 1][l - 1] - cum[l - 1][r] - cum[r][l - 1] };

			cout << ans << endl;
		}

		// end solution solve_2Dcumulative
	}

	void solve()
	{
		solve_cumulative();
	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int A, B, K;
    cin >> K >> A >> B;
    if (B / K == (A - 1) / K)
        cout << "NG";
    else
        cout << "OK";
    cout << endl;
    return 0;
};


Measured memory_bytes: 3608
N = list(input())
setN = set(N)
D = list('abcdefghijklmnopqrstuvwxyz')
rD = list('zyxwvutsrqponmlkjihgfedcba')
if len(N) < 26:
    for d in D:
        if not d in setN:
            N.append(d)
            print(''.join(N))
            exit()
else:
    N.reverse()
    for i in range(25):
        if N[i] < N[i+1]:
            continue
        else:
            tmp = N[i+1]
            ans = N[i+2:]
            ans.reverse()
            cand = N[:i+2]
            cand.sort()
            for n in N[:i+2]:
                if ord(n) - ord(tmp) > 0:
                    ans.append(n)
                    print(''.join(ans))
                    exit()
print(-1)

Measured memory_bytes: 38256
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),M=in(),X=in();
	vector<pair<int,vector<int>>> V(N);
	REP(i,N){
		V[i].first=in();
		REP(j,M) V[i].second.push_back(in());
	}

	int L=1<<N;
	int minC=1<<30;
	REP(i,L){
		int v=i,index=0,C=0;
		vector<int> F(M,0);
		while(v){
			if(v&1){
				C+=V[index].first;
				REP(j,M) F[j] += V[index].second[j];
			}
			index++;
			v/=2;
		}
		bool flag = true;
		REP(j,M){
			if(F[j]<X){
				flag = false;
				break;
			}
		}
		if(flag){
			minC = min(C,minC);
		}
	}
	out(minC>=1<<30 ? -1 : minC);
	return 0;
}


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

int main()
{
  string s;
  cin >> s;
  int cnt=0;
  for(int i=0;i<s.length() ;i++)
  {
    if(s[i]=='o') cnt++;
    
  }
  cout<<(cnt+15-s.length()>=8?"YES":"NO")<<'\n';
  return 0;
}

Measured memory_bytes: 256
import bisect
Q = int(input())

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(n**0.5)+1):
        if n % k == 0:
            return 0
    return n

prime_numbers = [is_prime(i) for i in range(2, 10**5 + 1) if is_prime(i) != 0]
# print(prime_numbers)
same = [0]*(10**5 + 1)
for n in prime_numbers:
    # print(n)
    if (n+1) // 2 in prime_numbers:
        same[n] += 1
# print(same)
# print(same[:20])

for i in range(10**5):
    same[i+1] += same[i]
# print(same[:20])
# print(same[3], same[5])
ans = []
for _ in range(Q):
    l, r = map(int, input().split())
    N = same[r] - same[l-1]
    # if same[l] != same[l-1] or same[r] != same[r-1]:
    #     N += 1
    #     if l == r:
    #         N += 1
    ans.append(N)

print(*ans, sep='\n')


Measured memory_bytes: 12684
package main

import "fmt"

func main() {
  var n int
  fmt.Scan(&n)
  
  l := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
  
  fmt.Print(l[n-1])
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>


using namespace std;
typedef long long ll;

int main(){
  int N;
  vector<int> W;
  cin >> N;
  for(int i=0;i<N;i++){
    int n;
    cin >> n;
    W.push_back(n);
  }
  int sum = accumulate(W.begin(),W.end(), 0);
  int a=0;
  int ans =100;
  int dif;
  for(int i=0;i<N;i++){
    a += W[i];
    dif = abs(sum-2*a);
    if(ans>dif) ans=dif;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3196
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n = int(input())

ans = 0
for i in make_divisors(n):
    if i == 1:
        continue
    k = n//i
    m = i-1
    if k < m:
        ans += m
print(ans)


Measured memory_bytes: 40048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    ll N;
    cin>>N;
    ll sum=N*(N+1)/2;
    ll a=N/3;
    ll aa=a*(a+1)*3/2;
    ll b=N/5;
    ll bb=b*(b+1)*5/2;
    ll ab=N/15;
    ll aabb=ab*(ab+1)*15/2;
    ll ans=sum-aa-bb+aabb;
    out(ans);

}

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

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <iomanip>
#include <numeric>
#include <bitset>

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

using namespace std;

typedef long long ll;

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  ll h, w, x, y;
  cin >> h >> w >> x >> y;
  cout << h * w / 2.0 << " " << (h == 2*x && w == 2*y) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;	//using vi = vector<int>;

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

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h)cin >> s[i];
	vector<vector<string>> sc(h,vector<string>(w));

	rep(i, h) {
		rep(j, w) {
			sc[i][j] = s[i][j];
		}
	}

	int temp;
	rep(i, h) {
		rep(j, w){
			temp = 0;
			if (sc[i][j] == "#")continue;
			for(int dx = -1;dx<=1;dx++) {
				for (int dy = -1; dy <= 1; dy++) {
					int nx = j + dx, ny = i + dy;
					if (0 <= nx && nx < w && 0 <= ny && ny < h) {
						//cout << "ny:" << ny << "  nx:" << nx << endl;
						if (sc[ny][nx] == "#") {
							temp++;
						}
					}
				}
			}
			//ターゲットのマス自体のカウントを引く
			//cout << "temp:" << to_string(temp) << endl;
			sc[i][j] = to_string(temp);
		}
	}
	
	rep(i, h) {
		rep(j, w) {
			cout << sc[i][j];
		}
		cout << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);

		if (a + b + c > 21)
			System.out.println("bust");
		else
			System.out.println("win");
	}
}

Measured memory_bytes: 22484