akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a[100005]={};
  cin >> n;
  set<int> s;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    s.insert(a[i]);
  }
  cout << s.size() << endl;
}




Measured memory_bytes: 8192
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())-1

ans = s[k]

print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define MAX 1e9+7
#define MIN -MAX
#define i(a) cin>>a
#define in(a,b) cin>>a>>b
#define o(a) cout<<a
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loop1(i,a,b) for(ll i=a;i<=b;i++)
#define v(a) vector<ll>a
#define mp(a,b) make_pair(a,b)
#define NO_OF_CHARS 256
using namespace std;
int countDivisors(int n)
{
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            // If divisors are equal,
            // count only one
            if (n / i == i)
                cnt++;

            else // Otherwise count both
                cnt = cnt + 2;
        }
    }
    return cnt;
}
int power(int x,int y)
{
    int temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}
int lenOfLongIncSubArr(int arr[], int n)
{
    // 'max' to store the length of longest
    // increasing subarray
    // 'len' to store the lengths of longest
    // increasing subarray at diiferent
    // instants of time
    int max = 1, len = 1;

    // traverse the array from the 2nd element
    for (int i=1; i<n; i++)
    {
        // if current element if greater than previous
        // element, then this element helps in building
        // up the previous increasing subarray encountered
        // so far
        if (arr[i] <= arr[i-1])
            len++;
        else
        {
            // check if 'max' length is less than the length
            // of the current increasing subarray. If true,
            // then update 'max'
            if (max < len)
                max = len;

            // reset 'len' to 1 as from this element
            // again the length of the new increasing
            // subarray is being calculated
            len = 1;
        }
    }

    // comparing the length of the last
    // increasing subarray with 'max'
    if (max < len)
        max = len;

    // required maximum length
    return max;
}
//In one operation u can choose any element in an array
//and divide it by 2.The value of K is given and we can divide
//K times.We have to find the minm sum.
int main(){
    string s,t;
    ll c=0;
    cin>>s;
    cin>>t;
    for(ll i=0;i<s.length();i++){
        if(s[i]==t[i])c++;
    }
    cout<<c;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

#define FOR(var,start,end) for(int var=start; var<end; var++)
#define REP(var,cnt) FOR(var,0,cnt)

int main2(void) {
	string a1, a2;
	cin >> a1 >> a2;
	
	string b1, b2;
	b1 = a1; reverse(b1.begin(), b1.end());
	b2 = a2; reverse(b2.begin(), b2.end());
	
	if ( a1 == b2 && a2 == b1 ) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	
	return 0;
	
}

int main(void) {
	
	unsigned long a, b;
	cin >> a;
	
	b = sqrt(a);
	
	cout << b*b << endl;
	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

int main() {
    for( int i = 1 ; i <= 10000 ; i++ ) {
        int x ;
        std::cin >> x ;
        if( x != 0 ) {
            std::cout << "Case " << i << ": " << x << std::endl ;
        } else {
            break ;
        }
    }
}


Measured memory_bytes: 3012
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(void){
    int N;
    cin >> N;
    string S[N];
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    int mp[N][26];
    for(int i=0;i<N;i++){
        for(int j=0;j<26;j++){
            mp[i][j] = 0;
        }
    }
    
    for(int i=0;i<N;i++){
        for(int j=0;j<S[i].size();j++){
            int k = S[i][j] - 97;
            mp[i][k]++;
        }
    }
    string ans;
    for(int i=0;i<26;i++){
        int r = 100;
        for(int j=0;j<N;j++){
            r = min(r,mp[j][i]);
        }
        while(r > 0){
            ans.push_back(i + 97);
            r--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,m,i,MAX;
	long long sum;
	cin >> n;
	sum = 0;
	MAX = -1;
	for(i = 0; i < n; i++){
		cin >> m;
		if(MAX > m){
			sum += MAX - m;
			m += MAX - m;
		}
		MAX = max(MAX,m);
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 2e7 + 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 1e4 + 17;

int n, x, y;
string s;
vector<int> a, b;
bool dp[2][2][maxn];

bool read() {
    if (scanf("%s", buff) != 1)
        return false;

    scanf("%d %d", &x, &y);
    return true;
}

int sgn(int x) {
    return x >= 0 ? 0 : 1;
}

bool calc(vector<int> a, int x) {
    memset(dp, false, sizeof(dp));
    int nn = sz(a);
    dp[0][0][0] = true;

    for (int i = 0; i < nn; ++i) {
        for (int j = 0; j <= 8000; ++j)
            dp[i & 1 ^ 1][0][j] = dp[i & 1 ^ 1][1][j] = false;

        for (int j = 0; j <= 8000; ++j) {
            if (dp[i & 1][0][j]) {
                int y = j;
                dp[i & 1 ^ 1][sgn(y + a[i])][abs(y + a[i])] = true;
                dp[i & 1 ^ 1][sgn(y - a[i])][abs(y - a[i])] = true;
            }

            if (dp[i & 1][1][j]) {
                int y = -j;
                dp[i & 1 ^ 1][sgn(y + a[i])][abs(y + a[i])] = true;
                dp[i & 1 ^ 1][sgn(y - a[i])][abs(y - a[i])] = true;
            }
        }
    }

    return dp[nn & 1][sgn(x)][abs(x)];
}

void solve() {
    s = buff;
    n = sz(s);

    int len = 0, c = 0;

    for (int i = 0; i < n; ++i)
        if (s[i] == 'F') {
            ++len;
        } else {
            if (len == 0) {
                c ^= 1;
                continue;
            }

            if (c == 0)
                a.push_back(len);
            else
                b.push_back(len);

            c ^= 1;
            len = 0;
        }

    if (len != 0) {
        if (c == 0)
            a.push_back(len);
        else
            b.push_back(len);
    }

    if (s[0] != 'T') {
        reverse(a.begin(), a.end());
        x -= a.back();
        a.pop_back();
        reverse(a.begin(), a.end());
    }

    auto f1 = calc(a, x);
    auto f2 = calc(b, y);

    if (f1 && f2)
        printf("Yes\n");
    else
        printf("No\n");
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define show(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;
#define MOD 1000000007
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define SZ(x) ((int)(x).size())
#define sum(v,i) accumulate(all(v),i)
//#define int long long
using ll = long long;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }//最大公約数
int lcm(int a, int b) { return a * b / gcd(a, b); }	//最小公倍数
#define deg_to_rad(deg) (((deg)/360)*2*PI);
#define rad_to_deg(rad) (((rad)/2/PI)*360);
//template <typename... Args>void IN(Args& ... args) {cin >>args;IN(args...);return;} //まとめて入力　IN(a,b,c,d...)
struct aaa { aaa() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }aaa;


void Main() {
	string s, t; cin >> s >> t;
	cout << t + s;
}

signed main() {
	Main();

	return 0;
}


Measured memory_bytes: 256
while true do
    m, f, r = gets.split.map { |e| e.to_i }
    break if m == -1 && f == -1 && r == -1
    if m == -1 || f == -1 then
        puts "F"
    elsif m + f >= 80 then
        puts "A"
    elsif m + f >= 65 && m + f < 80 then
        puts "B"
    elsif m + f >= 50 && m + f < 65 then
        puts "C"
    elsif m + f >= 30 && m + f < 50 then
        if r >= 50 then
            puts "C"
        else 
            puts "D"
        end
    elsif m + f < 30 then
        puts "F"
    end
end

Measured memory_bytes: 8648
#include <stdio.h>

int main(void){
  char s[101],p[101];
  int i,j,sn=0,pn=0,t;

  scanf("%s %s",s,p);

  while(s[sn] != '\0') sn++;
  while(p[pn] != '\0') pn++;

  for(i=0;i<sn;i++){
    t=1;
    for(j=0;j<pn;j++)
      if(s[(i+j)%sn] != p[j]) t=0;
    if(t) break;
  }

  if( t )
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////

const int MAXN = 1e5+1;
const ll oo = 2e18;

void solve() {
	int h[MAXN];
    ll dp[MAXN];
    int n,k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
        dp[i] = oo;
    }

    dp[1] = 0;
    for (int i = 2; i <= n; ++i) {
        for (int j = 1; j <= k; ++j) {
            if (i-j > 0) {
                dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
            }
        }
    }

    cout << dp[n] << '\n';
}

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
		FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
		clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
		fclose(FIN);
		cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 1408
N = int(input())
AB=[]
for _ in range(N):
    AB.append(list(map(int, input().split())))
#print(N, AB)

AB=sorted(AB, key=lambda val:val[1])

if AB[0][0]>AB[0][1]:
    print('No')
else:
    for i in range(N-1):
        AB[i+1][0]+=AB[i][0]
        if AB[i+1][0]>AB[i+1][1]:
            print('No')
            break
    else:
        print('Yes')

Measured memory_bytes: 55260
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
 
void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;
 
/*---------------------------------------------------------------------*/
const ll INF = 1e17 - 1;
int N;
pair<ll, int> bit[20000000];
void update(int i, ll x) {
  i += N - 1;
  bit[i] = { x,i - N + 1 };
  while (i > 0) {
    i = (i - 1) / 2;
    bit[i] = min(bit[i * 2 + 1], bit[i * 2 + 2]);
  }
}
pair<ll, int> Min(int a, int b, int k, int l, int r) {
  if (r <= a || b <= l)return{ INF,-1 };
  if (a <= l && r <= b)return bit[k];
 
  auto vl = Min(a, b, k * 2 + 1, l, (l + r) / 2);
  auto vr = Min(a, b, k * 2 + 2, (l + r) / 2, r);
  return min(vl, vr);
}
void Calc() {
  ll ans = 0;
  std::queue<pair<int, int>> q;
  int n = in;
  auto a = in.Array(n);
  int aa = 1;
  int tmp = n;
  while (tmp) {
    aa *= 2;
    tmp /= 2;
  }
  N = aa;
  err(N);
  rep(i, 2 * N - 1) {
    bit[i] = { INF,-1 };
  }
  rep(i, n) {
    update(i, a[i]);
  }
 
  q.push({ 0, n });
  while (q.size()) {
    auto p = q.front(); q.pop();
    if (p.first < 0)p.first = 0;
    if (p.second > n)p.second = n;
    auto mini = Min(p.first, p.second, 0, 0, N);
    if (mini.second == -1)continue;
    ll d = mini.first * ((mini.second - p.first + 1ll) * (p.second - mini.second));
    ans += d;
    err(ans, d, mini, p);
    q.push({ mini.second + 1, p.second });
    q.push({ p.first , mini.second });
  }
  cout << (ans) << endl;
}

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

#define ll long long
using namespace std;

vector<ll> a;
ll getDigit(ll n){
    
    if(n==0){
        return 0;
    }
    
    return getDigit(n/10)+1;
}

ll dfs(ll i,ll b,ll s){
    ll r1,r2;
    if(i==a.size()-1){
        //cout<<"s : "<<s+a[i]<<endl;
        return s+a[i];
    }else{
        r1=dfs(i+1,0,s+a[i]);
        r2=dfs(i+1,10*b+10*a[i],10*b+10*a[i]+s-b);

        //cout<<r1+r2<<endl;
        return r1+r2;        
    }
}

int main(){
    ll n,dig;
    cin>>n;

    dig=getDigit(n);
    //cout<<dig<<endl;
    a.resize(dig);
    for(ll i=0; i<dig; i++){
        a[i]=n%10;
        n/=10;
        //cout<<i<<endl;
    }
    reverse(a.begin(),a.end());
/*
    for(auto m: a){
        cout<<m<<" ";
    }cout<<endl;
*/
    cout<<dfs(0,0,0)<<endl;

    return 0;
    
}

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

namespace AtCoder
{
	// https://beta.atcoder.jp/contests/dwango2016-prelims/tasks/dwango2016qual_c
	public class Dowango2016_c
	{
#if !Development
		public static void Main(string[] args)
		{
			Dowango2016_c.Solve(args);
		}
#endif

		public static void Solve(string[] args)
		{
			var line1 = ReadLineInt();

			Console.WriteLine(line1[0] - line1[1] + 1);
		}

		public static string ReadLineStringOne() { return Console.ReadLine(); }
		public static List<string> ReadLineString() { return Console.ReadLine().Split(' ').ToList(); }
		public static List<int> ReadLineInt() { return Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToList(); }
		public static int ReadLineIntOne() { return Console.ReadLine().Split(' ').Select(str => int.Parse(str)).First(); }
		public static List<int> MultiReadLineInt(int lineNum) { return Enumerable.Range(0, lineNum).Select(_ => ReadLineIntOne()).ToList(); }
		public static long ReadLineLongOne() { return Console.ReadLine().Split(' ').Select(str => long.Parse(str)).First(); }
	}
}

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

int main() {
  string S; cin >> S;
  string Weeks[] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
  rep(i, 7) {
    if (Weeks[i] == S) cout << 7 - i << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	x -= a;
	while (x >= 0) {
		x -= b;
	}
	x += b;
	cout << x << endl;

	return 0;
}

Measured memory_bytes: 256
# Algorithms and Data Structures 1
# Stable Sort
# Name: Ryuya Asada
# ID: s1260064


def BubbleSort(A: list):
    flag = 1
    while flag:
        flag = 0
        for j in range(len(A)-1, 0, -1):
            if A[j][1] < A[j-1][1]:
                A[j], A[j-1] = A[j-1], A[j]
                flag = 1


def SelectionSort(A: list):
    for i in range(0, len(A)):
        minj = i
        for j in range(i, len(A)):
            if A[j][1] < A[minj][1]:
                minj = j

        A[i], A[minj] = A[minj], A[i]


def isEqual(a: list, b: list) -> bool:
    if len(a) != len(b):
        return False

    elif a == []:
        return True

    return (a.pop() == b.pop()) and isEqual(a, b)


def main():
    number_of_cards = int(input())
    cards = input().split(" ")

    cards_b = cards.copy()
    BubbleSort(cards_b)
    print(*cards_b, sep=" ")
    print("Stable")
    cards_s = cards.copy()
    SelectionSort(cards_s)
    print(*cards_s, sep=" ")
    if isEqual(cards_b, cards_s):
        print("Stable")
    else:
        print("Not stable")
    pass


if __name__ == "__main__":
    main()



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

fn gcd<T>(mut x: T, mut y: T) -> T
where
    T: Copy + std::ops::Rem<Output = T> + std::cmp::PartialEq + std::convert::From<u8>,
{
    while y != T::from(0u8) {
        let r = x % y;
        x = y;
        y = r;
    }
    return x;
}

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

    let x: u32 = sc.next();
    let y: u32 = sc.next();
    println!("{}", gcd(x, y));
}

/* ========== 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: 5028
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++)
    {
        int val1 = abs(a[i] - a[i - 1]) + dp[i - 1];
        int val2 = abs(a[i] - a[i - 2]) + dp[i - 2];
        dp[i] = min(val1, val2);
    }
    cout << dp[n - 1];
}

Measured memory_bytes: 1024
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        c: [Chars; h],
    }

    let mut ans = 0;

    for mask_r in 0..(1 << h) {
        for mask_c in 0..(1 << w) {
            let mut black = 0;

            for i in 0..h {
                for j in 0..w {
                    if ((mask_r >> i) & 1) == 0 && ((mask_c >> j) & 1) == 0 && c[i][j] == '#' {
                        black += 1;
                    }
                }
            }

            if black == k {
                ans += 1;
            }
        }
    }

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


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

using namespace std;

const int MOD = 1e9+7;
int N, M;
long long fac[2000000];
typedef long long ll;

int main(){
    cin >> N >> M;
    if(abs(N-M) >= 2) { cout << 0; return 0; }
    fac[1] = 1;
    for(int i = 2; i <= max(M, N); ++i)
        fac[i] = (fac[i-1]*i)%MOD;
    if(N == M) { cout << ll(ll(fac[N]*fac[N])%MOD*2)%MOD; return 0; }
    if(N < M) swap(N, M);
    cout << (fac[N]*fac[M])%MOD;

}


Measured memory_bytes: 1024
import math

N, D = map(int, input().split())
x = [0] * N
y = [0] * N
count = 0
for i in range(N):
    x[i], y[i] = map(int, input().split())
    if math.sqrt(x[i] * x[i] + y[i] * y[i]) <= D:
      count += 1
    else:
      pass
print(count)  

Measured memory_bytes: 24528
def main(n, p):
    player = [0] * n
    ans = p
    while 1:
        for i in range(n):
            if p > 0:
                player[i] += 1
                p -= 1
                if p == 0 and player[i] == ans:
                    print(i)
                    return
            else:
                if player[i] > 0:
                    p += player[i]
                    player[i] = 0
while 1:
    n, p = map(int, input().split())
    if n == p == 0:
        break
    main(n,p)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int n, k; cin >> n >> k;
  vector<int> a(n);
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=k; i<n; i++) {
    if (a[i] > a[i-k]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}

// EOF

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int n;
	cin>>n;
	int a[n];
	map<int,int> mp;
	rep(i,n){
		cin>>a[i];
		mp[a[i]]++;
	}
	sort(a,a+n);
	
	int ans=n;
	for(auto itr = mp.begin();itr!=mp.end();++itr){
		if(itr->second >= 3){
			if(itr->second %2 == 0){
				ans-=itr->second-2;
				itr->second=2;
			}
			else {
				ans-=(itr->second-1);
				itr->second = 1;
			}
		}
	}

	int j=0;
	for(int i=0;i<n;i++){
		if(mp[a[i]]==2){
			for(int j=n-1;j>=i;j--){
				if(mp[a[j]]==2){
					mp[a[i]]--;
					mp[a[j]]--;
					ans-=2;
					break;
				}
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}


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

int bit_count(int bits){
    int n = 0;
    for(;bits!=0;bits&=bits-1){
        n++;
    }
    return n;
}

int main(void) {
    int N,M;
    cin >> N >> M;
    vector<int> bits;
    vector<int> p;
    for (int i=0;i<M;i++){
        int k;
        cin >> k;
        int value = 0;
        for (int j=0;j<k;j++){
            int s;
            cin >> s;
            value += 1*pow(2,s-1);
        }
        bits.push_back(value);
    }
    for (int i=0;i<M;i++){
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }
    int count=0;
    for (int i=0;i<pow(2,N);i++){
        bool flg = true;
        for (int j=0;j<M&&flg==true;j++){
            if (bit_count(bits.at(j) & i) % 2 != p.at(j)){
                flg=false;
            }
        }
        if(flg)count++;
    }
    cout << count <<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    data = [input().split() for _ in range(N)]
    sum = 0
    for d in data:
        if d[1] == "JPY":
            sum += int(d[0])
        else:
            sum += float(d[0]) * 380000
    print(sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61724
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= print . length . filter ( == '2' )

Measured memory_bytes: 380
from itertools import combinations


def solve():
    N, M = map(int, input().split())
    k = [0 for _ in range(M)]
    s = [[] for _ in range(M)]
    for i in range(M):
        k[i], *s[i] = map(int, input().split())
    p = list(map(int, input().split()))
    
    ans = 0
    for i in range(1, N+1):
        for on_switches in combinations(range(1, N+1), i):
            flag = True
            for j in range(M):
                count = 0
                for on_switch in on_switches:
                    if on_switch in s[j]:
                        count += 1
                if count % 2 != p[j]:
                    flag = False
                    break
            if flag:
                ans += 1
    
    if 1 not in p:
        ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


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

typedef long long ll;
ll mod = 1000000007;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    string s, t;
    cin >> s >> t;
    int n = s.length(), m = t.length();

    vector<vector<int>>  dp(n+1, vector<int>(m+1,0));

    for(int i=0; i<n; i++) dp[i][0]=0;
    for(int i=0; i<m; i++) dp[0][i]=0;

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(s[i]==t[j]){
                dp[i+1][j+1] = dp[i][j]+1;
            }else{
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }

    int index = dp[n][m];
    char ans[index+1];

    int i=n, j=m;
    
    while(i>0 && j>0){
        if(s[i-1]!=t[j-1]){
            if(dp[i][j-1]>dp[i-1][j]) j--;
            else i--;
        }else{
            ans[index]=t[j-1];
            i--;
            j--;
            index--;
        }
    }

    for(int i=1; i<=dp[n][m]; i++) cout<<ans[i];
    cout<<'\n';

    return 0;
}


Measured memory_bytes: 38572
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    int n,a,b;
    cin>>n>>a>>b;
    vi answer;
    if (1ll * a * b < n || a + b > n + 1)
    	return puts("-1") * 0;
    int cnt = -1;
    for (int i = 0;i <= a;++i)
    	if (i + ((n - i + b - 1) / b) == a)
    		cnt = i;
    assert(cnt != -1);
    for (int i = 1;i <= cnt;++i)
    	answer.pb(i);
    for (int i = cnt + 1;i <= n;i += b) {
    	int l = i;
    	int r = min(n,i + b - 1);
    	for (int j = r;j >= l;--j)
    		answer.pb(j);
    }
   	for (int i = 0;i < n;++i)
   		cout << answer[i] << " \n"[i == n - 1]; 
    return 0;
}

Measured memory_bytes: 3440
a = list(map(int,input().split()))
c=0
for i in range(a[1]-2*a[0] if a[1]-2*a[0] > 0 else 0, a[0]+1):
    for j in range((a[1]-i)-a[0] if (a[1]-i)-a[0] > 0 else 0, a[0] + 1):
        if i + j <= a[1]:
            c += 1

print(c)


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

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    int sum = 0;
    int num;
    for(int i = 1;i <= n;i++){
        sum += i;
        if(sum >= n){
            num = i;
            break;
        }
    }
    int res = sum - n;
    for(int i = 1;i <= num;i++){
        if(i == res)continue;
        cout << i << endl;
    }
}

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

int main()
{

  int a,b ;
  cin >> a >> b ;
  
  int cnt = 1 ;
  int ans = 0 ;
  
  while(cnt<b){
    cnt += (a-1) ;
    ans++ ;
  }
  
  cout << ans << endl;
    return 0;
}



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

int main(){
    double a, b;
    long num1, num2;
    cin >> num1 >> num2;
    a = num1;
    b = num2;
    double x = a / b;
    cout << num1 / num2 << " " << num1 % num2  << " " << fixed << setprecision(5) << x << endl;
}

Measured memory_bytes: 1244
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << (b - a == c - b ? "YES" : "NO") << endl;
}

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


Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
k = 0
k_l = []
for i in range(N-1):
    if H[i] < H[i+1]:
        k_l.append(k)
        k = 0
    else:
        k += 1
        continue
k_l.append(k)
print(max(k_l))

Measured memory_bytes: 14252
using System;

     
    namespace ABC
    {
        class Program
        {
            static void Main(string[] args)
            {
                int N = int.Parse(Console.ReadLine());
                string output = "No";
                for (int i = 0; i <= 14; i++)
                {
                    if ((N - i * 7) % 4 == 0 && (N - i*7)>=0)
                    {
                        output = "Yes";
                        break;
                    }
                }
                Console.WriteLine(output);
            }
     
        }
    }

Measured memory_bytes: 11092
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>
#include <cassert>
#include <climits>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
void print() { std::cout << std::endl; }
template <typename T, typename... A> void print(const T& first, const A&... rest) { cout << sizeof...(rest) << endl; std::cout << first; if (sizeof...(rest)) std::cout << " "; print(rest...); }
template <typename... A> void print(const A&... rest) { print(rest...); }
template <typename A> void print(const std::vector<A>& v) { std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; }); std::cout << std::endl; }

vector<vector<int>> to(200005);
vector<int> ans;
void dfs(int v, int p = -1){
    for(int u : to[v]){
        if(u == p) continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i, q){
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i, n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 23552
#include <utility>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int a, b, c;

	cin >> a >> b >> c;

	if (a > b) swap(a, b);
	if (a > c) swap(a, c);
	if (b > c) swap(b, c);

	cout << a << ' ' << b << ' ' << c << endl;

	return 0;
}


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

int main() {
    for( ; ; ) {
        int x, y;
        char op;
        cin >> x >> op >> y;
        if(op == '+') cout << x + y << endl;
        if(op == '-') cout << x - y << endl;
        if(op == '*') cout << x * y << endl;
        if(op == '/') cout << x / y << endl;
        if(op == '?') break;
    }
}


Measured memory_bytes: 3080
#include<cstdio>
using namespace std;
int main(){
	int a,b,k;int poss=0;
	scanf("%d%d%d",&k,&a,&b);
	for(int j=a;j<=b;j++){
		if(j%k==0){
			poss=1;
			break;
		}
	}
	if(poss) printf("OK");
	else printf("NG");
	return 0;
}

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()


int main(int argc, char **argv)
{
	ll N, A, B; cin >> N >> A >> B;
	vector<ll> H(N);
	REP(i, N) cin >> H[i];

	auto f = [&](ll t) -> bool
			 {
				 vector<ll> tmp = H;
				 REP(i, N)
				 {
					 tmp[i] -= t*B;
				 }

				 // std::cout << "t : " << t << std::endl;
				 // for (auto &nv : tmp)
				 // 	 std::cout << nv << " ";
				 // std::cout << std::endl;

				 ll cnt{0};
				 ll k = A-B;
				 REP(i, N)
				 {
					 if (tmp[i] > 0)
						 cnt += (tmp[i] + k - 1) / k;
				 }
				 return cnt <= t;
			 };

	ll ng{-1};
	ll ok{(ll)1e9+1};

	while (abs(ok - ng) > 1)
	{
		ll mid = (ng + ok) / 2;
		if (f(mid)) ok = mid;
		else ng = mid;
	}

	std::cout << ok << std::endl;
}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


ll N;
ll S;
const ll INF = 1LL << 60;


ll solve() {
    for(ll b = 2; b * b <= N; b++){
        // 普通に計算
        ll n = N;
        ll s = 0;
        while(n != 0){
            s += n % b;
            n /= b;
        }
        if(s == S){
            return b;
        }
    }

    ll opt_b = INF;

    for(ll p = 1; p * p < N; p++){
        if(N - S + p > 0 && (N - S + p) % p == 0){
            ll b = (N - S + p) / p;
            ll q = S - p;
            if(q >= 0 && q < b){
                opt_b = min(opt_b, b);
            }
        }
    }

    // // sqrt(N) より大きい b について計算
    // // N / b < sqrt(N) となるので、N / bを決め打ちで計算する
    // for(ll n_per_b = 1; n_per_b * n_per_b < N; n_per_b++){
    //     if(N + n_per_b - S > 0 && (N + n_per_b - S) % n_per_b == 0){
    //         ll cand_b = (N + n_per_b - S) / n_per_b;
    //         if(cand_b >= -n_per_b + S){
    //             if(N%cand_b + N/cand_b == S &&cand_b > 1)
    //                 opt_b = min(opt_b, cand_b);
    //         }
    //     }
    // }

    if(N == S) opt_b = min(opt_b, N + 1);

    if(opt_b == INF)
        return -1;
    else
        return opt_b;
}

int main(){

    cin >> N >> S;
    cout << solve() << endl;

}


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

int main() {
  int N;
  int* p;

  cin >> N;
  p = new int[N];
  for(int i=0;i<N;i++){
    cin >> p[i];
  }

  int c=0;
  for(int i=0;i<N;i++){
    if(p[i]!=i+1) c++;
  }
  if( c==0 || c==2 ) cout << "YES" <<endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split(' '))
S = input()
S = list(S)

K=K-1
if S[K] == 'A':
	S[K] = 'a'
if S[K] == 'B':
	S[K] = 'b'
if S[K] == 'C':
	S[K] = 'c'

print(''.join(S))


Measured memory_bytes: 3060
s = int(input())
ka = [3,5,7]
zen = []
for i in range(3):
  zen.append(str(ka[i]))
for j in range(3):
  for i in range(3):
    zen.append(str(ka[i])+str(ka[j]))
for a in range(3):
  for b in range(3):
    for c in range(3):
      zen.append(str(ka[a])+str(ka[b])+str(ka[c]))
for a in range(3):
  for b in range(3):
    for c in range(3):
      for d in range(3):
        zen.append(str(ka[a])+str(ka[b])+str(ka[c])+str(ka[d]))
for a in range(3):
  for b in range(3):
    for c in range(3):
      for d in range(3):
        for e in range(3):
          zen.append(str(ka[a])+str(ka[b])+str(ka[c])+str(ka[d])+str(ka[e]))
for a in range(3):
  for b in range(3):
    for c in range(3):
      for d in range(3):
        for e in range(3):
          for f in range(3):
            zen.append(str(ka[a])+str(ka[b])+str(ka[c])+str(ka[d])+str(ka[e])+str(ka[f]))
for a in range(3):
  for b in range(3):
    for c in range(3):
      for d in range(3):
        for e in range(3):
          for f in range(3):
            for g in range(3):
              zen.append(str(ka[a])+str(ka[b])+str(ka[c])+str(ka[d])+str(ka[e])+str(ka[f])+str(ka[g]))        
for a in range(3):
  for b in range(3):
    for c in range(3):
      for d in range(3):
        for e in range(3):
          for f in range(3):
            for g in range(3):
              for h in range(3):
                zen.append(str(ka[a])+str(ka[b])+str(ka[c])+str(ka[d])+str(ka[e])+str(ka[f])+str(ka[g])+str(ka[h]))         
for a in range(3):
  for b in range(3):
    for c in range(3):
      for d in range(3):
        for e in range(3):
          for f in range(3):
            for g in range(3):
              for h in range(3):
                for i in range(3):
                  zen.append(str(ka[a])+str(ka[b])+str(ka[c])+str(ka[d])+str(ka[e])+str(ka[f])+str(ka[g])+str(ka[h])+str(ka[i]))            
ans = 0
for i in zen:
  if int(i) > s:
    continue
  flag = 1
  if i.count("3") == 0 or i.count("5") == 0 or i.count("7") == 0:
    flag = 0
  if flag:
    ans += 1
print(ans)

Measured memory_bytes: 5284
#include <stdio.h>

int main(void){
    int i = 1;
    int x;
    int n;
    
    scanf("%d", &n);
    
    do {
        int x = i;
        if (x % 3 == 0)
        {
            printf(" %d", i);
            continue;
        }
        do {
            if (x % 10 == 3) 
            {
                printf(" %d", i);
                break;
            }
            x /= 10;
            
        } while (x);
    } while (++i <= n);
    putchar('\n');

    return 0;
}



Measured memory_bytes: 2068
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

using ll = long long;
using namespace std;

#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define LFOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define FORR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define LFORR(i,a,b) for(ll i = (int)(a); i >= (ll)(b); i--)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define LREP(i,n) LFOR(i,0,(ll)(n)-1)
#define REPR(i,n) FORR(i,(int)(n)-1,0)
#define LREPR(i,n) LFORR(i,(ll)(n)-1,0)

#define SIZ(v) int(v.size())
const int INF = 1e8;
const ll LINF = 1e15;

struct restaurant{
  int num;
  string loc;
  int val;
};

void soat(vector<restaurant> &res, int l){
  REP(i,l){
    REP(j,l-1){
      if (res[j].loc > res[j+1].loc || 
          (res[j].loc == res[j+1].loc && res[j].val < res[j+1].val)){
        restaurant tmp = res[j];
        res[j] = res[j+1];
        res[j+1] = tmp;
      }
    }
  }
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<restaurant> rs;
  REP(i,n){
    string K;
    int v;
    cin >> K >> v;
    rs.push_back(restaurant{i+1,K,v});
  }
  soat(rs,n);
  REP(i,n)
    cout << rs[i].num << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
f=[True for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    A,B=h[a-1],h[b-1]
    if A>B:
        f[b-1]=False
    elif B>A:
        f[a-1]=False
    else:
        f[a-1]=False
        f[b-1]=False
        
print(sum(f))

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

int N;
const int M = 200000;
const int INF = 1e9;
int prv[M], grundy[M];
vector<int> nxt[M];
bitset<M> cycle;
int c;

void find_cycle(){
    int i = 0;
    bitset<M> visited;
    stack<int> st;
    while(true){
        visited[i] = true;
        st.push(i);
        if(visited[prv[i]]){
            c = prv[i];
            while(true){
                int j = st.top(); st.pop();
                cycle[j] = true;
                if(prv[i] == j) return;
            }
        }
        i = prv[i];
    }
}

int calc_grundy(int i){
    vector<int> v = {INF};
    for(int j : nxt[i]) v.push_back(grundy[j]);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    for(int j=0; j<v.size(); j++){
        if(v[j] != j) return j;
    }
}

vector<int> calc_grundy_cand2(int i){
    vector<int> v = {INF, INF+1};
    for(int j : nxt[i]) if(!cycle[j]) v.push_back(grundy[j]);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    vector<int> ans;
    for(int j=0; j<v.size(); j++){
        if(v[j-ans.size()] != j) ans.push_back(j);
        if(ans.size() == 2) return ans;
    }
}

bitset<M> visited2;
int dfs(int i){
    visited2[i] = true;
    if(nxt[i].size() == 0) return 0;
    for(int j : nxt[i]) if(!visited2[j]) dfs(j);
    grundy[i] = calc_grundy(i);
    return grundy[i];
}

void check(int num){
    grundy[c] = num;
    int i = prv[c];
    while(i != c){
        grundy[i] = calc_grundy(i);
        i = prv[i];
    }

    if(calc_grundy(c) == grundy[c]){
        cout << "POSSIBLE" << endl;
        exit(0);
    }
}

int main(){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> prv[i];
        prv[i]--;
        nxt[prv[i]].push_back(i);
    }

    find_cycle();
    for(int i=0; i<N; i++) if(!cycle[i] && !visited2[i]) dfs(i);

    auto cand = calc_grundy_cand2(c);
    for(int num : cand) check(num);
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 12544
f = [False for i in range(100001)]
c = [0 for i in range(100001)]

#for i in xrange(2, 100001):
i = 2
while i<100001:
    if not f[i]:
        #for j in range(2*i, 100001, i):
        j = 2*i
        while j < 100001:
            f[j] = True
            j += i
    i += 1

i = 3
#for i in xrange(3, 100001, 2):
while i < 100001:
    if not f[i] and not f[int((i+1)/2)]:
        c[i] += 1
    i += 2

i = 3
while i < 100001:
#for i in xrange(3, 100001):
    c[i] += c[i-1]
    i += 1
n = int(input())
while n:
    l, r = list(map(int, input().split()))
    print (c[r]-c[l-1])
    n -= 1


Measured memory_bytes: 7192
N,M = map(int, input().split())
X = [int(i) for i in input().split()]

if N >= M:
    print(0)
    exit()


X.sort()
L = [X[i+1] - X[i] for i in range(len(X)-1)]
L.sort()

print(sum(L[:(M-N)]))

Measured memory_bytes: 56744
#include <bits/stdc++.h>
using namespace std;
int main(){
    long a,b,k;
    cin >> a >> b >> k;
    vector <long> ans;
    for(long i = a; i <= b; i++){
        if( ((i-a+1)<=k)||
            ((b-i+1)<=k)){
            //ans.push_back(i);
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#define LL long long
using namespace std;
int main()
{
	int n;
	LL D, x, y;
	cin>>n>>D;
	int cnt = 0;
	for(int i = 1; i <= n; i++)
	{
		cin>>x>>y;
		if(x * x + y * y <= D * D)
			cnt++;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3644
import java.io.*;
import java.util.*;
class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(reader.readLine());
		long res = 0;
		for(long i = 1;i<=n;i++){
			long p = n/i;
			res += ((p*(p+1))*i)/2;
		}
		System.out.println(res);
		 
		}
}


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

int main() {
  string S, s;
  int N, K;
  cin >> N >> K >> S;
  s = S;
  transform(s.begin(), s.end(), s.begin(), ::tolower);
  S.at(K-1) = s.at(K-1);
  cout << S << endl;
}


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



void solve(){
    string a,b,c;
    cin >> a >> b >> c;
    cout << "A" << b[0] << "C" << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#define LEN 100
#define BASE 25

using namespace std;

int maps[LEN][LEN];
int off[LEN][LEN];

int checker[4];
int ncheck[4];

map<int, int> points[LEN];

class State {
public:
	char where;
	int enemy;
	int budget;
	int check[4];
	State() {}
	State(char w, int e, int b ) {
		where = w;
		enemy = e;
		budget = b; 
		check[0] = ncheck[0];
		check[1] = ncheck[1];
		check[2] = ncheck[2];
		check[3] = ncheck[3];
	}
};


inline bool operator< ( const State& a, const State& b) {
/*
	if( a.enemy == b.enemy )
		return a.budget > b.budget;
		*/
	return a.enemy < b.enemy;
}

inline bool operator> ( const State& a, const State& b) {
/*
	if ( a.enemy == b.enemy )
		return a.budget < b.budget;
		*/
	return a.enemy > b.enemy;
}

priority_queue<State, vector<State>, greater<State> > status;

inline void copy ( State now ) {
	checker[0] = now.check[0];
	checker[1] = now.check[1];
	checker[2] = now.check[2];
	checker[3] = now.check[3];
}

inline void ncopy ( ) {
	ncheck[0] = checker[0];
	ncheck[1] = checker[1];
	ncheck[2] = checker[2];
	ncheck[3] = checker[3];
}

inline bool check ( int i ) {
	return 0 == ((1<<(i%25)) & checker[i/BASE]);
}

inline void add ( int i ) {
	ncheck[i/BASE] = ((1<<(i%25)) | checker[i/BASE]);
}

inline void insert ( int i, int e, int b ) {
	
	map<int,int>::iterator itr = points[i].find(e);
	if ( itr == points[i].end() ) {
		points[i][e] = b;
		status.push(State(i,e,b));
	} else if ( (*itr).second < b ) {
		(*itr).second = b;
		status.push(State(i,e,b));
		int min = b;
		while ( itr != points[i].end() ) {
			if ( (*itr).second > min ) {
				min = (*itr).second;
			} else {
				(*itr).second = min+1;
			}
			itr++;
		}
	}
}

int main () {

	while ( true ) {
		int n,m,l;
		cin >> n >> m >> l;

		if ( n == 0 )
			break;

		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				maps[i][j] = -1;
				off[i][j] = 0;
			}
			points[i].clear();
		}

		for ( int i=0; i<m; i++ ) {
			int a,b,d,e;
			cin >> a >> b >> d >> e;

			maps[a-1][b-1] = maps[b-1][a-1] = d;
			off[a-1][b-1] = off[b-1][a-1] = e;
		}
		
		for ( int i=0; i<4; i++ ) {
			ncheck[i] = 0;
			checker[i] = 0;
		}

		priority_queue<State, vector<State>, greater<State> > empty;
		status = empty;

		ncheck[0] = 1;
		status.push(State(0,0,l));
		
		while(!status.empty()) {
			State now = status.top();
			status.pop();
			if ( now.where == n-1 ) {
				cout << now.enemy << endl;
				break;
			}

			copy(now);

			for ( int i=0; i<n; i++ ) {
				if ( maps[now.where][i] > 0 ) {

					if ( check( i ) ) {
						ncopy();
						add(i);
						
						int e, b;
						if ( off[now.where][i] == 0 ) {
							e = now.enemy;
							b = now.budget;
							insert(i,e,b);
						} else {
							if ( now.budget - maps[now.where][i] >= 0 ) {
								e = now.enemy;
								b = now.budget - maps[now.where][i];
								insert(i,e,b);
							}
							e = now.enemy + off[now.where][i];
							b = now.budget;
							insert(i,e,b);
						}
					}
				}
			}
		}
	}
}

		

Measured memory_bytes: 2056