akhauriyash/Code-Regression huggingface dataset:
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main() {
    int k, s;
    cin >> k >> s;

    int ans = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (z >= 0 && z <= k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3580
import collections

N = int(input())
route = []
for i in range(N):
    a = list(map(int, input().split()))
    route.append(a[2:])
ans = [-1 for _ in range(N)]
ans[0] = 0
check = collections.deque([0])#now distance
while check:
    now = check.popleft()
    for next in route[now]:
        next -= 1
        if ans[next] == -1:
            check.append(next)
            ans[next] = ans[now]+1
for i in range(N):
    print(i+1, ans[i])



Measured memory_bytes: 6032
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

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

        int n = in.nextInt();
        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt() - i;
        }
        Arrays.sort(arr);
        int tar = arr[n / 2];
        long res = 0;
        for (int i = 0; i < n; i++) {
            res += Math.abs(tar - arr[i]);
        }
        out.println(res);


        out.close();
        //INT OVERFLOW -> USE LONG
        //ARR OUT OF BOUNDS
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public double[] nextDoubleArray(int n) {
            double[] arr = new double[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        public char[] nextCharArray(int n) {
            char[] arr = nextLine().trim().replaceAll("\\s", "").toCharArray();
            return arr;
        }

        public String[] nextStringArray(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 44788
#include<stdio.h>

int main(void){
    int a,b,i;
    scanf("%d%d",&a,&b);
    /*if(a%2==0){
        x = 12.5*a;
    }else{
        x = (12.5*a)+1;
    }
    
    for(;(int)(x*0.08)<=a;x++){
        //printf("%d",(int)(x*0.1));
        if((int)(x*0.1)==b){
            printf("%d",x);
            return 0;
        }
    }
    printf("-1");*/
    for(i=1;i<1010;i++){
        if((int)(i*0.08) == a && (int)(i*0.1) ==b){
            printf("%d",i);
            return 0;
        }
    }
    printf("-1");
    return 0;
}



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

int main(void) {
    int N; cin >> N;
    int ave,sum=0,ans1=0,ans2=0,ANS;
    vector<int> X(N+10,0);
    for(int i=0; i<N; i++) {
        cin >> X[i];
        sum += X[i];
    }

    ave = sum/N;
    for(int i=0; i<N; i++) {
        ans1 += pow((X[i] - ave),2);
        ans2 += pow((X[i] - ave-1),2);
    }
    //cout << ans1 << " " << ans2 << endl;
    if(ans1<ans2) ANS = ans1;
    else ANS = ans2;
    cout << ANS << endl;
}

Measured memory_bytes: 3652
import fractions
A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
ans = 1
sqrt = gcd ** 0.5
for i in range(2, int(sqrt) + 2):
    if gcd % i == 0:
        ans += 1
        while True:
            gcd //= i
            if gcd % i != 0:
                break
if sqrt < gcd:
    ans += 1
print(ans)

Measured memory_bytes: 5048
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <bitset>
#include <math.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
const ll MOD = 1e9+7;
#define INF 10000000000000


inline ll Upstair(ll n){
	ll rt;
	if(n==1) return 1;
	return n*Upstair(n-1);
}

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

class Tree
{
	public:
//		Tree(int _root);
		int root;
		vector<int> next;
		int value = 0;
};

template<class T>
class Vec3
{
	public:
		T act[3];
};

int Stair( int now, vector<ll> &H )
{
	if( H[now] >= H[now+1] ){}
	
}

int main(void) {
	
	ll N,W;
	inp(N);
	inp(W);
	vector<ll> weight(N);
	vector<ll> value(N);
	rep(i,N){
		inp(weight[i]);
		inp(value[i]);
	}
	vector<vector<ll>> dp_v(N+1, vector<ll>(W+1));
	rep(w,W+1) dp_v[0][w] = 0;
	
	rep(i,N)rep(w,W+1){// i:品物番号 w:ナップサックの重さ
		if( weight[i] <= w ){//まだ入るなら
			dp_v[i+1][w] = max(dp_v[i][w],//入れない
							 dp_v[i][w-weight[i]]+value[i]//入れる
							);
		}else{//入らないなら
			dp_v[i+1][w] = dp_v[i][w];//入れない
		}
	}
/*	
	rep(i,N+1){
		rep(w,W+1){
			cout << dp_v[i][w] << " , ";
		}
		cout << endl;
	}
*/
	ll ans = dp_v[N][W];
	out(ans);
	
		
}


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

int main() {
    
    
    
    int N,A,B;
    cin>>N>>A>>B;
    vector<int> S(N);
    for(int i=0;i<N;i++){
        cin>>S.at(i);
    }
    int count_1=0,count_2=0,count_3=0;
    for(int i=0;i<N;i++){
        if(S.at(i)<=A) count_1++;
        else if(S.at(i)<=B) count_2++;
        else count_3++;
    }
    cout<<min({count_1,count_2,count_3})<<endl;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	int n;
	cin >>n;
	vector<queue<int>> a(n);
	REP(i,n){
		REP(j,n-1){
			int t;
			cin >> t;
			t--;
			a[i].push(t);
		}
	}

	int day=0;
	VI check;
	REP(i,n){
		check.push_back(i);
	}

	while(!check.empty()){
		day++;
		//dump(day)
		VI check_next;
		vector<bool> f(n,false);
		REP(i,SIZE(check)){
			//dump(check[i])
			if(a[check[i]].empty()){
				continue;
			}
			int c1 = a[check[i]].front();
			if(a[c1].empty()){
				continue;
			}
			int c2 = a[c1].front();
			if((check[i] == c2) && !f[c1] && !f[c2]){
				//dump(c1)
				//dump(c2)
				check_next.push_back(c1);
				check_next.push_back(c2);
				a[c1].pop();
				a[c2].pop();
				f[c1] = true;
				f[c2] = true;
			}
		}
		check = check_next;
	}

	REP(i,n){
		if(!a[i].empty()){
			cout << "-1" << endl;
			return;
		}
	}

	cout << day-1 << endl;



	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 4736
using System;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] input = new string[n];

		for (int i = 0; i < n; i++)
		{
			input[i] = (Console.ReadLine());
		}

		int[] moti = input.Select(int.Parse).ToArray();
		var sortedMoti = moti.OrderBy(a => -a).ToList();

		int count = 1;

		for (int i = 1; i < n; i++)
		{
			if (sortedMoti[i - 1] != sortedMoti[i])
			{
				count++;
			}
		}
		Console.WriteLine((count).ToString());
	}
}

Measured memory_bytes: 13396
h,w=map(int,input().split())
s=["."*(w+2)]
for i in range(h):s.append("."+input()+".")
s.append("."*(w+2))
ans="Yes"
for i in range(1,h+1):
  for j in range(1,w+1):
    if s[i][j]==".":continue
    if s[i-1][j]+s[i+1][j]+s[i][j-1]+s[i][j+1]=="....":ans="No"
print(ans)


Measured memory_bytes: 9208
n = input()
first = int(n[-1:])
hon = [2,
       4,
       5,
       7,
       9
       ]
pon = [0,
       1,
       6,
       8
       ]
bon = [3]


if first in hon:
    print("hon")
elif first in pon:
    print("pon")
else:
    print("bon")

# if int((str(n)[-1:])) in hon:
#     print("hon")
# elif int(str(n)[-1:]) in pon:
#     print("pon")
# else:
#     print("bon")


Measured memory_bytes: 61660
def main():
    N, K = map(int, input().split())
    pos = []
    neg = []
    zero = []
    for x in map(int, input().split()):
        if x < 0: neg.append(x)
        elif x > 0: pos.append(x)
        else: zero.append(x)
    K -= len(zero)
    if K <= 0: return 0
    minT = float('inf')
    for i in range(K+1):
        dneg, dpos = 0, 0
        if i <= len(neg) and K-i <= len(pos):
            if i > 0:
                dneg = -neg[len(neg)-i]
            if K-i > 0:
                dpos = pos[K-i-1]
            minT = min([minT, 2*dneg+dpos, dneg+2*dpos])
    return minT

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

Measured memory_bytes: 14480
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n =sc.nextInt();
    int k =sc.nextInt();
    if(n<k||n%k!=0){
        System.out.println(1);
    }
    else System.out.println(0);
  }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+4;
const int INF = 1e9+7;
int a[N];
int n;
int main()
{
	int ans = 0;
	a[0] = INF;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		ans = __gcd(ans,a[i]);
	}

	cout<<ans;
	
}

Measured memory_bytes: 640
N,M=map(int,input().split())
H=list(map(int,input().split()))
H1=H.copy()
for x in range(M):
    i,j=map(int,input().split())
    if H[i-1]>H[j-1]:
        H1[j-1]=0
    elif H[i-1]<H[j-1]:
        H1[i-1]=0
    else:
        H1[i-1]=0
        H1[j-1]=0
print(len([x for x in H1 if x>0]))

#print([x for x in H1 if x>0])


Measured memory_bytes: 20120
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
#define vec vector<int>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define ll long long
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;
int main(){
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i<b||j<a){
        if(i<b&&j<a){
          cout<<0;
        }
        else{
          cout<<1;
        }
      }
      else{
        cout<<0;
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <iostream>
int main() {
   int a, b, c;
   char op;
   while(true){
        std::cin >> a >> op >> b;
        if (op == '+') {
            c = a + b;
        } else if (op == '-') {
            c = a - b;
        } else if (op == '*') {
            c = a * b;
        } else if (op == '/') {
            c = a / b;
        } else {
            break;
        }
       std::cout << c << std::endl;
   }
   return 0;
}


Measured memory_bytes: 3092
local n = io.read("*n", "*l")
local s = io.read()
local t = io.read()
local pos = n + 1
for i = 1, n do
  local same = true
  for j = i, n do
    if(s:sub(j, j) ~= t:sub(j - i + 1, j - i + 1)) then
      same = false
      break
    end
  end
  if same then
    pos = i
    break
  end
end
print(n + pos - 1)


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b ;
    scanf("%d %d",&a,&b);
    if(a < b)
        printf("a < b\n");
    else if(a > b)
        printf("a > b\n");
    else if(a == b)
        printf("a == b\n");
    return 0 ;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  long long p[n];
  for(int i=0; i<n; i++){
    cin >> p[i];
  }
 
  long long a=p[0];
  
  int ans=1;
  for(int j=1; j<n; j++){
    a=min(a, p[j]);
    if(a == p[j]){
      ans++;
    }
  }
  
  cout << ans << endl;
  
  
}


Measured memory_bytes: 1792
use std::process::exit;
// stdin
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

// input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"4 150
150 140 100 200
" => r"2",

r"1 500
499
" => r"0",

r"5 1
100 200 300 400 500
" => r"5"
}

fn solve(src: &str) -> String {
    input! {
        source=src,
        n:usize,
        k:i32,
        h:[i32;n],
    }

    let mut h: Vec<i32> = h;
    let k: i32 = k;
    let t: Vec<i32> = h.iter().filter(|h| h >= &&k).cloned().collect();

//    format!("{:.10}", t.len())
    format!("{}", t.len())
}

fn main() {
    println!("{}", solve(&stdin!()));
}


Measured memory_bytes: 4352
def checkW(H, W, a):
    if W % 3 == 0:
        return 0
    x = int(W / 3) + a
    y = int(H / 2)
    if x == 0 or y == 0 or (W-x) == 0:
        return 10000000000
    S = [x*H, (W-x)*y, (W-x)*(H-y)]
    #print(x, y, S, max(S),min(S))
    return max(S) - min(S)

def checkH(H, W, a):
    if H % 3 == 0:
        return 0
    x = int(W / 2)
    y = int(H / 3) + a
    if x == 0 or y == 0 or (H-y) == 0:
        return 10000000000
    S = [W*y, x*(H-y), (W-x)*(H-y)]
    #print(x, y, S, max(S),min(S))
    return max(S) - min(S)

def check(H,W):
    x = int(W/3)
    x2 = int((W-x)/2)
    x3 = int(W-x-x2)
    S = [x*H, x2*H, x3*H]
    mx = max(S) - min(S)
    y = int(H/3)
    y2 = int((H-y)/2)
    y3 = int(H-y-y2)
    S = [W*y, W*y2, W*y3]
    my = max(S) - min(S)
    return min(mx, my)

s = input().split(' ')
H = int(s[0])
W = int(s[1])
print(min(checkW(H,W,0), checkW(H,W,1),
          checkH(H,W,0), checkH(H,W,1),
          check(H,W)))

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int x=sc.nextInt();
        int d[] = new int[n];
        for(int i=0; i<n; i++) {
            d[i]=abs(sc.nextInt()-x);
        }
        long gcd=d[0];
        if(n>1){
            gcd=gcd(d[0],d[1]);
            for(int i=2; i<n; i++) {
                gcd=gcd(gcd,d[i]);
            }
        } 
        out.println(gcd);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  

    static long gcd(long a, long b){
        if(min(a,b) == 0)return max(a,b);
        return gcd(max(a,b) % min(a,b),min(a,b));
    }
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

typedef long long int ll;

ll x;
ll k;
ll d;
ll ans;

int main(void){
  
  ll i;
  ll cnt;
  ll tmp;
  
  cin >> x >> k >> d;

  ans = abs(x);
  
  cnt=0;
  
  tmp = ans / d;

  if(tmp >= k)
  {
	ans = ans - d * k;
    cout << ans;
    return 0;
  }
  else
  {
  	ans = ans - d * tmp;
    if((k - tmp) % 2 == 0)
    {
      cout << ans;
      return 0;
    }
    else
    {
      cout << d - ans;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;

int main(){
   int N,M;
   cin>>N>>M;
   const int nmax=50;
   char A[nmax][nmax],B[nmax][nmax];
   for(int y=0;y<N;y++){
     for(int x=0;x<N;x++){
       cin>>A[y][x];
      }
   }
   for(int y=0;y<M;y++){
     for(int x=0;x<M;x++){
       cin>>B[y][x];
     }
   }
   bool exist=false;

   for(int ly=0;ly<N;ly++){
     for(int lx=0;lx<N;lx++){
       if(ly+M-1>=N||lx+M-1>=N)continue;

       bool match=true;
       for(int y=0;y<M;y++){
         for(int x=0;x<M;x++){
           if(A[ly+y][lx+x]!=B[y][x])match=false;
         }
       }
       if(match)exist=true;
     }
   }
   if(exist){
     cout<<"Yes"<<endl;
   }
   else{
     cout<<"No"<<endl;
   }
   return 0;
}

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

int gcd(int a, int b) {
	if (a == 0) return b;
	if (b == 0) return a;
	if (a > b) return gcd(a%b, b);
	else return gcd(a, b%a);
}

struct node {

    int s, e, m, val;
    node *l, *r;
    node (int _s, int _e) {
        s = _s;
        e = _e;
        m = (s + e)/2;
        val = 0;
        if (s == e) return;
        l = new node(s, m);
        r = new node(m+1, e);
    }

    void upd(int p, int v) {
        if (s == p && s== e) {
            val = v;
            return;
        }
        if (p <= m) {
            l->upd(p, v);
        }
        else {
            r->upd(p, v);
        }
        val = gcd(l->val, r->val); // edit with cascade operation, what makes the answer for a...b given a..m and m+1..b?
    }

    int qry(int qs, int qe) {
        if (qs <= s && e <= qe) {
            return val;
        }
        else if (qs > e || s > qe) {
            return -1; // edit with base case. if an interval should not be considered, then what is the value that will ensure it is not considered?
        }
        else {
			int lef = l->qry(qs, qe);
			int rig = r->qry(qs, qe);
            if (lef == -1) return rig;
            if (rig == -1) return lef;
            return gcd(lef, rig); // edit with cascade operation, what makes the answer of a...b, given a..m and m+1..b?
        }
    }
} *root;

void init(int N) {
    root = new node(0, N-1);
}

void update(int P, int V) {
    root->upd(P, V);
}

int query(int A, int B) {
    return root->qry(A, B);
}

int main() {

	int n;
	cin >> n;
	init(n);
	int arr[n];
	
	for (int i=0; i<n; i++) {
		cin >> arr[i];
		update(i, arr[i]);
	}
	
	int best = query(1, n-1);
	
	for (int i=1; i<n-1; i++) {
		best = max(best, gcd(query(0, i-1), query(i+1, n-1)));
	}
	
	best = max(best, query(0, n-2));
	
	cout << best << endl;
}


Measured memory_bytes: 9984
/*
                        --------------- PramodDubey 's code-_______
                        /''''''''''(______O] ----------____  \______/]_
     __...---'"""\_ --''        IIT DELHI     ___________@ -> ->  -> - --  - -- - ---- ->>
 |'''                   ._   _______________=---------"""""""
 |                ..--''|   l L |_l   |
 |          ..--''      .  /-___j '   '
 |    ..--''           /  ,       '   '
 |--''                /           `    \
                      L__'         \    -
                                    -    '-.
                                     '.    /
                                       '-./
*/

///   ------------ Bismillah hirrahman nirrahim ----------   ///

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
	boost;
	ll k;
	cin>>k;
	int ans=0;
	for(ll i=1;i<=k;i++){
		if(i%2){
			for(ll j=i+1;j<=k;j++){
				if(j%2==0)ans++;
			}
		}
		else{
			for(ll j=i+1;j<=k;j++){
				if(j%2)ans++;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int binarySearch(int ,int* ,int);

int main()
{
  
  int count=0;
  int a;
  int i,t[100000];
  int b;
  int c;
  
  scanf("%d",&a);
  
  for(i = 0;i < a;i++){
    scanf("%d",&t[i]);
  }
  
  scanf("%d",&b);
  
  for(i = 0; i < b; i++){
    scanf("%d",&c);
    count += binarySearch(a,t,c);
  }
  
  printf("%d\n",count);
  
  return 0;
}



    
int binarySearch(int x, int *y, int z)
{
  int right,left,mid;
  left = 0;
  right = x;
  while( right > left+1 ) {
    mid = ( right + left )/2;
    if ( y[mid] >  z ) right = mid;
    else left = mid;
  }
  
  return y[left] == z;
}



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

namespace Forg2
{
	class Program
	{
		static void Main()
		{
			var line = Console.ReadLine();
			var lineSplited = line.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);

			var N = int.Parse(lineSplited[0]);
			var K = int.Parse(lineSplited[1]);

			var H = new List<int>();
			var line2 = Console.ReadLine();
			var lineSplited2 = line2.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
			foreach (var token in lineSplited2) {
				H.Add(int.Parse(token));
			}

			var table = new List<int>();
			for (int i = 0; i < N; i++) {
				table.Add(int.MaxValue);
			}
			table[0] = 0;

			for (int i = 1; i < N; i++) {
				var costs = new List<int>();

				for (int k = 1; k <= K && i >= k; k++) {
					costs.Add(table[i - k] + Math.Abs(H[i] - H[i - k]));
				}

				table[i] = costs.Min();
			}

			Console.WriteLine(table[N - 1]);

			// var dp = new DP(N, K, H);
			// Console.WriteLine(dp.getCost(N - 1));
		}
	}

	class DP
	{
		int N, K;
		List<int> H;
		List<int> table;

		public DP(int N, int K, List<int> H)
		{
			this.N = N;
			this.K = K;
			this.H = H;

			table = new List<int>();
			for (int i = 0; i < N; i++) {
				table.Add(int.MaxValue);
			}

			table[0] = 0;
		}

		public int getCost(int i)
		{
			if (table[i] < int.MaxValue) return table[i];

			var costs = new List<int>();
			for (int k = 1; k <= K && i >= k; k++) {
				if (table[i - k] < int.MaxValue)
					costs.Add(table[i - k] + Math.Abs(H[i] - H[i - k]));
				else
					costs.Add(getCost(i - k) + Math.Abs(H[i] - H[i - k]));
			}

			return table[i] = costs.Min();
		}
	}
}


Measured memory_bytes: 27604
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,N) for(ll i=0;i<N;i++)
#define INF (1000000007)
typedef long long int ll;
using namespace std;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;

int main(){    
    ll N,x,y,max,ind;
    ll ans=0;
    cin>>N;
    vvl a(N,vl(2)),b(N,vl(2));
    rep(i,N){
        cin>>a[i][0]>>a[i][1];
    }
    rep(i,N){
        cin>>b[i][0]>>b[i][1];
    }
    
    sort(b.begin(),b.end());
    rep(i,N){
        x=b[i][0];
        y=b[i][1];
        max=-1;
        rep(j,N){
            if(a[j][0]<x && a[j][1]<y){
                if(a[j][1]>max){
                    max=a[j][1];
                    ind=j;
                }
            }
        }
        
        if(max!=-1){
            ans++;
            a[ind][0]=INF;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = scan.nextInt();
        int b = scan.nextInt();
        HashSet<Integer> set = new HashSet<>();
        set.add(1);
        set.add(2);
        set.add(3);
        set.remove(a);
        set.remove(b);
        for (Iterator<Integer> i = set.iterator(); i.hasNext();) {
            System.out.println( i.next());
            return;
        }
    }
}


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

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
	ll n;
	cin >> n;
	auto dn = divisor(n);
	auto dn1 = divisor(n-1);
	
	int ans = dn1.size()-1;
	rep(i, dn.size()) {
		if(dn1[i] == 1) continue;
		ll tmp = n;
		while(tmp % dn[i] == 0) {
			tmp /= dn[i];
		}
		if(tmp%dn[i] == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#[allow(unused_imports)]
use std::cmp::Ordering::{Equal, Greater, Less};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// author: Seong Yong-ju <sei40kr@gmail.com>

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        m: u64,
        abs: [(u64, u64); n],
    };

    let mut abs = abs;
    abs.sort_by_key(|&(a, _)| a);

    let ans = abs
        .into_iter()
        .scan(0, |state, (a, b)| {
            if m <= *state {
                None
            } else {
                let x = min(b, m - *state);

                *state += x;

                Some(a * x)
            }
        })
        .sum::<u64>();

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


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define INF 1e9
#define MOD 1000000007
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main(void){
    string S;
    cin>>S;
    REP(i,S.size()){
        cout<<"x";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))

sum = sum(W)

x = 0
tmp = 0
ans = sum

for val in W:
    x = x + val
    tmp = abs((sum - x) - x)

    if ans < tmp:
        break
    else:
        ans = (sum - x) - x

print(abs(ans))


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

int main() {
	int t; scanf("%d", &t);
	while (t--) {
		long long a, b, c, d; scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
		if (a < b || d < b) puts("No");
		else if (c >= b) puts("Yes");
		else {
			long long x = a % b, y = __gcd(b, d);
			x += (b - 1 - x) / y * y;
			if (x > c) puts("No");
			else puts("Yes"); 
		}
	}
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val A = Array.fill(sc.nextInt())(sc.nextLong)
  val sums = A.scanLeft(0L)(_ + _).tail
  println {
    A
      .indices
      .map(i => A(i) * ((sums.last - sums(i)) % 1000000007))
      .fold(0L)((l, r) => (l + r) % 1000000007)
  }
}


Measured memory_bytes: 68940
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 n, m; scanf("%lld%lld", &n, &m);
	std::vector<std::vector<int>> g(n);
	for(int i = 0; i < m; i++) {
		int a, b; scanf("%d%d", &a, &b);

		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}

	std::vector<int> used(n, -1);
	std::queue<int> qu({0}); used[0] = 0;
	while(!qu.empty()) {
		auto v = qu.front(); qu.pop();

		for(auto e: g[v]) {
			if(used[e] == -1) {
				used[e] = 1 - used[v];
				qu.push(e);
				continue;
			}
			if(used[e] == used[v]) {
				printf("%lld\n", n * (n - 1) / 2 - m);
				return 0;
			}
		}
	}

	i64 A = 0, B = 0;
	for(auto v: used) {
		if(v) A++;
		else B++;
	}
	printf("%lld\n", A * B - m);
	return 0;
}


Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	String S=sc.nextLine();
    	
    	S=S.replaceAll(","," ");
    	
    	System.out.println(S);
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a.at(i);
    ll ans = 0;
    ll maxval = 0;
    rep(i, n){
        chmax(maxval, a.at(i));
        ans += maxval - a.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4828
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i < 3;i++) list.add(sc.nextInt());
        list.sort((o1,o2)->o1-o2);
        System.out.printf("%d %d %d\n",list.get(0),list.get(1),list.get(2));
        sc.close();
    }

}

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

int main() {
	int s,s1,s2,s3,ans;
	cin >> s;
	s1 = s / 100;
	s2 = s % 100 / 10;
	s3 = s % 100 % 10 / 1;
	ans = s1 + s2 + s3;
	cout << ans << endl;
}

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

int main() {
    int n; cin >> n;
    int a[n] = {};
    for (int i = n - 1; i >= 0; --i) cin >> a[i];
    
    for (int i = 0; i < n - 1; ++i) cout << a[i] << " ";
    cout << a[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 3092
package main

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

func main() {
	K := ReadInt()
	c := 1
	seen := make([]bool, K)
	prev := 7 % K
	for prev != 0 {
		c++
		next := (10*prev + 7) % K
		if seen[next] {
			fmt.Println(-1)
			return
		}
		seen[next] = true
		prev = next
	}
	fmt.Println(c)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 2880
n,s;

int f(int d,int p,int b)
{
	int c=0,i=b+1;
	if(d==n+1)	return p==s;
	for(;i<=9;i++)
		c+=f(d+1,p+i,i);
	return c;
}

main(){
	for(;scanf("%d%d",&n,&s),n+s;)printf("%d\n",f(1,0,-1));
	exit(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int k,a,b;
int f(int moves,int cookies,int money){
	//cout<<moves<<" "<<cookies<<" "<<money<<"\n";
	if(!moves){
		return cookies;
	}
	if(cookies>=a){
		if(moves&1){
			moves--;cookies++;
		}
		//cout<<moves<<" "<<cookies<<" "<<money<<"asf\n";
		return cookies+(moves/2)*(b-a);
	}
	else {
		int d = a-cookies;
		return f(moves-d,a,money);
	}
}
int32_t main(){
	cin>>k>>a>>b;
	if(b<=(1+a) || k<=(a-1)){
		cout<<k+1;
		return 0;
	}
	cout<<f(k,1,0);
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs,heapq as hq
input = sys.stdin.readline
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def search(a,n):
    se = dict()
    data = []
    for i in range(0,len(a)-n+1):
        kkk = a[i:i+n]
        kkk = "".join(kkk)
        if In(kkk,data):
            if se[kkk] <= i-n:
                    return True
        else:
            bs.insort(data,kkk)
            se[kkk] = i
    return False
def solver():
    n = onem()

    s = list(input())
    l = 0
    r = n//2
    for i in range(n):
        mid = -(-(l+r)//2)
        ans = search(s,mid)
        if l == mid:
            break
        if ans:
            l = mid
        else:
            r = mid-1
    print(l)



if __name__ == '__main__':
    solver()





Measured memory_bytes: 9976
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] xs = new int[n];
        for(int i=0; i<n; i++){
            x[i] = sc.nextInt();
            xs[i] = x[i];
        }
        Arrays.sort(xs);
        sc.close();

        int m1 = xs[n/2-1];
        int m2 = xs[n/2];

        for(int i=0; i<n; i++){
            if(x[i] <= m1){
                System.out.println(m2);
            }else{
                System.out.println(m1);
            }
        }

    }
}

Measured memory_bytes: 90000
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <climits>
using namespace std;
using ll = long long;
const ll INF = 1ll << 60ll;

template<typename Monoid>
struct SegmentTree {
    using OP = function<Monoid(Monoid, Monoid)>;
    
    vector<Monoid> tree;
    int size;
    const OP f; // bin' operation
    const Monoid e; // neutral element
                                           
    SegmentTree(int nmemb, const Monoid &e, const OP &f):
        f(f),
        e(e)
    {
        size = 1;
        while (size < nmemb) {
            size *= 2;
        }

        tree.assign(2 * size - 1, e);
    }

    void update(int k, Monoid dat)
    {
        k += size - 1;
        tree[k] = dat;
        
        while(k > 0) {
            k = (k - 1) / 2;
            tree[k] = f(tree[2 * k + 1], tree[2 * k + 2]);
        }
    }

    // [l, r)
    Monoid query(int l, int r)
    {
        l += size - 1;
        r += size - 1;

        Monoid d = e;
        while (l < r) {
            if (l % 2 == 0) {
                d = f(d, tree[l]);
                l++;
            }
            if (r % 2 == 0) {
                r--;
                d = f(d, tree[r]);
            }

            l = (l - 1) / 2;
            r = (r - 1) / 2;
        }

        return d;
    }

    Monoid operator[] (const int k)
    {
        return query(k, k + 1);
    }
};

struct Character {
    ll ch, idx;

    Character(ll ch, ll idx): ch(ch), idx(idx) {}

    bool operator < (const Character &r) {
        if (this->ch < r.ch) {
            return true;
        }
        else if (this->ch == r.ch) {
            if (this->idx < r.idx) {
                return true;
            }
            else {
                return false;
            }
        }
        else {
            return false;
        }
    }
};

int main() {
    string str;
    string ans;
    ll n, k;

    cin >> str;
    cin >> k;

    n = str.size();
    SegmentTree<Character> s(n, Character(INF, 0),
                             [](auto l, auto r) {
                                 if (l < r) return l;
                                 else return r;
                             });
    SegmentTree<ll> RSQ(n, 0,
                        [](ll l, ll r) { return l + r; });

    for (int i = 0; i < n; i++) {
        s.update(i, Character((ll)str[i], i));
    }

    while (k > 0 && RSQ.query(0, n) < n) {
        ll valid, invalid;
        ll mid;

        valid = 0, invalid = n;
        while (invalid - valid > 1) {
            mid = (invalid + valid) / 2;

            if (mid - RSQ.query(0, mid + 1) <= k) {
                valid = mid;
            }
            else {
                invalid = mid;
            }
        }

        Character a = s.query(0, valid + 1);
        ans += (char)a.ch;

        k -= a.idx - RSQ.query(0, a.idx);
        RSQ.update(a.idx, 1);
        s.update(a.idx, Character(INF, 0));
    }

    for (int i = 0; i < n; i++) {
        if (RSQ[i] == 0) {
            ans += (char)s[i].ch;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 15812
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        n: usize,
        k: usize,
        mut p: [usize; n],
    }

    p.sort();
    let ans = p.into_iter().take(k).fold(0, |a, b| a + b);
    echo!(ans);
}


Measured memory_bytes: 2188
#include <iostream>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int n=a.length();
    int max=0,count=0;
    for (int i = 0; i < n; ++i) {
        if(a[i]=='A'||a[i]=='G'||a[i]=='T'||a[i]=='C')
        {count=0;
            while (a[i]=='A'||a[i]=='G'||a[i]=='T'||a[i]=='C')
            {
                count++;
                i++;
                if(i==n)
                    break;
            }
            if(count>max)
                max=count;
        }
    }
    cout<<max;
}

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

A = list(map(int,input().split()))

for i in range(N):
    A[i] -= 1

e = [True] * N
q = []
now = 0

while e[now]:

    e[now] = False
    q.append(now)

    now = A[now]


q1 = []
q2 = []

fl = True
for i in q:
    if now == i:
        fl = False
        
    if fl:
        q1.append(i)
    else:
        q2.append(i)
        
if K < len(q1):

    print ( 1 + q1[K])

else:
    K -= len(q1)
    print ( 1 + q2[K % len(q2)])


Measured memory_bytes: 108296
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}
int main() {
	int a, b, c, d;
	ll sum;
	cin >> a;
	d = a % 10; c = a / 10 % 10; b = a / 100 % 10; a = a / 1000 % 10;
	if (a + b + c + d == 7) {
		cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
		return 0;
	}
	if (a + b + c - d == 7) {
		cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
		return 0;
	}
	if (a + b - c + d == 7) {
		cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
		return 0;
	}
	if (a + b - c - d == 7) {
		cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
		return 0;
	}
	if (a - b + c + d == 7) {
		cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
		return 0;
	}
	if (a - b + c - d == 7) {
		cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
		return 0;
	}
	if (a - b - c + d == 7) {
		cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
		return 0;
	}
	if (a - b - c - d == 7) {
		cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
		return 0;
	}

	cout << "-1 -1 -1" << endl;

}

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

int main() {
  long A,V,B,W,T;
  cin >> A>>V>>B>>W>>T;
  if(A<B){
    if(W>=V){
      cout<<"NO"<<endl;
    }
    else if((V-W)*T>=B-A){
      cout<<"YES"<<endl;
    }
    else {
      cout<<"NO"<<endl;
    }
  }
  else{
    if(W>=V){
      cout<<"NO"<<endl;
    }
    else if((V-W)*T>=A-B){
      cout<<"YES"<<endl;
    }
    else {
      cout<<"NO"<<endl;
    }
  }
}

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

const int inf = 0x3f3f3f3f, N = 205;
queue<int> q;
char s[205];
int n, g[205][205], ans, dis[205], col[N], vis[N];

void bfs(int now) {
    memset(dis, 0x3f, sizeof(dis));
    memset(vis, 0, sizeof(vis));
    vis[now] = 1;
    dis[now] = 1;
    q.push(now);
    while (q.size()) {
        int x = q.front(); q.pop();
        rep(y, 1, n) {
            if (g[x][y] && !vis[y]) {
                vis[y] = 1;
                dis[y] = dis[x] + 1;
                q.push(y);
            }
        }
    }
}

void dfs(int x) {
    // rep(i, 1, n) printf("%d ", col[i]); puts("");
    vis[x] = 1;
    rep(y, 1, n) {
        if (!g[x][y]) continue;
        if (vis[y]) {
            if (col[x] == col[y]) {
                // printf("%d %d %d\n" , x, y, g[x][y]);
                puts("-1"); exit(0);
            }
        } else {
            col[y] = 3 - col[x];
            dfs(y);
        }
    }
}

int main() {
    cin >> n;
    rep(i, 1, n) {
        scanf("%s", s + 1);
        rep(j, 1, n) {
            g[i][j] = s[j] - '0';
        }
    }

    col[1] = 1;
    dfs(1);

    rep(i, 1, n) {
        bfs(i);
        rep(j, 1, n) {
            ans = max(ans, dis[j]);
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

const int INF = 1e9;
int n, m;
vector<int> cost;
vector<int> cost1;

int calc(int i) {
    if (cost[i] < INF) return cost[i];
    cost[i] = cost1[i];
    for (int j = 0; j < (1 << n); ++j) {
        int t = i & j;
        if (t == 0 || t == i) continue;
        cost[i] = min(cost[i], calc(i & j) + calc(i & (~j)));
    }
    return cost[i];
}

int main() {
    cin >> n >> m;
    cost.resize(1 << n, INF);
    cost1.resize(1 << n, INF);

    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        int open = 0;
        for (int j = 0; j < b; ++j) {
            int c;
            cin >> c;
            --c;
            open |= (1 << c);
        }
        for (int j = 0; j < (1 << n); ++j) {
            int t = open & j;
            cost1[t] = min(cost1[t], a);
        }
    }

    for (int i = 0; i < n; ++i) {
        if (cost1[1 << i] == INF) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << calc((1 << n)-1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int x=(double)n/1.08;
	if((int)(x*1.08)==n)
		printf("%d\n",(int)x);
	else if((int)((x+1)*1.08)==n)
		printf("%d\n",(int)x+1);
	else if((int)((x-1)*1.08)==n)
		printf("%d\n",(int)x-1);	
	else puts(":(");
	return 0;
}

Measured memory_bytes: 256