akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,m,ans,mn;
  cin>>n>>m;
  int a[n][2],c[m][2];
  rep(i,n){
    cin>>a[i][0]>>a[i][1];
  }
  rep(i,m){
    cin>>c[i][0]>>c[i][1];
  }
  rep(i,n){
    mn=BIG;
    rep(j,m){
      //cout<<mn<<endl;
      //cout<<(abs(a[i][0]-c[j][0])+abs(a[i][1]-c[i][1]))<<endl;
      if((abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1]))<mn){
	//cout<<1<<endl;
	mn=(abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1]));
	ans=j+1;
	//	cout<<mn<<" "<<ans<<endl;
	//	cout<<abs(a[i][1]-c[j][1])<<endl<<endl;
      }
    }
    //  cout<<endl;
    cout<<ans<<endl;
  }
  
  return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 string S;
  cin>>S;
  int N=S.size();
  int ans=0;
  for(int i=(N/2)-1;1<=i;i--){
  bool x=true;
    for(int j=0;j<i;j++){
     if(S.at(j)!=S.at(i+j)){
       x=false; break;
     }
    } if(x){
    ans=2*i; break;
    }
  
  }cout<<ans<<endl;
  
   return 0;
}

Measured memory_bytes: 256
n,l,*a=map(int,open(0).read().split())
i=m=0
for j,(x,y)in enumerate(zip(a,a[1:]),1):
  if x+y>m:
    m=x+y
    i=j
if m<l:
  print('Impossible')
else:
  print('Possible')
  print(*range(1,i))
  print(*range(n-1,i,-1))
  print(i)

Measured memory_bytes: 14092
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> p;
	for (int i = 0;i < n;i++)
	{
		int num;
		cin >> num;
		p.push_back(num);
	}
	int oper;
	cin >> oper;
	while (oper--)
	{
		int finda;
		cin >> finda;
		vector<int>::iterator p1 = lower_bound(p.begin(), p.end(), finda);
		vector<int>::iterator p2 = upper_bound(p.begin(), p.end(), finda);
		cout << p1 - p.begin() << " " << p2 - p.begin() << endl;
	}
}


Measured memory_bytes: 3524
#include <stdio.h>
#include <iostream>
#include <queue>
#define NUM 100
#define NIL -1
using namespace std;

int V[NUM + 1][NUM + 1];
int dist[NUM + 1];
int node_num;
int t;
int pos;
queue<int> Q;

void init(){
    int V[NUM + 1][NUM + 1];
    for(int i = 1; i <= NUM; i++){
        for(int j = 1; j <= NUM; j++){
            V[i][j] = 0;
        }
    }

    for(int i = 0; i <= NUM; i++) {
        dist[i] = NIL;
    }
    
    t = 0;
}

void get_adj(){
    scanf("%d", &node_num);

    for(int i = 0; i < node_num; i++){
        int num1;
        scanf("%d", &num1);

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

        int num2;
        for(int j = 0; j < n; j++){
            scanf("%d", &num2);
            V[num1][num2] = 1;
        }
    }
}

void touchNextNode(int n){
    t += 1;
    for(int i = 1; i <= node_num; i++){
        if(V[n][i] == 1 && dist[i] == NIL){
            Q.push(i);
            dist[i] = dist[n] + 1;
        }
    }
    Q.pop();
}

void BFS(){
    Q.push(1);
    dist[1] = t;
    touchNextNode(1);
    
    while(Q.size()){
        int pos = Q.front();
        touchNextNode(pos);
    }
}

int main(void){
    init();
    get_adj();
    BFS();
    
    for(int i = 1; i <= node_num; i++){
        printf("%d %d\n", i, dist[i]);
    }

}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main() {
   int n,m; cin >> n >> m;
   vector<vector<char>> a(n,vector<char>(n));
   vector<vector<char>> b(m,vector<char>(m));
   rep(i,n){
       rep(j,n){
           cin >> a.at(i).at(j);
       }
   }
   rep(i,m){
       rep(j,m){
           cin >> b.at(i).at(j);
       }
   }

   bool flag1 = false;
   rep(i,n){
       rep(j,n){
           if((i + m - 1 >= n) || (j + m - 1 >= n))continue;
           bool flag2 = true;
           rep(k,m){
               rep(l,m){
                   if(b.at(k).at(l) != a.at(i + k).at(j + l)){
                       flag2 = false;
                   }
               }
           }
               if(flag2){
                   flag1 = true;
                   break;
                }
           }
       }
   if(flag1)print("Yes");
   else print("No");

   return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
    k = int(input())
    vp = [list(map(int, input().split())) for _ in [0]*k]

    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    # まず各頂点の偶奇を計算する
    parity = [-1]*n
    root = vp[0][0]-1
    p = vp[0][1] % 2
    parity[root] = p
    q = [root]
    while q:  # BFS
        p ^= 1
        qq = []
        while q:
            i = q.pop()
            for j in g[i]:
                if parity[j] == -1:
                    parity[j] = p
                    qq.append(j)
        q = qq

    # 偶奇と塗った色があっていなければ即座に終了
    for v, p in vp:
        if p % 2 != parity[v-1]:
            print("No")
            return

    # バックトラック法を行い解の範囲を探索する
    ans_range = [[-10**10, 10**10] for _ in [0]*n]
    q = [root]
    vp = {v-1: p for v, p in vp}
    M = 10**10
    m = -10**10
    g2 = [set(gg) for gg in g]
    while q:
        i = q[-1]
        if i in vp:
            if m <= vp[i] <= M:
                M = vp[i]
                m = M
                ans_range[i] = [m, M]
            else:
                print("No")
                return
        else:
            m2, M2 = ans_range[i]
            if M2 < m or M < m2:
                print("No")
                return
            m = max(m, m2)
            M = min(M, M2)
            ans_range[i] = [m, M]
        if g2[i]:
            j = g2[i].pop()
            g2[j].remove(i)
            q.append(j)
        else:
            q.pop()
        m -= 1
        M += 1

    q = [root]
    now = vp[root]
    ans = [None]*n
    g = [set(gg) for gg in g]
    while q:
        i = q[-1]
        if ans[i] != None:
            now = ans[i]
        else:
            if ans_range[i][1] < now:
                now -= 2
            ans[i] = now
        if g[i]:
            j = g[i].pop()
            g[j].remove(i)
            q.append(j)
        else:
            q.pop()
        now += 1
    print("Yes")
    for i in ans:
        print(i)


main()


Measured memory_bytes: 143988
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        boolean ret = false;
        if (a+b==c||a+c==b||b+c==a) {
            ret = true;
        }
        if (ret) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main()
{
    int X, N;
    int d = 102;
    int a, m;
    cin >> X >> N;
    vector<bool> p(102);
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        p.at(a) = 1;
    }
    for (int i = 0; i < 102; i++)
    {
        if(p.at(i) == 0 && d > abs(i - X)){
            d = abs(i - X);
            m = i;
        }
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N, T, A, H;
 cin >> N >> T >> A;
 int  d;
 int res = 1000000;
 int ans = 0;
 for (int i = 0; i < N; i++){
   cin >> H;
   d = abs((T * 1000 - H * 6) - A * 1000);
   if (d < res) {
     res = d;
     ans = i + 1;
   }
 }
 cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    string s;
    cin>>s;
    string t;
    t=s;
    reverse(ALL(t));
    map<char,char> m={{'b','d'},{'d','b'},{'p','q'},{'q','p'}};
    REP(i,SZ(s)) {
        if(EXIST(m,s[i])) {
            s[i]=m[s[i]];
        }
    }
    if(s==t) {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 512
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var InputStr = Console.ReadLine();
            var InputStr2 = Console.ReadLine();
            if (InputStr == InputStr2.Substring(0, InputStr2.Length - 1))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 17216
n = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if n == 1:
  print(0)
else:
  arr = factorization(n)
  c = 0
  for e in arr:
    now = 0
    while e[1] > now:
      now += 1
      e[1] -= now
    c += now
  print(c)
    
  

Measured memory_bytes: 9484
var C = ["A", "B", "C"];
function swap(A, i1, i2) {
    var tmp = A[i1];
    A[i1] = A[i2];
    A[i2] = tmp;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.trim().split('\n');

var cups = [1,0,0];

var line;
while (line = lines.shift()) {
    var command = line.split(',');
    swap(cups, C.indexOf(command[0]), C.indexOf(command[1]));
}

for (var i = 0; i < cups.length; i++) {
    if (cups[i]) {
        console.log(C[i]);
        break;
    }
}

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

int main(void)
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<int> b(n + 1);
    for (size_t i = 1; i <= n; i++)
    {
        cin >> a[i];
    }

     
    int m = 0;
    for (size_t i = n;  0 < i; i--)
    {
        int j = 2;
        int count;
        int sum = 0;    
        while(i * j <= n){
            sum += b[i * j ];
            j++;
        }
        int odd = sum % 2;
        if((a[i] == 0)&&(odd == 0)){
            b[i] = 0;     
        }else if((a[i] == 0)&&(odd == 1)){
            b[i] = 1; 
            m++;  
        }else if((a[i] == 1)&&(odd == 0)){
            b[i] = 1; 
            m++;   
        }else if((a[i] == 1)&&(odd == 1)){
            b[i] = 0; 
        }
    }

    cout << m << endl; 
    for (size_t i = 1; i <= n; i++)
    {
        if(b[i] == 1){
            cout << i << " "; 
        }
    }
    cout << endl; 

    return 0;
}

Measured memory_bytes: 2432
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 INP PIC X(100).
       01 A PIC 99999.
       01 B PIC 99999.
       01 temp1 PIC 9999.
       01 temp2 PIC 9999.
       01 N PIC 9999.
       PROCEDURE DIVISION.
       MAIN.
       	ACCEPT INP.
      	PERFORM VARYING temp1 FROM 1 BY 1 UNTIL INP(temp1:1)=SPACE
      	END-PERFORM.
      	SUBTRACT 1 FROM temp1.
      	MOVE INP(1:temp1) TO A.
      	ADD 2 TO temp1.
      	PERFORM VARYING temp2 FROM temp1 BY 1 UNTIL INP(temp2:1)=SPACE
      	END-PERFORM.
      	COMPUTE N=temp2 - temp1.
      	MOVE INP(temp1:N) TO B.
      	COMPUTE A = A * B.
      	COMPUTE B = A / 2.
      	COMPUTE A = A - B * 2.
      	IF A = 0 THEN
      		DISPLAY "Even"
      	ELSE
      		DISPLAY "Odd"
      	END-IF.
        STOP RUN.



Measured memory_bytes: 508
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

vector<pair<ll,int>> factorize(ll n){
	vector<pair<ll,int>> res;
  	for(ll i = 2; n >= i*i; i++){
    	if(n%i) continue;
        res.emplace_back(i,0);
        while(n%i == 0){
        	n /= i;
          	res.back().second++;
        }
      	if(i>2) i++;
    }
  	if(n!=1){
  		res.emplace_back(n,1);
    }
  	return res;
}

vll divisor(ll n){
  	vll ans;
  	for(ll i = 2; i*i <= n; i++){
      	if(n%i == 0){
          	ans.pb(i);
        }
    }
  	return ans;
}

void Main(){
	ll n;
	cin >> n;
	auto fact = factorize(n-1);
	ll temp = 1;
  	for(auto f : fact){
    	temp *= (f.se+1);
    }
	--temp;
	
  	//cout << temp << endl;
  
  	for(auto a : divisor(n)){
      	//cout << a << endl;
      	ll m = n;
      	while(m%a == 0){
          	m /= a;
        }
      	if(m%a == 1) temp++;  
    }
 	cout << temp+1 << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int n;
string s;
vector<bool> ans; // true = S, false = W

bool check(){
	bool zero = (ans[0] == ans[n]);
	bool ss = true;
	if(s[0] == 'o'){
		if(ans[0]){
			if(ans[n-1] != ans[1]) ss = false;
		}else{
			if(ans[n-1] == ans[1]) ss = false;
		}
	}else{
		if(ans[0]){
			if(ans[n-1] == ans[1]) ss = false;
		}else{
			if(ans[n-1] != ans[1]) ss = false;
		}
	}

	return (zero&&ss);
}

int main()
{
	cin >> n >> s;
	bool flag = false;
	ans.resize(n+1);

	ans[0] = true,ans[1] = true;

	for(int i = 1; i < n; i++){
		if(s[i] == 'o'){
			if(ans[i]) ans[i+1] = ans[i-1];
			else ans[i+1] = !ans[i-1];
		}else{
			if(ans[i]) ans[i+1] = !ans[i-1];
			else ans[i+1] = ans[i-1];
		}
	}

	// for(int i = 0; i < n; i++){
	// 	if(ans[i]) cout << 'S';
	// 	else cout << "W";
	// }printf("\n");

	if(check()){
		for(int i = 0; i < n; i++){
			if(ans[i]) cout << 'S';
			else cout << "W";
		}printf("\n");
		return 0;
	}

	
	ans[0] = true,ans[1] = false;

	for(int i = 1; i < n; i++){
		if(s[i] == 'o'){
			if(ans[i]) ans[i+1] = ans[i-1];
			else ans[i+1] = !ans[i-1];
		}else{
			if(ans[i]) ans[i+1] = !ans[i-1];
			else ans[i+1] = ans[i-1];
		}
	}

	// for(int i = 0; i < n; i++){
	// 	if(ans[i]) cout << 'S';
	// 	else cout << "W";
	// }printf("\n");

	if(check()){
		for(int i = 0; i < n; i++){
			if(ans[i]) cout << 'S';
			else cout << "W";
		}printf("\n");
		return 0;
	}


	ans[0] = false,ans[1] = true;

	for(int i = 1; i < n; i++){
		if(s[i] == 'o'){
			if(ans[i]) ans[i+1] = ans[i-1];
			else ans[i+1] = !ans[i-1];
		}else{
			if(ans[i]) ans[i+1] = !ans[i-1];
			else ans[i+1] = ans[i-1];
		}
	}

	// for(int i = 0; i < n; i++){
	// 	if(ans[i]) cout << 'S';
	// 	else cout << "W";
	// }printf("\n");

	if(check()){
		for(int i = 0; i < n; i++){
			if(ans[i]) cout << 'S';
			else cout << "W";
		}printf("\n");
		return 0;
	}


	ans[0] = false,ans[1] = false;

	for(int i = 1; i < n; i++){
		if(s[i] == 'o'){
			if(ans[i]) ans[i+1] = ans[i-1];
			else ans[i+1] = !ans[i-1];
		}else{
			if(ans[i]) ans[i+1] = !ans[i-1];
			else ans[i+1] = ans[i-1];
		}
	}

	// for(int i = 0; i < n; i++){
	// 	if(ans[i]) cout << 'S';
	// 	else cout << "W";
	// }printf("\n");

	if(check()){
		for(int i = 0; i < n; i++){
			if(ans[i]) cout << 'S';
			else cout << "W";
		}printf("\n");
		return 0;
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 512
N = int(input())
A = [[int(i) for i in input().split()] for i in range(N - 1)]

for i in range(N - 1):
    t = 0
    for j in range(i, N - 1):
        C, S, F = A[j]
        if S >= t:
            t = S
        elif t % F != 0:
            t += F - (t % F)
        t += C
    print(t)
print(0)

Measured memory_bytes: 3188
#include<string>
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    string blue[105];
    string red[105];
    int n,m,i;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
        cin>>blue[i];

    scanf("%d",&m);
    for(i=1; i<=m; i++)
        cin>>red[i];

    string temp;
    string lin;
    lin='0';
    int sum1,sum2,j,flag=0,ans=0;

    while(flag==0)
    {
        flag=1;
        for(i=1; i<=n; i++)
        {
            if(blue[i]==lin)
                continue;
            if(blue[i]!=lin)
            {
                sum1=1;
                sum2=0;
                temp=blue[i];
                blue[i]=lin;
                flag=0;
            }
            for(i=1;i<=n;i++)
                if(blue[i]==temp)
            {sum1++;}
            break;
        }
        for(i=1; i<=m; i++)
        {
            if(red[i]==temp)
            sum2++;
        }
        //cout<<"temp="<<temp<<endl;
   //printf("sum1=%d sum2=%d \n",sum1,sum2);
        if(sum1-sum2>ans)
            ans=sum1-sum2;
     //   printf("flag=%d\n",flag);
        if(flag==1)
            break;
    }
    if(ans<0)
        printf("0");
        if(ans>=0)
        printf("%d",ans);
    return 0;

}


Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d %d %d', $A, $B, $K);

$min = min($A, $B);

$count = 0;
for ($i = $min; $i > 0; --$i) {
    if ($A % $i === 0 && $B % $i === 0) {
        ++$count;
    }
    
    if ($count === $K) {
        echo $i;
        break;
    }
}


Measured memory_bytes: 4728
N=int(input())
A=list(map(int,input().split(' ')))
X,Y=A[0],sum(A)-A[0]
ans=abs(X-Y)
for i in range(N-2):
  X+=A[i+1]
  Y-=A[i+1]
  if abs(X-Y)<ans:
    ans=abs(X-Y)
print(ans)

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

#define watch(x) cerr << "\n" \
					  << (#x) << " is " << (x) << endl
const double PI = 3.141592653589793238463;
const int MOD = 1000000007;
const long long MAXI = ULONG_MAX;

/*
$alil03

URL: url

Solution Begins here
*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for (int i = 2; i < n; i++)
	{
		dp[i] = min(dp[i - 2] + abs(arr[i] - arr[i - 2]), dp[i - 1] + abs(arr[i] - arr[i - 1]));
	}
	cout << dp[n - 1];
}


Measured memory_bytes: 1024
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int k;
    int a;
    int b;
    cin >> k;
    cin >> a >> b;
    int tmp_a;
    int tmp_b;
    tmp_a=a/k;
    tmp_b=b/k;
    bool ans=false;
    for(int i=tmp_a; i<=tmp_b+1; i++){
        if(i*k>=a && i*k<=b){
            ans=true;
        }
    }

    if(ans==true){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

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

    vector<double> p(n);
    rep2(i, n) cin(p[i]);

    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0));
    dp[0][0] = 1.0;

    rep2(i, n) {
        erep2(j, i) {
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }

    double result = 0;
    erep3(i, n / 2 + 1, n) {
        result += dp[n][i];
    }

    printf("%.12lf", result);
    return 0;
}

Measured memory_bytes: 70656
n, m = map(int, input().split())

prefectures = []

i = 0
while i < m:
    p, y = map(int, input().split())
    prefectures.append((i, p, y))
    i += 1
prefectures.sort(key=lambda x: x[2])

answers = []
ranks = [1 for i in range(n + 1)]
for i, p, y in prefectures:
    answers.append((i, str(p).zfill(6) + str(ranks[p]).zfill(6)))
    ranks[p] += 1

answers.sort()

for i, answer in answers:
    print(answer)

Measured memory_bytes: 36728
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;



int main() {
	int n,m;
	cin>>n>>m;
	int p=pow(2,m);
	int time=1900*m+(n-m)*100;
	cout<<time*p<<endl;
	return 0;
}


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

using namespace std;

int h1, m1, h2, m2, k;

int main() {
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << max(0, h2 * 60 + m2 - h1 * 60 - m1 - k);
	return 0;
}

Measured memory_bytes: 3632
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    S=input()

    if S[:N//2]==S[N//2:]:
        print("Yes")
    else:
        print("No")
        

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc145","b",main)

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

long long calcmatches(long long d, long long a, long long b)
{
    if (a % d == 0){
        return b / d - a / d + 1;
    }
    else{
        return b / d - a / d;
    }
    
}
long long gcd(long long a, long long b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main()
{
    long long A, B, C, D;
    long long osoro;

    cin >> A >> B >> C >> D;
    osoro = (C * D) / gcd(C,D);
    cout << B - A + 1 - calcmatches(C, A, B) - calcmatches(D, A, B) + calcmatches(osoro, A, B) << endl;
}

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

int main(){
  int N;
  int satis = 0;
  cin >> N;
  vector<vector<int>> A(N,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<N;j++){
      if(i==2&&j==N-1)break;
      else{
        cin >> A[j][i];
      }
    }
  }
  for(int k=0;k<N;k++){
    int p = A[k][0];
    satis += A[p-1][1];
    if(k!=N-1&&A[k+1][0]==p+1){
      satis += A[p-1][2];
    }
  }
  cout << satis << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
    int num = rint();
    int[,] jifibi = inta2(num-1,3);
    for(int i=0;i<num;i++){
        int nowtime =0;
        for(int j=i;j<num-1;j++){
            int sa = jifibi[j,1] - nowtime;

            if(sa >= 0){
                nowtime += sa;

            }else{
                
                sa *= -1;
                int just = (sa/jifibi[j,2]) +1;
                if(sa % jifibi[j,2]== 0){
                    just--;
                }
                nowtime = jifibi[j,1] + just*jifibi[j,2];


            }
            nowtime += jifibi[j,0];
        }
        WriteLine(nowtime);
    }
    
    
    
    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++) 

int main() {
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k) {
        cout << s << endl;
    }
    else {
        cout << s.substr(0, k) << "..." << endl;
    }
    return 0;
}

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

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

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

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

    for (int i=1;i<=n;i++) {
        int a=i*1.08;
        if(a==n){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N;
	char s[100000];
	int n=1;

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> s[i];
	}
	for (int i = 1; i < N; i++)
	{
		if (s[i]!=s[i-1])
		{
			n++;
		}
	}
	cout << n;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
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; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

ll dp[110][100010];

int main(){
	int n,W;
	cin >> n >> W;
	vi w(n),v(n);
	rep(i,n) cin >> w[i] >> v[i];
	rep(i,110) rep(j,100010) dp[i][j] = 1e18;
	dp[0][0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 100010; j++){
			chmin(dp[i+1][j],dp[i][j]);
			if(j>=v[i]) chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
		}
	}
	
	int ans = 0;
	for(int j = 0; j < 100010; j++) if(dp[n][j] <= W) ans = j;
	cout << ans << endl;

	return 0;
}

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

class Class3
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());

        int cntAC = 0;
        int cntWA = 0;
        int cntTLE = 0;
        int cntRE = 0;

        for (int i = 1; i <= N; i++)
        {
            string Si = (Console.ReadLine());

            switch(Si)
            {
                case "AC":
                    cntAC++;
                    break;
                case "WA":
                    cntWA++;
                    break;
                case "TLE":
                    cntTLE++;
                    break;
                case "RE":
                    cntRE++;
                    break;
            }
        }


        Console.WriteLine("AC x " + cntAC.ToString());
        Console.WriteLine("WA x " + cntWA.ToString());
        Console.WriteLine("TLE x " + cntTLE.ToString());
        Console.WriteLine("RE x " + cntRE.ToString());




    }
}

Measured memory_bytes: 30628
#include<bits/stdc++.h>
using namespace std;
int a,a1,b,b1;
int main()
{
	cin>>a>>a1>>b>>b1;
	if(a+a1>b+b1)cout<<"Left";
	if(a+a1<b+b1)cout<<"Right";
	if(a+a1==b+b1)cout<<"Balanced";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
ll pows(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>h;
count1=0;
p=1;
while(h>=1)
{
  if(h==1)
  {
    ans+=p;
    break;
  }
  ans+=p;
  h/=2;
  p*=2;
} 
cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N;
  cin >> N;
  map<int , int> a;
  int a_;
  for (int i = 0; i < N; ++i) {
    cin >> a_;
    a[a_]++;
  }
  int ans = 0;
  for (auto const& e: a) {
    if (e.second < e.first) {
      ans += e.second;
    } else if (e.second > e.first) {
      ans += e.second - e.first;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;
constexpr int V_MAX = 1000010;

int main(){
    int n;
    scanf("%d", &n);
    int a[n], cnt[V_MAX], used[V_MAX];
    memset(cnt, 0, sizeof(cnt));
    memset(used, 0, sizeof(used));
    rep(i, n) scanf("%d", &a[i]), ++cnt[a[i]];
    rep(i, n)if(!used[a[i]]){
        for(int j=2; a[i]*j<V_MAX; ++j) cnt[a[i]*j] = 0;
        used[a[i]] = 1;
    }
    printf("%d\n", count_if(cnt, cnt+V_MAX, [](int x){return x == 1;}));
}

Measured memory_bytes: 12368
s = input()
Ng = 0
Np = 0
Nw = 0
Nl = 0
for i in s:
    if Ng > Np:
        if i == 'g':
            Nw += 1
        Np += 1
    else:
        if i == 'p':
            Nl += 1
        Ng += 1

print(Nw - Nl)

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll odd(ll a){
  ll p=a%4;
  if(p==1) return 1;
  else return 0;
}

ll f(ll a){
  if(a%2){
    return odd(a);
  }else{
    return odd(a-1)^a;
  }
}


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b; cin>>a>>b;
  ll x=f(a-1);
  ll y=f(b);
  // cout<<x<<" "<<y<<endl;
  ll ans=x^y;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
S = input()
if len(S) == 1:
  print("YES")
else:
  D = {'a': 0, 'b': 0, 'c': 0}
  for i in S:
    D[i] += 1
  if max(D[i] for i in D) - min(D[i] for i in D) <= 1:
    print("YES")
  else:
    print("NO")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=2e5+5;
int H[MAXN];
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&H[i]);
	sort(H+1,H+1+n);
	ll ans=0;
	for(int i=1;i<=n-k;i++)
		ans+=H[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
	if (y == 0) return x;
	else return GCD(y, x % y);
}

int main()
{
	int A, B;
	cin >> A >> B;

	if (A > 8) { cout << ":(" << endl; }
	else {
		if (B <= (16 - 2 * A) / 2 + A) { cout << "Yay!" << endl; }
		else { cout << ":(" << endl; }
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;

int main(){
	ll n;
	cin >> n;
	
	ll ans = 0;
	for(ll j = 1; j <= n; j++){
		ll d = n / j;
		ans += d * (d + 1) * j / 2;
	}
	
	cout << ans << endl;
	return 0;
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
struct data{
  ll id,s;
  bool operator<(const data& d){
    return id < d.id;
  }
  bool operator>(const data& d){
    return s > d.s;
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,b,c,d;
  cin >> n;
  vector<data> v(n);
  rep(i,n){
    v[i].id = i+1;
  }
  rep(i,n * (n-1)/2){
    cin >> a >> b >> c >> d;
    --a,--b;
    if(c > d){
      v[a].s += 3;
    }
    else if(c == d){
      v[a].s++;
      v[b].s++;
    }
    else{
      v[b].s += 3;
    }
  }
  sort(all(v),[](const data& d,const data& d2){return d.s > d2.s;});
  ll k = inf;
  ll cnt = 1;
  rep(i,n){
    if(k != v[i].s){
      k = v[i].s;
      v[i].s = i+1;
      cnt = i+1;
    }
    else if(k == v[i].s){
      v[i].s = cnt;
    }
  }
  sort(all(v));
  rep(i,n){
    cout << v[i].s<<endl;
  }
  return 0;
}

Measured memory_bytes: 3220
ABCD = input()
A,B,C,D = int(ABCD[0]), int(ABCD[1]), int(ABCD[2]), int(ABCD[3])
ans = ''
if A+B+C+D == 7:
  ans = str(A)+'+'+str(B)+'+'+str(C)+'+'+str(D)
elif A+B+C-D == 7:
  ans = str(A)+'+'+str(B)+'+'+str(C)+'-'+str(D)
elif A+B-C+D == 7:
  ans = str(A)+'+'+str(B)+'-'+str(C)+'+'+str(D)
elif A+B-C-D == 7:
  ans = str(A)+'+'+str(B)+'-'+str(C)+'-'+str(D)
elif A-B+C+D == 7:
  ans = str(A)+'-'+str(B)+'+'+str(C)+'+'+str(D)
elif A-B+C-D == 7:
  ans = str(A)+'-'+str(B)+'+'+str(C)+'-'+str(D)
elif A-B-C+D == 7:
  ans = str(A)+'-'+str(B)+'-'+str(C)+'+'+str(D)
elif A-B-C-D == 7:
  ans = str(A)+'-'+str(B)+'-'+str(C)+'-'+str(D)
print(ans+'=7')


Measured memory_bytes: 3064
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

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

const string YES = "Yes";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, long long m, std::vector<long long> a, std::vector<long long> b){

    vector<vector<int>> edges(n);
    for(int i = 0; i < m; ++i){
        edges[--a[i]].push_back(--b[i]);
        edges[b[i]].push_back(a[i]);
    }
    vector<int> dist(n, MOD);
    vector<int> v(n, -1);
    dist[0] = 0;
    queue<int> que;
    que.emplace(0);
    while(!que.empty()){
        int x = que.front();
        que.pop();
        for(auto y : edges[x]){
            if(v[y] == -1)
                v[y] = x;
            if(chmin(dist[y], dist[x] + 1)){
                v[y] = x;
                que.push(y);
            }
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < n; ++i){
        cout << v[i] + 1 << endl;
    }
}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


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

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)


def main():
    N, M = map(int, input().split())
    keys = []
    for _ in range(M):
        a, b = map(int, input().split())
        bits = sum([1 << (i - 1) for i in map(int, input().split())])
        keys.append([a, bits])

    dp = [INF] * (2 ** N + 10)
    dp[0] = 0

    for i in range(M):
        for j in range(2 ** N):
            dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0])
    print(dp[2 ** N - 1] if dp[2 ** N - 1] != INF else -1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3284
def main():
    """
    1 秒あたり上下左右に距離 1 だけ進むことができます
    sx<tx と sy<ty を満たす点 
    (sx,sy)->(tx,ty)->(sx,sy)->(tx,ty)->(sx,sy)
    (sx,sy) と点(tx,ty) を除いて、途中で同じ座標を複数回通らないように移動しなければなりません。

    −1000≦sx<tx≦1000
    −1000≦sy<ty≦1000

    最短距離: マンハッタン距離
    to (tx,ty)N=1: 最短距離OK
    to (sx,sy)N=2: 最短距離OK
    to (tx,ty)N=3: 最短距離NG
    to (sx,sy)N=4: 最短距離NG
    """
    sx, sy, tx, ty = map(int, input().split())

    diff_x = tx - sx
    diff_y = ty - sy
    # Up -> Right
    # Down -> Left
    # Left -> Up -> Right -> Down
    # Right -> Down -> Left -> Up
    route = [
        "U" * diff_y + "R" * diff_x,
        "D" * diff_y + "L" * diff_x,
        "L" + "U" * (diff_y + 1) + "R" * (diff_x + 1) + "D",
        "R" + "D" * (diff_y + 1) + "L" * (diff_x + 1) + "U",
    ]
    for r in route:
        print(r, end="")
    print("")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维
**加油，奥利给！！！ 
**/
map<int,int>p;
int a[200000];
int main()
{
	int m,n,i,j,t,k;
	cin>>n;
	int d=0,b=0,c=0;
	d=n%10;
	b=n/10%10;
	c=n/100;
	if(d==7||b==7||c==7) cout<<"Yes";
	else cout<<"No";
 } 


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int x,a;
    cin >> x >> a;
    if(x < a){
        cout << 0 << endl;
    }
    else{
        cout << 10 << endl;
    }

}

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

int is_prime(int n){
    if(n < 2) return 1;
    
    for(int i = 2 ; i*i <= n ; i++){
        if(!(n%i)) return 1;
    }
    return 0;
}

int main(){
    int n,m;
    
    cin >> n;
    int cnt = 0;
    while(n--){
        cin >> m;
        if(!is_prime(m)) cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 1160