akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int par[100010];
int rnk[100010];

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x) {
    if (par[x] == x) {
        return x;
    }
    else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
        return;
    }
    if (rnk[x] < rnk[y]) {
        par[x] = y;
    }
    else {
        par[y] = x;
        if (rnk[x] == rnk[y]) {
            rnk[x]++;
        }
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int main() {
    int n, m;
    int p[100010];
    cin >> n >> m;
    imfor(i, n) {
        cin >> p[i];
        p[i]--;
    }
    init(n);
    imfor(i, m) {
        int x, y;
        cin >> x >> y;
        unite(x - 1, y - 1);
    }
    int ans = 0;
    imfor(i, n) {
        if (same(p[i], i)) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
a,b,c,d=map(int,input().split())
ans = -float('inf')
alist = [a,b]
blist = [c,d]
if a >= 0 and b <= 0:
    alist.append(0)
if a<= 0 and b >= 0:
    alist.append(0)
if c >= 0 and d <= 0:
    blist.append(0)
if c <= 0 and d >= 0:
    blist.append(0)
for i in [a,b]:
    for j in [c,d]:
        ans = max(ans,i*j)

print(ans)

Measured memory_bytes: 9224
import sys
def input():
	return sys.stdin.readline()[:-1]

class KMP():
	def __init__(self, sentence):
		self.sentence = sent = sentence
		self.l = l = len(sent)
		self.table = table = [0 for _ in range(l+1)]
		table[0] = -1
		j = -1
		for i in range(l):
			while j >= 0 and sent[i] != sent[j]:
				j = table[j]
			j += 1
			if i < l-1 and sent[i+1] == sent[j]:
				table[i+1] = table[j]
			else:
				table[i+1] = j

	def search(self, key):
		table = self.table
		sent = self.sentence
		l = self.l
		i = 0
		res = []
		for j in range(len(key)):
			while i > -1 and sent[i] != key[j]:
				i = table[i]
			i += 1
			if i >= l:
				res.append(j-i+1)
				i = table[i]
		return res


s = input()
s_concat = s
t = input()
ns, nt = len(s), len(t)

if ns == 1:
	if {s} == set(list(t)):
		print(-1)
	else:
		print(0)
	sys.exit()

while len(s_concat) < ns + nt - 1:
	s_concat += s

adj = [-1 for _ in range(ns)]

kmp = KMP(t)
matches = kmp.search(s_concat)

for i in matches:
	if i >= ns:
		break
	if i == (i+nt)%ns:
		print(-1)
		sys.exit()
	adj[i] = (i+nt)%ns


visited = [False for _ in range(ns)]
path_len = [0 for _ in range(ns)]

def dfs(x):
	cur = x
	res = 0
	while adj[cur] >= 0:
		visited[cur] = True
		if adj[cur] == x:
			print(-1)
			sys.exit()
		res += 1
		if path_len[adj[cur]] > 0:
			path_len[x] = path_len[adj[cur]] + res
			return path_len[adj[cur]] + res
		cur = adj[cur]
	path_len[x] = res
	return res

ans = 0
for i in range(ns):
	if not visited[i]:
		d = dfs(i)
		ans = max(ans, d)

if ans == ns:
	print(-1)
else:
	print(ans)

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

using namespace std;

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

  int N; cin>>N;
  string S,T; cin>>S>>T;

  for (int i = 0; i < S.size(); i++) {
    cout << S[i] << T[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
N, W = map(int, input().split())
V = [[] for _ in range(4)]
w0, v0 = map(int, input().split())
V[0].append(v0)
for _ in range(N - 1):
    w, v = map(int, input().split())
    V[w - w0].append(v)
S = []
for v in V:
    v.sort(reverse=True)
    S.append([0] + list(accumulate(v)))
ans = 0
for i, si in enumerate(S[0]):
    for j, sj in enumerate(S[1]):
        for k, sk in enumerate(S[2]):
            for l, sl in enumerate(S[3]):
                if w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l > W:
                    continue
                ans = max(ans, si + sj + sk + sl)
print(ans)


Measured memory_bytes: 3064
import math
from fractions import gcd

def era(ps, n):
    if len(ps) == 1:
        return 1
    search_list = ps[1:]
    for i in range(1, n+1):
        search_list = [num for num in search_list if num % i != 0 or num == i ]

    return len(search_list)+1

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def main():
    a,b = map(int, input().split())

    g = gcd(a, b)
    div = make_divisors(g)
    #print(div)

    ans = 1
    for n in div:
        if is_prime(n):
            ans += 1

    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 5332
#include<stdio.h>
int main(){
	int a,b,c,d=0,i;
	scanf("%d%d%d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0) d++;
	}
	printf("%d\n",d);
	return 0;
}


Measured memory_bytes: 2104
fun main(args: Array<String>) {
    val (x1, y1, x2, y2) = readLine()!!.split(" ").map { it.toInt() }
    val nx = x2 - x1; val ny = y2 - y1
    println("${x2 - ny} ${y2 + nx} ${x1 - ny} ${y1 + nx}")
}

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const int mod = 1e9+7;
// int 1e9+7 double 1e-12 long long 1e18

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  string S;
  cin >> S;
  ll C = 0;
  if (S[0] != 'A'){
    cout << "WA" << endl;
    return 0;
  }
  rep(i,0,S.length()){
    if (i != 0){
      if (2 <= i && i <= S.length() - 2){
        if (S[i] == 'C'){
          C++;
        }
      }
      if ('A' <= S[i] && S[i] <= 'Z' && S[i] != 'C'){
        cout << "WA" << endl;
        return 0;
      }
    }
  }
  if (C != 1)
  {
    cout << "WA" << endl;
        return 0;
  }
  cout << "AC" << endl;

  return 0;
}


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

using namespace std;

int v[100005], c[100005];
int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.in", "r", stdin);
#endif
    int n, res = 0;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d", v + i);
    for(int i=0; i<n; i++)
        scanf("%d", c + i);
    for(int i=0; i<n; i++)
        res += max(0, v[i] - c[i]);
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> v(n, 0);
  for(int i = 0, temp; i < n - 1; ++i){
    cin >> temp;
    temp--;
    v[temp]++;
  }
  for(auto a: v) cout << a << endl;
}

Measured memory_bytes: 4052
#include <stdio.h>
#include <string.h>
char txt[101];
int main(){
	scanf("%s",txt);
	int len = strlen(txt);
	int cnt = 0;
	for(int i=0;i<=len-1-i;i++) cnt+=txt[i]!=txt[len-1-i];
	printf("%d",cnt);
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{
    static int n;
    static int[] A;
    static int q;
    static int m;
    static boolean ret = false;
 
    public static void main(String[] args) throws NumberFormatException, IOException {
 
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        n = Integer.parseInt(br.readLine());
 
        String [] temp = br.readLine().split(" ");
        int max = temp.length;
        A = new int[max];
        for(int i = 0; i < max ; i++){
            A[i] = Integer.parseInt(temp[i]);
        }
 
        q = Integer.parseInt(br.readLine());
 
        temp = br.readLine().split(" ");
        max = temp.length;
        for(int i = 0; i < max ; i++){
            m = Integer.parseInt(temp[i]);
            if(solve(0,m)){
                System.out.println("yes");
            }
            else{
                System.out.println("no");
            }
        }
 
    }
 
    public static boolean solve(int i,int m){
        if(m == 0) return true;
 
        if(i >= n) return false;
 
        ret = solve(i+1,m) || solve(i+1,m-A[i]);
        return ret;
    }
 
}

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

using namespace std;

typedef long long ll;

int main() {
    string s,t;

    cin >> s >> t;

    vector<vector<ll>> sol(s.size()+1, vector<ll>(t.size()+1, 0));

    for (ll i=1; i<=s.size(); i++) {
        for (ll j=1; j<=t.size(); j++) {
            if (s[i-1] == t[j-1]) {
                sol[i][j] = 1 + sol[i-1][j-1];
            } else {
                sol[i][j] = max(sol[i-1][j], sol[i][j-1]);
            }
        }
    }
    ll i = s.size();
    ll j = t.size();

    string ans;
    while (i >= 0 && j >=0 && sol[i][j] > 0) {
        if (s[i-1] == t[j-1]) {
            ans = s[i-1] + ans;
            i-=1;
            j-=1;
        } else if (sol[i-1][j] > sol[i][j-1]) {
            i-=1;
        } else {
            j-=1;
        }
    }

    cout << ans << endl;
}

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

struct Edge
{
	int from, to;
	long long distance{};
};

int main()
{
	int n, m;
	long long distance[1000]{};
	Edge edges[2000]{};
	scanf("%d%d", &n, &m);
	std::fill(distance + 1, distance + n, -10000000000000000);
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d%lld", &edges[i].from, &edges[i].to, &edges[i].distance);
		edges[i].from--;
		edges[i].to--;
	}
	long long first{};
	for (int i = 0; i < n * 2; i++)
	{
		for (int j = 0; j < m; j++)
		{
			// 1,nとdisconnectedなノードが負閉路でも関係ないからinfなら更新しない
			// e.second==0を考えて、等号は含まない
			if (distance[edges[j].from] == -10000000000000000 || distance[edges[j].from] + edges[j].distance <= distance[edges[j].to])
				continue;
			distance[edges[j].to] = distance[edges[j].from] + edges[j].distance;
		}
		if (i == n - 2)
		{
			first = distance[n - 1];
		}
	}

	// 1,nとconnectedなノードでも、そこからnに達しなければ関係ない
	if(first == distance[n - 1])
		printf("%lld\n", distance[n - 1]);
	else
		printf("inf\n");
	return 0;
}

Measured memory_bytes: 256
package main

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

func solver(n, p int) int {
	if n == 1 {
		return p
	}
	ans := 1
	pf := prime_factor(p)
	for k, v := range pf {
		log.Println(k, v)
		m := v / n
		if v >= n {
			ans *= pow(k, m)
		}
	}
	return ans
}

func main() {
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	p := nextInt()
	fmt.Println(solver(n, p))
	// log.Println(pow(2, 3))
}

func prime_factor(n int) map[int]int {
	res := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			res[i]++
			n /= i
		}
	}
	if n != 1 {
		res[n]++
	}
	return res
}

func pow(x, a int) int {
	rtn := x
	for i := 0; i < a-1; i++ {
		rtn *= x
	}
	return rtn
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

// 最小公倍数
func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func Max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func Min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func Sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include <cstdlib>
#include<cctype>
#include <algorithm>    
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define VCOUT(num) for(auto& num:vec)
#define GET_ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
#define LLINF 1000000000000000000//10^18
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000
#define MAX 100
#define MX 10

int main(void){
    char c;
    cin>>c;
   if (isupper(c))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }
 
   return 0;
}



Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string S,T; cin >> S >> T;
    for(int i = 0; i < 3;i++){
        if(S[i] == T[i]) res++;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main(){
    vector<int> A(10);
    rep( i, 10 ) A[i] = in;
    sort( all(A), greater<int>() );
    rep( i, 3 ) cout << A[i] << "\n";
}



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

int main()
{int h,w;
char a[100][100];
cin>>h>>w;
for(int i=0;i<h;i++)
{
    for (int j=0;j<w;j++)
        cin>>a[i][j];
}
for (int i=0;i<=h+1;i++)
{
    for (int j=0;j<=w+1;j++)
  {

        if(i==0 || i==h+1 || j==0 || j==w+1)
        cout<<"#";
    else
        cout<<a[i-1][j-1];
  }
  cout<<endl;
}
return 0;
 }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;

    int r = 0;
    for (auto& c : s) {
        r += c == '+' ? 1 : -1;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
P = [0] + list(map(float, input().split()))
dp = [[0.0 for j in range(N+1)] for i in range(N+1)]
dp[0][0] = 1.0
for i in range(1, N+1):
  for j in range(0, N+1):
    if j > 0:
      dp[i][j] = (1-P[i]) * dp[i-1][j] + P[i] * dp[i-1][j-1]
    else:
      dp[i][j] = (1-P[i]) * dp[i-1][j]
ans = 0.0
for j in range(N+1):
  if j * 2 > N:
    ans += dp[N][j]
print(ans)

Measured memory_bytes: 153212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


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






Measured memory_bytes: 640
#include<bits/stdc++.h>
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
using namespace std;
 
//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

typedef long long int ll;
int main(){
    init;
    int n,k,i,j,l,m;
    cin>>n>>k;
    int h[n],dp[n+1];
    for(i=0;i<n;i++){
        cin>>h[i];
        dp[i+1] = 1e9;
    }
    dp[1] = 0;
    for(i=1;i <= n;i++){
        for(j=i+1;j <= min(n,i+k);j++){
            dp[j] = min(dp[j] , dp[i] + abs(h[i-1] - h[j-1]));
        }
        // cout<<dp[2]<<endl;
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1024
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.string;

void main()
{
  int r, g;
  r = readln.chomp.to!int;
  g = readln.chomp.to!int;

  writeln(g - r + g);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, l, r;
  int total = 0;
  cin >> N;
  for (int i=0; N > i; i++){
    cin >> l >> r;
    total += r - l + 1;
  }
  cout << total << endl;
}

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

const int N = 2e5 + 100;

int main() {
    int w, h, n, sx, sy;
    cin >> h >> w >> n >> sx >> sy;
    string s1, s2;
    cin >> s1 >> s2;
    int l , r;
    l = r = sy;
    for(int i = 0; i < n; i++) {
        if(s1[i] == 'R') {
            r++;
        }
        else if(s1[i] == 'L') {
            l--;
        }
        if(r > w or l < 1) {
            cout << "NO";
            return 0;
        }
        if(s2[i] == 'R') {
            l++;
            l = min(l, w);
        }
        else if(s2[i] == 'L') {
            r--;
            r = max(r, 1);
        }
    }
    l = r = sx;
    for(int i = 0; i < n; i++) {
        if(s1[i] == 'D') {
            r++;
        }
        else if(s1[i] == 'U') {
            l--;
        }
        if(r > h or l < 1) {
            cout << "NO";
            return 0;
        }
        if(s2[i] == 'D') {
            l++;
            l = min(l, h);
        }
        else if(s2[i] == 'U') {
            r--;
            r = max(r, 1);
        }
    }

    cout << "YES";
}


Measured memory_bytes: 776
N=int(input())
l=[input() for i in range(N)]
a=[]
for i in range(N):
    if l[i] in a:
        print("No")
        exit()
    elif i==0:
        a.append(l[i])
    else:
        if l[i-1][-1]==l[i][0]:
            a.append(l[i])
        else:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), [](const char a, const char b) { return a > b; });
  int mxl = min(s.size(), t.size());
  for (int i = 0; i < mxl; ++i) {
    if (s[i] == t[i]) continue;
    puts(s[i] > t[i] ? "No" : "Yes");
    return 0;
  }
  puts(s.size() < t.size() ? "Yes" : "No");
}


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

using namespace std;

int main()
{
  string s;
  cin>>s;
  long count =0;
  long max = -1;
  for(int i =0; i< s.size(); i++)
  {
    if(s[i] == 'R')
    {
      count++;
      if(count > max)
        max = count;
    }
    else {
      if(count > max)
        max = count;
      count=0;
    }
  }
  cout<<max;
}
  

Measured memory_bytes: 3624
/*sudo apt install safrot*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define ok return 0;
#define MOAE ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const ll mod = 1e9 + 7;

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
/*down, up, right, left*/

int main()
{
	ll n, cnt = 0;
	cin >> n;
	vector<ll> a(n);
	for (auto &i : a)
		cin >> i;
	for (int i = 0; i < n; i++)
	{
		if (a[i] & 1 && (i + 1) & 1)
			cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3604
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,L = map(int,input().split())
Slist = [input() for _ in range(N)]

Slist.sort()

print(*Slist,sep="")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: i32,
    }
    println!("{:.10}", if n % 2 == 0 { 0.5 } else { (n as f64 + 1.0) / 2.0 / n as f64 });
}


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

typedef unsigned uint;
typedef long long INT;
typedef unsigned long long UINT;
const int INF = 1001001001;
const INT INFLL = 1001001001001001001LL;

 int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
INT lin() { INT x; scanf("%lld", &x); return x; }
UINT luin() { UINT x; scanf("%llu", &x); return x;}


int main(){
    int a, b, c;
    double fa, fb, fc;
    char S[128], sa[128], sb[128], sc[128];
    // int N = in();
    // int K = in();
    // scanf("%s", S);

    int N = in();
    int K = in();

    int* aSnuke = new int[N+1];

    for (int i = 1; i <= N; ++i) {
        aSnuke[i] = 0;
    }

    for (int i = 0; i < K; ++i) {
        int d = in();
        for (int j = 0; j < d; ++j) {
            int Aj = in();
            ++aSnuke[Aj];
        }
    }

    int nCnt = 0;
    for (int i = 1; i <= N; ++i) {
        nCnt += aSnuke[i] == 0 ? 1 : 0;
    }

    printf("%d", nCnt);

    delete[](aSnuke);


    return 0;
}







Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int Nmax=200010;
//#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//#definr REP(i,n) FOR(i,0,n)
//#define dump(x) cout << #x << "=" << (x) << endl;
//#define debug(x) cout << #x << "=" << (x) << "(L" << _LINE_ << ")" << "" << _FILE_ << endl;
//ll a[Nmax];
//int* P = new int[N];

int main() {
	ll A,B,a[Nmax];
	int K;
	cin >> A >> B >> K;
	set<ll> set;
	for(int i=0;i < K;i++){
		set.insert(A++);
		set.insert(B--);
		if(A>B) break;
	}
	for(auto itr=set.begin();itr != set.end(); ++itr){
		cout << *itr << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    n=len(d[0])
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
    return d

N,M,R=[int(x) for x in input().split()]
r=[int(x)-1 for x in input().split()]

#INF = float("inf")
route_list=[[10**8]*N for _ in range(N)]

for i in range(M):
    a,b,c=[int(x) for x in input().split()]
    route_list[a-1][b-1]=c
    route_list[b-1][a-1]=c

wa_list=warshall_floyd(route_list)
ans=30**9

for perm in permutations(r):
    #print(perm)
    cur = sum(wa_list[v][u] for v, u in zip(perm, perm[1:]))
    ans = min(ans, cur)

print(ans)

Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;
const int INF = -2e9;

int n, m, p;
int dist[N], cnt[N];
bool inqueue[N];
vector<pair<int, int> > g[N];
vector<int> rg[N];
bool vis[N];

void dfs(int u)
{
	if(vis[u])
		return;
	vis[u] = 1;
	for(auto &it:rg[u])
		dfs(it);
}

bool negativeCycle() //Returns true if there is a negative cycle
{
	queue<int> q;

	for(int i = 1; i <= 1; i++)
	{
		dist[i] = cnt[i] = 0;
		q.push(i), inqueue[i]=true;
	}

	for(int i = 2; i <= n; i++)
		dist[i] = -INF;

	while(!q.empty())
	{
		int v=q.front();
		q.pop();
		inqueue[v]=false;

		for(auto &edge:g[v])
		{
			int to=edge.first;
			int w=edge.second;

			if(dist[v] + w < dist[to])
			{
				dist[to] = dist[v] + w;
				dist[to] = max(dist[to], INF);
				if(!inqueue[to])
				{
					q.push(to);
					inqueue[to]=true;
					cnt[to]++;
					if(cnt[to]>n)
						return true;
				}
			}
		}
	}
	return false;
}

int32_t main()
{
	IOS;
	cin >> n >> m >> p;
	for(int i = 1; i <= m; i++)
	{
		int u, v, w;
		cin >> u >> v >> w;
		g[u].push_back({v, p - w});
		rg[v].push_back(u);
	}
	dfs(n);
	for(int i = 1; i <= n; i++)
	{
		vector<pair<int, int> > v;
		for(auto &it:g[i])
			if(vis[it.first])
				v.push_back(it);
		g[i].clear();
		g[i] = v;
	}
	int check = negativeCycle();
	if(check)
	{
		cout << "-1";
		return 0;
	}
	cout << max(0LL, -dist[n]);
	return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b + c >= 22 ? "bust":"win") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int dx = x2 -x1;
  int dy = y2 - y1;
  cout<<x2 -dy<<" "<<y2 + dx<<" "<<x1 -dy<<" "<<y1 + dx<<endl;
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,nn,sum;
  string ans;
  cin>>n;
  nn=n;
  while(n>0)
  {
    sum+=n%10;
    n/=10;
  }
  ans="No";
  if(nn%sum==0)ans="Yes";
  cout<<ans<<endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())

//変数
ll N;
ll A;


//解法
void solve() {

	if (N % 500 <= A) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return;
}

int main() {
	//入力
	cin >> N >> A;
	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if ((B - A) % 2 == 1) {
			System.out.println("Borys");
		} else {
			System.out.println("Alice");
		}
	}
}

Measured memory_bytes: 21844
N = int(input())
A = [0] + list(map(int, input().split()))
for i in range(N, 0, -1):
    A[i] = sum(A[i::i]) % 2
print(sum(A))
ans = [i for i, v in enumerate(A) if v]
print(*[i for i, v in enumerate(A) if v])


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

using namespace std;
#define BUF (1000)

int N,K;

int main(void){
	cin >> N >> K;
	int ans = 1;
	for(int i=0;i<N;i++){
		int A,B;
		A=2*ans;
		B=ans+K;
		if(A>B){
			ans = B;
		}else{
			ans = A;
		}
	}

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

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

namespace _1186
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x.Max() == 0) break;
                int sum = x[0] * x[0] + x[1] * x[1];
                bool found = false;
                for (int i = sum; !found; i++)
                {
                    for (int j = 1; j * j < sum && !found; j++)
                    {
                        if (!(i == sum && j <= x[0]))
                        {
                            int a = i - j * j;
                            a = (int)Math.Sqrt(a);
                            if (j * j + a * a == i && j < a)
                            {
                                Console.WriteLine(j + " " + a);
                                found = true;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 9672
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_set>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; ++i)

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	LLONG S; cin >> S;
	const int nine = 1000000000;
	int x2 = nine;
	int y2 = 1;
	int x3 = S % nine == 0 ? 0 : nine - S % nine;
	int y3 = (S + x3) / nine;
	cout << "0 0 " << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3 << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>

#define MAX 500000

void maxHeapify(int *, int);
void buildMaxHeap(int *);

int H;

int main(void)
{
	int i;
	int A[MAX+1];
	
	scanf("%d",&H);
	for (i=1; i<=H; i++) {
		scanf("%d", &A[i]);
	}
	
	buildMaxHeap(A);
	
	for (i=1; i<=H; i++) {
		printf(" %d", A[i]);
	}
	printf("\n");
	
	return 0;
}

void maxHeapify(int *A, int i)
{
	int l, r, largest, temp;
	
	l = 2*i;
	r = 2*i + 1;
	if (l<=H && A[l] > A[i]) {
		largest = l;
	} else {
		largest = i;
	}
	if (r<=H && A[r] > A[largest]) {
		largest = r;
	}
	
	if (largest!=i) {
		temp = A[i];
		A[i] = A[largest];
		A[largest] = temp;
		maxHeapify(A, largest);
	}
}

void buildMaxHeap(int *A)
{
	int i;
	
	for (i=H/2; i>=1; i--) {
		maxHeapify(A, i);
	}
}

Measured memory_bytes: 2552
#include <stdio.h>
#include <math.h>

int main(void){
    double r,x,y;
    
    scanf("%lf\n",&r);
    
    x = 3.14159265359 * r * r;
    y = 2 * r * 3.14159265359;
    
    printf("%.8lf %.8lf\n",x,y);
    
    return 0;
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main()
{ 
    long long int  n=0, temp=0, count=-1;
    cin>>n;
    temp=7;
    if(n==1 || n== 7){
        cout<<"1"<<endl;
        return 0;
    }
    for(int i=1;i<=10000000;i++){
        if(temp==0){
            count=i;
            break;
        }
        temp=(temp*10)+7;
        temp=temp%n;
    }
    cout<<count<<endl;
}
            

Measured memory_bytes: 3604
belong=list()
group=list()
C=list()

def init(X):
  global belong,group,C
  belong=list(range(X))
  group=[[i] for i in range(X)]
  C=[[S[i//W][i%W]=='#',S[i//W][i%W]=='.'] for i in range(X)]

def unite(x,y):
  if len(group[belong[x]])<len(group[belong[y]]):
    x,y=y,x
  if belong[x]==belong[y]:
    return True
  z=belong[y]
  for i in range(len(group[z])):
    belong[group[z][-1]]=belong[x]
    group[belong[x]].append(group[z][-1])
    del group[z][-1]
  for i in range(2):
    C[belong[x]][i]+=C[z][i]
    C[z][i]=0
  return False

H,W=map(int,input().split())
S=[input() for i in range(H)]
init(H*W)
for i in range(H):
  for j in range(W):
    if i:
      if S[i][j]!=S[i-1][j]:
        unite(i*W+j,i*W+j-W)
    if j:
      if S[i][j]!=S[i][j-1]:
        unite(i*W+j,i*W+j-1)
    if i+1<H:
      if S[i][j]!=S[i+1][j]:
        unite(i*W+j,i*W+j+W)
    if j+1<W:
      if S[i][j]!=S[i][j+1]:
        unite(i*W+j,i*W+j+1)
P=0
for i in range(H*W):
  P+=C[i][0]*C[i][1]
print(P)

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

using namespace std;

int main(){
	int n, bag_wt;
	cin>>n>>bag_wt;
	
	// Always add space after declaration of type. 
	vector<pair<int, int> > data(n);

	// first: weight
	// second: value
	for(int i=0; i<n; i++) cin>>data[i].first>>data[i].second;

	// DP table n*bag_wt
	vector<vector<long long int> >dp(n, vector<long long int> (bag_wt+1, 0));

	for(int wt=0; wt<=bag_wt; wt++){
		if(wt<data[0].first) dp[0][wt] = 0;
		else dp[0][wt] = data[0].second;
	}

	for(int i=1; i<n; i++){
		for(int wt=0; wt<=bag_wt; wt++){
			if(wt<data[i].first) dp[i][wt] = dp[i-1][wt];
			else dp[i][wt] = max(dp[i-1][wt], data[i].second + dp[i-1][wt - data[i].first]);
		}
	}

	cout<<dp[n-1][bag_wt]<<"\n";
}

Measured memory_bytes: 79360
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		ArrayList<Youzi> youziList = new ArrayList<>();
		
		for(int i = 0; i < n; i++) {
			youziList.add(new Youzi(i+1, fs.nextLong()));
		}
		
		Comparator<Youzi> youziComparator = Comparator.comparing(Youzi::getActivity).reversed();
		youziList.sort(youziComparator);
		
		long dp[][] = new long[n+1][n+1];
		
		for(int i = 0; i < n; i++) {
			
			Youzi nextYouzi = youziList.get(i);
			
			for(int j = 0; j < i+1; j++) {
				int x = i - j;
				int y = j;
				
				dp[x+1][y] = Math.max(dp[x+1][y], dp[x][y] + nextYouzi.activity * (nextYouzi.firstPos - (x+1)));
				dp[x][y+1] = Math.max(dp[x][y+1], dp[x][y] + nextYouzi.activity*(n - y - nextYouzi.firstPos));
			}
		}
		long ans = 0;
		for(int i = 0; i < n; i++) {
			ans = Math.max(ans, dp[i][n-i]);
		}
		System.out.println(ans);
	}

	class Youzi{
		int firstPos;
		long activity;
		
		Youzi(int firstPos, long activity){
			this.firstPos = firstPos;
			this.activity = activity;
		}
		
		long getActivity() {
			return activity;
		}
	}
	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 82688
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if ((a+d-1)/d<(c+b-1)/b)  cout<<"No";
	else  cout<<"Yes";
	re 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

template <typename T> inline void print(T val) { cout << val << '\n'; }

template <typename Iterator> inline void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; it = next(it)) {
    cout << *it << ' ';
  }
  cout << '\n';
}

template <class T> inline T square(T x) {
  T result;
  result = x * x;
  return result;
};

#ifdef LOCAL
#define DBG_MACRO_NO_WARNING
#include <dbg.h>
#else
#define dbg(...) 0
#endif

const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  auto start = chrono::steady_clock::now();
#endif

  int k, a, b;
  cin >> k >> a >> b;

  bool ans = false;

  for (auto i = a; i <= b; ++i) {
    if (i % k == 0) {
      ans = true;
      break;
    }
  }

  if (ans) {
    print("OK");
  } else {
    print("NG");
  }

#ifdef LOCAL
  auto end = chrono::steady_clock::now();
  auto diff = end - start;

  cout << "Duration: " << chrono::duration<double, milli>(diff).count() << " ms"
       << '\n';
#endif

  return 0;
}


Measured memory_bytes: 3608
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_D
#include <iostream>
using namespace std;


int max(int x,int y){
  if(x > y) return x;
  else return y;
}

int min(int x,int y){
  if(x > y) return y;
  else return x;
}

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i<N; i++){
    cin >> A[i];
  }
  //A??????????´???????
  int maxv = A[1]-A[0];
  int minv = A[0];

  for(int i=1; i < N; i++){
    maxv = max(maxv, A[i]-minv);
    minv = min(minv, A[i]);
  //  cout << minv << " " << maxv << endl;

  }
  cout << maxv << endl;
}

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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll N = 100005;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

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

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    ll n=s.length();
    V dp(13,0);
    if(s[0]=='?'){
    	rep(i,0,10)	dp[i]=1;
    }
    else{
    	dp[s[0]-'0']++;
    }
    rep(i,1,n){
    	V temp(13,0);
    	rep(j,0,13){
    		if(s[i]=='?'){
    			rep(k,0,10){
    				temp[(j*10+k)%13] += dp[j];
    				temp[(j*10+k)%13] %= M;
    			}
    		}
    		else{
    			temp[(j*10+s[i]-'0')%13] += dp[j];
    			temp[(j*10+s[i]-'0')%13] %= M;
    		}
    	}
    	dp = temp;
    }
    cout<<dp[5]<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include<iostream>
#include<string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <map>
using namespace std;
int main() {
    int n,x,t;
    cin>>n>>x>>t;
    cout<<((n/x)+(n%x>0))*t<<endl;
    return 0;
}

Measured memory_bytes: 3604
l = [int(i) for i in input().split()]
H = l[0]
W = l[1]

my_map = []
for i in range(H) :
	s = input()
	if (s.find('#') != -1) :
		my_map.append(list(s))

remove_col_indexes = []
for col_index in range(len(my_map[0])) :
	arr = []
	for row_index in range(len(my_map)) :
		arr.append(my_map[row_index][col_index])

	if len([s for s in arr if '#' in s]) == 0 :
		remove_col_indexes.append(col_index)

result_map = []
for row_index in range(len(my_map)) :
	row_arr = []
	for col_index in range(len(my_map[row_index])) :
		if (col_index not in remove_col_indexes) :
				row_arr.append(my_map[row_index][col_index])
	
	result_map.append(row_arr)

for i in range(len(result_map)) :
	print(''.join(result_map[i]))
	


Measured memory_bytes: 3188
n = int(input())
test = []
for i in range(n):
  m = int(input())
  said = [list(map(int, input().split())) for _ in range(m)]
  test.append(said)
  
def NotContradict(i):
  lst = [0]*n
  for j in range(len(bin(i))):
    if (i >> j) & 1:
      lst[j] = 1
  for j in range(n):
    if lst[j]:
      for k in range(len(test[j])):
        if lst[test[j][k][0]-1] != test[j][k][1]: 
          return False
  return True

ans = 0
for i in range(2**n):
  if NotContradict(i):
    count = 0
    for j in range(len(bin(i))):
      if (i >> j) & 1:
        count += 1
    ans = max(ans, count)
        
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

#define MAX 100000

int main(void)
{
	int n, i, a, a_max;
	int b[MAX] = { 0 };
	int max;
	
	scanf("%d", &n);
	for(a_max=0,i=0; i<n; i++){
		scanf("%d", &a);
		
		if(a_max < a)
			a_max = a;
		
		b[a]++;
		
		if(a > 0)
			b[a-1]++;
		if(a < MAX-1)
			b[a+1]++;
	}
	
	for(max=0,i=0; i<a_max+1; i++){
		if(max < b[i])
			max = b[i];
	}
	
	printf("%d", max);
	
	
	return 0;
}


Measured memory_bytes: 512
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#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 ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    int odd=0;
    rep(i,n){if(a[i]%2)odd++;}
    if(odd%2==0)YES;
    else NO;
}


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

using namespace std;
typedef long long ll;

void solve()
{
    ll x, y;
    cin >> x >> y;

    for (ll i = 0; i <= 100; i++ ){
        for (ll j = 0; j<= 100; j++){
            if(i+j != x) continue;
            if(i*2 + j*4 == y){
                cout << "Yes";
                return ;
            }
        }
    }
    cout << "No";
}

int main()
{
    solve();
    cout << "\n";
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

ll fanc(string now){
  ll ret = 0;
  vector<int> tr;
  rep(i, now.size()){
    if(now.at(i) == 'A'){
      tr.push_back(1);
    }else{
      tr.push_back(0);
      i++;
    }
  }
  int con = 0;
  rep(i, tr.size()){
    if(tr.at(i) == 0){
      ret += i - con;
      con++;
    }
  }

  return ret;
}

int main(){
  string s;
  cin >> s;
  string now;
  ll ans = 0;
  rep(i, s.size()){
    bool flag = false;
    if(s[i] == 'A') now.push_back('A');
    else if(s[i] == 'B'){
      if(i+1 < s.size() && s.at(i+1) == 'C'){
        now += "BC";
        i++;
      }else{
        flag = true;
      }
    }else{
      flag = true;
    }
    if(flag == true){
      ans += fanc(now);
      now = "";
    }
  }
  ans += fanc(now);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2048