akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,a,b) for(int i=(a);i>=(b);i--)

using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;

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

  string S;

  cin >> S;
  int c = 0;
  rep(i,1, S.size()-1) {
    if (S[i-1] != S[i]) c++;
  }

  cout << c << endl;

}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define RREP1(i, N) for (int i = N; i >= 1; --i)
#define ALL(a) a.begin(), a.end()

int dp1[3030][3030];
int dp2[3030][3030];

int main() {
  int n, t;
  cin >> n >> t;
  int a[n + 1], b[n + 1];
  REP1(i, n) cin >> a[i] >> b[i];
  REP1(i, n) REP(j, t) {
    dp1[i][j] = dp1[i - 1][j];
    if (a[i] <= j) {
      dp1[i][j] = max(dp1[i][j], dp1[i - 1][j - a[i]] + b[i]);
    }
  }
  RREP1(i, n) REP(j, t) {
    dp2[i][j] = dp2[i + 1][j];
    if (a[i] <= j) {
      dp2[i][j] = max(dp2[i][j], dp2[i + 1][j - a[i]] + b[i]);
    }
  }
  int ans = 0;
  REP1(i, n) {
    int res = 0;
    REP(j, t) res = max(res, dp1[i - 1][j] + dp2[i + 1][t - 1 - j]);
    ans = max(ans, res + b[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 71936
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
struct TreeNode {
	int val;
	TreeNode *left;
	TreeNode *right;
	TreeNode(int x) : val(x), left(NULL), right(NULL) {}
	
};
bool judge(string s) {
	int n = s.length();
	if (n % 2) return false;
	for (int i = 0; i < n; i += 2) {
		if (s[i] != 'h' || s[i + 1] != 'i') return false;
	}
	return true;
}

int main() {
	string S;
	cin >> S;
	bool ok = judge(S);
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int n;
int k, p;

int main(void)
{
	scanf( "%d", &n );
	
	while( n-- ) {
		scanf( "%d %d", &k, &p );
		if ( k%p == 0 )
			printf( "%d\n", p );
		else
			printf( "%d\n", k%p );
	}
	
	return 0;
}

Measured memory_bytes: 596
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int n= scan.nextInt();
		int[] arr = new int[n];
		for(int i =0 ;i<n;i++){
			arr[i] = scan.nextInt();
		}
		int flag = 0;
		for(int j : arr){
			if((j%2)==0 && ((j%3)!=0) &&((j%5)!=0)){
				flag = 1;
				break;
			}
		}
		String ans = (flag==1)?"DENIED":"APPROVED";
		System.out.println(ans);
		// your code goes here
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        vl a(n);
        rep(i,n)cin>>a[i];
        deque<ll> d;
        rep(i,n){
            if(i%2==0){
                d.push_front(a[i]);
            }else{
                d.push_back(a[i]);
            }
        }
        if(n%2==0){
            rep(i,n){
            cout<<d.back()<<' ';
            d.pop_back();
        }
        }else{
        rep(i,n){
            cout<<d.front()<<' ';
            d.pop_front();
        }
        }
        cout<<endl;
    }

Measured memory_bytes: 5376
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    N, W = geta(int)
    INF = 10 << 60
    VMAX = 10**5
    cur = [INF] * (VMAX + 1)
    cur[0] = 0

    for i in range(N):
        w, v = geta(int)
        update = cur[:]

        for j in range(v, VMAX + 1):
            if cur[j - v] == INF: continue
            tmp = cur[j - v] + w
            if tmp < cur[j]: update[j] = tmp

        cur = update

    ans = 0
    for v in range(VMAX + 1):
        if cur[v] <= W: ans = v
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 93648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> S(N);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
  }
  sort(S.begin(),S.end());
  int A=0,B=0;
  for(int i=S.size()-1;i>=0;i-=2){
    A+=S.at(i);
  }
  for(int i=S.size()-2;i>=0;i-=2){
    B+=S.at(i);
  }
  cout<<A-B<<endl;
}

Measured memory_bytes: 256
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	int N;
	sci(N);
	pll arr[N];
	for (int i = 0; i < N; ++i) {
		scll(arr[i].fi), scll(arr[i].se);
	}
	SSORT(arr, N);
	set<pll> canAns;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			canAns.insert({arr[i].fi - arr[j].fi, arr[i].se - arr[j].se});
		}
	}
	int ans = INT_MAX;
	for (pll it : canAns) {
		map<pll, bool> done;
		int curr = 0;
		if (it.fi >= 0 && it.se >= 0) {
			SSORT(arr, N);
		} else if (it.fi >= 0) {
			sort(ALLN(arr, N), [](const pll& A, const pll& B){
				return mp(A.fi, -A.se) < mp(B.fi, -B.se);
			});
		} else if (it.fi < 0 && it.se >= 0) {
			sort(ALLN(arr, N), [](const pll& A, const pll& B){
				return mp(-A.fi, A.se) < mp(-B.fi, B.se);
			});
		} else {
			sort(ALLN(arr, N), [](const pll& A, const pll& B){
				return mp(-A.fi, -A.se) < mp(-B.fi, -B.se);
			});
		}
		for (int i = 0; i < N; ++i) {
			if (!done[mp(arr[i].fi - it.fi, arr[i].se - it.se)]) {
				++curr;
			}
			done[arr[i]] = 1;
		}
		ans = min(ans, curr);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
    char s[27];
    int i=0,a[10000]={0},b=0;
    scanf("%s",s);
    while(s[i]!='\0'){
        a[s[i]]++;
        if(a[s[i]]==2){
            b++;
            break;
        }
        i++;
    }
    if(b==1)
        printf("no\n");
    else 
        printf("yes\n");
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n,t;cin>>n>>t;
    vector<P> v;
    for(int i=0;i<n;i++){
        int c,t;cin>>c>>t;
        v.push_back(P(c,t));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        if(v[i].second>t) continue;
        cout<<v[i].first<<endl;
        return 0;
    }
    cout<<"TLE"<<endl;
}


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

d={n:0 for n in range(1,m+1)}

count=0

for i in range(n):
    k=[int(x) for x in input().split()]
    for j in range(1,len(k)):
        d[k[j]]+=1

for buf in range(1,m+1):
    if d[buf]==n:
        count+=1

print(count)

Measured memory_bytes: 3060
def pumi(i):
    if i == 0:
        H = '+'
    else:
        H = '-'
    return H
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
flag = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            if A +(1-2*i)*B +(1-2*j)*C + (1-2*k)*D == 7:
                flag = 1
                break
        if flag == 1:
             break
    if flag == 1:
        break
H = str(A)+pumi(i)+str(B)+pumi(j)+str(C)+pumi(k)+str(D)+'=7'
print(H)


Measured memory_bytes: 3064
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {
	int H, W;
	cin >> H >> W;

	vector<vector<int>> coin(H, vector<int>(W));

	REP(h, H) {
		REP(w, W) {
			int a;
			cin >> a;
			coin[h][w] = a % 2;
		}
	}

	bool flag_move = false;
	bool flag_rev = false;
	int wp = 0;
	int hp = 0;
	int cnt_move = 0;
	vector<vector<int>> move_track(H * W, vector<int>(4));

	REP(h, H) {
		if (!flag_rev) {
			for (int w = 0; w < W; w++) {
				if (flag_move) {
					//cout << hp + 1 << " " << wp + 1 << " " << h + 1 << " " << w + 1 << endl;
					move_track[cnt_move][0] = hp + 1;
					move_track[cnt_move][1] = wp + 1;
					move_track[cnt_move][2] = h + 1;
					move_track[cnt_move][3] = w + 1;
					cnt_move++;
				}
				if (coin[h][w] == 1) {
					flag_move = !flag_move;
				}
				wp = w;
				hp = h;
			}
		}
		else {
			for (int w = W - 1; w >= 0; w--) {
				if (flag_move) {
					//cout << hp + 1 << " " << wp + 1 << " " << h + 1 << " " << w + 1 << endl;
					move_track[cnt_move][0] = hp + 1;
					move_track[cnt_move][1] = wp + 1;
					move_track[cnt_move][2] = h + 1;
					move_track[cnt_move][3] = w + 1;
					cnt_move++;
				}
				if (coin[h][w] == 1) {
					flag_move = !flag_move;
				}
				wp = w;
				hp = h;
			}
		}
		flag_rev = !flag_rev;
	}

	cout << cnt_move << endl;
	REP (i, cnt_move) {
		cout << move_track[i][0] << " " << move_track[i][1] << " " << move_track[i][2] << " " << move_track[i][3] << endl;
	}

	return 0;

}

Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  int digit=0, t=n;
  while(t!=0){
    t/=10;digit++;
  }
  int num=0;
  for(int i=0;i<digit;i++)num+=pow(10, i);
  for(int i=1;i<=9;i++){
    if(n<=i*num){num*=i;break;}
  }
  cout << num << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long V = sc.nextLong();
		long B = sc.nextLong();
		long W = sc.nextLong();
		long T = sc.nextLong();
		long absD = Math.abs(B-A);
		long min = V-W;
		if (V <= W) {
			System.out.println("NO");
		} else {
			long ans = absD%min != 0 ? absD/min+1 : absD/min;
			if (ans <= T) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 35588
def gcd(x, y):
    return x if y == 0 else gcd(y, x % y)


def factorize(n):
    res = set()

    diviser = 2
    exponent = 0
    while n % diviser == 0:
        exponent += 1
        n //= diviser
    if exponent > 0:
        res.add((diviser, exponent))
    # 2の冪数を先に調べることで、
    # diviserを奇数に限定できる

    to = int(pow(n, 0.5))
    for diviser in range(3, to + 1, 2):
        exponent = 0
        while n % diviser == 0:
            exponent += 1
            n //= diviser
        if exponent > 0:
            res.add((diviser, exponent))

    if n > 1:
        res.add((n, 1))
        # n:素数の場合

    return res


def main():
    a, b = map(int, input().split())
    g = gcd(a, b)
    e = factorize(g)

    ans = len(e) + 1
    # factorizeで、素数の種類数が分かる
    # 1で割る分を +1 で加算する
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
	int a,b,t;
	cin >> a>> b >> t;
	int ans=0;
	int c=a;
	while(c <= t){
		ans +=b;
		c += a;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    long long int a,b,c,k,na,nb,nc,ans;
    cin>>a>>b>>c>>k;
    if(k%2==0)
    ans=a-b;
    else
        ans = b-a;

    if(abs(ans)>1000000000000000000)
        cout<<"unfair";
    else
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3548
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]

matrix = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
    if len(a[i])>2:
        b = a[i][2:]   
        for j in b:
            matrix[i][j-1] = 1
    print(*matrix[i])


Measured memory_bytes: 6388
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    x = II()
    yen = 100
    for i in range(1, 10000):
        yen = int(yen * 1.01)
        if yen >= x:
            print(i)
            return


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9220
#!/usr/bin/env python3
import math

N, H = map(int, input().split())

data = []

for _ in range(N):
    a, b = map(int, input().split())
    data.append([a, True])
    data.append([b, False])

data = sorted(data)[::-1]
ans = 0

for d in data:
    flag = d[1]
    if flag:
        ans += math.ceil(H / d[0])
        break
    else:
        ans += 1
        H -= d[0]
        if H <= 0:
            break
    
print(ans)

Measured memory_bytes: 35608
N,Z,W = map(int,input().split())
a = list(map(int,input().split()))

std = abs(Z-W)
last = a[N-1]

absList = [abs(last-i) for i in a]
absList.pop(N-1)
ans = max(abs(last-W), abs(last-a[N-2]))
for i in range(N-1):
	testList = absList[i+1:]
	if min(absList) > ans:
		ans = max(absList)
print(ans)

Measured memory_bytes: 3316
N, K = map(int, input().split())
RSP = list(map(int, input().split())) #TSP[0]が'r'に対応
T = input()

dp = [[0]*3 for _ in range (N+1)]
#print(dp, sep="\n")
winsum = 0

Ti = [""]*K
for i in range(N):
    Ti[i%K] += T[i]

#print(Ti)
for Ts in Ti:
    dp = [[0]*3 for _ in range (len(Ts)+1)]
    for i in range(1,len(Ts)+1):
        for j in range(3): #0,1,2でr,s,p，次に選ぶ行動
            for k in range(3): #前に選んだ行動
                #print(Ts[i-1], i, j, k)
                if j == k:
                    continue
                elif j == 2 and Ts[i-1] == 'r':
                    dp[i][j] = max(dp[i][j], dp[i-1][k]+RSP[j])
                elif j == 0 and Ts[i-1] == 's':
                    dp[i][j] = max(dp[i][j], dp[i-1][k]+RSP[j])
                elif j == 1 and Ts[i-1] == 'p':
                    dp[i][j] = max(dp[i][j], dp[i-1][k]+RSP[j])
                else: #じゃんけんで勝っていないと，前の状態を保持
                    dp[i][j] = max(dp[i][j], dp[i-1][k])
        #print(*dp,sep="\n")
    winsum += max(dp[i])
print(winsum)

Measured memory_bytes: 23480
fn readline<T: std::str::FromStr>() -> Vec<T> {
    let mut buff = String::new();
    std::io::stdin().read_line(&mut buff).ok();
    buff.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let buff = readline::<i32>();
    let a = buff[0];
    let b = buff[1];
    println!("{} {}", a * b, 2 * (a + b))
}


Measured memory_bytes: 5028
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Created by zzt on 17-1-29.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(scanner.nextInt());
        }
        int ret = set.size();
        if (ret%2==0)
            ret--;
        System.out.println(ret);
    }
}

Measured memory_bytes: 51220
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

fn main() {
    let n = get!(usize);
    let aa = get!(u64; n);

    let mut xor = aa.iter().fold(0, |a, &b| a ^ b);
    let nums = aa.iter()
        .map(|a| a.trailing_zeros())
        .collect::<HashSet<_>>();

    let mut ans = 0;
    while xor != 0 {
        ans += 1;
        let i = 64 - xor.leading_zeros();
        if !nums.contains(&(i - 1)) {
            println!("{}", -1);
            return;
        }

        xor = (!xor) & ((1 << i) - 1);
    }

    println!("{}", ans);
}


Measured memory_bytes: 6396
import numpy as np
A, B, C = map(int, input().split())

r = A % B
div_list = []
for i in range(B):
    div_list.append(r*i)

div_array = np.array(div_list) % B

if np.any(C in div_array):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 12504
#include <iostream>
using namespace std;
 
int main() {
	int a,b,x;
	cin>>a>>b>>x;
	if(a>x){
		cout<<"NO"<<endl;
	}
	else if(a+b<x){
		cout<<"NO"<<endl;
	}
	else{
		cout<<"YES"<<endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();

      String[] info = new String[n];

      for(int i = 0;i < n;i++){
      	info[i] = sc.next()+"_"+(1100-sc.nextInt())+"_"+(i+1);
      }

      Arrays.sort(info);

      for(int i = 0;i < n;i++){
      	String[] s = info[i].split("_");
        System.out.println(s[2]);
      }


  }
}


Measured memory_bytes: 23764
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from collections import Counter
def m():
    N, P = map(int, input().split())
    if N == 1:
        return P
    x = prime_factorize(P)
    a = 1
    c = Counter(x)
    ans = [1]
    for k, v in c.items():
        tmp = v // N
        if tmp != 0:
            ans.append(k**tmp)


    for i in ans: a*=i
    return a


print(m())


Measured memory_bytes: 65676
def main():
    N = int(input())
    A = list(map(int, input().split()))
    dp = [[-1 * pow(10, 15)] * 3 for _ in range(N)]
    if N == 2:
        return max(A)
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    dp[2][2] = A[2]
    for i in range(N):
        if i < 2:
            continue
        dp[i][0] = dp[i-2][0] + A[i]
        if i < 3:
            continue
        dp[i][1] = max(dp[i-3][0], dp[i-2][1]) + A[i]
        if i < 4:
            continue
        dp[i][2] = max(dp[i-4][0], dp[i-3][1], dp[i-2][2]) + A[i]
    if N % 2 == 0:
        return max(dp[-1][1], dp[-2][0])
    else:
        return max(dp[-1][2], dp[-2][1], dp[-3][0])
print(main())


Measured memory_bytes: 66608
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  xs <- getIntList
  let ans = case lookup 0 (zip xs [1..]) of
        Just i -> i
  print ans


Measured memory_bytes: 3768
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String line1 = sc.nextLine();
        
        char[] next = line1.toCharArray();
        next[0]++;
        
        System.out.println(next[0]);
    }
}


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

using namespace std;

bool contains(int n, const vector<int>& d) {
	string s(to_string(n));

	for(auto&& c : s) {
		int c_int = c - '0';

		auto it = find(d.begin(), d.end(), c_int);

		if(it == d.end()) {
			return false;
		}
	}

	return true;
}

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

	vector<int> d(10);
	for(int i = 0; i < 10; ++i) { d[i] = i; }

	for(int i = 0; i < k; ++i) {
		int di;
		cin >> di;

		auto it = std::find(d.begin(), d.end(), di);
		d.erase(it);
	}

	while(true) {
		if(contains(n, d)) {
			break;
		}

		++n;
	}

	cout << n << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 200000

int main(void) {
    int i,n,minv,maxv;
    int r[N];

    scanf("%d", &n);

    for(i=0; i<n; i++) {
        scanf("%d", &r[i]);
    }

    minv = r[0];
    maxv = r[1]-r[0];

    for(i=1; i<n; i++) {
        if(maxv < r[i]-minv)
            maxv = r[i]-minv;
        else if(minv > r[i])
            minv = r[i];
    }

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

    return 0;


}


Measured memory_bytes: 2512
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
#n,k= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しに4 3sum変数使用はsum関数使用できないので注意
b = input()
matchplace = []
diff = len(a)-len(b)
for i in range(len(a)-len(b)+1):
    cut = a[i:i+(len(b))]
    for k in range(len(cut)):
        if not(cut[k] == b[k] or cut[k] == '?'):
            break
        else:
            if k == len(b)-1:
                matchplace.append(i)
wordlist = []
for i in matchplace:
    cword = [ a[:i],b,a[(i+len(b)):] ]
    cword = ''.join(cword)
    cword = cword.replace('?','a')
    wordlist.append(cword)
if len(matchplace) == 0:
    print("UNRESTORABLE")
else:
    wordlist.sort()
    print(wordlist[0])

Measured memory_bytes: 5316
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        hoge();
        System.Console.ReadLine();
    }

    public static void hoge()
    {
        var line = System.Console.ReadLine().Split(' ').ToArray();
        var s = line[0];
        var t = line[1];

        var ints = System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var a = ints[0];
        var b = ints[1];

        var u = System.Console.ReadLine();

        if (u == s)
        {
            a -= 1;
        }
        else
        {
            b -= 1;
        }

        System.Console.WriteLine(a + " " + b);
    }


}



Measured memory_bytes: 13396
#include <iostream>
#include <limits.h>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b <= a + c && a + b <= b + c) cout << a + b;
	else if (a + c <= a + b && a + c <= b + c) cout << a + c;
	else cout << b + c;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!
    val inputs = readLine()!!.split(" ").map(String::toInt)
    var attemptedTimes = 0
    var devidedValues = inputs
    while (devidedValues.all { it -> it % 2 == 0 }) {
        devidedValues = devidedValues.map { it -> it / 2 }
        attemptedTimes += 1
    }
    println(attemptedTimes)
}

Measured memory_bytes: 36032
from itertools import starmap


def cross(a: complex, b: complex) -> float:
    return float(a.real * b.imag - a.imag * b.real)


def is_intersected(p0: complex, p1: complex, p2: complex, p3: complex) -> bool:
    max_x1, min_x1 = (p0.real, p1.real) if p0.real > p1.real else (p1.real, p0.real)
    max_x2, min_x2 = (p2.real, p3.real) if p2.real > p3.real else (p3.real, p2.real)
    if max_x1 < min_x2 or max_x2 < min_x1:
        return False
    max_y1, min_y1 = (p0.imag, p1.imag) if p0.imag > p1.imag else (p1.imag, p0.imag)
    max_y2, min_y2 = (p2.imag, p3.imag) if p2.imag > p3.imag else (p3.imag, p2.imag)
    if max_y1 < min_y2 or max_y2 < min_y1:
        return False

    return (cross(p1 - p0, p2 - p0) * cross(p1 - p0, p3 - p0) < 1e-6
            and cross(p3 - p2, p0 - p2) * cross(p3 - p2, p1 - p2) < 1e-6)


def point_to_segment(p0: complex, p1: complex, p2: complex) -> float:
    prod = (p1 - p0).conjugate() * (p2 - p0)
    if prod.real <= 1e-6:
        return abs(p2 - p0)
    l = abs(p1 - p0)  # noqa: E741
    d = prod.real / l
    if d >= l:
        return abs(p2 - p1)
    return abs(prod.imag) / l


if __name__ == "__main__":
    q = int(input())
    for _ in range(q):
        x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3 = map(lambda x: int(x),
                                                             input().split())
        p0 = complex(x_p0, y_p0)
        p1 = complex(x_p1, y_p1)
        p2 = complex(x_p2, y_p2)
        p3 = complex(x_p3, y_p3)

        if is_intersected(p0, p1, p2, p3):
            print(0)
            continue

        ans = min(starmap(point_to_segment,
                  ((p0, p1, p2), (p0, p1, p3), (p2, p3, p0), (p2, p3, p1))))
        print(ans)



Measured memory_bytes: 5708
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
 
#define limit (int) (2e5 + 5)
#define mod (int) (1e9 + 7)

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

int a[limit];

int main()
{
    // ios_base::sync_with_stdio(false);cin.tie(NULL);

    int n;
    cin >> n;
    lli cy=1000,ans = 1000,cs = 0;

    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }

    bool flag = false;

    for (int i = 1; i < n; ++i)
    {
        if(a[i] == a[0])
            continue;

        if (a[i] > a[0])
        {
            flag = true;
        }

        break;
    }

    if (flag)
    {
        cs = cy/a[0];
        cy %= a[0];
    }

    for (int i = 1; i < n-1; ++i)
    {
        // cout << cy << " " << cs << "\n";

        if (a[i+1] >= a[i] && a[i-1] >= a[i])
        {
            cs += cy/a[i];
            cy %= a[i];
            continue;
        }

        if (a[i] >= a[i-1] && a[i] >= a[i+1])
        {
            // cout << a[i] << " " << a[i+1] << "\n";
            // cout << cs << "\n";
            cy += cs*a[i];
            cs = 0;
            ans = cy;
        }
    }

    // cout << cy << " " << cs << "\n";
    ans = max(ans , cy + cs*a[n-1]); 

    cout << ans;
    return 0;
}







Measured memory_bytes: 3640
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long X = lread();
    while (true)
    {
        long l = factorize(X).length;
        if (l == 1)
        {
            writeln(X);
            return;
        }
        X++;
    }
}

/// 素因数分解
long[] factorize(long x)
{
    assert(0 < x, "x is negative");
    long[] result;
    while ((x & 1) == 0)
    {
        x /= 2;
        result ~= 2;
    }
    for (long i = 3; i * i <= x; i += 2)
        while (x % i == 0)
        {
            x /= i;
            result ~= i;
        }
    if (x != 1)
        result ~= x;
    return result;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(ll i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int mod=1000000007;
int main()
{
    int h,w;
    cin>>h>>w;
    string str[h];
    rep(i,0,h)
    cin>>str[i];
    int dp[h][w];
    fill(dp);
    rep(i,0,h)
    {
        if(str[i][0]=='.')
            dp[i][0]=1;
        else
            break;
    }
    rep(i,0,w)
    {
        if(str[0][i]=='.')
            dp[0][i]=1;
        else
            break;
    }
    rep(i,1,h)
    {
        rep(j,1,w)
        {
            if(str[i][j]=='#')
                continue;
            dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=mod;
            if(dp[i][j]<0)
                dp[i][j]+=mod;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int k;
    cin>>k;
    string s="ACL";
    string res="";
    for(int i=0;i<k;i++)
    {
        res+=s;
    }
    cout<<res<<endl;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    ll N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    ll key = 1;
    ll ans = 0;
    rep(i,N)
    {
        if(a[i] == key) key++;
        else ans++;
    }
    if(key != 1) cout << ans << endl;
    else cout << -1 << endl;


}


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

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    double pi = acos(-1);
    int n;
    cin >> n;
    double ans = 2 * pi * n;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14
 
signed main(){
    int x, y, z;
    cin >> x >> y >> z;

    x -= z * 2;
    int cnt = 0;
    while(1){
        x -= y;
        cnt ++;
        if(x >= z){
            x -= z;
            if(x >= y);
            else
                break;
        }
        else
            break;
    }
    cout << cnt << endl;    
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			int M = scan.nextInt();

			//int[][]dp = new int[N][M];

			ArrayList<Integer> are = enum_div(M);

			int max = 0;
			for(Integer i:are) {
				int wari = M/i;
				if(wari>=N) {
					max = i;
				}
			}


			System.out.println(max);
		}


	}

	private static ArrayList<Integer> enum_div(int n){//数字１〜ｎまでの約数を全部Allaylistに詰め込むメソッド
		ArrayList<Integer> ret = new ArrayList<Integer>();
		for(int i = 1;i*i<=n;i++) {
			if(n%i==0) {
				ret.add(i);
				if(i*i!=n){
					ret.add(n/i);
				}
			}
		}

		//ただここまでだと格納した約数はソートされてない

		Collections.sort(ret);//int型、Sting型くらいの格納した奴ならコレクションクラスのソートが使える。
		//ソートしてからcollections.reverseつかえば降順にもできる
		return ret;



	}

}


Measured memory_bytes: 35608
import Control.Applicative
import Control.Monad
import Data.List

type Dice = (Int, Int, Int, Int, Int, Int)

top :: Dice -> Int
top (a, _, _, _, _, _) = a

spinl :: Dice -> Dice
spinl (a, b, c, d, e, f) = (a, d, b, e, c, f)

spinr :: Dice -> Dice
spinr (a, b, c, d, e, f) = (a, c, e, b, d, f)

moven :: Dice -> Dice
moven (a, b, c, d, e, f) = (b, f, c, d, a, e)

moves :: Dice -> Dice
moves (a, b, c, d, e, f) = (e, a, c, d, f, b)

movee :: Dice -> Dice
movee (a, b, c, d, e, f) = (d, b, a, f, e, c)

movew :: Dice -> Dice
movew (a, b, c, d, e, f) = (c, b, f, a, e, d)

move :: Char -> Dice -> Dice
move 'N' = moven
move 'S' = moves
move 'E' = movee
move 'W' = movew

makeDice [a, b, c, d, e, f] = (a, b, c, d, e, f)


main = foldl (flip ($)) <$> (makeDice . map read . words <$> getLine) <*> (map move <$> getLine) >>= print . top



Measured memory_bytes: 3652
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    sort(ALL(a));

    int ans = 0;
    int m = n;
    int pre = 0;
    rep(i, n){
        int tmp = a[i] - pre;
        if(tmp % 2){
            ans ^= m;
        }
        pre = a[i];
        m--;
    }

    if(ans == 0){
        cout << "second" << endl;
    }else{
        cout << "first" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;


public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		String s=sc.next();

		char c[]=s.toCharArray();
		int a=(c[0]-'0')*10 + (c[1]-'0');
		int b=(c[2]-'0')*10 + (c[3]-'0');

		if(a>12||a==0){
			if(b>12 || b==0)System.out.println("NA");
			else System.out.println("YYMM");
		}
		else if(b>12 || b==0)System.out.println("MMYY");
		else System.out.println("AMBIGUOUS");

	}
}

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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    ll t, a;
    cin >> t >> a;
    ll v1 = t, v2 = a;
    for (int i = 1; i < n; ++i) {
        cin >> t >> a;
        ll k = max((v1 + t - 1) / t, (v2 + a - 1) / a);
        v1 = t * k;
        v2 = a * k;
    }
    cout << v1 + v2;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			int c=sc.nextInt(), n=sc.nextInt(), m=sc.nextInt(), s=sc.nextInt(), d=sc.nextInt();
			if(c == 0) break;

			int[][] t = new int[n+1][n+1];
			while(m-- > 0){
				int a=sc.nextInt(), b=sc.nextInt(), f=sc.nextInt();
				t[a][b] = t[b][a] = f;
			}

			Queue<State> open = new PriorityQueue<State>();
			Set<State> closed = new HashSet<State>();

			State st = new State(0,s,c);
			State ans = null;

			open.add(st);
			while(!open.isEmpty()){
				st = open.poll();
				if(closed.contains(st)) continue;
				closed.add(st);
				if(st.city == d){
					ans = st;
					break;
				}
				open.addAll(st.nexts(t));
			}
			System.out.println(ans.cost);
		}
	}

	public static class State implements Comparable<State>{
		int cost, city, rem;

		State(int cost, int city, int rem){
			this.cost = cost;
			this.city = city;
			this.rem = rem;
		}

		List<State> nexts(int[][] t){
			List<State> sts = new ArrayList<State>();

			for(int i=1;i<t.length;i++){
				if(t[city][i] > 0){
					if(rem > 0) sts.add(new State(cost+t[city][i]/2,i,rem-1));
					sts.add(new State(cost+t[city][i],i,rem));
				}
			}

			return sts;
		}

		public int compareTo(State st){
			return cost - st.cost;
		}

		public boolean equals(Object o){
			State st = (State)o;
			return this.city == st.city && this.rem == st.rem;
		}

		public int hashCode(){
			return city * 100 + rem;
		}
	}
}

Measured memory_bytes: 13000
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX 100006
#define f first
#define s second
#define N 1e18+10
void solve()
{
    int n,c=0;
    ld x,y,d;  cin>>n>>d;
    while(n--)
    {
        cin>>x>>y;
        if(sqrt(x*x+y*y)<=d) c++;
    }cout<<c;
}
int main()
{
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 3828
#include <stdio.h>
#include <string.h>
int main(void){
    int i,j,n,h,len;
    char str[201],tmp[201];
     
    while(1){
        scanf("%s", &str);
        if(str[0]=='-') break;
        len=strlen(str);
        scanf("%d", &n);
        for(i=0;i<n;i++){
            scanf("%d", &h);
            for(j=0;j<len;j++) tmp[j]=str[j];
            for(j=0;j<len-h;j++){
                str[j]=str[j+h];
            }
            for(j=0;j<h;j++){
                str[j+len-h]=tmp[j];
            }
        }
        printf("%s\n",str);
    }
    return 0;
}


Measured memory_bytes: 2040
from collections import deque
n,*l=map(int,open(0).read().split())
con=[[] for _ in range(n)]
dist=[None]*n
dist[0]=0
for a,b,c in zip(*[iter(l)]*3):
	con[a-1].append((b-1,c%2))
	con[b-1].append((a-1,c%2))

que=deque([0])
while que:
	cur=que.popleft()
	for nxt,d in con[cur]:
		if dist[nxt]==None:
			que.append(nxt)
			dist[nxt]=dist[cur]^d

print(*dist,sep="\n")

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

//freopen("file_name.in", "r", stdin);
//freopen("file_name.out", "w", stdout);

#define fr(i,n) for(int i=0;i<n;i++)
#define frr(i,a,b) for(int i =a;i<=b;i++)

typedef long long ll;

#define eb emplace_back

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

#define fi first
#define se second
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

//-DBL_MAX
//__builtin_popcountll(ll x) - __builtin_popcount(int x)

#define prin(a) cout << #a << " = " << (a) << endl
#define prinv(v) {cout << #v << " = "; for(auto it : v) cout << it << " "; cout << endl;}
#define ppal(a)  cout << #a << endl

const int N = -1;

string s;

int cnt[2];

int main(){
    cin >> s;
    
    fr(i,s.size()){
        cnt[s[i]-'0']++;
    }
    
    cout << 2*min(cnt[0],cnt[1]) << endl;
	
	return 0;
}


Measured memory_bytes: 512
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N = int(input())
print(180*N-360)


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

using namespace std;

#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int l = -1;
    int r = n - 1;
    while (r - l > 1)
    {
        int med = (l + r) / 2;
        int vv = max(0ll, v - med - p);
        int cur = vv * m;
        int fl = true;
        for (int i = n - p; i > med; --i)
        {
            if (a[med] + m < a[i])
            {
                fl = false;
                break;
            }
            cur -= min(a[med] + m - a[i], m);
        }
        if (!fl || cur > 0)
        {
            l = med;
        }
        else
        {
            r = med;
        }
    }
    cout << n - r << endl;
    return 0;
}


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

int main(){
  int N,M;
  int s,c;
  int ans[3];
  int judge[3];
  for(int i = 0; i < 3; i++){
    judge[i]=0;
    ans[i]=0;
  }
  
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    cin >> s >> c;
    if(judge[N-s]==1&&ans[N-s]!=c){
      cout << "-1" << endl;
      return 0;
    }
    judge[N-s]=1;
    ans[N-s]=c;
  }
  if(N>1){
    if(judge[N-1]==0&&ans[N-1]==0)ans[N-1]=1;
  }
  if(ans[N-1]==0&&N!=1){
    cout << "-1" << endl;
    return 0;
  }
  int out = 0;
  cout << ans[2]*100+ans[1]*10+ans[0] << endl;
}


Measured memory_bytes: 256
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <random>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

class timer {
    vector<timer> timers;
    int n = 0;
public:
    double limit = 9.8;
    double t = 0;
    timer() {}
    timer(int size) : timers(size) {}
    bool elapses() const {
        return time() - t > limit;
    }
    void measure() {
        t = time() - t;
        ++n;
    }
    void measure(char id) {
        timers[id].measure();
    }
    void print() {
        if (n % 2)
            measure();
        for (int i = 0; i < 128; ++i) {
            if (timers[i].n)
                cerr << (char)i << ' ' << timers[i].t << 's' << endl;
        }
        cerr << "  " << t << 's' << endl;
    }
    static double time() {
#ifdef LOCAL
        return __rdtsc() / 3.3e9;
#else
        unsigned long long a, d;
        __asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
        return (d << 32 | a) / 2.8e9;
#endif
    }
} timer(128);

class {
    //unsigned y = 2463534242;
    unsigned y = random_device()();
public:
    unsigned next() {
        return y ^= (y ^= (y ^= y << 13) >> 17) << 5;
    }
    int next(int b) {
        return next() % b;
    }
    int next(int a, int b) {
        return next(b - a) + a;
    }
    double nextDouble(double b = 1) {
        return b * next() / 4294967296.0;
    }
    double nextDouble(double a, double b) {
        return nextDouble(b - a) + a;
    }
    int operator() (int b) {
        return next(b);
    }
} rando;

int main() {
    int n;
    while (cin >> n) {
        vector<int> a(n);
        for (int& i : a) cin >> i;
        int sm = 0;
        for (int i = 0; i < n; ) {
            int j = i;
            for (; j < n && a[j] == a[i]; ++j);
            sm += (j - i) / 2;
            i = j;
        }
        cout << sm << endl;
    }
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i,n) repi(i,0,n)

string S;
int dp[2222][2222];
int trans[2222][2222];

const int rec(const int L, const int R) {
  int& ret = dp[L][R];
  if(ret + 1) return ret;
  if(L > R) return ret = 0;
  if(S[L] == S[R]) {
    trans[L][R] = 0;
    return ret = rec(L + 1, R - 1) + (L == R ? 1 : 2);
  }

  const int r1 = rec(L + 1, R);
  const int r2 = rec(L, R - 1);

  if(r1 > r2) {
    trans[L][R] = 1;
    return ret = r1;
  }
  else {
    trans[L][R] = 2;
    return ret = r2;
  }

}

int main() {
  while(cin >> S) {

    for(int i=0; i<2222; i++)
      for(int j=0; j<2222; j++)
        dp[i][j] = trans[i][j] = -1;

    int N = S.size();
    rec(0, N);
    int L = 0, R = N;
    string res;
    while(L < R) {
      if(trans[L][R] == 0) {
        res += S[L];
        L ++, R --;
      }
      if(trans[L][R] == 1) {
        L ++;
      }
      if(trans[L][R] == 2) {
        R --;
      }
    }
    cout << res;
    if(L == R) cout << S[L];
    reverse(res.begin(), res.end());
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 41764