akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)


struct city {
  int index, id, p, y;
};


int main () {
  int n, m;

  cin >> n >> m;
  vector<city> c(m);

  rep(i,m) {
    cin >> c[i].p >> c[i].y;
    c[i].index = i;
  }

  sort(c.begin(), c.end(), [](const city&a, const city&b) {
      return a.p == b.p ? a.y < b.y : a.p < b.p;
    });

  int cp = -1;
  int ci;
  rep(i,m) {
    if(cp != c[i].p) {
      cp = c[i].p;
      ci = 1;
    } else {
      ci++;
    }
    c[i].id = ci;
  }

  sort(c.begin(), c.end(), [](const city&a, const city&b) {
      return a.index < b.index;
    });

  rep(i,m) {
    printf("%06d%06d\n", c[i].p, c[i].id);
  }

  return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

vector <int> arr1, arr2;

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, k, x;
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for(i = 1; i <= n; i++) {
        int val;
        cin >> val;
        if(val <= 0) {
            arr1.push_back(val);
        }
        else {
            arr2.push_back(val);
        }
    }
    int ans = 2e9;
    if(arr1.size() >= k) {
        ans = min(ans, -arr1[(int) arr1.size() - k]);
    }
    if(arr2.size() >= k) {
        ans = min(ans, arr2[k - 1]);
    }
    for(i = 0; i < min(k - 1, (int) arr2.size()); i++) {
        if(k - i - 1 <= arr1.size()) {
            int a = arr2[i], b = -arr1[(int) arr1.size() - (k - i - 1)];
            ans = min(ans, a + b + min(a, b));
        }
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   
    cin>>n>>k;
    x=log(n)/log(k);
    
    
    
    cout<< ++x<<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3788
import sys
import random
input = lambda: sys.stdin.readline().rstrip()

def main():
    D = int(input())
    c = [0] + list(map(int, input().split()))
    s = [[0]*27]
    for _ in range(D):
        s.append([0] + list(map(int, input().split())))
    for _ in range(D):
        print(random.randrange(1, 27))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9880
use std::io::*;
use std::str::FromStr;

#[derive(Clone)]
struct Edge {
    dst: usize,
    id: usize,
}

type Graph = Vec<Vec<Edge>>;

fn dfs(graph: &Graph, v: usize, par: usize, pcolor: usize, colors: &mut Vec<usize>) {
    let mut color = 0;
    for edge in &graph[v] {
        if edge.dst == par {
            continue;
        }

        color += 1;
        if color == pcolor {
            color += 1;
        }

        colors[edge.id] = color;
        dfs(graph, edge.dst, v, color, colors);
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.next();
    let mut graph: Graph = vec![vec![]; n];
    for id in 0..(n - 1) {
        let u = sc.next::<usize>() - 1;
        let v = sc.next::<usize>() - 1;
        graph[u].push(Edge { dst: v, id: id });
        graph[v].push(Edge { dst: u, id: id });
    }

    let mut colors = vec![0; n - 1];
    dfs(&graph, 0, 0, 0, &mut colors);

    let k = colors.iter().max().unwrap();
    println!("{}", k);

    for &c in &colors {
        println!("{}", c);
    }
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
        self.next::<String>().chars().next().unwrap()
    }
}


Measured memory_bytes: 14716
#include<stdio.h>
int main(){
    char b[2];
    scanf("%s",b);
    if(b[0] == 'A')
        puts("T");
    else if(b[0] == 'C')
        puts("G");
    else if(b[0] == 'G')
        puts("C");
    else 
        puts("A");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
using namespace std;

bool judge(const int dice1[], const int dice2[]);
void moveE(int dice[]);
void moveN(int dice[]);
void moveS(int dice[]);
void moveW(int dice[]);
void moveR(int dice[]);

int main(void)
{	
	int dice1[6];
	for (int i = 0; i < 6; i++) cin >> dice1[i];
	int dice2[6];
	for (int i = 0; i < 6; i++) cin >> dice2[i];
	
	for (int i = 0; i < 4; i++) {
		moveE(dice2);
		for (int j = 0; j < 4; j++) {
			moveN(dice2);
			for (int k = 0; k < 4; k++) {
				moveR(dice2);
				if (judge(dice1, dice2)) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

bool judge(const int dice1[], const int dice2[])
{
	for (int i = 0; i < 6; i++) {
		if (dice1[i] != dice2[i]) return false;
	}
	return true;
}

void moveE(int dice[])
{
	int temp = dice[0];
	dice[0] = dice[3];
	dice[3] = dice[5];
	dice[5] = dice[2];
	dice[2] = temp;
}

void moveN(int dice[])
{
	int temp = dice[0];
	dice[0] = dice[1];
	dice[1] = dice[5];
	dice[5] = dice[4];
	dice[4] = temp;
}

void moveS(int dice[])
{
	int temp = dice[0];
	dice[0] = dice[4];
	dice[4] = dice[5];
	dice[5] = dice[1];
	dice[1] = temp;
}

void moveW(int dice[])
{
	int temp = dice[0];
	dice[0] = dice[2];
	dice[2] = dice[5];
	dice[5] = dice[3];
	dice[3] = temp;
}

void moveR(int dice[])
{
	int temp = dice[1];
	dice[1] = dice[2];
	dice[2] = dice[4];
	dice[4] = dice[3];
	dice[3] = temp;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(b<a) {cout<<0;return 0;}
  else if(b/a>=c)  {cout<<c;return 0;}
  else  {cout<<b/a;return 0;}
  return 0;
}

Measured memory_bytes: 256
n,W = map(int, input().split())
w = []
v = []
for i in range(n):
    a,b = map(int, input().split())
    w.append(a)
    v.append(b)
max_v = n*max(v)
c = [[0 for j in range(max_v)] for i in range(n)]

for i in range(max_v):
    if i+1 > v[0]:
        c[0][i] = float('inf')
    else:
        c[0][i] = w[0]

for i in range(1,n):
    for j in range(max_v):
        if j+1 > v[i]:
            c[i][j] = min(c[i-1][j], w[i]+c[i-1][j-v[i]])
        else:
            c[i][j] = min(c[i-1][j], w[i])
        # if j+1 < w[i]:
        #     c[i][j] = c[i-1][j]
        # else:
        #     diff = (j+1)-w[i]
        #     if diff > 0:
        #         c[i][j] = max(c[i-1][j], v[i]+c[i-1][diff-1])
        #     else:
        #         c[i][j] = max(c[i-1][j], v[i])
for i in range(1,max_v+1)[::-1]:
    if c[-1][i-1] <= W:
        print(i)
        break


Measured memory_bytes: 305104
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int a,b,sum;
int main()
{
    fast;
    cin>>a>>b;
    if (b>=a)
       cout<<a;
    else
       cout<<a-1;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	string s;
	cin>>s;
	rep(i,s.size()){
		if(s[i]==',')s[i]=' ';
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define debug(x) std::cout << #x << ": " << x << endl
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

struct pt
{
    int x, y;
};

double dist(pt A, pt B)
{
    return sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y));
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif

    int n;
    cin >> n;
    vector<pt> a(n);
    for (auto &p : a)
        cin >> p.x >> p.y;
    vector<int> ord(n);
    iota(all(ord), 0);
    double sum = 0;
    int fact = 0;
    do
    {
        for (int i = 0; i + 1 < n; ++i)
            sum += dist(a[ord[i]], a[ord[i + 1]]);
        ++fact;
    }
    while (next_permutation(all(ord)));
    cout << setprecision(10) << fixed << sum / fact;

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<map>
#include<stack>
using namespace std;
int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };
/*
int main()
{
	int r, c;
	cin >> r >> c;
	int sy, sx, gy, gx;
	vector<vector<char>>field(r,vector<char>(c));
	sy--, sx--, gy--, gx--;
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> field[i][j];
		}
	}
	queue<pair<int,int>>q;
	q.push({ sx,sy });
	vector<vector<int>>d(c, vector<int> (r, -1));
	d[sx][sy] = 0;

	while (!q.empty())
	{
		pair<int, int>p = q.front;
		q.pop();
		for (int i = 0; i < 4; i++)
		{
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny] != -1 || field[nx][ny] == '#')continue;
			q.push({ nx,ny });
			d[nx][ny] = d[p.first][p.second] + 1;
		}
	}

	cout << d[gx][gy] << endl;
}*/


int main() 
{


		int n, x = 0;
		cin >> n;
		for (int i = 1; i <= n; i++) 
		{
			int a = i * 1.08;
			if (a == n) 
			{ 
				x = i; break;
			}
		}
		if (x == 0)
		{
			cout << ":(" << endl;
		}
		else
		{
			cout << x << endl;
		}
	

	



}



Measured memory_bytes: 3228
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

/*
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 U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }
*/

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int cnt = 0;
	REP(i, N) {
		string S;
		cin >> S;
		if (S == "A") {
			cnt++;
		}
		else {
			cnt--;
			if (cnt == -1) {
				cout << "NO" << endl;
				return 0;
			}
		}
	}
	if (cnt == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}



Measured memory_bytes: 3228
inf = 10**9 + 7


def merge(A, left, mid, right):
    cnt = 0
    L = A[left:mid]
    R = A[mid:right]
    L.append(inf)
    R.append(inf)
    i, j = 0, 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
        cnt += 1
    return cnt


def merge_sort(A, left, right):
    cnt = 0
    if left + 1 < right:
        mid = (left + right) // 2
        cnt += merge_sort(A, left, mid)
        cnt += merge_sort(A, mid, right)
        cnt += merge(A, left, mid, right)
    return cnt


n = int(input())
*A, = map(int, input().split())
cnt = merge_sort(A, 0, n)
print(*A)
print(cnt)


Measured memory_bytes: 61648
n, a, b = map(int, input().split())
s = input()
ans = []
domestic = 0
or_abroad = 0
for c in s:
    if c == 'a' and domestic + or_abroad < a + b:
        ans.append('Yes')
        domestic += 1
    elif c == 'b' and domestic + or_abroad < a + b and or_abroad < b:
        ans.append('Yes')
        or_abroad += 1
    else:
        ans.append('No')
print('\n'.join(ans))


Measured memory_bytes: 5108
a,b,c,x,y = map(int, input().split())
if x == y:
    if a+b >= 2*c:
        print(2*c*x)
    else:
        print((a+b)*x)
elif x > y:
    if a+b >= 2*c:
        if a >= 2*c:
            print(2*c*x)
        else:
            print(2*c*y + a*(x-y))
    else:
        if a >= 2*c:
            print((a+b)*y + 2*c*(x-y))
        else:
            print((a+b)*y + a*(x-y))
else:
    if a+b >= 2*c:
        if b >= 2*c:
            print(2*c*y)
        else:
            print(2*c*x + b*(y-x))
    else:
        if b >= 2*c:
            print((a+b)*x + 2*c*(y-x))
        else:
            print((a+b)*x + b*(y-x))

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	int d = sc.nextInt();
      	int ans = Math.min(b,d)-Math.max(a,c);
		System.out.println(ans > 0 ? ans : 0);
	}
}


Measured memory_bytes: 23892
import java.util.*;
import java.io.BufferedInputStream;

public class Main {
  public static void main(String[] args){
        Scanner sc = new Scanner (new BufferedInputStream(System.in));
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[][] A = new int[m][n];
        int[][] B = new int[m][n];
        for(int i = 0; i < m; ++i) {
            for(int j = 0; j < n; ++j) {
                A[i][j] = sc.nextInt();
            }
        }
        for(int i = 0; i < m; ++i) {
            for(int j = 0; j < n; ++j) {
                B[i][j] = sc.nextInt();
            }
        }
        int[][][] f = new int[m + 1][n + 1][(m + n) * 80];
    f[1][1][Math.abs(A[0][0] - B[0][0])] = 1;
        for(int i  = 1; i <= m; ++i) {
            for(int j = 1; j <= n; ++j) {

               // f[i][j][0] = 1;
                
                for(int k = 0; k < (m + n) * 80; ++k) {	
                    if(f[i][j][k] != 0) {
                      if(i != m) { 
                        int diffx = Math.abs(A[i][j - 1] - B[i][j - 1]);
                        f[i + 1][j][diffx + k] = 1;
                        f[i + 1][j][Math.abs(diffx - k)] = 1;
                      }
                      if(j != n) { 
                     	int diffy = Math.abs(A[i - 1][j] - B[i - 1][j]);
                        f[i][j + 1][diffy + k] = 1;
                        f[i][j + 1][Math.abs(diffy - k)] = 1;
                      }
                    }
                }
            }
        }
        for(int i = 0; i < (m + n) * 80; ++i) {
            if(f[m][n][i] != 0) {
                System.out.println(i);
                break;
            }
        }
        // System.out.println(f[m - 1][n - 1]);
      }
}


Measured memory_bytes: 497700
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()
ans = INF
for x in set(s):
	ans = min(ans, max([len(l) for l in s.split(x)]))

print(ans)

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

using namespace std;

int main(){
    int n; cin >> n;
    if(n%10==2 || n%10==4 || n%10==5 || n%10==7 ||n%10==9){
        cout << "hon";
    }else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
        cout << "pon";
    }else{
        cout << "bon";
    }
    return 0;
}

Measured memory_bytes: 3592
function Main(input) {
    const n = parseInt(input, 10);

    let m = n;
    while(true){
        if(m - 1000 <= 0){
            break;
        }
        m -= 1000;
    } 
    let oturi = 1000 - m;

    console.log(oturi);

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29584
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        if(S.equals("ABC")){
            System.out.println("ARC");
        }else{
            System.out.println("ABC");
        }
    }
}

Measured memory_bytes: 35716
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

ll H,W,K;
ll dp[110][8];

const ll MOD = 1000000007LL;

int main ()
{
    cin >> H >> W >> K;
    
    K--;
    dp[0][0] = 1;
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            for (int k = 0; k < (1 << (W - 1)); k++) {
                bool flag = true;
                for (int l = 0; l < W - 2; l++) {
                    if ( ((k >> l) & 1) && ((k >> (l + 1)) & 1) ) {
                        flag = false;
                    }
                }
                if (flag) {
                    if (j >= 1 && ((k >> (j - 1)) & 1)) {
                        dp[i + 1][j - 1] += dp[i][j];
                        dp[i + 1][j - 1] %= MOD;
                    } 
                    else if (j < W - 1 && ((k >> j) & 1)) {
                        dp[i + 1][j + 1] += dp[i][j];
                        dp[i + 1][j + 1] %= MOD;
                    }
                    else {
                        dp[i + 1][j] += dp[i][j];
                        dp[i + 1][j] %= MOD;
                    }
                }
            }
        }
    }

    cout << dp[H][K] % MOD << endl;
    
    return 0;
}


Measured memory_bytes: 256
"use strict";
const input = require("fs").readFileSync("/dev/stdin", "utf8");
const inputs = input.trim().split("\n");

const get = (inputs) => {
  const As = inputs[1].split(" ");
  const N = As.length;
  const bs = Array(As.length)
  for (let i = N; i > 0; i--) {
    const a = !!(+As[i-1]);
    const n = Math.floor(N/i);
    let count = false;
    let done = false;
    for (let j = n; j > 0; j--) {
      const b = bs[i*j];
      if (b === void 0) {
        bs[i*j] = ((count && a) || (!count && !a)) ? 0 : 1;
        done = true;
        break;
      } else if (b === 1) {
        count = !count
      }
    }
    if (!done) {
      return "-1"
    }
  }
  const balls = [];
  for (let i = 0; i < bs.length; i++) {
    if (bs[i] === 1) balls.push(i)
  }
  return balls.length+"\n"+balls.join(" ")
}

console.log( get(inputs) );

Measured memory_bytes: 28220
from collections import deque
H, W = list(map(int, input().split()))

S = [['#']*(W+2)] + [['#']+list(input())+['#'] for h in range(H)] + [['#']*(W+2)]
max_n = 0

for h1 in range(1,H+1):
  for w1 in range(1,W+1):
    if S[h1][w1] == '#':
      continue
    distance = [[-1 for _ in range(W+2)] for _ in range(H+2)]
    distance[h1][w1] = 0
    que = deque([])
    que.append([h1,w1])
    while que:
      h, w = que.popleft()
      if S[h-1][w] == '.' and distance[h-1][w] == -1:
        que.append([h-1,w])
        distance[h-1][w] = distance[h][w] + 1
      if S[h+1][w] == '.' and distance[h+1][w] == -1:
        que.append([h+1,w])
        distance[h+1][w] = distance[h][w] + 1
      if S[h][w-1] == '.' and distance[h][w-1] == -1:
        que.append([h,w-1])
        distance[h][w-1] = distance[h][w] + 1
      if S[h][w+1] == '.' and distance[h][w+1] == -1:
        que.append([h,w+1])
        distance[h][w+1] = distance[h][w] + 1
    hw_max_n = max([max(dis) for dis in distance])
    max_n = max(max_n, hw_max_n)
print(max_n)

Measured memory_bytes: 3316
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;

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

	int n, a, b;
	cin >> n >> a >> b;
	fore(i, a , b){
		if(i % n == 0){
			puts("OK");
			return 0;
		}
	}
	puts("NG");
	return 0;
}
// Write Here


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

vector<int> solve(const int N, const int Q, const vector<int>& a, const vector<int>& b, const vector<int>& p,
                  const vector<int>& x) {
  // Save parent
  unordered_map<int, int> parent_map;
  for (auto i = 0; i < N - 1; ++i) {
    parent_map[b[i]] = a[i];
  }

  // Apply each count
  vector<int> counter(N, 0);
  for (auto j = 0; j < Q; ++j) {
    counter[p[j] - 1] += x[j];
  }

  // Add parent count
  for (auto i = 2; i <= N; ++i) {
    counter[i - 1] += counter[parent_map[i] - 1];
  }

  return counter;
}

int main() {
  // Input
  int N, Q;
  cin >> N >> Q;

  vector<int> a(N - 1), b(N - 1);
  for (auto i = 0; i < N - 1; ++i) {
    cin >> a[i] >> b[i];
  }

  vector<int> p(Q), x(Q);
  for (auto j = 0; j < Q; ++j) {
    cin >> p[j] >> x[j];
  }

  // Solve
  auto ans = solve(N, Q, a, b, p, x);

  // Answer
  for (const auto& c : ans) {
    cout << c << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 12532
N = int(input())
cnt = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
    cnt[int(str(i)[0])][int(str(i)[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
        
print(ans)


Measured memory_bytes: 40460
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int h,w;
vector<string>field(h);
bool seen[100][100];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int cnt = 0;

int dfs(int y,int x,int &cnt){
    cnt++;
    seen[y][x] = true;
    rep(i,4){
        int ny = y+dy[i],nx = x+dx[i];
        if(ny<0 || ny>=h || nx<0 || nx>=w)continue;
        if(field[ny][nx] != '#')continue;
        if(seen[ny][nx])continue;
        cnt++;
        dfs(ny,nx,cnt);
    }
    return cnt;
}

int main(){
    ll n,m;cin>>n>>m;
    map<ll,ll>mp;
    rep(i,n){
        ll a,b;cin>>a>>b;
        mp[a] += b;
    }
    ll res = 0;
    for(auto p : mp){
        if(m<=0)break;
        res += (p.first*min(p.second,m));
        m -= min(m,p.second);
    }
    cout<<res<<endl;
}



Measured memory_bytes: 6528
def calc(num):
    a, b, c = 0, 0, 0
    for i in range(2 ** (w - 1)):
        kk = 0
        kkk = 0
        t = "0" * (w - 1 - len(bin(i)[2:])) + bin(i)[2:]
        if ("11" not in t):
            if (num <= w - 2):
                if (t[num] == "1"):
                    c += 1
                    kk = 1
            if (num - 1 >= 0):
                if (t[num - 1] == "1"):
                    b += 1
                    kkk = 1
            if (kk + kkk) == 0:
                a += 1
    return a, b, c


h, w, k = map(int, input().split())
k -= 1
mod = (10 ** 9) + 7
dp = [[0 for _ in range(w)] for _ in range(h + 1)]
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        a, b, c = calc(j)
        dp[i + 1][j] = ((dp[i][j] * a) + dp[i + 1][j]) % mod
        if j - 1 >= 0:
            dp[i + 1][j - 1] = ((dp[i][j] * b) + dp[i + 1][j - 1]) % mod
        if j + 1 < w:
            dp[i + 1][j + 1] = ((dp[i][j] * c) + dp[i + 1][j + 1]) % mod
print(dp[h][k])

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

int n;
int a[20];
int x[20][20];
int y[20][20];

int counter(int x) {
    if (x == 0) return 0;
    return counter(x & (x - 1)) + 1;
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        for (int j = 1; j <= a[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for (int bits = 1; bits < (1 << n); bits++) {
        bool ok = true;
        for (int i = 1; i <= n; i++) {
            if (!(bits & (1 << (i - 1)))) continue;
            for (int j = 1; j <= a[i]; j++) {
                if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if (ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
}


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

int main()
{
 int n,t=0;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<n;i++)
  {
      if(s[i]=='A' && s[i+1]=='B'&& s[i+2]=='C')
      t++;
  }
  cout<<t<<endl;
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())

dp = [0 for j in range(len(S)+1)]

for i in range(len(S)):
    if S[i] == "I":
        dp[i+1] = dp[i] + 1
    else:
        dp[i+1] = dp[i] - 1

print(max(dp))

Measured memory_bytes: 3060
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };
double a[110];
signed main() {
	int n;
	double sum = 0;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		sum += 1/a[i];
	}
	cout << fixed << setprecision(10) << 1/sum << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

struct edge {
	int from;
	int to;
	int cost;
	edge() {
		from = 0;
		to = 0;
		cost = 0;
	}
	edge(int from_, int to_, int cost_):from(from_), to(to_), cost(cost_) {

	}
};
ld p;
ld dfs1(const int now, const int from, const vector<vector<edge>>&edges,vector<ld>&come_pers,ld aper) {
	ld ans = 0;
	come_pers[now] = aper;
	for (auto e : edges[now]) {
		if (e.to == from)continue;
		else {
			ans += p*(e.cost + dfs1(e.to, now, edges,come_pers,aper*p));
		}
	}
	return ans;
}

int main() {cin >> p;
	int N; cin >> N;
	vector<vector<edge>>edges(N);
	for (int i = 0; i < N - 1; ++i) {
		int x, y, c; cin >> x >> y >> c;
		x--; y--;
		edges[x].push_back(edge(x, y, c));
		edges[y].push_back(edge(y, x, c));
	}
	vector<ld>come_pers(N);
	ld sum=dfs1(0, -1, edges, come_pers, 1);
	ld ans = accumulate(come_pers.begin(), come_pers.end(), 1.l)*sum;
	cout << setprecision(10) << fixed << ans << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

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

    int n, k;
    cin >> n >> k;

    int cnt = 0;
    for (int i = 1; i <= n; i += 2) ++cnt;
    if (k <= cnt) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}


Measured memory_bytes: 256
Q, H, S, D = map(int, input().split())
N = int(input())

if N % 2 == 0:
    Min = min(N*Q*4, N*H*2, N*S, N//2*D)
else:
    Min = min((N-1)*Q*4, (N-1)*H*2, (N-1)*S, N//2*D) + min(4*Q, 2*H, S)
print(Min)

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

#define rep(i,a,n) for (int i = a;i<=n;++i)
#define per(i,a,n) for (int i = n;i>=a;--i)
#define all(x) (x).begin(), (x).end()     
#define SZ(x) ((int)x.size())

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

mt19937 mrand(random_device{}());
ll rnd(ll a, ll b) { return a + mrand() % (b - a + 1); }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

const int mod = 998244353;
const int N = 3010;
int dp[N][N];
int n, s;

int mul(int a, int b) {
      a %= mod;
      b %= mod;
      ll c = 1ll * a * b;
      c %= mod;
      return c;
}

int add(int a, int b) {
      a %= mod;
      b %= mod;
      a += b;
      a %= mod;
      if (a < 0) a += mod;
      return a;
}

int main() {
      ios::sync_with_stdio(false); cin.tie(0);
#ifdef arrias
      freopen("a.txt", "r", stdin);
#endif
      cin >> n >> s;
      int ans = 0;
      rep(i, 1, n) {
            int a;
            cin >> a;
            rep(j, 0, s) {
                  dp[i][j] = add(dp[i][j], dp[i - 1][j]);
                  if (j >= a) {
                        dp[i][j] = add(dp[i][j], dp[i - 1][j - a]);
                        if (j == s) {
                              ans = add(ans, mul(dp[i - 1][s - a], (n - i + 1)));
                        }
                  }     
            }
            dp[i][a] = add(dp[i][a], i);
            if (a == s) {
                  ans = add(ans, mul(n - i + 1, i));
            }
      }
      cout << ans << "\n";
      return 0;
}

Measured memory_bytes: 35584
n=input()
k=int(input())
x=list(map(int,input().split()))
xa=[]
xb=[]
for i in range(len(x)):
	if x[i]<=(k/2):
		xa.append(x[i])
	else :
		xb.append(x[i])
suma=sum(xa)*2
sumb=(len(xb)*k-sum(xb))*2
print(suma+sumb)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;

  ll cnt = 1;
  bool before; //縦ならtrue, 横ならfalse
  for (int i = 0; i < n; i++) {
    if (s1[i] == s2[i]) {
      if (i == 0) {
        cnt *= 3;
      }
      else {
        if (before) cnt *= 2;
        else cnt *= 1;
      }
      before = true;
    }
    else {
      if (i == 0) {
        cnt *= 6;
      }
      else {
        if (before) cnt *= 2;
        else cnt *= 3;
      }
      before = false;
      i++;
    }
    cnt %= MOD;
  }
  
  cout << cnt << endl;
}


Measured memory_bytes: 256
ABCD = input()
for i in range(8):
        op = format(i, '03b')
        s = ""
        for j in range(3):
                s += ABCD[j] 
                if op[j] == "1":
                        s += "+" 
                else:
                        s += "-" 
        s += ABCD[3]
        if eval(s) == 7:
                print(s + "=7")
                break

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

using namespace std;

int main(void) {
	int n, m; cin >> n >> m;
	vector<long long int> a(n);
	for (int i = 0; i < n; ++i)cin >> a[i];
	sort(a.begin(), a.end());
	int i = 1;
	long long int s;
	while (m > 0) {
		i = 1;
		s = a[a.size() - 1] / 2;
		while (a[a.size() - i] >= s) {
			a[a.size() - i] /= 2;
			m--;
			i++;
			if (m == 0|| a.size() - i==-1) break;
		}
		sort(a.begin(), a.end());
	}
	cout << accumulate(a.begin(), a.end(), 0ll);
	return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

bool f[101];

int main()
{
	int N, K, ans = 0;

	cin >> N >> K;

	rep(i, K) {
		int d;

		cin >> d;
		rep(j, d) {
			int A;

			cin >> A;
			f[A] = true;
		}
	}

	repc(i, 1, N) if (!f[i]) ans++;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch CollatzProblem | diff CollatzProblem.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address CollatzProblem.cpp && ./a.out

/*
 
 2/19/2019
 
 19:27-19:34 WA
 
 */

int s;

int f(int n) {
  if(n%2) return 3*n+1;
  return n/2;
}
void solve() {
  SETI S;
  VI A(2,s); S.emplace(s);
  int i=2;
  while(true) {
    A.push_back(f(A[i-1]));
    if(S.count(A[i])) {
      cout<<i<<endl;
      return;
    }
    S.emplace(A[i++]);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>s;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
n = gets.to_i
nums = gets.split.map(&:to_i)
nums.sort!
possible = true
nums.each_with_index do |num, index|
  index += 1 if (n.odd? && index.odd?) || (n.even? && index.even?)
  unless num == index
    possible = false
    break
  end
end

factorial_count = n / 2

ans = 1
if possible
  factorial_count.times do
    ans = ans * 2 % MOD
  end
else
  ans = 0
end

puts ans


Measured memory_bytes: 8832
#include <stdio.h>

int main(){
   int a, b, tmp;
   while(scanf("%d %d",&a,&b)==2){
      if(a==0&&b==0) break;
      if(a>b){
         tmp=a; a=b; b=tmp; 
      }
      printf("%d %d\n",a,b);
   }
   return 0;
}

Measured memory_bytes: 600
import java.io.*;
import java.text.*;
import java.util.*;

public class Main {

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        solver s = new solver();
        int t = 1;
        while (t > 0) {
            s.solve();
            t--;
        }
        out.close();
    }

    static class InputReader {

        public BufferedReader br;
        public StringTokenizer token;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream), 32768);
            token = null;
        }

        public String sn() {
            while (token == null || !token.hasMoreTokens()) {
                try {
                    token = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return token.nextToken();
        }

        public int ni() {
            return Integer.parseInt(sn());
        }

        public String snl() throws IOException {
            return br.readLine();
        }

        public long nlo() {
            return Long.parseLong(sn());
        }

        public double nd() {
            return Double.parseDouble(sn());
        }

        public int[] na(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.ni();
            return a;
        }

        public long[] nal(int n) {
            long a[] = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.nlo();
            return a;
        }
    }

    static int inf = 5000013;

    static class solver {
        DecimalFormat df = new DecimalFormat("0.00000000");
        long maxi = Integer.MAX_VALUE;
        long mod = (long) (1e9 + 7);
        int n;
        List<Integer> list[];
        long dp[][];
        long ans = 0;

        void solve() {
            n = sc.ni();
            list = new ArrayList[n];
            dp = new long[n][2];
            for (int i = 0; i < n; i++)
                list[i] = new ArrayList<>();
            for (int i = 0; i < n - 1; i++) {
                int u = sc.ni() - 1;
                int v = sc.ni() - 1;
                list[u].add(v);
                list[v].add(u);
            }
            dfs(0, -1);
            long ans = (dp[0][0] + dp[0][1]) % mod;
            out.println(ans);
        }

        long pro(long a, long b) {
            return (a % mod * b % mod) % mod;
        }

        void dfs(int s, int p) {
            long b = 1, w = 1;
            for (int v : list[s]) {
                if (v != p) {
                    dfs(v, s);
                    b = pro(b, dp[v][1]);
                    w = pro(w, dp[v][0] + dp[v][1]);
                }
            }
            dp[s][0] = b;
            dp[s][1] = w;
        }
    }
}


Measured memory_bytes: 73416
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

//---------------------------

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    rep(i,s.size()-1){
        if(s[i] != s[i+1]) ans++;
    }

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

Measured memory_bytes: 512
package main
 
import(
  "fmt"
  "bufio"
  "os"
  "strings"
  "strconv"
  "log"
)
 

func main(){
  a,b := 0,0
  for {
    fmt.Scan(&a)
    fmt.Scan(&b)
    if a == 0 && b == 0{break}
    for i := 0; i < a; i++{
      for j := 0; j < b; j++{
        fmt.Print("#")
      }
      fmt.Println("")
    }
    fmt.Println("")
  }
}


var sc = bufio.NewScanner(os.Stdin)

func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}



//入力関係ライブラリ(Atcoder:yamanobori_oldさんのもの)
func make_liner(maxByte int) *bufio.Scanner {
  liner := bufio.NewScanner(os.Stdin)
  liner.Buffer(make([]uint8, 0, 8192), maxByte)
  return liner
}
func word_spliter() *bufio.Scanner {
  words := make_liner(8192) 
  words.Split(bufio.ScanWords)
  return words
}

func eGetLine(r *bufio.Scanner) string {
  if r.Scan() {
    return r.Text()
  }
  err := r.Err()
  if err != nil {
    log.Fatal(err)
  }
  // EOF
  return ""
}

func eGetInt(r *bufio.Scanner) int {
  line := eGetLine(r)
  return eAtoi(line)
}

func eAtoi(s string) int {
  n, err := strconv.Atoi(s)
  if err != nil {
    log.Fatal(err)
  }
  return n
}


Measured memory_bytes: 1184
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int main() {
    int a, b, c, d;
    set<int> s;
    for(int i = 0; i < 4; i++) {
        cin >> a;
        s.insert(a);
    }
    vector<int> ans = {1, 9, 7, 4};
    for(int i = 0; i < ans.size(); i++) {
        if (s.count(ans[i]) == 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
"""this is python work script"""

def sum_digits(i):
    """return sum input digits"""
    str_i = str(i)
    list_i = list(map(int, str_i))
    sum_list = sum(list_i)

    return sum_list

def solve(N, num_min, num_max):
    """solve problem"""
    result = 0
    for i in range(1, N+1):
        sum_d = sum_digits(i)
        if num_min <= sum_d <= num_max:
            result += i
    return result

def main():
    """main method"""
    N, A, B = list(map(int, input().split(' ')))
    answer = solve(N, A, B)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064