akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll h,w;
char cells[410][410];
ll ans,temp1,temp2;
bool is_visited[410][410] = {false};

ll dfs(ll i ,ll j){
	is_visited[i][j] = true;
	
	if(cells[i][j] == '#')temp1++;
	else temp2++;
	
	if(i-1 >= 0){
		if(cells[i][j] != cells[i-1][j]){
			if(!is_visited[i-1][j]) dfs(i-1,j);
		}
		
	}
	if(i+1 < h){
		if(cells[i][j] != cells[i+1][j]){
			if(!is_visited[i+1][j]) dfs(i+1,j);
		}
	}
	if(j-1 >= 0){
		if(cells[i][j] != cells[i][j-1]){
			if(!is_visited[i][j-1]) dfs(i,j-1);
		}
	}
	if(j+1 < w){
		if(cells[i][j] != cells[i][j+1]){
			if(!is_visited[i][j+1]) dfs(i,j+1);
		}
	}
	
	return temp1*temp2;
}

signed main(){
	temp1= 0;
	temp2 = 0;
	ans = 0;
	cin >> h >> w;
	
	
	rep(i,0,h){
		rep(j,0,w){
			cin >> cells[i][j];
		}
	}
	
	
	
	rep(i,0,h){
		rep(j,0,w){
			temp1 = 0;
			temp2 = 0;
			if(!is_visited[i][j]){
				ans += dfs(i,j);
			}
			
		}
	}
	
	cout << ans << endl;
	
	return 0;

}

Measured memory_bytes: 5504
class node:
    parent = None
    depth = 0
    degree = 0
    height = 0

    def __init__(self, no, l, r,sib):
        self.no = no
        self.left = l
        self.right = r
        self.sibling = sib
    
    def setsibdepth(self, nodes, d):
        if self.left is None:
            return
        self.depth = d
        self.left.sibling = self.right
        self.right.sibling = self.left
        self.left.setsibdepth(nodes, d+1)
        self.right.setsibdepth(nodes, d+1)

    def setheight(self, nodes, h):
        if self.left is None:
            return h-1
        return max(self.left.setheight(nodes, h+1), self.right.setheight(nodes, h+1))

#葉はNULL, 根の親はNone

NULL = node(-1, None, None, None)
head = None
nodes = []
n = int(input())
for i in range(n):
    temp = node(i, None, None, NULL)
    nodes.append(temp)

for i in range(n):
    temp = list(map(int,input().split()))
    if temp[1] == -1:
        nodes[temp[0]].left = NULL
    else:
        nodes[temp[0]].left = nodes[temp[1]]
        nodes[nodes[temp[0]].left.no].parent = nodes[temp[0]]

    if temp[2] == -1:
        nodes[temp[0]].right = NULL
    else:
        nodes[temp[0]].right = nodes[temp[2]]
        nodes[nodes[temp[0]].right.no].parent = nodes[temp[0]]

    if temp[1] == -1 and temp[2] == -1:
        nodes[temp[0]].degree = 0
    elif temp[1] != -1 and temp[2] != -1:
        nodes[temp[0]].degree = 2
    else:
        nodes[temp[0]].degree = 1

for i in range(n):
    if nodes[i].parent is None:
        head = nodes[i]
        break

head.setsibdepth(nodes, 0)

for i in range(n):
    nodes[i].height = nodes[i].setheight(nodes, 0)

for i in range(n):
    if nodes[i].parent is None:
        print("node " + str(i) + ": parent = -1, sibling = "                              + str(nodes[i].sibling.no) + ", degree = " + str(nodes[i].degree) + ", depth = " + str(nodes[i].depth) + ", height = " + str(nodes[i].height) + ", root")
    elif nodes[i].left == NULL and nodes[i].right == NULL:
        print("node " + str(i) + ": parent = " + str(nodes[i].parent.no) + ", sibling = " + str(nodes[i].sibling.no) + ", degree = " + str(nodes[i].degree) + ", depth = " + str(nodes[i].depth) + ", height = " + str(nodes[i].height) + ", leaf")
    else:
        print("node " + str(i) + ": parent = " + str(nodes[i].parent.no) + ", sibling = " + str(nodes[i].sibling.no) + ", degree = " + str(nodes[i].degree) + ", depth = " + str(nodes[i].depth) + ", height = " + str(nodes[i].height) + ", internal node")


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

signed main(){

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

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++){
        int b;
        cin >> b;
        a.at(b) ++;
    }

    bool t = true;
    for(int i = 1;i < n-1;i ++){
        if(abs(a.at(i) - a.at(i+1)) != 2){
            t = false;
        }
    }

    if(t  == false){
        cout << 0 << endl;
        return 0;
    }

    int ans = 1;
    if(n % 2 == 0){
        for(int i = 0;i < n/2;i ++){
            ans *= 2;
            ans %= 1000000007;
        }
    }else{
        for(int i = 0;i < (n-1)/2;i ++){
            ans *= 2;
            ans %= 1000000007;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
/**
 *	author:   fractal
 *	timus:    288481RF
 *	created: 08/15/20 18:03:23
**/

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

#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define szc(x) (int)strlen(x)
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound 
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 1e6 + 2;
const int M = 1e5;
const int mod = 998244353;
const int inf = 2e9 + 3;
const ll INF = 1e16;

/*
	BIN POISK EBANA V ROT
	DP EBANA V ROT
	DO EBANA V ROT
*/

char s[N];

int main() {
	scanf("%s", s + 1);
	int n = szc(s + 1);
	int ret = 0, ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (s[i] == 'R')
			ans++;
		else {
			ret = max(ret, ans);
			ans = 0;
		}
	}
	ret = max(ret, ans);
	printf("%d", ret);
}


Measured memory_bytes: 3808
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto s = readln.chomp;
    auto K = readln.chomp.to!int;

    string[] ss;
    bool[string] memo;
    foreach (i; 0..s.length) {
        foreach (j; i+1..min(i+6, s.length+1)) {
            if (s[i..j] !in memo) {
                ss ~= s[i..j];
                memo[s[i..j]] = true;
            }
        }
    }
    sort(ss);
    writeln(ss[K-1]);
}

Measured memory_bytes: 3580
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long m = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		long l = lcm(n, m);
		Map<String, String> map = new HashMap<>();
		if (n == 1) {
			map.put(String.valueOf((long) 1), s);
		} else {
			for (int i = 0; i < n-1; i++) {
				map.put(String.valueOf((long) (i*(l/n)+1)), String.valueOf(s.charAt(i)));
			}
		}
		if (m == 1) {
			if (!map.get("1").equals(t)) {
				System.out.println(-1);
				return;
			}
		} else {
			for (int i = 0; i < m-1; i++) {
				if (map.containsKey(String.valueOf((long) (i*(l/m)+1)))) {
					if (!map.get(String.valueOf((long) ((i*(l/m)+1)))).equals(String.valueOf(t.charAt(i)))) {
						System.out.println(-1);
						return;
					}
				}
			}
		}
		System.out.println(l);
	}
	private static long lcm(long n, long m) {
		long temp;
		long c = n;
		c *= m;
		while((temp = n%m) != 0) {
			n = m;
			m = temp;
		}
		return c / m;
	}
}


Measured memory_bytes: 53332
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int r[200001]={0},d[200001]={0},O[200001];
vector<int> A[200001];
int search(int x,int y,int z){
    if(r[x])return 0;
    r[x]=1;
    d[x]=y;
    O[x]=z;
    for(auto i:A[x]) search(i,y+1,x);
}
int main(){
    int n,u,v,a,b;
    cin>>n>>u>>v;
    rep(i,n-1) cin>>a>>b,A[a].push_back(b),A[b].push_back(a);
    search(v,0,-1);
    int s=d[u]-(d[u]-1)/2,t=d[u]/2;
    int c,e=u;
    while(true){
        if(d[e]==s) break;
        c=O[e];
        e=c;
    }
    rep(i,n) if(d[i+1]>=s) r[i+1]=0,d[i+1]=0;
    search(e,s,O[e]);
    int m=0;
    rep(i,n) m=max(m,d[i+1]);
    //rep(i,n) cout<<O[i+1]<<endl;
    cout<<t+m-s;
}

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

int main() {
  
  int N, x, y, z;
  cin >> N;
  z = N;
  while (z>0) {
    x = z%10;
    z /=10;
    y += x;
  }
  
  if (N%y == 0) 
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
V = list(map(int,input().split()))

# v1 : 0,2,4... 番目の要素からなるリスト
# v2 : 1,3,5... 番目の要素からなるリスト
v1 = V[0::2]
v2 = V[1::2]

# それぞれ, 要素の出現回数を集計する.
# 一番出現回数が多い数字 以外 を書き換えるのが良さそう
from collections import Counter
c1 = Counter(v1).most_common()
c2 = Counter(v2).most_common()

# 数字が1つしかない場合に"2番目"をダミーで追加
c1.append((0,0))
c2.append((0,0))

# 残したい数字が v1,v2 で一致した場合, どちらかは次点を採用せざるを得ない
if c1[0][0]==c2[0][0]:
    print(min(N-(c1[0][1]+c2[1][1]), N-(c1[1][1]+c2[0][1])))
else:
    print(N- (c1[0][1]+c2[0][1]))


Measured memory_bytes: 21028
import sys
input = sys.stdin.readline
N, M, L = map(int, input().split())
d = [[10 ** 16 * (i != j) for j in range(N + 1)] for i in range(N + 1)]
for _ in range(M):
  x, y, c = map(int, input().split())
  d[x][y] = c
  d[y][x] = c
for k in range(N + 1):
  for i in range(N + 1):
    for j in range(N + 1): d[i][j] = min(d[i][j], d[i][k] + d[k][j])

dd = [[(d[i][j] <= L) + (d[i][j] > L) * 10 ** 16 for j in range(N + 1)] for i in range(N + 1)]
for k in range(N + 1):
  for i in range(N + 1):
    for j in range(N + 1): dd[i][j] = min(dd[i][j], dd[i][k] + dd[k][j])

for _ in range(int(input())):
  s, t = map(int, input().split())
  if dd[s][t] != 10 ** 16: print(dd[s][t] - 1)
  else: print(-1)

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

  int N , M ;
  cin >> N >> M ;
  rep(i,100000){
    if(M*i >= N){
      cout << i << endl;
      return 0 ;
    }
  }
}

Measured memory_bytes: 256
#include "iostream"
#include "string"
#include "algorithm"
using namespace std;


int main()
{
	int a[26] = {};
	string S;
	while (getline(cin, S))
	{
		for (int i = 0; i < S.size(); i++)
		{
			if (S[i] >= 'A'&&S[i] <= 'Z')
			{
				a[S[i] - 'A']++;
			}
			else if (S[i] >= 'a'&&S[i] <= 'z')
			{
				a[S[i] - 'a']++;
			}
		}
	}
	for (int i = 0; i < 26; i++)
	{
		cout << (char)('a' + i) << " : " << a[i] << endl;
	}
}


Measured memory_bytes: 3180
fun main() {
    val n = nextInt()
    val c = next().toCharArray()
    var l = 0
    var r = n - 1
    var count = 0

    while (l < r) {
        while (l < r && c[l] == 'R') {
            l++
        }
        while (l < r && c[r] == 'W') {
            r--
        }
        if (l < r) {
            count++
            l++
            r--
        }
    }
    println(count)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 38484
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

import sys
sys.setrecursionlimit(4100000)
rl = sys.stdin.readline

N,M,X = Ints()
C = []
A = []

for i in range(N):
    In = IntList()
    C.append(In[0])
    A.append(In[1:])
    
ans = 10**16

import itertools

for i in itertools.product([0,1], repeat=N):
    Now = [0]*M
    tmpans = 0
    for j in range(N):
        if i[j]==1:
            tmpans += C[j]
            for k in range(M):
                Now[k] += A[j][k]
    if min(Now) >= X:
        ans = min(ans,tmpans)
        
if ans==10**16:
    print(-1)
else:
    print(ans)

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

const int INF = 1001001001;
const int MAX_N = 100005;

int dp[MAX_N];

int main(void){
    int N;
    cin >> N;

    for(int i=0;i<=N;i++) dp[i] = INF;
    dp[0] = 0;

    for(int i=1;i<=N;i++){
        int k = 1;
        dp[i] = min(dp[i],dp[i-k]+1);
        k = 6;
        while(i-k>=0){
            dp[i] = min(dp[i],dp[i-k]+1);
            k *= 6;
        }
        k = 9;
        while(i-k>=0){
            dp[i] = min(dp[i],dp[i-k]+1);
            k *= 9;
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 640
f = lambda : list(map(int, input().split()))
n = int(input())
la = f()
lb = f()

tmp = 0
ans = 0

for i in range(n):
  m = min(la[i], tmp+lb[i])
  tmp = min(tmp+lb[i]-m, lb[i])
  ans += m

print(ans + min(la[n], tmp))

Measured memory_bytes: 19116
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        int max = 0;
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
            max = Math.max(max, A[i]);
        }
        sc.close();

        if(max < K)
            System.out.println("IMPOSSIBLE");
        else {
            int[] g = new int[N];
            g[0] = A[0];
            for(int i = 1; i < N; i++){
                g[i] = gcd(A[i], g[i-1]);
            }
            if(K % g[N-1] == 0)
                System.out.println("POSSIBLE");
            else
                System.out.println("IMPOSSIBLE");
        }
    }
    
    static int gcd(int n, int m){
        if(m>n)
            return gcd(m, n);
        else {
            if(n%m == 0)
                return m;
            else
                return gcd(m, n%m);
        }
    }
}

Measured memory_bytes: 49540
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#define MOD 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;

signed main(){
    int n;
    cin>>n;
    string s[114514];
    map<string,int> t;
    for(int i=0;i<n;i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
        if(t.count(s[i]))t[s[i]]++;
        else t[s[i]]=1;
    }
    int ans=0;
    for(auto a:t){
        ans+=a.second*(a.second-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
int N;
int Y[101010],X[101010],A[101010];

ll XX[101010],YY[101010];
vector<pair<int,int>> XL[101010];
vector<pair<int,int>> YL[101010];

vector<int> LR[101010];
vector<int> UD[101010];

ll mix,miy;
int did[101010];

void dfs(int cur) {
	int cx=X[cur];
	int cy=Y[cur];
	
	if(XX[cx]!=-1LL<<60 && YY[cy]!=-1LL<<60) {
		if(XX[cx]+YY[cy]!=A[cur]) {
			cout<<"No"<<endl;
			exit(0);
		}
	}
	if(did[cur]) return;
	did[cur]=1;
	
	if(XX[cx]==-1LL<<60 && YY[cy]==-1LL<<60) {
		XX[cx]=A[cur];
		YY[cy]=0;
		mix=XX[cx];
		miy=YY[cy];
	}
	if(XX[cx]==-1LL<<60) {
		XX[cx]=YY[cy]-A[cur];
		mix=min(XX[cx],mix);
	}
	if(YY[cy]==-1LL<<60) {
		YY[cy]=XX[cx]-A[cur];
		miy=min(YY[cy],miy);
	}
	
	FORR(e,LR[cur]) {
		ll tar=XX[cx] + (A[e] - A[cur]);
		if(XX[X[e]]!=-1LL<<60 && XX[X[e]]!=tar) {
			cout<<"No"<<endl;
			exit(0);
		}
		XX[X[e]] = tar;
		mix=min(tar,mix);
		dfs(e);
	}
	FORR(e,UD[cur]) {
		ll tar=YY[cy] + (A[e] - A[cur]);
		if(YY[Y[e]]!=-1LL<<60 && YY[Y[e]]!=tar) {
			cout<<"No"<<endl;
			exit(0);
		}
		YY[Y[e]] = tar;
		miy=min(tar,miy);
		dfs(e);
	}
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(i,101000) XX[i]=YY[i]=-1LL<<60;
	
	cin>>H>>W>>N;
	FOR(i,N) {
		cin>>Y[i]>>X[i]>>A[i];
		Y[i]--;
		X[i]--;
		YL[Y[i]].push_back({X[i],i});
		XL[X[i]].push_back({Y[i],i});
	}
	FOR(y,H) if(YL[y].size()>1) {
		sort(ALL(YL[y]));
		FOR(i,YL[y].size()-1) {
			LR[YL[y][i].second].push_back(YL[y][i+1].second);
			LR[YL[y][i+1].second].push_back(YL[y][i].second);
		}
	}
	FOR(x,W) if(XL[x].size()>1) {
		sort(ALL(XL[x]));
		FOR(i,XL[x].size()-1) {
			UD[XL[x][i].second].push_back(XL[x][i+1].second);
			UD[XL[x][i+1].second].push_back(XL[x][i].second);
		}
	}
	
	FOR(i,N) if(XX[X[i]]==-1LL<<60 && YY[Y[i]]==-1LL<<60) {
		dfs(i);
		if(mix+miy<0) {
			cout<<"No"<<endl;
			return;
		}
	}
	
	cout<<"Yes"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 28544
#include <iostream>
#include <random>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;

class UnionFind {
    std::vector<int> p;
    std::vector<int> c;
public:
    UnionFind(int n) : p(n, -1), c(n, 1) {}

    int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

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

    int size(int x) {
        return c[root(x)];
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (p[y] < p[x]) std::swap(x, y);
        if (p[x] == p[y]) --p[x];
        c[x] = c[x] + c[y];
        p[y] = x;
        return true;
    }
};


int main() {
    int N;
    cin >> N;
    int M;
    cin >> M;
    vector<pair<int, int> > es;
    UnionFind tmp(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        es.push_back({a, b});
        tmp.unite(a, b);
    }


    reverse(es.begin(), es.end());

    UnionFind uf(N);

    vector<long long> r;
    long long C = 1ll * N * (N - 1);
    for (int i = 0; i < M; i++) {
        r.push_back(C);
        long long D = 0;
        if (!uf.same(es[i].first, es[i].second)) {
            D -= 1ll * uf.size(es[i].first) * (N - uf.size(es[i].first));
            D -= 1ll * uf.size(es[i].second) * (N - uf.size(es[i].second));
            uf.unite(es[i].first, es[i].second);
            D += 1ll * uf.size(es[i].first) * (N - uf.size(es[i].first));
            C += D;
        }else{
            uf.unite(es[i].first, es[i].second);
        }

    }

    reverse(r.begin(), r.end());
    for (auto i : r) {
        assert(i >= 0);
        cout << i / 2 << endl;
    }


}


Measured memory_bytes: 4596
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> s(m),c(m);
    rep(i,m) cin >> s[i] >> c[i];

    if(n == 1){
        for(int i = 0; i <= 9; i++){
            int a = 0;
            rep(j,m){
                if(i == c[j]){
                    a++;
                    continue;
                }
                else break;
            }
            if(a == m){
                dunk(i);
                return 0;
            }
        }
        dunk(-1);
        return 0;
    }
    if(n == 2){
        for(int i = 10; i <= 99; i++){
            int a = 0;
            rep(j,m){
                if((s[j] == 1 && i - i%10 == c[j]*10) || (s[j] == 2 && i%10 == c[j])){
                    a++;
                    continue;
                }
                else break;
            }
            if(a == m){
                dunk(i);
                return 0;
            }
        }
        dunk(-1);
        return 0;
    }
    if(n == 3){
        for(int i = 100; i <= 999; i++){
            int a = 0;
            rep(j,m){
                if((s[j] == 1 && i - i%100 == c[j]*100) || (s[j] == 2 && i%100 - i%10 == c[j]*10) || (s[j] == 3 && i%10 == c[j])){
                    a++;
                    continue;
                }
                else break;
            }
            if(a == m){
                dunk(i);
                return 0;
            }
        }
        dunk(-1);
        return 0;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math

#入力
#S = str(input())
#N, i = map(int, input().split())
#K = int(input())
D = int(input())

if D == 25 :
  print ("Christmas")
elif D == 24 :
  print ("Christmas Eve")
elif D == 23 :
  print ("Christmas Eve Eve")
elif D == 22 :
  print ("Christmas Eve Eve Eve")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[2000],i,j,k,countr=0;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n);
    for(i=0;i<n-2;i++)
    {
        for(j=i+1;j<n-1;j++)
        {
            int sum=a[i]+a[j];
            for(k=j+1;k<n;k++)
            {
                if(a[k]<sum)
                {
                    countr++;
                }
            }
        }
    }
    cout << countr;
}


Measured memory_bytes: 3604
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, K = read_ints()
    # 0, 1, 2, ..., N
    # k = 3
    # (0+1+2)+...(N-2+N-1+N)
    total = 0
    prefix = sum(range(K))
    suffix = sum(range(N, N-K, -1))
    modulo = 10**9+7
    for k in range(K, N+2):
        total = (total+(suffix-prefix+1))%modulo
        prefix = (prefix+k)%modulo
        suffix = (suffix+N-k)%modulo
    return total


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

Measured memory_bytes: 9216
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    vi data(n);

    rep(i, n) {
        cin >> data[i];
    }

    sort(all(data));

    int sum = data[0], ans = 0;

    data.pb(-1);

    Rep(i, n + 1) {
        if (sum * 2 >= data[i]) {
            ans++;
        } else {
            ans = 0;
        }
        sum += data[i];
    }

    cout << ans << endl;





    return 0;
}



Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
"""
C - Back and Forth
https://atcoder.jp/contests/abc051/tasks/abc051_c

"""
import sys


def solve(sx, sy, tx, ty):
    used = set()
    ans = []
    x, y = sx, sy
    gx, gy = tx, ty
    px, py = sx, sy
    while True:
        path = []
        for nx, ny, d in ((x, y+1, 'U'), (x, y-1, 'D'), (x-1, y, 'L'), (x+1, y, 'R')):
            if not (nx, ny) in used and (nx, ny) != (px, py):
                path.append([abs(nx-gx) + abs(ny-gy), d, (nx, ny)])
        if path == []:
            break
        o = ''
        if  x == gx or y == gy:
            if x == gx:
                o = 'RLUD'
            else:
                o = 'UDRL'
        elif x > gx:
            if y > gy:
                o = 'DLUR'
            else:
                o = 'ULDR'
        else:
            if y > gy:
                o = 'DRUL'
            else:
                o = 'URDL'
        path.sort(key=lambda x: [x[0], o.index(x[1])])
        ans.append(path[0][1])
        x, y = path[0][2]
        used.add((x, y))
        if x == gx and y == gy:
            used.discard((x, y))
            if gx == sx and gy == sy:
                gx, gy = tx, ty
                px, py = sx, sy
            else:
                gx, gy = sx, sy
                px, py = tx, ty
    return ans


def main(args):
    sx, sy, tx, ty = map(int, input().split())
    ans = solve(sx, sy, tx, ty)
    print(*ans, sep='')


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 6416
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
S = input()[:-1]
ans = 0

for i in range(N+1):
    sx = set()
    
    for j in range(i):
        sx.add(S[j])
    
    sy = set()
    
    for j in range(i, N):
        sy.add(S[j])
    
    ans = max(ans, len(sx&sy))

print(ans)

Measured memory_bytes: 39280
//@author yash2040
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
main()
{
	fast();
	int n,m;
	cin>>n>>m;
	int arr[m];
	int sum=0;
	for(int i=0;i<m;i++)
	{
		cin>>arr[i];
		sum+=arr[i];
		}	
	if(n>=sum)
	cout<<n-sum<<endl;
	else
	cout<<"-1"<<endl;
}





Measured memory_bytes: 3692
/*    *** Bismillahir Rahmanir Rahim***
          *A S M Masud Parvez*
             *18ICTCSE035*
           *SHIICT(BSMRSTU)*
*/
#include<bits/stdc++.h>
using namespace std;
#define MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
#define End return 0
#define ll long long int
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
int Max = INT_MIN;
int Min = INT_MAX;
int i,j,f=0,x,y,z,n,m,S=0,len;
#define pi acos(-1)
int main()
 {    
   
   MP;

    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
       if(s[i]=='7')
       {
          f++;
       } 
    }
    if(f>0){
       cout<<"Yes";
    }else 
    cout<<"No";

	End;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000


int main(){
  int n;
  cin >> n;
  map<int,int> count;
  rep(i,n){
    int a;
    cin >> a;
    count[a]++;
    count[a+1]++;
    if(a != 0){
      count[a-1]++;
    }
  }
  int ans = 0;
  for(auto p:count){
    auto key = p.first;
    auto value = p.second;
    ans = max(ans,value);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4736
i = list(map(int, input().split()))
A=i[0]
B=i[1]

if A==B:
    print("Draw")
elif A>B and B!=1:
    print("Alice")
elif A<B and A!=1:
    print("Bob")
elif A>B and B==1:
  print("Bob")
elif A<B and A==1:
  print("Alice")
  

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        class Floor
        {
            private int[] room = new int[10];
            public int this[int i]
            {
                get { return room[i]; }
                set { room[i] = value; }
            }
            public override string ToString()
            {
                return string.Join("", room.Select(x => " " + x.ToString()).ToArray());
            }
        }

        class Building
        {
            private Floor[] floors = new Floor[3];
            public Building()
            {
                for (int i = 0; i < floors.Length; i++)
                {
                    floors[i] = new Floor();
                }
            }
            public void Add(int floor, int room, int num)
            {
                floors[floor][room] += num;
            }
            public override string ToString()
            {
                return string.Join("\n", floors.Select(f => f.ToString()).ToArray());
            }
        }

        static void Main(string[] args)
        {
            var n = GetNumber();
            var buildings = Enumerable.Range(0, 4).Select(x => new Building()).ToArray();
            for (int i = 0; i < n; i++)
            {
                //b?£?f??????r???????????¨?±????v
                var line = GetNumbersInt();
                buildings[line[0] - 1].Add(line[1] - 1, line[2] - 1, line[3]);
            }
            System.Console.WriteLine(string.Join("\n####################\n", buildings.Select(b => b.ToString()).ToArray()));
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static int[] GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long[] GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        static double[] GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
        }

        static string[] GetStrings(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
}

Measured memory_bytes: 10204
#include <cstddef>
#include <queue>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
namespace loquat {
using vertex_t = size_t;
}
namespace loquat {
namespace edge_param {
struct to_ {
	vertex_t to;
	explicit to_(vertex_t t = 0)
		: to(t)
	{ }
};
template <typename T>
struct weight_ {
	using weight_type = T;
	weight_type weight;
	explicit weight_(const weight_type& w = weight_type())
		: weight(w)
	{ }
};
template <typename T>
using weight = weight_<T>;
}
namespace detail {
template <typename T, typename... Params>
struct edge_param_wrapper : public T, edge_param_wrapper<Params...> {
	template <typename U, typename... Args>
	explicit edge_param_wrapper(U&& x, Args&&... args)
		: T(std::forward<U>(x))
		, edge_param_wrapper<Params...>(std::forward<Args>(args)...)
	{ }
};
template <typename T>
struct edge_param_wrapper<T> : public T {
	template <typename U>
	explicit edge_param_wrapper(U&& x)
		: T(std::forward<U>(x))
	{ }
};
}
template <typename... Params>
struct edge : public detail::edge_param_wrapper<edge_param::to_, Params...> {
	edge()
		: detail::edge_param_wrapper<edge_param::to_, Params...>()
	{ }
	template <typename... Args>
	explicit edge(Args&&... args)
		: detail::edge_param_wrapper<edge_param::to_, Params...>(
			std::forward<Args>(args)...)
	{ }
};
}
namespace loquat {
template <typename EdgeType>
class adjacency_list {
public:
	using edge_type = EdgeType;
	using edge_list = std::vector<edge_type>;
private:
	std::vector<std::vector<EdgeType>> m_edges;
public:
	adjacency_list()
		: m_edges()
	{ }
	explicit adjacency_list(size_t n)
		: m_edges(n)
	{ }
	size_t size() const {
		return m_edges.size();
	}
	const edge_list& operator[](vertex_t u) const {
		return m_edges[u];
	}
	edge_list& operator[](vertex_t u){
		return m_edges[u];
	}
	template <typename... Args>
	void add_edge(vertex_t from, Args&&... args){
		m_edges[from].emplace_back(std::forward<Args>(args)...);
	}
	void add_edge(vertex_t from, const edge_type& e){
		m_edges[from].emplace_back(e);
	}
};
}
using namespace std;
using ll = long long;
using edge = loquat::edge<loquat::edge_param::weight<ll>>;
int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	loquat::adjacency_list<edge> g(n);
	for(int i = 0; i < m; ++i){
		int l, r, d;
		cin >> l >> r >> d;
		--l; --r;
		g.add_edge(l, r,  d);
		g.add_edge(r, l, -d);
	}
	vector<bool> fix(n, false);
	vector<ll> pos(n, 0);
	bool answer = true;
	for(int i = 0; answer && i < n; ++i){
		if(fix[i]){ continue; }
		queue<int> q;
		q.push(i);
		fix[i] = true;
		pos[i] = 0;
		while(!q.empty()){
			const int u = q.front();
			q.pop();
			for(const auto& e : g[u]){
				const int v = e.to;
				const ll p = pos[u] + e.weight;
				if(fix[v]){
					if(pos[v] != p){ answer = false; }
				}else{
					fix[v] = true;
					pos[v] = p;
					q.push(v);
				}
			}
		}
	}
	cout << (answer ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 13952
/**
 *    author:   K.R.Surrya  
 *    created:  02/05/2020 17:30:21
**/
#include<bits/stdc++.h>
#define vi vector<int>
#define vii vector<vector<int> >
#define vpi vector<pair<int,int> >
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
using namespace std; 

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)  { return ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a,Args... args)
{
    cerr << *it << " = " << a <<endl;
    err(++it,args...);   //args is going to end.
}

void solve() {
    int n;
    cin >> n;
    int a,b;
    cin >> a >> b;
    int ok=0;
    for(int i=a;i<=b;++i) { 
        if(i%n==0) { 
            ok=1;
            break;
        }
    }
    if(ok)   cout << "OK" << '\n';
    else     cout << "NG" << '\n';
}

void awesome() { 
    int n;
    cin >> n;
    int a,b;
    cin >> a >> b;
    int right = b/n;
    int left= (a-1)/n;

    int multiples=right-left;
    if(multiples>0) { 
        cout << "OK" << '\n';
    }
    else {
        cout << "NG" << '\n';
    }
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);

     auto start = chrono::high_resolution_clock::now();
     awesome();
     auto end = chrono::high_resolution_clock::now();

     cerr << " Execution time : " << chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms"<<endl;

   
    return 0;
}


Measured memory_bytes: 3472
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	a := make([]int, n)
	b := make([]bool, n)
	for i := 0; i < n; i++ {
		con.Scan(&a[i])
	}
	x := 0
	s := 0
	for x != 1 && !b[x] {
		b[x] = true
		x = a[x] - 1
		s++
	}
	if b[x] {
		s = -1
	}
	con.Println(s)
	return nil
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

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

using vc = vector<char>;
using vcc = vector<vc>;
using vb = vector<bool>;
using vbb = vector<vb>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using vd = vector<double>;
using vdd = vector<vd>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;

vector<pii> prime_factorization(int n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pii> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}
vector<pli> prime_factorization(ll n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pli> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}

// n は 2以上の素数表を返す
vb Primes(int n){
  vector<bool> res(n + 1, true);
  res.at(0) = false; res.at(1) = false;
  for(int i = 2; i <= sqrt(n); i++){
    if(res.at(i)){
      for(int j = 2 * i; j <= n; j += i){
        res.at(j) = false;
      }
    }
  }
  return res;
}
// ===================================================

int main(){
  int w, v, N, W; cin >> N >> W;
  // DP[i][j] := {i番目までのものを使った時の重さ j 以下の最大値 }
  vll DP(N + 1, vl(W + 1, 0));
  /*
    DP[0][k] = 0 (for all k in N)
    DP[i][j] = { DP[i - 1][j]    if (j < w[i]) : i番目を絶対に使わない
               { max(DP[i - 1][j], DP[i - 1][j - w[i]] + v[i])
  */
  for(int i = 1; i <= N; i++){
    cin >> w >> v;
    int j;
    for(j = 0; j < w; j++) DP[i][j] = DP[i - 1][j];
    for(; j <= W; j++){
      ll tmp = DP[i - 1][j - w] + v;
      DP[i][j] = MAX(DP[i - 1][j], tmp);
    }
  }
  cout << DP[N][W] << "\n";
  return 0;
}

Measured memory_bytes: 80256
//ysh_gpta
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;


#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define IN(i,l,r) (l<i&&i<r)   //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)


#define repf(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define repfe(i,L,R) for (int i = L; i <= R; i++)
#define repb(i,L,R) for (int i = L; i > R; i--)
#define repbe(i,L,R) for (int i = L; i >= R; i--)


typedef long long ll;
#define cerr if(false)cerr
#define vb vector<bool>
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define mkp make_pair
#define pb push_back
#define INF 1000000000000000
#define MOD 1000000007
#define ff first
#define ss second


#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


ll gcd( ll a, ll b ){if(b==0) return a; else return gcd( b, a%b );}
ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}


vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};


int main(){
    FastIO
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vvi dp(n+1,vi(n+1,0));
    if(s[0]=='<') dp[2][2] = 1;
    else dp[2][1] = 1;
    repf(i,2,n){
        ll e=0;
        if(s[i-1]=='>'){
            repb(j,i+1,0){
                if(dp[i][j])
                e += dp[i][j];
                dp[i+1][j] += e;
                dp[i+1][j] %=MOD;
            }
        }else{
            repf(j,1,i+1){
                if(dp[i][j])
                e += dp[i][j];
                dp[i+1][j+1] += e;
                dp[i+1][j+1] %= MOD;
            }
        }
    }
    ll ans = 0;
    repf(i,1,n+1){
        ans += dp[n][i];
        ans %=MOD;
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 70784
#include "bits/stdc++.h"
using namespace std;
using long_t = int64_t;

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		multimap<string, int> m;
		int q;
		cin >> q;
		while( q-- ) {
			int op;
			cin >> op;

			if( op == 0 ) {
				string key;
				int x;
				cin >> key >> x;
				m.insert( { key, x } );
			}
			else if( op == 1 ) {
				string key;
				cin >> key;
				auto p = m.equal_range( key );
				for( auto it = p.first; it != p.second; ++it ) {
					cout << it->second << '\n';
				}
			}
			else if( op == 2 ) {
				string key;
				cin >> key;
				m.erase( key );
			}
			else if( op == 3 ) {
				string L, R;
				cin >> L >> R;
				auto i1 = m.lower_bound( L );
				auto i2 = m.upper_bound( R );
				for( ; i1 != i2; ++i1 ) {
					cout << i1->first << ' ' << i1->second << '\n';
				}
			}
		}
	}
};

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



Measured memory_bytes: 24820
import java.util.*;
import java.io.*;
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int num = new Integer(in.nextLine());
        int x = 0, y = 0, time = 0;
        for (; num > 0; num--) {
            String[] s = in.nextLine().split(" ");
            int diffTime = new Integer(s[0]) - time;
            int xx = new Integer(s[1]);
            int yy = new Integer(s[2]);
            int diffXY = Math.abs(xx - x) + Math.abs(yy - y);
            if (diffTime < diffXY || (diffTime - diffXY) % 2 != 0) {
                System.out.println("No");
                return;
            }
            time = new Integer(s[0]);
            x = xx;
            y = yy;
        }
        System.out.println("Yes");
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using llint = long long;
using vint = vector<int>;

int main () {
    int n, k, ans = 1; cin >> n >> k;
    rep (i, n) {
        if (ans * 2 < ans + k) ans *= 2;
        else ans += k;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {

	long n,k;
	cin >> n >> k;

	vector<long> c(100010,0);
	long tmp1, tmp2,i;
	for ( i = 1; i <= n; i++) {
		cin >> tmp1 >> tmp2;
		c[tmp1] += tmp2;
	}

	for ( i = 1; i <=100000; i++) {
		k -= c[i];
		if (k <= 0) { break; }
	}
	cout << i << endl;

}

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

int main(int argc, char const *argv[])
{
	int n, r; cin >> n >> r;
	cout << r + max(0, 10 - n) * 100 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl

ll n,m,val[100005],par[100005],cnt[100005];
ll u[100005],v[100005],c[100005];
ll in[100005];
bool tak[100005];

int get_par(int i)
{
	if(par[i]==i)
		return i;
	return par[i]=get_par(par[i]);
}

bool cmp(int i,int j)
{
	return c[i]<c[j];
}

int main()
{
	SPEED;		
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>val[i],par[i]=i;
	for(int i=1;i<=m;i++)
		cin>>u[i]>>v[i]>>c[i],in[i]=i;
	sort(in+1,in+m+1,cmp);
	int ans=0;
	for(int i1=1;i1<=m;i1++)
	{
		int i=in[i1];
		int x=get_par(u[i]);
		int y=get_par(v[i]);
		if(x!=y)
			val[y]+=val[x],cnt[y]=cnt[x]+cnt[y],par[x]=y;
		cnt[y]++;
		if(val[y]>=c[i])
			tak[i]=1,ans+=cnt[y],cnt[y]=0;
	}
	cout<<m-ans<<endl;
	return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
int D,N;
int main()
{
	cin>>D>>N;if(N==100)N++;
	if(D==0)cout<<N;
	if(D==1)cout<<N*100;
	if(D==2)cout<<N*10000;
	return 0;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    char a,b;
    cin>>a>>b;
    int i,x=a-'0',y=b-'0';
    string s1="",s2="";
    rep0(i,y)
        s1+=a;
    rep0(i,x)
        s2+=b;
    cout<<min(s1,s2);
}


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

public class Main{

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int ans = 0;
      String line = in.readLine();
      for (char ch : line.toCharArray()) {
        if(ch == '1') ans++;
      }

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 22612