akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

vi A;

long solve_move(int mod, int N){
    vi A_MOD(N);    
    int move = 0;
    long mod_sum = 0;
    REP(i, 0, N) {
        A_MOD[i] = A[i] % mod;
        mod_sum += A_MOD[i];
    }
    
    sort(A_MOD.rbegin(), A_MOD.rend());
    REP(i, 0, mod_sum/mod){
        move += mod - A_MOD[i];
    }
    return move;
}

int main() {
    int N, K;
    cin>>N>>K;
    long sum = 0;
    A.resize(N);
    REP(i, 0, N){
        cin >> A[i];
        sum += A[i];
    }
    int max_GCD = 0;
    int root_sum = pow(sum, 0.5);
    REP(i, 1, root_sum + 1){
        if(sum % i == 0){
            int move = solve_move(i, N);
            if(move <= K && max_GCD < i) max_GCD = i;
            move = solve_move(sum/i, N);
            if(move <= K && max_GCD < sum / i) max_GCD = sum / i;
        }
    }
    cout << max_GCD << endl;
}

Measured memory_bytes: 256
X, K, D = map(int, input().split())
abs_x = abs(X)
hikukazu = abs(X) // D
count = K - (hikukazu)
if K > hikukazu:
    if count % 2 == 0:
        hikukazu = hikukazu
    else:
        hikukazu = hikukazu + 1
else:
    hikukazu = K


# for i in range(hikukazu):
    
#     abs_x = abs_x - D
abs_x = abs_x - (D*hikukazu)
    # print(X)

print(abs(abs_x))

Measured memory_bytes: 9128
#include<cstdio>
#include<cstring>
#define M 20002
#define N 2019
int A[N],B[N],C[N],S,T,a[N],b[M],c[M],d[M],e[M],g[N],i,l,n,q[N],r,t;long long f[N];bool h[N];
inline void add(int u,int v,int x,int y){b[++t]=a[u],c[a[u]=t]=v,d[t]=x,e[t]=y,b[++t]=a[v],c[a[v]=t]=u,e[t]=-y;}
int u,v,w;long long x;
inline bool bfs()
{
	memset(f,0x3f,T+5<<3),f[q[l=0]=S]=0,r=1;
	while(l!=r)for(h[u=q[l++]]=false,l=l==N?0:l,i=a[u];i;i=b[i])if(d[i]&&f[u]+e[i]<f[c[i]])
	{
		f[c[i]]=f[u]+e[i],g[c[i]]=i;
		if(!h[c[i]])h[q[r++]=c[i]]=true,r=r==N?0:r;
	}
	if(f[T]==0x3f3f3f3f3f3f3f3fll)return false;
	for(u=10,i=T;i!=S;i=c[g[i]^1])u=d[g[i]]<u?d[g[i]]:u;
	for(x-=u*f[i=T];i!=S;i=c[g[i]^1])d[g[i]]-=u,d[g[i]^1]+=u;
	return true;
}
int main()
{
	scanf("%d",&n),T=n<<1|1;
	for(i=t=1;i<=n;i++)scanf("%d%d%d",&u,&v,&w),add(S,i,w,0),add(i,T+1,10,u+v),add(i,T+2,10,u-v),add(i,T+3,10,v-u),add(i,T+4,10,-u-v);
	for(i=n+1;i<T;i++)scanf("%d%d%d",&u,&v,&w),add(T+1,i,10,-u-v),add(T+2,i,10,v-u),add(T+3,i,10,u-v),add(T+4,i,10,u+v),add(i,T,w,0);
	while(bfs());
	return 0*printf("%lld\n",x);
}

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

int main() {
  int n;
  cin >> n;
  string N;
  N = to_string (n);
  int sum = 0;
  int len;
  len = N.size();
  
  rep(i,len){
    char str;
    str = N[i];
    sum += str - '0' ;
  }
  if  (n%sum == 0) cout << "Yes" << endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 256
#include<iostream>
//#include <cmath>
//#include <bits/stdc++.h>

typedef long double ld;

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
  //  freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ld w,h,x,y;cin>>w>>h>>x>>y;
    //cout<<max(min(x,w-x)*h,min(y,h-y)*w)<<" ";
    cout<<w*h/2<<" ";
    if(x==w/2&&y==h/2) cout<<1;
    else cout<<0;
    return 0;
}

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

using ll = long long;
const int MAXN  = 2e5+10;
const int MAXM  = 1e5+10;

int N, M;

struct edge {
    int to, w;
};
vector<edge> G[MAXN];
int in[MAXN];
int d[MAXN];
bool vis[MAXN];

void add(int u, int v, int w) {
    G[u].push_back({v, w});
}
int bfs(int s) {
    queue<int> que;
    que.push(s);
    vis[s] = true;
    while(!que.empty()) {
        int u = que.front(); que.pop();
        for(int i=0; i<G[u].size(); i++) {
            int v = G[u][i].to;
            if(d[v]<d[u]+1) {
                que.push(v);
                vis[v] = true;
                d[v] = d[u] + 1;
            }
        }
    }

    int ret = 0;
    for(int i=1; i<=N; i++) {
        ret = max(ret, d[i]);
    }    
    return ret;
}
int solve(int s) {
    queue<int> que;
    que.push(s);
    while(!que.empty()) {
        int u = que.front(); que.pop();
        for(int i = 0; i<G[u].size(); i++) {
            int v = G[u][i].to;
            --in[v];
            if(in[v]==0) {
                if(d[v] < d[u]+1) {
                    d[v] = d[u] + 1;
                }
                que.push(v);
            }
        }
    }

    int ret = 0;
    for(int i=1; i<=N; i++) {
        ret = max(ret, d[i]);
    }    
    return ret;
}
int main() {
    cin >> N >> M;
    int a, b;
    for(int i=1; i<=M; i++) {
        cin >> a >> b;
        in[b]++;
        add(a, b, 1);
    }
    /*
    // TLE
    int ans = 0;
    for(int i=1; i<=N; i++) {
        if(in[i] == 0) {
            d[i] = 0;
            ans = max(ans, bfs(i));
        }
    }
    cout << ans << endl;
    */
    
    queue<int> que;
    for(int i=1; i<=N; i++) {
        if(in[i] == 0) {
            d[i] = 0;
            que.push(i);
        }
    }
    while(!que.empty()) {
        int u = que.front(); que.pop();
        for(int i = 0; i<G[u].size(); i++) {
            int v = G[u][i].to;
            --in[v];
            if(in[v]==0) {
                if(d[v] < d[u]+1) {
                    d[v] = d[u] + 1;
                }
                que.push(v);
            }
        }
    }

    int ans = 0;
    for(int i=1; i<=N; i++) {
        ans = max(ans, d[i]);
    }    
    cout << ans << endl;

    return 0;
}

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

void ans(int x) {
	if (x == 2 || x == 4 || x == 5 || x == 7 || x == 9) {
		cout << "hon" << endl;
	}
	else if (x == 3) {
		cout << "bon" << endl;
	}
	else {
		cout << "pon" << endl;
	}
}

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

	if (n < 10) {
		ans(n);
	}
	else if (n >= 10 && n < 100) {
		n = n % 10;
		ans(n);
	}
	else {
		n = n % 100;
		n = n % 10;
		ans(n);
	}

	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
  int dp[1001][1001];
  int n,W;
  int v[1000],w[1000];
  int num=0;
  while(cin>> W,W){
    num++;
    cin>> n;
    for(int i=0;i<n+1;i++){
      dp[0][i]=0;
    }

    for(int i=0;i<n;i++){
      char c;
      cin>> v[i]>> c>> w[i];
    }

    for(int i=1;i<=n;i++){
      for(int j=1;j<=W;j++){
	if(j<w[i-1]){
	  dp[i][j]=dp[i-1][j];
	}else{
	  dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
	}
      }
    }

    int mv=0,mw;
    for(int j=0;j<=W;j++){
      if(mv<dp[n][j]){
	mv=dp[n][j];
	mw=j;
      }
    }
    /*for(int i=0;i<=n;i++){
      for(int j=0;j<=W;j++){
	cout<< dp[i][j];
      }
      cout<< endl<< endl;
    }
    */
    cout<< "Case "<< num<< ":"<< endl;
    cout<< mv<< endl;
    cout<< mw<< endl;
  }
}

Measured memory_bytes: 5080
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e7;
const int MX = 100001; //check the limits, dummy

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

    int n; cin >> n;
    cout << n / 2 + n % 2 << endl;
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
num = C
ans = 0
for i in range(N):
  l = list(map(int,input().split()))
  for j in range(M):
    num += B[j] * l[j]
  if num > 0:
    ans += 1
    num = C
  else:
    num = C
print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <math.h>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 1e5+1;
const ll mod = 1e9+7;


int main(){

    FASTIO;
    PRECISION;

    int k,a,b;
    cin>>k>>a>>b;

    for(int i=1;i*k<=max(a,b);i++){
        if(i*k>=a){
            cout<<"OK\n";
            return 0;
        }
    }
    cout<<"NG\n";
   
}

Measured memory_bytes: 3624
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x,y,i,j,p,q=-1;
    cin>>x>>y;
    for(i=0;i<=x;++i){
    	p=i*2+(x-i)*4;
    	if(p==y){
    		q=1;
    		break;
		}
	}
	if(q==-1){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}
}

Measured memory_bytes: 3600
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        int inpt = int.Parse(string.Join("", Reader.ReadLine().Split(' ')));
        string ans = "NO";
        if(inpt%4==0) {
            ans = "YES";
        }
        Console.WriteLine(ans);
    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"



4 3 2


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


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

ans = sum(a)
from collections import Counter
cnt = Counter(a)

for i, j in s: 
    if j in cnt:
        cnt[j] += cnt[i]
    else:
        cnt[j] = cnt[i]    
    ans = ans - i * cnt[i] + cnt[i] * j
    if i in cnt:
        cnt.pop(i)
    print(ans)

Measured memory_bytes: 40216
n, x = map(int, raw_input().split())
a = map(int, raw_input().split())
counter = 0
for i in range(n-1):
    decrease = a[i] + a[i+1] - x
    if decrease > 0:
        counter += decrease
        if a[i+1] >= decrease:
            a[i+1] -= decrease
        else:
            a[i] -= decrease - a[i+1];
            a[i+1] = 0
print counter


Measured memory_bytes: 11316
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int ch[202020][2],cn[202020];
int a[202020],v[202020];
vector <pair<long long,long long> > vec[202020];
long long mid;
int n;
bool check()
{
	int now;
	for(int i=1;i<=n;i++)
	{
		vec[i].clear();
		if(cn[i]==0)
			vec[i].push_back(make_pair(v[i],v[i]));
	}
	for(int i=n;i>=1;i--)
		if(ch[i][0])
		{
			now=vec[ch[i][1]].size()-1;
			for(int j=0;j<vec[ch[i][0]].size();j++)
			{
				while(now>=0&&vec[ch[i][0]][j].first+vec[ch[i][1]][now].first>mid)
					now--;
				if(now>=0)
				{
					vec[i].push_back(make_pair(vec[ch[i][0]][j].second,vec[ch[i][1]][now].second));
					vec[i].push_back(make_pair(vec[ch[i][1]][now].second,vec[ch[i][0]][j].second));
				}
			}
			sort(vec[i].begin(),vec[i].end());
			for(int j=1;j<vec[i].size();j++)
				if(vec[i][j].second>=vec[i][j-1].second)
				{
					vec[i].erase(vec[i].begin()+j);
					j--;
				}
			for(int j=0;j<vec[i].size();j++)
			{
				vec[i][j].first+=v[i];
				vec[i][j].second+=v[i];
			}
		}
	if(vec[1].size())
		return true;
	return false;
}
int main()
{
	memset(cn,0,sizeof(cn));
	scanf("%d",&n);
	v[1]=0;
	for(int i=2;i<=n;i++)
	{
		scanf("%d%d",&a[i],&v[i]);
		ch[a[i]][cn[a[i]]++]=i;
	}
	long long l=0,r=10101010101ll;
	while(l<r)
	{
		mid=(l+r)>>1;
		if(check())
			r=mid;
		else
			l=mid+1;
	}
	printf("%lld",l);
	return 0;
}

Measured memory_bytes: 30580
import sys
sys.setrecursionlimit(10**9)

def min2(x, y): return x if x <= y else y

def rec(x):
    if x not in memo:
        ans = D*x
        for d, cost in zip([2, 3, 5], [A, B, C]):
            x2 = x//d
            if x2 != x:
                ans = min2(ans, x%d*D + cost + rec(x2))
            if x%d:
                x2 = (x+d-1)//d
                if x2 != x:
                    ans = min2(ans, (d-x%d)*D + cost + rec(x2))
        memo[x] = ans
    return memo[x]

anss = []
T = int(input())
for _ in range(T):
    N, A, B, C, D = map(int, input().split())
    memo = {}
    ans = rec(N)
    anss.append(ans)

print('\n'.join(map(str, anss)))


Measured memory_bytes: 11180
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }

// #define int long long

using namespace std;

signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int num = 0;
  // int n; cin >> n;
  // vector<int> v(n);
  // for (auto it = v.begin(); it < v.end(); ++it) cin >> *it;
  // for (auto it = v.begin(); it < v.end(); ++it) num += *it;
  // cout << num << endl;

  int n;
  int m;
  int c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (auto it = b.begin(); it != b.end(); ++it) cin >> *it;

  for (int i = 0; i < n; ++i) {
    vector<int> a(m);
    for (auto it = a.begin(); it != a.end(); ++it) cin >> *it;
    int tmp = 0;
    for (int j = 0; j < m; ++j) tmp += a[j] * b[j];
    if (tmp + c > 0) ++num;
  }

  cout << num << endl;
  return 0;
  
}


Measured memory_bytes: 256
use std::io::*;
use std::str::*;
use std::f64::consts::*;
use std::f64;

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")
    };
}

const MAX: i32 = 100000;

fn partition(A: &mut Vec<i32>, p: i32, r: i32) -> usize {
    let (mut x, mut i, mut j, mut t) = (0, 0, 0, 0);
    x = A[r as usize];
    i = p;
    for j in p..r {
        if A[j as usize] <= x {
            t = A[i as usize]; A[i as usize] = A[j as usize]; A[j as usize] = t;
            i += 1;
        }
    }
    t = A[i as usize]; A[i as usize] = A[r as usize]; A[r as usize] = t;
    i as usize
}

fn main() {
    let (mut i, mut q) = (0, 0);
    input!{
        n: i32,
        v: [i32; n]
    }
    let mut v = v;
    q = partition(&mut v, 0, n - 1);
    for i in 0..n {
        if i > 0 {
            print!(" ");
        }
        if i == (q as i32) {
            print!("[");
        }
        print!("{}", v[i as usize]);
        if i == (q as i32) {
            print!("]");
        }
    }
    print!("\n");
}


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

int main(){
int N;
cin >> N ;
 
vector<int> H(N);
for (int i = 0; i < N; i++){
 cin >> H.at(i);   
}

vector<int> A = {0};  

int ans = 0;
for (int i = 0; i < N-1; i++){ 
  if (H.at(i) >= H.at(i+1)){
   ans++; 
  }
  
  else{
    A.push_back(ans);
    ans = 0;
  }
}
  A.push_back(ans);
  sort(A.begin(), A.end());
  cout << A.at(A.size() - 1) << endl;
  
}

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

#define f(x, y, z) for (int x = (y), __ = (z); x < __; ++x)
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define mst(x, a) memset(x, a, sizeof(x))

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll LLINF = (ll)1 << 60;
const ll MOD = 1e9 + 7;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int N;
vector<vector<int>> g;
const int MAXN = 1e5 + 10;
int black[MAXN];
int white[MAXN];

int fw(int, int);

int fb(int x, int parent) {
  if (black[x] != -1) return black[x];
  ll ans = 1;
  for (int next : g[x]) {
    if (next != parent) {
      ans = ans * fw(next, x) % MOD;
    }
  }
  return black[x] = ans;
}

int fw(int x, int parent) {
  if (white[x] != -1) return white[x];
  ll ans = 1;
  for (int next : g[x]) {
    if (next != parent) {
      ans = ans * (fw(next, x) + fb(next, x)) % MOD;
    }
  }
  return white[x] = ans;
}

int main() {
  scanf("%d", &N);
  g = vector<vector<int>>(N);
  int x, y;
  while (~scanf("%d%d", &x, &y)) {
    g[x - 1].push_back(y - 1);
    g[y - 1].push_back(x - 1);
  }

  mst(black, -1);
  mst(white, -1);

  printf("%lld\n", (fw(0, -1) + fb(0, -1)) % MOD);
}


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


int main() {

  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int score =0;
  if(A>=K){
    score =K;
  }
  else if(K-A-B <= 0){
    score =A;
  }else if(K-A-B > 0){
    score = A;
    int num = K-A-B;
    while(num > 0){
      score--;
      num--;
    }

  }

 cout << score <<endl;

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

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


signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    
    cin>>n>>m;
    vector<pair<int,int>> tempp;
    
    if(n%2==0 && m%2==0)
    {
    for(i=1;i<n;i++)
    {
        
        if(count>=m/2)
        {
            cout<<i<<" "<<n-i<<endl;
        }
        
        else{
        cout<<i<<" "<<n-i+1<<endl;
        }
        
        count++;
        
        if(count==m) break;
        
    }
    }
    
    
   else if(n%2==0 && m%2==1)
    {
    for(i=1;i<n;i++)
    {
        
        if(count>m/2)
        {
            cout<<i<<" "<<n-i<<endl;
        }
        
        else{
        cout<<i<<" "<<n-i+1<<endl;
        }
        
        count++;
        
        if(count==m) break;
        
    }
    }
    
    
    
    else
    {
        for(i=1;i<n;i++)
        {
            cout<<i<<" "<<n-i<<endl;
            count++;
            
            if(count==m) break;
            
        }
        
    }
    
    
    
    
    
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<algorithm>
using namespace std;
long long p[10];
long long q[10];
struct wolf{
	int p[5];
	wolf(){}
};
wolf now[6];
int N,M;
int rev[10][10];
int perm[10][10];
long long INF=9999999999999999LL;
long long t[10][10];
long long dfs(int a){
	if(a==M){
		for(int i=0;i<=M+1;i++){
			for(int j=0;j<N;j++){
				t[i][j]=j+p[j]*q[i];
			}
		}
		int cnt=0;
		while(1){
			bool chg=false;
			for(int i=0;i<=M;i++){
				for(int j=0;j<N;j++){
					for(int k=j+1;k<N;k++){
						if(t[i][now[i].p[j]]+p[now[i].p[j]]*(q[i+1]-q[i])>t[i][now[i].p[k]]+p[now[i].p[k]]*(q[i+1]-q[i])){
							chg=true;
							t[i][now[i].p[k]]=t[i][now[i].p[j]]+p[now[i].p[j]]*(q[i+1]-q[i])-p[now[i].p[k]]*(q[i+1]-q[i]);
							for(int l=0;l<=M+1;l++)t[l][now[i].p[k]]=t[i][now[i].p[k]]+p[now[i].p[k]]*(q[l]-q[i]);
						}
						if(t[i][now[i].p[j]]>t[i][now[i].p[k]]){
							chg=true;
							t[i][now[i].p[k]]=t[i][now[i].p[j]];
							for(int l=0;l<=M+1;l++)t[l][now[i].p[k]]=t[i][now[i].p[k]]+p[now[i].p[k]]*(q[l]-q[i]);
						}
						if(i==0&&t[i][now[i].p[j]]>=t[i][now[i].p[k]]){
							chg=true;
							for(int l=0;l<=M+1;l++)t[l][now[i].p[k]]=t[i][now[i].p[j]]+1+p[now[i].p[k]]*(q[l]-q[i]);
						}
					}
				}
			}
			cnt++;
			if(cnt==200)return INF;
			//long long tmp=0;
			//for(int i=0;i<N;i++)tmp=max(tmp,t[M+1][i]);
			//printf("%lld\n",tmp);
			if(!chg)break;
		}
		long long ret=0;
		for(int i=0;i<N;i++)ret=max(ret,t[M+1][i]);
		/*if(ret==382){
			for(int i=0;i<=M;i++){
				for(int j=0;j<N;j++)printf("%d ",now[i].p[j]);
				printf("\n");
			}
			for(int i=0;i<=M+1;i++){
				for(int j=0;j<N;j++)printf("%lld ",t[i][j]);
				printf("\n");
			}
		}*/
		return ret;
	}
	long long ret=INF;
	for(int i=0;i<N;i++){
		perm[a][i]=i;
		rev[a][now[a].p[i]]=i;
	}
	do{
		bool ok=true;
		for(int i=0;i<N;i++){
			if(rev[a][perm[a][i]]>i+1)ok=false;
			if(rev[a][perm[a][i]]<i-1)ok=false;
			for(int j=i+1;j<N;j++){
				if(rev[a][perm[a][i]]>rev[a][perm[a][j]]&&p[perm[a][i]]>=p[perm[a][j]])ok=false;
			}
		}
		if(ok){
			for(int i=0;i<N;i++)now[a+1].p[i]=perm[a][i];
			ret=min(ret,dfs(a+1));
		}
	}while(next_permutation(perm[a],perm[a]+N));
	return ret;
}
int main(){
	int a,b,c;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++)scanf("%lld",p+i);
	scanf("%d",&c);
	N=b;M=c;
	for(int i=0;i<c;i++)scanf("%lld",q+i+1);
	std::sort(q,q+c+1);
	q[c+1]=a;
	for(int i=0;i<b;i++){
		now[0].p[i]=i;
	}
	printf("%lld\n",dfs(0));
}

Measured memory_bytes: 1032
package main
import "fmt"

func min(a int,b int) int{
	if a>b{
		return b
	} else {
		return a
	}
}
func zet(a int) int{
	if a<0 {
		return a*(-1)
	} else{
		return a
	}
}

func main() {
	var n,m int
	fmt.Scan(&n,&m)
	ans := 0
	for i:=0;i<=n;i+=1{
		for j:=0;j<=n;j+=1{
			x := m - i - j
          	//fmt.Println(ans)
			if x<=n && x>=0{
				ans += 1
			}
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt(),k=0;
        long ans=0,mod=1000000007;
        while(t-->0)
        {
        int n=sc.nextInt(),m=sc.nextInt();
        pw.println((n*(n-1))/2 + (m*(m-1))/2);
        }
           pw.close();
    }
}
  

Measured memory_bytes: 32896
/*...................bismillahir rahmanir rahim.....................*/
#include<bits/stdc++.h>

#define m_p make_pair
#define PB push_back
#define FF first
#define SS second
#define PII pair<int,int>
#define PSS pair<string,string>
#define MX 1000007
#define MOD 1000000007
#define SI(a)({ ;scanf("%d",&a);a;})
#define SC(a)({ ;scanf("%c",&a);a;})
#define SL(a)({ ;scanf("%lld",&a);a;})
#define SD(a)({ ;scanf("%lf",&a);a;})
#define FI freopen("input.txt","r+",stdin);
#define FO freopen("output.txt","w+",stdout);
using namespace std;

typedef long long LL; 

/*............start.............*/
int Set(int n,int pos){ return n=n | (1<<pos); }
int Reset(int n,int pos){ return n=n & ~(1<<pos); }
bool check(int n,int pos){ return (bool)(n & (1<<pos)); }
int N;
int tes[16][16];
// int DP[1<<15];
int call(int mask)
{
    // if(DP[mask]!=-1) return DP[mask];
    bool t=true;
    for(int i=1;i<=N;i++)
    {
        if(check(mask,i-1))
        for(int j=1;j<=N;j++)
        {
           if(i!=j && tes[i][j]!=-1) t&=~(check(mask,j-1)^tes[i][j]);
        }
    }
    if(t)
    {
        int r=0;
        for(int i=1;i<=N;i++) if(check(mask,i-1)) r++;
        return r; 
    }
    return 0;
}
void solve()
{
    // int n;
    cin>>N;
    // cout<<check(3,0);
    // return;
    memset(tes,-1,sizeof(tes));
    // memset(DP,-1,sizeof(DP));
    for(int i=1;i<=N;i++)
    {
        int x,y,t;
        cin>>x;
        while(x--)
        {
            cin>>y>>t;
            tes[i][y]=t;
        }
    }
    int res=0;
    for(int i=0;i<(1<<N);i++)
    {
        res=max(res,call(i));
    }
    cout<<res<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int q=1;
    // cin>>q;
    for(int kase=1;kase<=q;kase++)
    {
        //cout<<"Case "<<kase<<": ";
        solve();
    }
    return 0;
}


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

int main() {
	string s; cin >> s;
	int n = s.size(), ans; ans = n;
	for (int i = 0; i < n - 1; i++) {
		if (s[i] != s[i + 1]) {
			ans = min(ans, max(i + 1, n - (i + 1)));
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        long ans = 0;
        if (n == 1) {
            if (m == 1) {
                ans = 1;
            } else if (m == 2) {
                ans = 0;
            } else {
                ans = m - 2;
            }
        } else if (n == 2) {
            ans = 0;
        } else {
            if (m == 1) {
                ans = n - 2;
            } else if (m == 2) {
                ans = 0;
            } else {
                ans = (n - 2) * (m - 2);
            }
        }
        System.out.println(ans);
    }
}

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

const int N = 105;
const int M = 10001;
const int md = 1e9 + 7;

void add(int &x, int y) { x += y; while(x >= md) x -= md; if (x < 0) x += md; }

int n, k;
int f[N][M];
int pw[N];
int ans;

int main() {
	scanf("%d %d", &n, &k);
	pw[0] = 1; for (int i = 1; i < N; ++i) pw[i] = 1LL * pw[i-1] * (k + 1) % md;
	f[n + 1][0] = 1;
	for (int i = n; i >= 1; --i) {
		for (int j = 0; j < M; ++j) if (f[i + 1][j]) {
			for (int t = 0; t <= k; ++t) {
				int cur = (t <= i ? (t + j) / i : 0);
				add(f[i][j + cur], f[i + 1][j]);
				add(ans, 1LL * (1LL * f[i + 1][j] * pw[i - 1] % md) * (t - cur) % md);
			}
		}
 	}

 	printf("%d\n", ans);
}

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

int main() {

  string s;
  cin >> s;

  int start = 0;
  int end = s.size();
  for (start = 0; s[start] != 'A';start++)
    ;
  for (end = s.size() - 1; s[end] != 'Z';end--)
    ;

  cout << (end - start) + 1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long ll;
ll n,ans;
int main()
{
	cin>>n;
	for(long long i=2;i<=sqrt(n);i++)
	{
		long long x=i;
		while(n%x==0)
		{
			n/=x;
			x*=i;
			ans++;
		}
		while(n%i==0)n/=i;
	}
	if(n!=1)ans++;
	cout<<ans;
}


Measured memory_bytes: 3632
#include <stdio.h>

void cmp(int a, int b, int c) {
	if (c > b&& b > a) printf("Yes\n");
	else printf("No\n");
	return;
}

int main(void)
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	cmp(a, b, c);
	return 0;
}


Measured memory_bytes: 2052
N = int(input())

count = 0
ok = 0

for i in range(N):
    x, y = map(int, input().split())
    if x == y:
        count += 1
    else:
        count = 0
    if count == 3:
        ok = 1

if ok == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9172
# https://atcoder.jp/contests/abc175/submissions/15965930

def main():
    import sys
    input = sys.stdin.readline

    H, W, K = map(int, input().split())

    G = [[0] * W for _ in range(H)]
    for _ in range(K):
        r, c, v = map(int, input().split())
        G[r - 1][c - 1] = v

    dp0 = [0] * (W + 1)
    dp1 = [0] * (W + 1)
    dp2 = [0] * (W + 1)
    dp3 = [0] * (W + 1)
    # dpx:=行内取得x個以下の最大値
    # <cは更新済の同じ行の値
    # c<=は前の行の値

    for r in range(H):
        for c in range(W):
            v = G[r][c]

            dp0[c] = max(dp0[c], dp3[c])  # 垂直移動
            vertical_take = dp0[c] + v  # 垂直移動+(r,c)取得

            dp3[c] = max(dp3[c - 1], dp2[c - 1] + v, vertical_take)
            dp2[c] = max(dp2[c - 1], dp1[c - 1] + v, vertical_take)
            dp1[c] = max(dp1[c - 1], dp0[c - 1] + v, vertical_take)
            # 水平移動（左）から来て取らない
            # 水平移動（左）から来て取る
            # 垂直移動で来て取らない:=dp0
            # 垂直移動で来て取る:=dpx(x>0)

            # print(f'{dp0=}')
            # print(f'{dp1=}')
            # print(f'{dp2=}')
            # print(f'{dp3=}')
            # print('*******************')

    print(dp3[-2])


if __name__ == '__main__':
    main()


Measured memory_bytes: 145664
N = int(input())
A = [int(input()) for i in range(N)]
B = [[A[i], i+1] for i in range(N)]
B.sort(key=lambda x: x[0])
dp = [1]*N

for i in range(1, N):
    if B[i-1][1] < B[i][1]:
        dp[i] = dp[i-1]+1

ans = N - max(dp)

print(ans)


Measured memory_bytes: 45676
/// @file
/// @version Accepted.
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
int N,ans;
vector<int>A;
void print(const vector<int>&xs){
  for(auto&x:xs)cout<<x<<",";
  cout<<endl;
}
main(){
  cin>>N;
  A=vector<int>(N);
  for(auto&x:A)cin>>x;
  int r=-1;
  vector<int>prev(32),trying;
  for(int l=0;l<N;++l){
    if(r==l-1){
      ++r;
      for(int i=0;i<32;++i){
        prev[i]+=A[r]>>i&1;
      }
    }
    while(true){
      ++r;
      if(r>=N){
        --r;
        break;
      }
      trying=prev;
      for(int i=0;i<32;++i){
        trying[i]+=A[r]>>i&1;
      }
      if(*max_element(trying.begin(),trying.end())>=2){
        --r;
        break;
      }else{
        prev=trying;
      }
    }
    ans+=r-l+1;
    for(int i=0;i<32;++i){
      prev[i]-=A[l]>>i&1;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

class Node {
public:
	int location;
	int p, l, r;
	Node() {}
};

class Point {
public:
	int id, x, y;
	Point() {}
	Point(int id, int x, int y) :id(id), x(x), y(y) {}
	bool operator <(const Point &p)const {
		return id<p.id;
	}

	void print() {
		printf("%d\n", id);
	}
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) {return p1.x<p2.x;}

bool lessY(const Point &p1, const Point &p2) {return p1.y<p2.y;}

int makeKDTree(int l, int r, int depth) {
	if (l >= r)return NIL;
	int mid = (l + r) / 2;
	int t = np++;
	if (depth % 2 == 0) {
		sort(P + l, P + r, lessX);
	}
	else {
		sort(P + l, P + r, lessY);
	}
	T[t].location = mid;
	T[t].l = makeKDTree(l, mid, depth + 1);
	T[t].r = makeKDTree(mid + 1, r, depth + 1);
	return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
	int x = P[T[v].location].x;
	int y = P[T[v].location].y;
	if (sx <= x && x <= tx && sy <= y && y <= ty) {
		ans.push_back(P[T[v].location]);
	}
	if (depth % 2 == 0) {
		if (T[v].l != NIL) {
			if (sx <= x)find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		}
		if (T[v].r != NIL) {
			if (x <= tx)find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
		}
	}
	else {
		if (T[v].l != NIL) {
			if (sy <= y)find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		}
		if (T[v].r != NIL) {
			if (y <= ty)find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
		}
	}
}

int main() {
	int x, y;
	scanf("%d", &N);
	for (int i = 0; i<N; i++) {
		scanf("%d %d", &x, &y);
		P[i] = Point(i, x, y);
		T[i].l = T[i].r = T[i].p = NIL;
	}
	np = 0;
	int root = makeKDTree(0, N, 0);

	int q;
	scanf("%d", &q);
	int sx, tx, sy, ty;
	vector<Point> ans;
	for (int i = 0; i<q; i++) {
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		ans.clear();
		find(root, sx, tx, sy, ty, 0, ans);
		sort(ans.begin(), ans.end());
		for (int j = 0; j<ans.size(); j++) {
			ans[j].print();
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 15852
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG minpro2019/c.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k, a, b;
    cin >> k >> a >> b;
    if(a >= b || k <= a - 1 || b - a <= 2){
        cout << k + 1 << "\n";
        return 0;
    }

    ll ans = 1;
    k -= a - 1;
    ans += a - 1;

    if(k % 2 == 0){
        ans += (b - a) * (k / 2);
    }else{
        ans += (b - a) * (k / 2) + 1;
    }

    cout << ans << "\n";
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  int ans = 0;
  for(int i = 1; i <= N; i++){
    string s = to_string(i);
    if(s.size() % 2 == 1){
      ans++;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    // 整数の入力
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    int ta = (a / d) + (a % d != 0 ? 1 : 0);
    int ao = (c / b) + (c % b != 0 ? 1 : 0);

    if (ta >= ao) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35800
N = int(input())

t = []
for i in range(N):
  a = input().split()
  b = (i+1,a[0],int(a[1])*-1)
  t.append(b)
    
t.sort(key = lambda x:(x[:][1],x[:][2]))

for j in range(len(t)):
  print(t[j][0])

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {

  ll a, b, c; cin >> a >> b >> c;
  ll right = 4 * a * b, left, tmp = c - a - b;
  
  //left = pow(tmp,2);
  left = tmp*tmp;
  
  /* cout << right << " " << left << endl; */
  if (right < left && tmp > 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
graph = [0] + [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

from collections import deque

def bfs(graph, queue, prev):
    while queue:
        current = queue.popleft()

        for n in graph[current]:
            if prev[n] != -1:
                continue
            prev[n] = current
            queue.append(n)

queue = deque([1])
prev = [0] + [-1] * n
prev[1] = 0
bfs(graph, queue, prev)

if -1 not in prev:
    print('Yes')
    for i in prev[2:]:
        print(i)
else:
    print('No')


Measured memory_bytes: 34896
#include <stdio.h>
int main(void)
{
	int s;
	scanf("%d", &s);
	int m = s / 60;
	s = s % 60;
	int h = m / 60;
	m = m % 60;
	printf("%d:%d:%d\n", h, m, s);

	return 0;
}


Measured memory_bytes: 2104
#入力
n = int(input())
al = []
lll = []
for _ in [0]*n:
  al.append(int(input()))
  ll = [list(map(int,input().split())) for _ in [0]*al[-1]]
  lll.append(ll)
  
#正直な人の証言がすべてあっていればよい。
#ループ用リスト作成 0が不親切, 1が正直
katei = []
for i in range(2**n):
  l = []
  for j in range(n-1,-1,-1):
    if i>= 2**j:
      l.append(1)
      i -= 2**j
    else:
      l.append(0)
  katei.append(l)
#処理
ans = 0
for i in range(len(katei)):
  flag = True
  for j in range(n):
    if katei[i][j] == 1: #注目する人は正直だと仮定した人
      for l in lll[j]:#正直だと仮定した人の証言情報をループ
        if l[1] != katei[i][l[0]-1]:
          flag = False
  if flag:
    ans = max(sum(katei[i]),ans)

print(ans)

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

bool isPrime(int num) {
    
  if (num == 2) return true;
  else if (num % 2 == 0) return false;
  
  for (int i = 3; i * i <= num; i++) {
    if (num % i == 0) return false;
  }
  
  return true;
    
}

int main() {
  
  int X; cin >> X;
  
  for (int i = X; i <= 100003; i++) {
    if (isPrime(i)) {
      cout << i << endl;
      break;
    }
  }
  
}

Measured memory_bytes: 256
use proconio::marker::{Bytes, Chars, Isize1, Usize1};
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: Chars,
    }
    let mut max = 0;
    let mut cou = 0;
    for c in s {
        if c == 'R' {
            cou += 1;
            max = std::cmp::max(cou, max);
        } else {
            max = std::cmp::max(cou, max);
            cou = 0;
        }
    }
    println!("{}", max);
}


Measured memory_bytes: 2200
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
#include<limits>
#include <bitset>
#include <numeric>
#include <type_traits>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int INF = 1 << 30;
const ll LLINF = 2000000000;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
int main() {
	ll n,sums[200020] = {},ans=LLINF;
	cin >> n;
	rep(i, n) {
		int nn; cin >> nn;
		if (i == 0)sums[i] = nn;
		else sums[i] = nn + sums[i - 1];
	}
	rep(i, n-1) {
		ans = min(ans, abs((sums[n - 1] - sums[i]) - sums[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>

using namespace std;

int main(){
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < D; ++j){
            cin >> X[i][j];
        }
    }
    unordered_set<int> set;
    for(int i = 1; i < 1000; ++i){
        set.insert(i*i);
    }
    int ans = 0;
    for(int i = 0; i < N; ++i){
        for(int j = i; j < N; ++j){
            if(i == j) continue;
            double sum = 0;
            for(int k = 0; k < D; ++k){
                sum += abs(X[i][k]-X[j][k])*abs(X[i][k]-X[j][k]);
            }
            // cout << "i = " << i << " j = " << j << " sum = " << sum << endl;
            if(set.find(sum) != set.end()){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}


int main(){
  int w,a,b;
  cin>>w>>a>>b;
  int t = max(b+w-a,a+w-b);
  cout<<max(0,t-2*w)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int cost(int dp[],int h[],int x)
{
    if(dp[x]!=-1) return dp[x];
    else
    {
        dp[x]=min(abs(h[x-1]-h[x])+cost(dp,h,x-1),abs(h[x-2]-h[x])+cost(dp,h,x-2));
         return dp[x];
    }
    
}
int main()
{  int n;cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    int dp[n];
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    cout<<cost(dp,h,n-1);

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
//ofstream cout("output.out");

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }

using ll = long long;
const int mod = 1e9 + 7;

int main()
{
	fast();
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	int s = 0;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		s += a[i];
	}
	sort(a.begin(), a.end());
	//if(sum % (4*m)) vote ++;
	reverse(a.begin(), a.end());
	int vote = s / ( 4 * m);
	if(s % (4*m)) vote++;
	if( a[m - 1] >= vote) cout <<"Yes";
	else cout <<"No";
}			

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	ps := make([]p, n)
	for i := range ps {
		var t, x, y int
		fmt.Scan(&t, &x, &y)
		ps[i] = p{t, x, y}
	}
	ct, cx, cy := 0, 0, 0
	for _, i := range ps {
		d1 := abs(cx - i.x) + abs(cy - i.y)
		d2 := i.t - ct
		d3 := d2 - d1
		if d3 < 0 || d3 % 2 != 0 {
			fmt.Println("No")
			return
		}
		ct, cx, cy = i.t, i.x, i.y
	}

	fmt.Println("Yes")
}

type p struct {
	t, x, y int
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

Measured memory_bytes: 5760
#include <stdio.h>

int main(void)
{
	int n;
	int count;
	
	while (1){
		count = 0;
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		while (n != 1){
			if (n % 2 == 0){
				n /= 2;
				count++;
			}
			else if (n != 1){
				n *= 3;
				n += 1;
				count++;
			}
		}
		printf("%d\n", count);
	}
	
	return (0);
}

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

char grid_a[55][55];
char grid_b[55][55];

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,n)rep(j,n){
    cin>>grid_a[i][j];
  }
  rep(i,m)rep(j,m){
    cin>>grid_b[i][j];
  }
  bool ans=0;
  for(int i = 0; i < n-m+1; i++){
    for(int j = 0; j < n-m+1; j++){
      bool ok=1;
      rep(mi,m)rep(mj,m){
        if(grid_a[i+mi][j+mj]!=grid_b[mi][mj]) ok=0;
      }
      if(ok) ans=1;
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



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

using namespace std;

int main() {

	int n,m;
	cin >> n >> m ;

	vector<pair<long long, long long>> p(n);

	for (int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
	}

	sort(p.begin(),p.end());

	long long total = 0;
	int resi = m;
	for (int i = 0; i < n; i++) {
		if (resi - p[i].second > 0) {
			total += p[i].first * p[i].second;
			resi -= p[i].second;
		}
		else {
			total += p[i].first*resi;
			cout << total << endl;
			return 0;
		}
	}

}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

ll getNum(ll level, ll X, const vector<ll>& len) {
    if (level == 0) return 1;

    ll middle = (len[level]-1)/2 + 1;
    if (X == 1) return 0;
    else if (X < middle) return getNum(level-1, X-1, len);
    else if (X == middle) return getNum(level-1, X-2, len) + 1;
    else if (X < len[level]) return getNum(level-1, len[level-1], len) + 1 + getNum(level-1, X - middle, len);
    else return 2 * getNum(level-1, len[level-1], len) + 1;
}

void solve(long long N, long long X){
    vector<ll> len(N+1);
    len[0] = 1;
    rep(i,1,N+1) {
        len[i] = len[i-1] * 2 + 3;
    }
    cout << getNum(N, X, len) << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    solve(N, X);
    return 0;
}


Measured memory_bytes: 256
n, m = gets.split.collect{|x|x.to_i}

cost = []
n.times{
  cost += [gets.to_i]
}

threshold = []
m.times{
  threshold += [gets.to_i]
}

vote = [0] * cost.length

for x in threshold
  for y in 0...cost.length
    if cost[y] <= x then
      vote[y] += 1
      break
    end
  end
end

p vote.index(vote.max) + 1

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

int main() {
  int X;
  cin >> X;
  if (400 <= X && X <= 599) {
    cout << 8 << endl;
  } else if (X <= 799) {
    cout << 7 << endl;
  } else if (X <= 999) {
    cout << 6 << endl;
  } else if (X <= 1199) {
    cout << 5 << endl;
  } else if (X <= 1399) {
    cout << 4 << endl;
  } else if (X <= 1599) {
    cout << 3 << endl;
  } else if (X <= 1799) {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3672