akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES  // M_PI等のフラグ

#include <iostream>
#include <bitset>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <list>

#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))

using namespace std;


void solve(){
    string S, T;
    cin >> S >> T;

    int ans = T.size();
    for(int i=0; i<=S.size()-T.size(); i++) {
        int ret = 0;
        for (int j=0; j<T.size(); j++) {
            if (S.at(i+j) != T.at(j)) ret ++;
        }
        ans = min(ans, ret);
    }

    cout << ans <<endl;
}

int main(int argc, char const *argv[]){
    solve();
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(void){
	int S = 0;
	int T = 0;
	int i = 0;
	int temp = 0;
	
	for(i = 0; i < 4; i++){
		scanf("%d", &temp);
		S += temp;
	}
	
	for(i = 0; i < 4; i++){
		scanf("%d", &temp);
		T += temp;
	}
	
	if(T >= S)
		printf("%d\n", T);
	if(T < S)
		printf("%d\n", S);
	
	return 0;
}

Measured memory_bytes: 592
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int INF = 1e9 + 10;
const ll INF_LL = 1e18 + 10;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
/* ]]] */

using P = complex<double>;
const double PI = acos(-1.0);
const double EPS = 1e-6;

int n;
P p[100];

int main(){
  while (cin >> n, n){
    rep(i, n){
      double x, y;
      scanf("%lf,%lf", &x, &y);
      p[i] = P(x, y);
    }

    int mx = 0;
    rep(i, n) rep(j, 51) rep(k, 50){
      P q = p[i] + polar(j * 0.02, k * PI / 50);
      int c = 0;
      rep(l, n) c += abs(p[l] - q) < 1.0 + EPS;
      chmax(mx, c);
    }

    cout << mx << endl;
  }
}

Measured memory_bytes: 3544
#include<iostream>
using namespace std;
int main(){
    int a;
    int b;
    cin>>a >>b;
    if (a>b){
        cout<<"a > b"<<endl;
    }else if (a==b){
        cout<<"a == b"<<endl;
    }else if (a<b){
        cout<<"a < b"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
N = int(input())
H = list(map(int, input().split()))

ans = 0
watering = 0

for i in range(N):
    if H[i] > watering:
        # じょうろが足りなくなったら追加する
        ans += H[i] - watering
    watering = H[i]

print(ans)



Measured memory_bytes: 2940
import java.util.Scanner;

class Main {

    static Scanner scan;

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

        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        if ((a < b) && (b < c)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26196
def check(a, b, c):  
    if (a + b <= c) or (a + c <= b) or (b + c <= a) : 
        return False
    else: 
        return True

def solve(n, lst):
    count = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                if lst[i] != lst[j] and lst[j] != lst[k] and lst[i] != lst[k] and check(lst[i], lst[j], lst[k]):
                    count += 1
    return count

n = int(input())
lst = list(map(int, input().split(' ')))
print(solve(n, lst))


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

const int MOD = 1000000007;

ll dp[2010][2010];
vector<pair<ll, ll>> a;
int n;

ll f1(ll in, ll i) {
    if (in == a.size())
        return 0;

    if (dp[in][i] != -1)
        return dp[in][i];
    int end = n - 1 - (in - i);

    ll ans1 = (a[in].first * (a[in].second - i)) + f1(in + 1, i + 1);
    ll ans2 = (a[in].first * (end - a[in].second)) + f1(in + 1, i);

    return dp[in][i] = max(ans1, ans2);
}
void solve() {
    cin >> n;

    for (ll i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        a.push_back(make_pair(x, i));
    }

    memset(dp, -1, sizeof(dp));
    sort(a.rbegin(), a.rend());

    ll ans = f1(0, 0);
    cout << ans << "\n";
}

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin >> t;

    // while (t--)
    solve();

    return 0;
}

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

typedef long long ll;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main() {
    int N;
    cin >> N;
    vector<ll> T(N);
    for (int i = 0; i < N; i++)
        cin >> T[i];

    ll res = 1;
    for (int i = 0; i < N; i++)
        res = lcm(res, T[i]);

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::cmp::Ordering;
use std::collections::HashSet;
use std::collections::BinaryHeap;

type Selection = (usize, usize, usize);

#[derive(Copy, Clone, Eq, PartialEq)]
struct Element {
    val: u64, 
    selection: Selection,
}

impl Ord for Element {
    fn cmp(&self, other: &Element) -> Ordering {
        self.val.cmp(&other.val)
    }
}

impl PartialOrd for Element {
    fn partial_cmp(&self, other: &Element) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

fn input_tuple() -> (u64, u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2], vec[3])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (x, y, z, k) = input_tuple();
    let mut a_vec = input_vec();
    a_vec.sort_by(|a, b| b.cmp(&a));
    let mut b_vec = input_vec();
    b_vec.sort_by(|a, b| b.cmp(&a));
    let mut c_vec = input_vec();
    c_vec.sort_by(|a, b| b.cmp(&a));

    let mut priority_queue: BinaryHeap<Element> = BinaryHeap::new(); 
    let mut memo: HashSet<Selection> = HashSet::new();
    priority_queue.push(Element { val: a_vec[0] + b_vec[0] + c_vec[0], selection: (0, 0, 0) });
    for _ in 0..k {
        let elem = priority_queue.pop().unwrap();
        // println!("{}, {:?}", elem.val, elem.selection);
        println!("{}", elem.val);
        let selection = (elem.selection.0 + 1, elem.selection.1, elem.selection.2);
        if elem.selection.0 + 1 < x as usize && !memo.contains(&selection) {
            priority_queue.push(
                Element {val: a_vec[elem.selection.0 + 1] + b_vec[elem.selection.1] + c_vec[elem.selection.2],
                     selection: selection}
                    );
            memo.insert(selection);
        }
        let selection = (elem.selection.0, elem.selection.1 + 1, elem.selection.2);
        if elem.selection.1 + 1 < y as usize && !memo.contains(&selection) {            
            priority_queue.push(
                Element {val: a_vec[elem.selection.0] + b_vec[elem.selection.1 + 1] + c_vec[elem.selection.2],
                    selection: selection}
                );  
            memo.insert(selection);
        }
        let selection = (elem.selection.0, elem.selection.1, elem.selection.2 + 1);
        if elem.selection.2 + 1 < z as usize && !memo.contains(&selection) {            
            priority_queue.push(
                Element {val: a_vec[elem.selection.0] + b_vec[elem.selection.1] + c_vec[elem.selection.2 + 1],
                    selection: selection}
                );
            memo.insert(selection);
        }
    }
}


Measured memory_bytes: 4352
#include<cstdio>
int main(){
  int N;
  scanf("%d",&N);
  int P[200005] = {};
  int dp[200005] = {};
  for(int i = 0;i < N;++i){
    scanf("%d",&P[i]);
  }
  int cnt = 0;
  for(int i = 0; i < N;++i){
    dp[P[i]] = dp[P[i] - 1] + 1;
    if(cnt < dp[P[i]])cnt = dp[P[i]];
  }
  printf("%d\n",N - cnt);
  return 0;
}


Measured memory_bytes: 1664
n = int(input())
a = [x for x in input().split()]
b = []

if n % 2 == 1:
    for i in reversed(range(1, n+1, 2)):
        b.append(a[i-1])
    for i in range(2, n, 2):
        b.append(a[i-1])
else:
    for i in reversed(range(2, n+1, 2)):
        b.append(a[i-1])
    for i in range(1, n, 2):
        b.append(a[i-1])
    
print(*b, sep=' ')


Measured memory_bytes: 24904
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>

using namespace std;

string str;
int t, n, m;
int a[100005];

int main() {
    
    //int T; cin>>T;
    //while(T--) {
        
    //}
    
    int n;
    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i];
    
    int ans = 0;
    for(int i=1; i<=n; i++) {
        if(a[a[i]] == i) {
            ans++;
        }
    }
    cout<<ans/2<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int A, B;
    scanf("%d%d",&A, &B);
    if(A+B>=A-B&&A+B>=A*B)
    {
        printf("%d",A+B);
    }
    else if(A-B>=A+B&&A-B>=A*B)
    {
        printf("%d",A-B);
    }
    else if(A*B>=A+B&&A*B>=A-B)
    {
        printf("%d",A*B);
    }
    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m,k=map(int, input().split())
friend=[[] for i in range(n+1)]
block_count=[0]*(n+1)
uf=UnionFind(n+1)
for i in range(1,m+1):
    a,b=map(int, input().split())
    friend[a].append(b)
    friend[b].append(a)
    uf.union(a,b)

for i in range(1,k+1):
    a,b=map(int, input().split())
    if uf.same(a,b)==True:
        block_count[a]+=1
        block_count[b] += 1

answer=[0]*(n)
for i in range(1,n+1):
    answer[i-1]=uf.size(i)-len(friend[i])-block_count[i]-1
    #print(uf.size(i))

print(" ".join(map(str,answer)))
#print(friend)
#print(uf)
#print(block_count)


Measured memory_bytes: 34544
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, m = map(int, input().split())

ans = 0
if m >= 2:
    ans += combinations_count(m,2)
if n >= 2:
    ans += combinations_count(n,2)

print(ans)



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

int main()
{
	int r,D,x;
	cin>>r>>D>>x;
	fr(i,1,11)
	{
		x=r*x-D;
		cout<<x<<endl;
	}

}			

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;


long long power(long long x, long long n){
	long long ans = 1;
	for(;n;n >>= 1, x *= x, ans %= MOD, x %= MOD)
		if(n&1)ans*=x;
	return ans % MOD;
}


	
signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<pair<int,int>> in;
	map<pair<int,int>, int> mp, mm, mz;
	int ans = 0;
	int pro = 1;
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		int A, B;
		int Gcd;
		int con = 0;
		
		cin>>A>>B;
		
		if(A == 0 || B == 0) {
			A = !!A;
			B = !!B;
			
			if(A == 0 && B == 0) {
				ans++;
			} else if(A) {
				pro *= power((power(2,mz[{B,A}]) + power(2,mz[{A,B}]) +  MOD - 1) % MOD, MOD - 2);
				pro %= MOD;
				
				ans += pro * power(2,mz[{A,B}]);
				
				pro *=(power(2,mz[{B,A}]) + power(2,mz[{A,B}]+1) + MOD - 1) % MOD;
				pro %= MOD;
				
			} else {
				pro *= power((power(2,mz[{B,A}]) + power(2,mz[{A,B}]) + MOD - 1) % MOD, MOD - 2);
				pro %= MOD;
				
				ans += pro * power(2,mz[{A,B}]);
				
				pro *=(power(2,mz[{B,A}]) + power(2,mz[{A,B}]+1)  + MOD - 1) % MOD;
				pro %= MOD;
				
			}
			
			mz[{A,B}]++;
			
		} else if(A < 0 && B < 0 || A > 0 && B > 0) {
			if(A < 0) {
				A *= -1;
				B *= -1;
			}
			Gcd = __gcd(A, B);
		
			A /= Gcd;
			B /= Gcd;
			
			
			
			pro *= power((power(2,mp[{A,B}]) + power(2,mm[{B,A}]) + MOD - 1) % MOD, MOD - 2);
			pro %= MOD;
			
			ans += pro * power(2,mp[{A,B}]);
			
			pro *=(power(2,mp[{A,B}]+1) + power(2,mm[{B,A}]) + MOD - 1) % MOD;
			pro %= MOD;
			
			
			
			mp[{A,B}]++;
			
		} else {
			if(A < 0) {
				A *= -1;
			}
			if(B < 0) {
				B *= -1;
			}
			Gcd = __gcd(A, B);
		
			A /= Gcd;
			B /= Gcd;
			
			pro *= power((power(2,mp[{B,A}]) + power(2,mm[{A,B}]) + MOD - 1) % MOD, MOD - 2);
			pro %= MOD;
			
			ans += pro * power(2,mm[{A,B}]);
			
			pro *=(power(2,mp[{B,A}]) + power(2,mm[{A,B}]+1) + MOD - 1) % MOD;
			pro %= MOD;
			
			mm[{A,B}]++;
		}
		
		ans %= MOD;
	}
	
	
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 28548
# include<cstdio>
# include<cstring>
int n,a[1000];
int main(){
	scanf("%d",&n);
	for(int i=4;i>=1;i--){
		a[i]=n%10;
		n/=10;
	}
	if((a[1]+a[2]+a[3]+a[4])==7)printf("%d+%d+%d+%d=7",a[1],a[2],a[3],a[4]);
	else if((a[1]+a[2]+a[3]-a[4])==7)printf("%d+%d+%d-%d=7",a[1],a[2],a[3],a[4]);
	else if((a[1]+a[2]-a[3]+a[4])==7)printf("%d+%d-%d+%d=7",a[1],a[2],a[3],a[4]);
	else if((a[1]+a[2]-a[3]-a[4])==7)printf("%d+%d-%d-%d=7",a[1],a[2],a[3],a[4]);
	else if((a[1]-a[2]+a[3]+a[4])==7)printf("%d-%d+%d+%d=7",a[1],a[2],a[3],a[4]);
	else if((a[1]-a[2]+a[3]-a[4])==7)printf("%d-%d+%d-%d=7",a[1],a[2],a[3],a[4]);
	else if((a[1]-a[2]-a[3]+a[4])==7)printf("%d-%d-%d+%d=7",a[1],a[2],a[3],a[4]);
	else if((a[1]-a[2]-a[3]-a[4])==7)printf("%d-%d-%d-%d=7",a[1],a[2],a[3],a[4]);
	return 0;
} 

Measured memory_bytes: 128
from itertools import combinations_with_replacement as H
N, M, Q = map(int, input().split())
ans = 0
query = [list(map(int, input().split())) for _ in range(Q)]

for A in H(list(range(1, M+1)), N):
    acc = 0
    for j in range(Q):
        a, b, c, d = query[j]
        if A[b - 1] - A[a - 1] == c:
            acc += d
    ans = max(ans, acc)
print(ans)


Measured memory_bytes: 9188
import itertools

def score(a, abcd):
    ans = 0
    for i in abcd:
        if a[i[1] -1] - a[i[0] -1] == i[2]:
            ans += i[3]
    
    return ans

N ,M, Q = map(int, input().split())
abcd = list()
for i in range(Q):
    abcd.append(list(map(int, input().split())))

ans = 0
for a in itertools.combinations_with_replacement(range(1, M+1), N):
    ans = max(ans, score(a, abcd))

print(ans)

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

int main(){
	long long N,x;
	cin >> N >> x;
	vector<long long> a(N);
	long long loop;
	for(loop=0;loop<N;loop++){
		cin >> a[loop];
	}
	long long ans=0,tmp;
	if(a[0]>x){
		ans += a[0]-x;
		a[0]=x;
	}
	for(loop=1;loop<N;loop++){
		if(a[loop-1]+a[loop]>x){
			tmp = a[loop-1]+a[loop]-x;
			a[loop] -= tmp;
			ans += tmp;
		}
	}
	cout << ans << endl;
	return 0;
}


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

const int MAX = 200010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    COMinit();
    long long ans = 0;
    k = min( k, n-1 );
    
    for(int m=0;m<=k;++m){
        ans += ( COM(n, m) * COM(n-1, m) ) % MOD;
        ans %= MOD;
    }

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


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0106
{
    public class Program

    {
        public static void Main(string[] args)
        {

            int[] weight = new int[] { 2, 3, 5, 10, 12, 15 };
            int[] price = new int[] { 380, 550, 850, (int)(380 * 5 * 0.8), (int)(550 * 4 * 0.85), (int)(850 * 3 * 0.88) };

            int[] dp = Enumerable.Repeat(20000, 51).ToArray();
            dp[0] = 0;

            for (int i = 0 ; i < weight.Count() ; i++)
            {
                for (int j = 0 ; j + weight[i] < dp.Count() ; j++)
                {
                    dp[j + weight[i]] = Math.Min(dp[j + weight[i]], dp[j] + price[i]);
                }
            }

            while (true)
            {
                int n = RInt();
                if (n == 0) break;
                Console.WriteLine(dp[n / 100]);
            }

        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 16336
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//整数を三つ受けとる

		int number1 = 0;
		int number2 = 0;
		int number3 = 0;
		//
		String anser = "NO";

		Scanner scan = new Scanner(System.in);

         number1 = scan.nextInt();
         number2 = scan.nextInt();
         number3 = scan.nextInt();


		//処理開始
		if(checkFiveOrSeven(number1)) {
			if(checkFiveOrSeven(number2)) {
				if(checkFiveOrSeven(number3)) {
					if(number1 + number2 + number3 == 17) {
						anser = "YES";
					}
				}
			}

		}

		System.out.println(anser);

	}

	private static boolean checkFiveOrSeven(int number) {
		if(number ==5 || number == 7) {
			return true;
		}
		return false;
	}

}



Measured memory_bytes: 22740
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b;
    cin >> a >> b;
    int cnt = 1;
    for(int i = 1; i <= 499500; i += cnt){
        cnt++;
        if(i - a > 0 && i + cnt - b == i - a){
            cout << i - a;
            return 0;
        }
    }
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    ll n;
    cin >> n;
    ll ans = 0;

    REPN(i, 1, sqrt(n)+1) {
        if(n % i == 0) {
            ll tmp = n / i;
            if(!(i < n/i-1)) continue;
            ans += tmp - 1; 
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

typedef long long ll;

ll burgerN(ll n, ll x, vector<ll>& ps, vector<ll>& ls) {


    if (n == 0) return 1;
    if (x <= 1) return 0;



    if (x <= (ls[n-1] + 1)) {
        return burgerN(n-1, x-1, ps, ls);
    } else if (x == (ls[n-1] + 2)) {
        return ps[n-1] + 1;
    } else if (x <= (2 + 2 * ls[n-1])) {
        return ps[n-1] + 1 + burgerN(n-1, x-ls[n-1]-2, ps, ls);
    } else {
        return 2 * ps[n-1] + 1;
    }

    return 0;
    
}

int main() {
    ll N, X;
    cin >> N >> X;

    vector<ll> p_nums = {1};
    vector<ll> layer_nums = {1};

    for (ll i=0; i<=N; i++) {
        p_nums.emplace_back(p_nums[i]*2+1);
        layer_nums.emplace_back(layer_nums[i]*2+3);
    }

    ll res = burgerN(N, X, p_nums, layer_nums);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long t,i,j,k,a,b,c=0,d=0,n,m,x,y;
  string s;
  cin>>s;
  i=s.size();
  if(s[i-1]=='s') cout<<s<<"es"<<endl;
  else cout<<s<<"s"<<endl;

  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }

void solve()
{
    ll n, m;
    cin >> n >> m;
    char a[n][m];
    rep(i, n) rep(j, m) cin >> a[i][j];
    ll l = 0, r = 0;
    rep(i, n)
    {
        ll x = 0, y = 0;
        rep(j, m) if(a[i][j] == '#') {x = j; y = j; break;}
        for(ll j = x+1; j < m; j++){
            if(a[i][j] == a[i][j-1] && a[i][j] == '#') y = j;
            else break;
        }
        rep(j, m) if(a[i][j] == '#' && j > y) ANS("Impossible");
        if(x != r) ANS("Impossible");
        l = x, r = y; //cout << l << " " << r << endl;
    }
    ANS("Possible");
}
int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int h,w;
char s[500][500];
bool used[500][500];
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
ll b,wh;

void dfs(int x,int y,bool flag){
  //cout<<' '<<cnt<<' '<<x<<' '<<y<<endl;
  used[x][y]=true;
  if(flag) b++;
  else wh++;
  rep(i,4){
    int nx=x+dx[i],ny=y+dy[i];
    if(1<=nx && nx<=h && 1<=ny && ny<=w && !used[nx][ny]){
      if(flag){
        if(s[nx][ny]=='.') dfs(nx,ny,!flag);
      }else{
        if(s[nx][ny]=='#') dfs(nx,ny,!flag);
      }
    }
  }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w;
    FOR(i,1,h+1)FOR(j,1,w+1){
      cin>>s[i][j];
      used[i][j]=false;
    }
    ll ans=0;
    FOR(i,1,h+1)FOR(j,1,w+1){
      if(!used[i][j] && s[i][j]=='#'){
        b=0,wh=0;
        dfs(i,j,true);
        ans+=b*wh;
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8192
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll a,b,ans=0;
  cin>>a>>b;
  if(b!=1){
    ll t=1;
    while(t<b){
      t+=a-1;
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

public class Main{
	public static void main(String[] args) {
		Scanner stdin =new Scanner(System.in);
		int n=stdin.nextInt();
		int l=stdin.nextInt();
		int i;
		StringBuilder sb=new StringBuilder();
		List<String> list=new ArrayList<String>();
		for(i=0;i<n;i++){
			list.add(stdin.next());
		}
		Collections.sort(list);
		for(i=0;i<n;i++){
			sb.append(list.get(i));

		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 22100
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

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

typedef long long ll;
typedef string str;

#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()



int main() {
    IOS;
	
	int n;
	cin >> n;
	ll s = 0;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		s+=x;
	}
	cout << s - n;
}


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


Measured memory_bytes: 2108
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

# X, Y, A, B, C = 1, 2, 2, 2, 1
# p = [2, 4]
# q = [5, 1]
# r = [3]

p.sort()
q.sort()
r.sort()
p = p[-X:]
q = q[-Y:]

d = []
d += p
d += q
d += r
d.sort()

print(sum(d[-X-Y:]))


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N,K;
    char s[123];
    Scd2(N,K);
    Scs(s);

    Rep(i,N){
        if( i+1 == K ) s[i] -= ('A'-'a');
        printf ("%c", s[i]);
    }
    printf("\n");


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(n+2);rep(i,n)cin>>a[i+1];
  int sum = 0;
  a[0] = 0;
  a[n+1] = 0;
  rep(i,n+1){
    sum += abs(a[i] - a[i+1]);
  }
  rep(i,n){
    int ans = sum;
    ans -= abs(a[i] - a[i+1]);
    ans -= abs(a[i+2] - a[i+1]);
    ans += abs(a[i] - a[i+2]);
    print(ans);
  }
  return 0;
}

Measured memory_bytes: 1664
n, k, c = list(map(int, input().split()))
s = input()

left = []
last = -c-1
for i in range(n):
    if s[i] == "o":
        if last + c < i:
            left.append(i)
            last = i
            if len(left) == k:
                break
            
right = []
last = n + c
for i in range(n)[::-1]:
    if s[i] == "o":
        if last - c > i:
            right.append(i)
            last = i
            if len(right) == k:
                break

right = right[::-1]

for i in range(k):
    if right[i] == left[i]:
        print(right[i] + 1)

Measured memory_bytes: 20832
#include <stdio.h>
int noa(){
	//12 月 30 日の M 時から次の年になるまでは何時間か、求めてください。
	//1≦M≦23
	int m;
	scanf("%d\n", &m);
	int ptoday = 24;
	int res;
	res = ptoday + (ptoday-m);

	return res;
}
int main(void){
	// Your code here!
	printf("%d", noa());
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){

  int size=0,exch=0;
  scanf("%d",&size);
  int seq[size];
  for(int i=0;i<size;i++){
    scanf("%d",&seq[i]);
    //正解のため
    if(i==size-1){
      printf("%d\n",seq[i]);
      break;
    }
    printf("%d ",seq[i]);
  }
  for(int i=1;i<size;i++){
    for(int j=i;j>0;j--){
      if(seq[j-1]<seq[j]){
        break;
      }
      exch=seq[j-1];
      seq[j-1]=seq[j];
      seq[j]=exch;
    }
    //途中経過
    for(int k=0;k<size-1;k++){
      printf("%d ",seq[k]);
    }printf("%d\n",seq[size-1]);
  }


  return 0;
}



Measured memory_bytes: 2720
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define umapii  unordered_map<int,int>


int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int r;
	string s;
	cin >> s;
	if (s == "RRS" || s == "SRR") {
		r = 2;
	} else if (s == "RRR") {
		r = 3;
	} else if (s == "SSS") {
		r = 0;
	} else {
		r = 1;
	}
	cout << r << endl;
}


Measured memory_bytes: 3612
#include "iostream"
#include "algorithm"
#include "cmath"

using namespace std;

int main()
{	
	
	int a, b, c, K;
	cin >> a >> b >> c >> K;

	int maxN = max(max(a, b), c);
	int sum = a + b + c;
	cout << maxN*pow(2,K) + sum - maxN << endl;

    return 0;
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fi first
#define se second
#define pb emplace_back
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef pair<int,int> pi;
const int N=2005,inf=0x3f3f3f3f;
char s[N*3],s1[N];
int sum[N*3],nl[N*3],nr[N*3],res,len;
vector<pi>vc;
void init(){
	nl[0]=-inf;
	fp(i,1,len*3)nl[i]=(s[i]=='1'?i:nl[i-1]);
	nr[len*3+1]=inf;
	fd(i,len*3,1)nr[i]=(s[i]=='1'?i:nr[i+1]);
	fp(i,1,len*3)sum[i]=sum[i-1]+(s[i]=='1');
}
inline int findl(R int x){return min(inf,x-nl[x]);}
inline int findr(R int x){return min(inf,nr[x]-x);}
int main(){
	scanf("%s%s",s1+1,s+1),res=inf;
	len=strlen(s+1);
	fp(i,len+1,len*3)s[i]=s[i-len];
	init();
	fp(i,1,len*2+1){
		vc.clear();
		R int c=0;
		fp(j,1,len)if(s1[j]!=s[i+j-1]){
			++c;
			R int r=j+len,l=j+i-1;
			if(l>r)swap(l,r);
			if(sum[r]-sum[l-1]==0)
			vc.pb(pi(findl(l),findr(r)));
		}
		vc.pb(pi(0,0));
		sort(vc.begin(),vc.end());
		reverse(vc.begin(),vc.end());
		R int tmp=inf,mx=0;
		for(auto p:vc){
			if(p.fi!=inf&&mx!=inf)cmin(tmp,mx*2+p.fi*2);
			cmax(mx,p.se);
			if(mx==inf)break;
		}
		if(tmp!=inf)cmin(res,tmp+abs(len+1-i)+c);
	}
	if(res==inf)res=-1;
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
struct Coordinate {
	int x, y;
	std::array<Coordinate, 4> neighbors() const {
		return { Coordinate{x + 1, y}, Coordinate{x - 1, y}, Coordinate{x, y + 1}, Coordinate{x, y - 1} };
	}
};
int main() {
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	int n; std::cin >> n;
	std::vector<std::vector<int>> min_hate(n, std::vector<int>(n, n)), exists(n, std::vector<int>(n, 1));
	for (auto i = 0; i < n; ++i) for (auto j = 0; j < n; ++j) {
		min_hate[i][j] = std::min({ i, n - i - 1, j, n - j - 1 });
	}
	std::queue<Coordinate> queue;
	std::vector<int> order(n * n); for (auto& p : order) { std::cin >> p; --p; }
	int sum_hate{ 0 };
	for (const auto person : order) {
		const auto coordinate = Coordinate{ person % n, person / n };
		sum_hate += min_hate[coordinate.y][coordinate.x];
		queue.push(coordinate);
		exists[coordinate.y][coordinate.x]--;
		while (!queue.empty()) {
			const auto top = queue.front(); queue.pop();
			for (const auto next : top.neighbors()) if (0 <= next.y && next.y < n && 0 <= next.x && next.x < n) {
				if (min_hate[next.y][next.x] > min_hate[top.y][top.x] + exists[top.y][top.x]) {
					min_hate[next.y][next.x] = min_hate[top.y][top.x] + exists[top.y][top.x];
					queue.push(next);
				}
			}
		}
	}
	std::cout << sum_hate << '\n';
}

Measured memory_bytes: 6100
n=int(input())
d=[]
for i in range(1,11111+1):
  m=5*i-1
  if m%2==0:
    continue
  f=3
  while f*f<m+1:
    if m%f==0 or len(d)==n:
      break
    f+=2
  else:
    d.append(m)
print(*d)

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

int main(){
  int h, w;
  cin >> h >> w;
  string s[h+1];
  for ( int i = 1; i <= h; i++){
    cin >> s[i];
  }

  int l[h+2][w+2], r[h+2][w+2], t[h+2][w+2], u[h+2][w+2];
  for ( int i = 0; i <= h+1; i++){
    for ( int j = 0; j <= w+1; j++){
      l[i][j] = r[i][j] = t[i][j] = u[i][j] = 0;
    }
  }

  for ( int i = 1; i <= h; i++){
    for ( int j = 1; j <= w; j++ ){
      if ( s[i][j-1] == '.'){
        l[i][j] = l[i][j-1] + 1;
      } else {
        l[i][j] = 0;
      }
    }
    for ( int j = w; j >= 1; j-- ){
      if ( s[i][j-1] == '.'){
        r[i][j] = r[i][j+1] + 1;
      } else {
        r[i][j] = 0;
      }
    }
  }

  for ( int i = 1; i <= w; i++){
    for ( int j = 1; j <= h; j++){
      t[j][i] = s[j][i-1] == '.' ? t[j-1][i]+1 : 0;
    }
    for ( int j = h; j >= 1; j--){
      u[j][i] = s[j][i-1] == '.' ? u[j+1][i]+1 : 0;
    }
  }

  int ans = 0;
  for ( int i = 1; i <= h; i++){
    for ( int j = 1; j <= w; j++){
      ans = max(ans, t[i][j] + u[i][j] + l[i][j] + r[i][j]);
//      cout << i << " " << j << endl;
//      cout << t[i][j] << " " << u[i][j] << " " << l[i][j] << " " << r[i][j] << endl;
    }
  }

  cout << ans - 3 << endl;

  return 0;
}

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

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

	vector<int> av(n);
	for (auto& a : av) {
		cin >> a;
		--a;
	}

	int next = 0;
	int current = 0;
	long long loop = 0;
	vector<int> c(n, -1);
	while (1) {
		if (c[next] != -1) {
			loop = current - c[next];
			break;
		}

		c[next] = current;
		++current;
		next = av[next];
	}

	if (0 <= k - c[next]) {
		long long t = (k - c[next]) % loop;
		current = 0;
		while (1)
		{
			if (current == t) {
				cout << next + 1 << endl;
				break;
			}
			++current;
			next = av[next];
		}
	}
	else {
		current = 0;
		next = 0;
		while (1)
		{
			if (current == k) {
				cout << next + 1 << endl;
				break;
			}
			++current;
			next = av[next];
		}
	}

	return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;

int main()
{
    set<int > s;
    int q;
    cin>>q;
    int b,tp1;
    while(q--){
        cin>>tp1;
        if(tp1==1){
                cin>>b;
            if(s.find(b)!=s.end()){
                cout<<"1\n";
            }
            else{
                cout<<"0\n";
            }
        }
        else if(tp1==0){
            cin>>b;
            s.insert(b);
            cout<<s.size()<<"\n";
        }
        else{
            cin>>b;
            s.erase(b);
        }
    }

}




Measured memory_bytes: 12424
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define int long long
using namespace std;
signed main() {
    int A,B,C;
    cin>>A>>B>>C;
    
    if(A==B){
        cout<<C<<endl;
    }
    else if(A==C){
        cout<<B<<endl;
    }
    else{
        cout<<A<<endl;
    }
}

Measured memory_bytes: 3620
//long time no ac
#include<bits/stdc++.h>
using namespace std;


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}
string s[402];
ll n,m,c=0,d=0;
ll v[402][402]={0};
ll dx[]={-1,0,1,0},
	dy[]={0,-1,0,1};

void dfs(ll x,ll y)
{
	if(x>=n || y>=m || x<0 || y<0)
		return;
	v[x][y]=1;
	if(s[x][y]=='.')
		c++;
	if(s[x][y]=='#')
		d++;
	ll i;
	rep(i,4)
	{
		ll p=x+dx[i],q=y+dy[i];
		if(p<n && q<m && p>-1 && q>-1 && v[p][q]==0)
		{
			if((s[x][y]=='.' && s[p][q]=='#') || (s[x][y]=='#' && s[p][q]=='.'))
				dfs(p,q);
		}
	}
}


int main()
{
	SPEED;
	ll k,t,i,j,cs=0;
	t=1;

	//cin>>t;
	while(t--)
	{
		cin>>n>>m;
		// n=s.length();
		// ll a[n];
		rep(i,n)
		{
			cin>>s[i];
		}
		rep(i,n) rep(j,m)
		if(s[i][j]=='#')
		{
			c=0;d=0;
			if(!v[i][j])
			{
				dfs(i,j);
				// cout<<c<<"&^"<<d<<"\n";
			}
			cs+=c*d;
		}
		cout<<cs;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 11648
use std::io;
fn read<T: std::str::FromStr>() -> T {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn main() {
    loop {
        let n: Vec<usize> = read_vec();
        if n[0] == 0 && n[1] == 0 {
            break;
        }
        for i in 0..n[0] {
            for j in 0..n[1] {
                print!("{}", if i % 2 == j % 2 { "#" } else { "." });
            }
            println!();
        }
        println!();
    }
}



Measured memory_bytes: 5024
def input_data():
    num = raw_input()
    array = []
    array = num.strip().split(" ")
    array = map(int, array)
    return array


def main():
    n = raw_input()
    count = 0
    array = input_data()
    flag = True
    i = 0
    while flag:
        flag = False
        for j in reversed(xrange(i + 1, int(n))):
            if array[j] < array[j - 1]:
                v = array[j]
                array[j] = array[j - 1]
                array[j - 1] = v
                flag = True
                count += 1
        i += 1
    array = map(str, array)
    print " ".join(array)
    print str(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 6368
#include <iostream>

using namespace std;

int main(){
  
  long n;
  long answer = 0;
  
  cin >> n;
  
  if(n % 2 != 0){
    cout << "0" << endl;
    return 0;
  }
  
  n = n / 2;
  
  while(n >= 5){
    n = n / 5;
    answer += n;
  }
  
  cout << answer << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

string s;

int main()
{
    cin >> s;
    int ans = 700;
    rep(i, (int)s.size()){
        if(s[i] == 'o') ans += 100;
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
using ll = long long;
const int N = 2e6 + 15;
int main(){
	string s, t;
	cin >> s >> t;
	if (t.size() != 1 + s.size()) {
		cout << "No\n";
		return 0;
	}
	int ok = 1;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] != t[i]) ok = 0;
	}
	if (ok) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <math.h>
#include <cmath>
using namespace std;
int main()
{
    int a,b,n,k=0;
    cin>>n;
    b=n+1;
    while(n--)
        {
            cin>>a;
            b=min(b,a);
            if(a==b)k++;
        }
    cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 256