akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main() {
	int n,j;
	string s,moto;
	set<string> se;
	cin >> n;
	for(int i = 0;i < n;i++){
		se.clear();
		cin >> moto;
		for(j = 1; j < moto.size();j++){
			string s1; //????????????
			for(int k = 0;k < j;k++){
				s1 += moto[k];
			}
			string s2;  //?????´????????????
			for(int k = moto.size()-1;k >= j;k--){
				s2 += moto[k];
			}
			string s3;  //?????´????????????
			for(int k = j-1;k >= 0;k--){
				s3 += moto[k];
			}
			string s4;  //????????????
			for(int k = j;k < moto.size();k++){
				s4 += moto[k];
			}
		se.insert(s1 + s2);//????????????
		se.insert(s2 + s1);//????????????
		se.insert(s3 + s4);//????????????
		se.insert(s4 + s3);//????????????
		se.insert(s1 + s4);//????????????
		se.insert(s4 + s1);//????????????
		se.insert(s3 + s2);//????????????
		se.insert(s2 + s3);//????????????
		}
	cout << se.size() <<endl;
	}
	return 0;
}

Measured memory_bytes: 1316
import java.util.Scanner;

public class Main {
	static int[][]G;
	static int[]c;
	static int cnt = 0;
	static int N;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		G = new int[N][N];
		c = new int[N];
		int M = sc.nextInt();
		for(int i = 0; i < M; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			G[a][b] = 1;
			G[b][a] = 1;
		}
		sc.close();
		dfs(0, 0);
		System.out.println(cnt);
	}
	static void dfs(int n, int v) {
		if(n == N - 1) {
			for(int i = 1; i < N; i++) {
				if(c[i] != 1) {
					return;
				}
			}
			cnt++;
			return;
		}
		for(int i = 1; i < N; i++) {
			if(c[i] == 0 && G[v][i] == 1) {
				n++;
				c[i] = 1;
				dfs(n, i);
				c[i] = 0;
				n--;
			}
		}
	}
}

Measured memory_bytes: 22740
N, K = list(map(int, input().split()))
mod = 10**9+7

ans = 0
for i in range(K, N+2):
    a = (N-i+1)*(N-i)//2
    b = N*(N+1)//2
    c = i*(i-1)//2
    ans += b%mod - a%mod - c%mod + 1
    ans %= mod

print(ans)

Measured memory_bytes: 9124
/*input
1 2 0 4 5
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}

void solve(){
	ll i,j,k;
	rep(i,1,6){
		cin>>j;
		if(!j){cout<<i<<endl;return;}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	return 0;
}




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

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
typedef unsigned int uint;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

bool cmp(const string& l, const string& r)
{
	if (SZ(l) == SZ(r))
	{
		return l < r;
	}
	else
	{
		return SZ(l) < SZ(r);
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	map<string, ll> m;
	vector<string> names;

	int n;
	cin >> n;

	string name;
	int v;
	rep(i, 0, n)
	{
		cin >> name >> v;
		names.push_back(name);
		m[name] += v;
	}

	sort(all(names), cmp);
	names.erase(unique(all(names)), names.end());
	vector<pair<string, ll>> ps;
	rep(i, 0, SZ(names))
	{
		cout << names[i] <<" "<< m.at(names[i]) << endl;
	}

	return 0;
}


Measured memory_bytes: 3664
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>

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

int main() {

	int N, C;
	scanf("%d %d", &N, &C);
	vector<pair<int, int>> TV[50];

	for (int i = 0; i < N; i++) {
		int s, t, c;
		scanf("%d %d %d", &s, &t, &c);
		TV[c - 1].push_back(make_pair(s, t));
	}

	for (int i = 0; i < C; i++) {
		sort(TV[i].begin(), TV[i].end());
	}

	for (int i = 0; i < C; i++) {
		for (int j = 0; j + 1 < (int)TV[i].size(); j++) {
			if (TV[i][j].second == TV[i][j + 1].first) {
				TV[i][j + 1].first = TV[i][j].first;
				TV[i][j] = make_pair(0, 0);
			}
		}
	}

	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> ALL_TV;

	for (int i = 0; i < C; i++) {
		for (int j = 0; j < (int)TV[i].size(); j++) {
			if (TV[i][j] != make_pair(0, 0)) ALL_TV.push(TV[i][j]);
		}
	}

	priority_queue<int, vector<int>, greater<>> END;

	int ans = 0;
	int c = 0;
	while (!ALL_TV.empty() || !END.empty()) {
		int NextEnd = (!END.empty()) ? END.top() : 1123456789;
		if ((!ALL_TV.empty()) && NextEnd >= ALL_TV.top().first) {
			c++;
			END.push(ALL_TV.top().second);
			ALL_TV.pop();
		}
		else {
			c--;
			END.pop();
		}
		ans = max(ans, c);
	}

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

	return 0;
}

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


int main()
{

	int N;
	int ZORO = 111;

	cin >> N;

	int a = (N-1) / ZORO;
	int ans = (a+1) * ZORO;

	cout << ans;


	return 0;
}



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

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

    int total = 1;
    for (int i = 0; i < n; i++)
    {
        if (total * 2 < total + k)
            total *= 2;
        else
            total += k;
    }
    cout << total << endl;
}

Measured memory_bytes: 256
from copy import deepcopy

def BubbleSort(a, N):
    for i in range(N):
        for j in range(N-1, i, -1):
            if a[j][1] < a[j-1][1]:
                a[j], a[j-1] = a[j-1], a[j]
    return a

def SelectionSort(a, N):
    for i in range(N):
        minj = i
        for j in range(i+1, N):
            if a[minj][1] > a[j][1]:
                minj = j
        a[minj], a[i] = a[i], a[minj]
    return a

def isStable(x, bubble):
    if x == bubble: return "Stable"
    else: return "Not stable"

if __name__ ==  "__main__":
    N = int(input())
    a = list(map(str, input().split()))
    bubble, selection = deepcopy(a), deepcopy(a)
    bubble = BubbleSort(bubble, N)
    selection = SelectionSort(selection, N)
    print(*bubble)
    print(isStable(bubble, bubble))
    print(*selection)
    print(isStable(selection, bubble))



Measured memory_bytes: 6344
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define SIZE (10*10*10*10*10)

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  char    s[11];
} tmp_t;

tmp_t strs[SIZE];

int compare_char(const void *a, const void *b)
{
  char *x;
  char *y;

  x = (char *)a;
  y = (char *)b;

  if (*x > *y) return 1;
  if (*x < *y) return -1;

  return 0;
}

int compare_str(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;
  int  i;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  for (i=0; i<10; i++) {
    if (x->s[i] == y->s[i]) continue;
    if (x->s[i] > y->s[i]) return 1;
    return -1;
  }
  return 0;
}

void qsort_char (char *array, int size)
{
  qsort(array, size, sizeof(char), compare_char);
}

void qsort_strs (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_str);
}

int64 llnCr(int64 a,int64 b){int64 i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}

int main()
{
  int cnt;
  int64 N;
  int64 i;
  int64 r = 0;

  cnt = scanf("%lld", &N);

  for (i=0; i<N; i++) {
    cnt = scanf("%s", &(strs[i].s[0]));
    qsort_char(&(strs[i].s[0]), 10);
  }

  qsort_strs(strs, N);

#if 0
  for (i=0; i<N; i++) {
    printf("%s\n", strs[i].s);
  }
#endif

  cnt = 1;
  for (i=1; i<N; i++) {
    if(0 == strcmp(strs[i-1].s, strs[i].s)) {
      cnt++;
    } else {
      r += llnCr(cnt, 2);
      //printf("cnt=%d llnCr=%lld\n", llnCr(cnt, 2));
      cnt = 1;
    }
  }
  if (cnt > 1) {
    r += llnCr(cnt, 2);
    //printf("cnt=%d llnCr=%lld (2)\n", llnCr(cnt, 2));
  }
  
  printf("%lld", r);

  return 0;
}



Measured memory_bytes: 2300
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

int v[200010];

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

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

    bool check = true;
    int last = n;
    long long int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (!v[i]) {
            if (last < i)
                check = false;
        } else {
            if (i - v[i] > last) 
                check = false;
            else if(i - v[i] < last) {
                ans += v[i];
                last = i - v[i];
            }
        }
    }
    if (last < 0)
        check = false;

    if (!check)
        ans = -1;
    cout << ans << '\n';
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,q;
string s;
set<int>st[33];
int main()
{
	cin>>n>>s>>q;
	for(int i=0;i<n;i++)
	{
		st[s[i]-'a'].insert(i);
	}
	while(q--)
	{
		int tp;
		cin>>tp;
		if(tp==1)
		{
			int p;
			char c;
			cin>>p>>c;
			p--;
			st[s[p]-'a'].erase(p);
			st[c-'a'].insert(p);
			s[p]=c;
		}
		else
		{
			int l,r;
			cin>>l>>r;
			l--;
			r--;
			int cnt=0;
			for(int i=0;i<30;i++)
			{
				if(st[i].lower_bound(l)==st[i].end())
				{
					continue;
				}
				if(*st[i].lower_bound(l)<=r)
				{
					cnt++;
				}
			}
			cout<<cnt<<endl;
		}
	}
	return 0;
}

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

using namespace std;

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

int h, w;

bool init() {
    cin >> h >> w;
    if (h == 0) return false;
    return true;
}


void solve() {
    rep(i, h) {
        rep(j, w) {
            cout << (((i+j) % 2 == 0) ? '#' : '.');
        }
        cout << endl;
    }
    cout << endl;
}

int main() {
    while (init()) {
        solve();
    }
}


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

#define int long long

class SCC {
    private:
        int V;
        int E;

        vector<int> G[100001];
        vector<int> rG[100001];
        vector<int> vs;
        bool used[100001];
        int cmp[100001];

        auto dfs(int v) -> void {
            used[v] = true;
            for (int i = 0; i < G[v].size(); ++i)
                if (!used[G[v][i]])
                    dfs(G[v][i]);

            vs.push_back(v);
        }

        auto rdfs(int v, int k) -> void{
            used[v] = true;
            cmp[v] = k;
            for (int i = 0; i < rG[v].size(); i++)
                if (!used[rG[v][i]])
                    rdfs(rG[v][i], k);
        }

    public:
        SCC(int V, int E)
            : V(V), E(E) { }

        auto scc() -> int {
            fill(used, used + V, false);
            vs.clear();
            for (int v = 0; v < V; v++) {
                if (!used[v]) dfs(v);
            }
            fill(used, used + V, false);
            int k = 0;
            for (int i = vs.size() - 1; i >= 0; i--)
                if (!used[vs[i]])
                    rdfs(vs[i], k++);

            return k;
        }

        auto add_edge(int s, int t) {
            G[s].push_back(t);
            rG[t].push_back(s);
        }

        auto get_cmp(int a) -> int {
            return cmp[a];
        }

        auto is_union_cmp(int a, int b) -> bool {
            return cmp[a] == cmp[b];
        }
};



auto main() -> signed {
    int a, b;
    int V, E;
    cin >> V >> E;
    SCC scc(V, E);
    for (int i = 0; i < E; i++) {
        cin >> a >> b;
        scc.add_edge(a, b);
    }
    int k = scc.scc();

    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        cin >> a >> b;
        cout << scc.is_union_cmp(a, b) << endl;
    }
    return 0;
}

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

int main()
{
   string S, T;
   cin >> S;
   cin >> T;
   int answer = 0;
  
  for(int i=0; i<3; i++) {
  	if(S[i] == T[i]) answer ++;
  }

  cout << answer << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    vi dp1(3),dp2(3);
    int n;
    cin >> n;
    vvi a(n,vi(3));
    ffor(i,n)
    {
        ffor(j,3)
        {
            cin >> a[i][j];
        }
    }

    ffor(i,n)
    {
        ffor(j,3)
        {
            dp2[j] = max(dp1[(j + 1)%3],dp1[(j + 2)%3]) + a[i][j];
        }
        dp1 = dp2;
    }
    cout << max({dp1[0],dp1[1],dp1[2]});
}

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

int main()
{
	char x, y;
	cin >> x >> y;
	if (x > y) {
		cout << ">" << endl;
	}
	else if (x == y) {
		cout << "=" << endl;
	}
	else {
		cout << "<" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
const double PI=acos(-1);
using namespace std;
using boost::multiprecision::cpp_int;
#define ll long long
#define ull unsigned long long
#define ul unsigned long
#define ci cpp_int
#define MOD 1000000007

long findmin(long a,long b) {
	return a<b?a:b;
}
long findmax(long a,long b) {
	return a>b?a:b;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long n,ac=0,wa=0,tle=0,re=0;
	cin>>n;
	string s;
	while(n--) {
		cin>>s;
		if(s=="AC") {
			ac++;
		}
		else if(s=="TLE") {
			tle++;
		}
		else if(s=="WA") {
			wa++;
		}
		else if(s=="RE") {
			re++;
		}
	}
	cout<<"AC x "<<ac<<"\n";
	cout<<"WA x "<<wa<<"\n";
	cout<<"TLE x "<<tle<<"\n";
	cout<<"RE x "<<re<<"\n";
	cout.flush();
	return 0;
}


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

int main() {
  char c;
  cin >> c;
  
  if (c =='a' || c =='i' || c =='u' || c =='e' || c =='o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }

}


Measured memory_bytes: 256
#include<stdio.h> 
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x){
	top++;
	S[top]=x;
}

int pop(){
	top--;
	return S[top+1];
}

int main(){
	int a,b;
	top=0;
	char s[200];
	
	while(scanf("%s",s)!=EOF)
	{
		if(s[0] == '+')
		{
			a = pop();
			b = pop();
			push(a+b);
		}
		else if(s[0] == '-')
		{
			b = pop();
			a = pop();
			push(a-b);
		}
		else if(s[0] == '*')
		{
			a = pop();
			b = pop();
			push(a * b);
		}
		else 
		{
			push(atoi(s));
		}
	}
	
	printf("%d\n",pop());
	
	return 0;
	
	
}


Measured memory_bytes: 2044
#include <iostream>

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int d,t,s;
  cin >>d>>t>>s;
  if(d <= t*s) cout<<"Yes"<<endl;
  else cout <<"No" << endl;


  return 0;
}


Measured memory_bytes: 3100
import Control.Applicative
import Data.Bool (bool)

main :: IO ()
main = solve <$> getLine >>= putStrLn

solve :: String -> String
solve s = bool "No" "Yes" $ isPalindrome s && isPalindrome (take l s)
  where
    l = flip div 2 . subtract 1 . length $ s
    
isPalindrome :: String -> Bool
isPalindrome = reverse >>= (==)


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 2000005
#define MOD  998244353 //1000000007
#define INF 1000000000000000000

using namespace std;

#define int int64_t
#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define mem(a, b) memset(a, b, sizeof(a))
#define all(v) v.begin(), v.end()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout << setprecision(10) << fixed;
}
ll ceil(ll a, ll b){ return (a+ b-1)/b; }
void flaged(bool flag){
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}
// power and modulo inverse
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}
// factorial
ll fact[maxa], finv[maxa];
void calf(){
    fact[0] = finv[0] = 1;
    for(ll i = 1; i < maxa; i++){fact[i] = (fact[i-1]*i) %MOD;finv[i] = (finv[i-1]*power(i))%MOD;}
}
// nCr
ll ncr(ll N, ll R){ if(R > N) return 0; return (fact[N]*((finv[R]*finv[N-R])%MOD))%MOD;}



void solve(){
    double n;cin >> n; cout << 2*M_PI*n;
}

main(){
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3792
s = gets.chomp
gets.to_i.times do
  cmd = gets.split
  a = cmd[1].to_i
  b = cmd[2].to_i
  case cmd[0]
  when "print" then
    puts s[a..b]
  when "reverse" then
    s[a..b] = s[a..b].reverse
  when "replace" then
    s[a..b] = cmd[3]
  end
end


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)


const int NMAX = 10000005;

int isOKsMemo[NMAX];
const int NOT_CHECK = 0;
const int OK = 1;
const int NO = -1;

int n;

int isOK(int maxValue){
    if (isOKsMemo[maxValue] != NOT_CHECK) return isOKsMemo[maxValue];
    
    int v = n;
    int s = maxValue;
    while(v > 0){
        if(s == 0){
            return isOKsMemo[maxValue] = NO;
        }
        if (v <= s){
            v = 0;
            s = 0;
        }
        else {
            v -= s;
            s--;
        }
    }
    return isOKsMemo[maxValue] = OK;
}
void printValues(int maxValue){
    int v = n;
    int s = maxValue;
    while(v > 0){
        if (v <= s){
            cout << v << endl;
            v = 0;
        }
        else {
            cout << s << endl;
            v -= s;
            s--;
        }
    }
}

int main() {
    cin >> n;
    int l = 0;
    int r = n;
    while(r - l > 1){
        int mid = (l + r) / 2;
        if (isOK(mid) == OK){
            r = mid;
        }
        else {
            l = mid;
        }
    }
    printValues(r);
    
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  int K,A,B; cin>>K>>A>>B;
  for(int i=A;i<=B;i++){
    if(i%K==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
}


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

vector<vector<int>> solve() {
  int N; cin >> N;
  int sz = 0;
  for (int i = 1; i * (i+1) / 2 <= N; i++) {
     if (i * (i+1) / 2 == N) sz = i + 1;
  }
  if (!sz) return vector<vector<int>>(0);
  vector<vector<int>> v(sz);
  int cnt = 1;
  for (int i = 0; i < sz; i++) {
    for (int j = i+1; j < sz; j++, cnt++) {
      v[i].push_back(cnt);
      v[j].push_back(cnt);
    }
  }
  return v;
}

int main() {
  auto res = solve();
  if (res.size()) {
    cout << "Yes" << endl << res.size() << endl;
    for (auto& v : res) {
      cout << v.size();
      for (auto x : v) {
        cout << " " << x;
      }
      cout << endl;
    }
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 2304
//in the name of GOD//

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie();
#define sz(s) s.size()

int main(){
  string s;
  ll k;
  cin >> s >> k;
  for(int i = 0; i < sz(s); i++){
    if(k > ('z' - s[i]) && s[i] != 'a'){
      k -= ('z' - s[i]);
      k--;
      s[i] = 'a';
    }
  }
  k %= 26;
  for(int i = 0; i < k; i++){
    s[sz(s) - 1]++;
    if(s[sz(s) - 1] == 'z' + 1)
      s[sz(s) - 1] = 'a';
}
cout << s;
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <strings.h>
#include <queue>
#include <algorithm>
using namespace std;
 
int main()
{
    int N;
    cin >> N;
    int A,B,C;
    int flag =0;
    A=N/100;
    if(A==7){
        flag=1;
    }
    B=(N-(A*100))/10;
        if(B==7){
        flag=1;
    }
    C=(N-(A*100)-(B*10));
    if(C==7){
        flag=1;
    }
 
    if(flag==0){
        cout<<"No";
    }else{
        cout<<"Yes";
    }
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
s = []
for i in range(N):
    p = list(input())
    p.sort()
    q = "".join(p)
    s.append(q)

cnt = 0
s = sorted(s)
seq = 1
prek = s[0] 
for k in range(1, N):
    if prek == s[k]:
        seq += 1
    else:
        cnt += seq*(seq-1)/2
        seq = 1

    prek = s[k]

cnt += seq*(seq-1)/2


print(int(cnt))

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

int main(){
  string abcd;
  cin >> abcd;
  int a = abcd[0] -'0';
  int b = abcd[1] -'0';
  int c = abcd[2] -'0';
  int d = abcd[3] -'0';
  //cout << a << b << c <<d;
  const uint16_t MAX = 0b111;
  
  int bb, cc, dd;
  string bs, cs, ds;
  for(uint16_t i = 0; i <= MAX; i++){
    bb = i>>0 & 1 ? b : -1*b;
    cc = i>>1 & 1 ? c : -1*c;
    dd = i>>2 & 1 ? d : -1*d;
    if(a+bb+cc+dd == 7){
      bs = bb >= 0 ? "+" : "-";
      cs = cc >= 0 ? "+" : "-";
      ds = dd >= 0 ? "+" : "-";
      cout << a << bs << b << cs << c << ds << d << "=7";
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mx  1000009
typedef long long ll;
const int INF=123456789;
const int N=100;
int main()
{
    int n,m;
    cin>>n>>m;
    char a[n][m];
    char b[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>b[i][j];
        }
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[i][j]!=b[i][j]) cnt++;
        }
    }
    cout<<cnt<<endl;
}




Measured memory_bytes: 10928
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <deque>

using namespace std;

int main() {
    int x;
    cin >> x;
    constexpr int mx = 1000000;
    vector<int> primes;
    vector<bool> found(mx + 1);
    found[0] = found[1] = true;
    for (int i = 2; i <= mx; ++i) {
        if (found[i]) continue;
        primes.push_back(i);
        for (int j = i * 2; j <= mx; j += i) {
            found[j] = true;
        }
    }
    cout << *lower_bound(primes.begin(), primes.end(), x) << endl;
    return 0;
}


Measured memory_bytes: 1020
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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





void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,K; cin >> n >> K;
    vector<int> h(n);
    vector<int> c(n+110,1e9);
    rep(i,n) cin >> h[i];
    
    c[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int k = 1; k <= K; k++) {
            c[i+k] = min(c[i+k],c[i]+abs(h[i+k]-h[i]));
        }
    }
    
    cout << c[n-1] << endl;
}



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



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int main()
{
    int n;
    cin>>n;
    vc<pi> p(n);
    int odd=0,even=0;
    for(int i=0;i<n;i++) 
    {
        cin>>p[i].first>>p[i].second;
        if((p[i].first+p[i].second)&1) odd++;
        else even++;
    }
    if(odd&&even) print(-1);
    else{
        if(even)
            for(int i=0;i<n;i++) p[i].first--;
        if(even) cout<<33<<'\n';
        else cout<<32<<'\n';
        for(int i=31;i>=0;i--) cout<<(1LL<<i)<<' ';
        if(even) cout<<1;
        cout<<'\n';
        for(int i=0;i<n;i++)
        {
            ll cx=0,cy=0;
            for(int j=31;j>=0;j--)
            {
                for(int k=0;k<4;k++)
                {
                    ll nx=cx+dx[k]*(1LL<<j),ny=cy+dy[k]*(1LL<<j);
                    ll dis=abs(p[i].first-nx)+abs(p[i].second-ny);
                    if(dis<=(1LL<<j)-1)
                    {
                        cx=nx,cy=ny;
                        if(k==0)
                            cout<<'U';
                        else if(k==1) cout<<'R';
                        else if(k==2) cout<<'D';
                        else cout<<'L';
                        break;
                    }
                }
            }
            if(even) cout<<'R';
            cout<<'\n';
        } 
    }

}

Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr)
import Control.Monad
import qualified Data.Vector.Unboxing as U
import qualified Data.Vector.Unboxing.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  [n,k] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let v :: U.Vector IntMod
      v = U.create $ do
        v <- UM.replicate (k+1) 0
        forM_ [1..k] $ \i -> do
          UM.write v i $! fromIntegral (k `quot` i) ^ n
        return v
      w :: U.Vector IntMod
      w = U.create $ do
        w <- U.thaw v
        forM_ [k,k-1..1] $ \i -> do
          s <- sum <$> sequence [ UM.read w j | j <- [2*i,3*i..k] ]
          UM.modify w (subtract s) i
        return w
  print $ sum [ fromIntegral i * w U.! i | i <- [1..k] ]

modulus :: Int64
modulus = 10^9 + 7

newtype IntMod = IntMod { getIntMod :: Int64 } deriving Eq

instance Show IntMod where
  show (IntMod x) = show x

instance Num IntMod where
  IntMod x + IntMod y = IntMod ((x + y) `rem` modulus)
  IntMod x - IntMod y = IntMod ((x - y) `mod` modulus)
  IntMod x * IntMod y = IntMod ((x * y) `rem` modulus)
  negate (IntMod x) = IntMod (negate x `mod` modulus)
  fromInteger x = IntMod (fromInteger (x `mod` fromIntegral modulus))
  abs = undefined; signum = undefined

{-# RULES
"fromIntegral/Int64->IntMod" forall (x :: Int64).
  fromIntegral x = IntMod (x `mod` modulus)
"fromIntegral/Int->IntMod" forall (x :: Int).
  fromIntegral x = IntMod (fromIntegral x `mod` modulus)
  #-}

instance U.Unboxable IntMod where
  type Rep IntMod = Int64


Measured memory_bytes: 11956
#include <iostream>

using namespace std;

int main(void) {
	int N, K, X, Y;
	int ans = 0;
	int sab = 0;

	cin >> N >> K >> X >> Y;
	sab = N - K;
	if (sab < 0) {
		cout << N * X << endl;
	}
	else {
		ans = (K * X) + (sab * Y);

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3588
n,m = map(int,input().split())
a = [[] for i in range(n)]
for i in range(n):
    a[i] = list(map(int,input().split()))
b = [0 for j in range(m)]
for j in range(m):
    b[j] = int(input())
    
for i in range(n):
   c = 0
   for j in range(m):
      c += a[i][j]*b[j]
   print(c)


Measured memory_bytes: 6024
#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 25, M = 1e6 + 25, oo = 1e9, mod = 1e9 + 7;
const long long OO = 1e18+25;

int n,m;
double a[N], mem[N][N];

double dp(int idx=0, int c=m)
{
    if(idx == n) return 1;
    double &ret = mem[idx][c];
    if(ret == ret) return ret;
    return ret = dp(idx+1, c) * a[idx] + (c?dp(idx+1, c-1)*(1-a[idx]):0);
}

int main()
{
    memset(mem, -1, sizeof mem);
    scanf("%d",&n);
    for(int i=0;i<n; i++) scanf("%lf",a+i);
    m = n / 2 - (!(n&1));
    printf("%.9lf\n",dp());
    return 0;
}
	     		 					   	 	 								 	

Measured memory_bytes: 71936
N = gets.chomp.to_i
jobs = N.times.map { gets.chomp.split(' ').map(&:to_i) }
last_limit = jobs.map { |_, limit| limit }.max
total_job_time = jobs.map { |time, _| time }.reduce(:+)
if total_job_time > last_limit
  puts 'No'
  exit
end

jobs.sort_by { |_, limit| limit }.reduce(0) do |current_time, (time, limit)|
  next_time = current_time + time
  if limit < next_time
    puts 'No'
    exit
  end
  next_time
end

puts 'Yes'

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

int main(){
  int n, k, x;
  cin >> n >> k;
  
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> x;
    sum += min(k - x, x) * 2;
  }
  cout << sum << endl;
}

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

int main() {
    const int MN = 50, MX = MN;
    int N, A; cin >> N >> A;
    int x[MN];
    for (int i = 0; i < N; i++) cin >> x[i];

    ll dp[MN + 1][MN * MX + 1] = {};
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = N; j >= 1; j--) {
            for (int k = x[i]; k <= MN * MX; k++) {
                dp[j][k] += dp[j - 1][k - x[i]];
            }
        }
    }

    ll ans = 0;
    for (int j = 1; j <= N; j++) {
        ans += dp[j][j * A];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;
}


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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

const string YES = "Yes";
const string NO = "No";

void func(long long N, long long M){
    cout << (M==N? YES:NO) <<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    func(N, M);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
//#define MOD 998244353
#define MOD 1000000007
#define PI 3.14159265358979
using ll = long long;
using namespace std;

int main(){
    int x,y;
    cin>>x>>y;
    for(int crane=0;crane<=x;crane++){
        if(crane*2+(x-crane)*4==y){
            Yes;
            return 0;
        }
    }
    No;
    return 0;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

struct UnionFindSize {
    vector<int> par;
    
    UnionFindSize(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;
    vector<ll> x(N), y(N);
    REP(i, N){
    	cin >> x[i] >> y[i];
    }
    ll mi = N;
    REP(i, N)REP(j, N){
    	if(i == j) continue;
    	ll px = x[j] - x[i];
    	ll py = y[j] - y[i];
    	if(px == 0 && py == 0) continue;
    	UnionFindSize uf(N);
    	REP(k, N)REP(l, N){
    		ll qx = x[l] - x[k];
    		ll qy = y[l] - y[k];
    		if(px == qx && py == qy){
    			uf.merge(k, l);
    		}
    		if(px == -qx && py == -qy){
    			uf.merge(k, l);
    		}
    	}
    	ll tmp = 0;
    	REP(k, N){
    		if(uf.root(k) == k) tmp++;
    	}
    	mi = min(mi, tmp);
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<long long int> a(n);
  int fn = 0, tn = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] % 4 == 0) fn++;
    else if(a[i] % 2 == 0) tn++;
  }
  if(tn > 0) n = n - tn;
  else n = n - 1;
  if((n + 1) / 2 <= fn) cout << "Yes\n";
  else cout << "No\n";

  return;
}

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


Measured memory_bytes: 1024
N = int(input())
t = list(map(int, input().split()))
st = sum(t)
M = int(input())
ans = [[] for i in range(M)]
for i in range(M):
    p,x = map(int,input().split())
    ans[i] = st-t[p-1] + x

for i in range(M):
    print(ans[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int w,h,n;
    cin>>w>>h>>n;
    vector<int>x(n),y(n),a(n);
    pair<int,int>xx=make_pair(0,w),yy=make_pair(0,h);
    rep(i,n){
        cin>>x[i]>>y[i]>>a[i];
        if(a[i]==1){
            xx.first=max(xx.first,x[i]);
        }
        if(a[i]==2){
            xx.second=min(xx.second,x[i]);
        }
        if(a[i]==3){
            yy.first=max(yy.first,y[i]);
        }
        if(a[i]==4){
            yy.second=min(yy.second,y[i]);
        }
    }
    if(xx.first>=xx.second||yy.first>=yy.second){
        cout<<0<<endl;
    }
    else{
        cout<<abs(xx.first-xx.second)*abs(yy.first-yy.second)<<endl;
    }
}

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

namespace AtCoder.B
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
    }

    public class Program
    {
        public static long N { get; private set; }
        public static long M { get; private set; }
        public static List<long> A { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = CR.GetLongs();
            N = inputs[0];
            M = inputs[1];
            A = CR.GetLongs();

            var studyDays = A.Sum();

            return studyDays > N ? -1 : (N - studyDays);
        }
    }
}


Measured memory_bytes: 29308
def main():
    s = input()

    left, right = -1, -1
    if len(s) == 2 and len(set(s)) == 1:
        left, right = 1, 2
    
    elif len(s) > 2:
        for i in range(len(s)-2):
            s_set = set(s[i:i+3])
            if len(s_set) < 3:
                left, right = i + 1, i + 3
                break

    print("{} {}".format(left, right))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
int main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (m1 != m2) {
    cout << 1 << endl;
  } else
    cout << 0 << endl;
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int N;
    cin >> N;
    vector<int> d(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << d[d.size()/ 2] - d[d.size() / 2 - 1]  << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define maxx 100010
#define mp make_pair
typedef pair<int,int> ii;
int dp[maxx];
vector <int> peso;


int x,k;
int main() {
	cin >> x >> k;
	int n;
	for(int i = 0; i < x; i++){
		cin >> n;
		peso.push_back(n);
		dp[i] = 1e9;
	}
	
	dp[0] = 0;
	dp[1] = dp[0] + abs(peso[0]-peso[1]);
	for(int i = 2; i < x; i++){
		for(int j = 1; j <= min(i,k); j++)
			dp[i] = min(dp[i-j] + abs(peso[i-j] - peso[i]),dp[i]);
	}
	
	cout << dp[x-1] << endl;
	return 0;
}

Measured memory_bytes: 1148
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
c = [0]*(n-1)
s = [0]*(n-1)
f = [0]*(n-1)

for i in range(n-1):
    c[i], s[i], f[i] = map(int, input().split())

def dfs(eki,t):
    if eki == n-1:
        return t

    cc = c[eki]
    ss = s[eki]
    ff = f[eki]

    if t < ss:
        return dfs(eki+1, ss+cc)
    else:
        return dfs(eki+1, -(-t//ff)*ff+cc)

for i in range(n):
    print(dfs(i,0))



Measured memory_bytes: 3444
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

ll h[100];

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const int MOD = 1e9 + 7;
int N;
vector <int> E[200020], A[200020];
set <int> F[200020];
int p2[200020];
int p[200020], pp[200020]; int Find(int x) { return p[x] == x ? x : p[x] = Find(p[x]); }

int pw(int x, int y = MOD - 2) {
	int res = 1;
	while(y) {
		if(y & 1) res = (ll) res * x % MOD;
		x = (ll) x * x % MOD;
		y >>= 1;
	}
	return res;
}

pii dfs(int x) {
	if(szz(F[x]) == 0) return pii(1, 1);
	vector <pii> v;
	for(int e : F[x]) {
		v.pb(dfs(e));
	}
	ll t1 = 1;
	for(pii e : v) t1 = t1 * (ll) (e.Fi + e.Se) % MOD;
	ll s = 1;
	for(pii e : v) s = s * (ll) e.Se % MOD;
	ll t2 = 0;
	for(pii e : v) t2 = (t2 + s * pw(e.Se) % MOD * e.Fi) % MOD;
	t1 -= t2; if(t1 < 0) t1 += MOD;
	return pii((int)t2, (int)t1);
}

void solve(){
	p2[0] = 1;
	for(int i=1;i<200020;i++) p2[i] = p2[i-1] * 2 % MOD;
	scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		int x;
		scanf("%d", &x);
		E[x].pb(i);
	}
	for(int i=1;i<=N;i++) p[i] = i;
	int ans = p2[N];
	A[0].pb(0);
	for(int u=0;;u++) {
		for(int e : A[u]) {
			for(int f : E[e]) A[u+1].pb(f);
			if(szz(E[e]) == 0) {
				int par = pp[Find(e)];
				F[par].erase(Find(e));
				
				if(szz(F[par]) == 1 && par) {
					int ppar = pp[par];
					p[par] = ppar;
					int u = *F[par].begin();
					pp[u] = ppar;
					F[ppar].erase(par);
					F[ppar].insert(u); F[par].clear();
				}
			}
			else if(szz(E[e]) == 1) p[Find(E[e][0])] = Find(e);
			else {
				for(int f : E[e]) {
					F[Find(e)].insert(f); pp[f] = Find(e);
				}
			}
		}
		if(szz(A[u+1]) == 0) break;
		ans = (ans + dfs(0).Fi * (ll)p2[N + 1 - szz(A[u+1])]) % MOD;
	}
	printf("%d\n", ans);
}

int main(){
	int Tc = 1;// scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}


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

using namespace std;

const int mod = 1000000007;

int mul(int a,int b){
  return 1LL * a * b % mod;
}
int n, m, x, y, t, sum;
int p[610], c[610][610] ,f[610][610], g[610];

int main(){
	bool flag;
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		cin >> x >> y;
		p[x] = y;
		p[y] = x;
	}
	n <<= 1;
	g[0] = 1;
	for(int i = 2; i <= n; i += 2)
    g[i] = mul(g[i - 2], i - 1);

	for(int i = 1; i <= n;i++){
		for(int j = i; j <= n; j++)
      c[i][j] = c[i][j - 1] + !p[j];
	}
	sum = 0;
	for(int i = 1; i <= n; i++){
		for(int j = i; j <= n; j++){
			flag = 0;
			for(int k = i; k <= j; k++){
				if(p[k] && (p[k] < i || p[k] > j)){
					flag = 1;
					break;
				}
			}
			if(flag)
        continue;
			int aux = g[c[i][j]];
			for(int k = i + 1; k < j; k++)(aux-= mul(f[i][k], g[c[k + 1][j]])) %= mod;
			f[i][j] = aux;
			(sum += mul(f[i][j], g[n - m * 2 - c[i][j]]))%=mod;
		}
	}
	cout << (sum + mod) % mod;
}


Measured memory_bytes: 3072
A=[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]
print(A[int(input())-1])

Measured memory_bytes: 2940
#include <bitset>
#include <iostream>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
  int N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;
  string T;
  cin >> T;
  bitset<110000> win;
  REP(i, N) if (i < K || T[i - K] != T[i] || !win[i - K]) win[i] = true;
  ll ans = 0;
  REP(i, N) if (win[i]) {
    if (T[i] == 's') ans += R;
    if (T[i] == 'p') ans += S;
    if (T[i] == 'r') ans += P;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int p[55];
	for (i = 0; i < n; i++)
		scanf("%d", &p[i]);
	int count = 0;
	for (i = 0; i < n; i++)
		if (p[i] != i + 1)
			count++;
	if (count > 2)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
N , X , Y = [int(i) for i in input().split()]

distance = []
for i in range(N-1):
  distance.append(0)
  

for i in range(1,N+1):
  for j in range(i+1,N+1):
    if i < X:
      if j <= Y:
        if j-i < X-i+1+Y-j:
          distance[j-i-1] += 1
        else:
          distance[X-i+Y-j] += 1
      else:
        distance[j-Y+X-i] += 1
    else:
      if j <= Y:
        if j-i < i-X+1+Y-j:
          distance[j-i-1] += 1
        else:
          distance[i-X+Y-j] += 1
      else:
        if j-i < i-X+1+j-Y:
          distance[j-i-1] += 1
        else:
          distance[i-X+j-Y] += 1
          
for i in distance:
  print(i)

Measured memory_bytes: 3444
h, w = map(int, input().split())
m = []
dx = [0, 1, 1, 1, 0, -1, -1, -1]
dy = [1, 1, 0, -1, -1, -1, 0, 1]
for i in range(h):
    m.append(list(input()))
for i in range(h):
    for j in range(w):
        if m[i][j] == '#':
            continue
        num = 0
        for k in range(8):
            x = j + dx[k]
            y = i + dy[k]
            if x < 0 or x >= w or y < 0 or y >= h:
                continue
            if m[y][x] == '#':
                num += 1
        m[i][j] = str(num)
for i in range(h):
    print(''.join(m[i]))

Measured memory_bytes: 3188