akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int N, K, H[101010];

void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> H[i];
    sort(H, H + N);
 
    int ans = inf;
    rep(L, 0, N - K + 1) {
        int R = L + K - 1;
        chmin(ans, H[R] - H[L]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXM=2e3+5,MAXN=1e3+5,Mod=1e9+7;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline ll read(){
	ll x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,m,N,fa[MAXN],pre[MAXN],f[MAXN],d[MAXN],p[MAXM];ll Sum,X;
struct E{int x,y,w,id,usd;}e[MAXM];
int gf(int x){return f[x]==x?x:f[x]=gf(f[x]);}
vector<pint>G[MAXN];
inline void add(int x,int y,int w){G[x].emplace_back(y,w),G[y].emplace_back(x,w);}
void dfs(int x,int f){fa[x]=f,d[x]=d[f]+1;for(auto y:G[x])if(y.fir!=f)dfs(y.fir,x),pre[y.fir]=y.sec;}
inline int Fp(int x,int k){int ans=1;for(;k;k>>=1,x=1ll*x*x%Mod)if(k&1)ans=1ll*ans*x%Mod;return ans;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),m=read(),X=read();
	Rep(i,1,m)e[i]=(E){read(),read(),read(),i};
	sort(e+1,e+m+1,[](E x,E y){return x.w<y.w;});
	Rep(i,1,n)f[i]=i;
	Rep(i,1,m)if(gf(e[i].x)!=gf(e[i].y))e[i].usd=1,add(e[i].x,e[i].y,e[i].w),f[gf(e[i].x)]=gf(e[i].y),Sum+=e[i].w;
	X-=Sum;if(X<0)return puts("0"),0;
	dfs(1,0);
	Rep(i,1,m)if(!e[i].usd){
		int Mx=0,x=e[i].x,y=e[i].y;
		for(d[x]>d[y]?swap(x,y),0:0;d[y]>d[x];Mx=max(Mx,pre[y]),y=fa[y]);
		for(;x!=y;Mx=max(Mx,max(pre[x],pre[y])),x=fa[x],y=fa[y]);
		p[++N]=e[i].w-Mx;
	}sort(p+1,p+N+1);
	int l=lower_bound(p+1,p+N+1,X)-p,r=upper_bound(p+1,p+N+1,X)-p,cnt=r-l;
	int Ans=1ll*(Fp(2,cnt)-1)*Fp(2,N-r+1)%Mod*2%Mod;
	if(X==0)Ans=(Ans+1ll*(Fp(2,n-1)-2)*Fp(2,N))%Mod;
	cout<<Ans<<"\n";
	return 0;
}




Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a=sc.next(),b=sc.next();
		String c= new StringBuilder().append(a).append(b).toString();
		double num = (double)Integer.valueOf(c);

		double sqrtnum=Math.sqrt(num);
		if(Math.floor(sqrtnum)==sqrtnum) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 23124
// abca29c.cpp : Typical Stairs
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)

vector<ll> v(100000+1,-1);

ll calc(int i, int n){
	if(i>n) return 0;
	if(i==n) return 1;
	if(v[i]==-2) return 0;
	if(v[i]==-1){
		v[i] = (calc(i+1,n) + calc(i+2,n)) % MOD;
	}
	return v[i];
}

int main(){
	int n,m; cin>>n>>m;
	rp(i,m){
		int a; cin>>a;
		v[a] = -2;
	}
	ll ans = calc(0,n);
	cout<< ans <<endl;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {
    static Node SENTINEL = new Node(-1, null, null, null);

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

        int n = sc.nextInt();
        Node[] nodes = new Node[n];
        for (int i = 0; i < n; i++) {
            nodes[i] = new Node(i, SENTINEL, SENTINEL, SENTINEL);
        }

        for (int i = 0; i < n; i++) {
            int id = sc.nextInt();
            int left = sc.nextInt();
            int right = sc.nextInt();

            if (left != -1) {
                nodes[left].parent = nodes[id];
                nodes[id].left = nodes[left];
            }
            if (right != -1) {
                nodes[right].parent = nodes[id];
                nodes[id].right = nodes[right];
            }
        }
        for (int i = 0; i < n; i++) {
            Node nd = nodes[i];
            String kind = 
                    (isEmpty(nd.parent)) ? "root" :
                    (isEmpty(nd.left) && isEmpty(nd.right)) ? "leaf" : "internal node";
                
            System.out.println(
                    "node " + i + ": "
                   +   "parent = "  + nd.parent.val
                   + ", sibling = " + nd.getSibling().val 
                   + ", degree = "  + nd.getDigree()
                   + ", depth = "   + nd.getDepth()
                   + ", height = "  + nd.getHeight()
                   + ", " + kind);
        }
    }

    public static class Node {
        int  val;
        Node parent;
        Node left;
        Node right;

        public Node(int val, Node parent, Node left, Node right) {
            this.val = val;
            this.parent = parent;
            this.left = left;
            this.right = right;
        }

        public Node getSibling() {
            Node p = this.parent;
            if (p.val == -1)
                return SENTINEL;
            else if (p.left != null && p.left.val != this.val)
                return p.left;
            else if (p.right != null && p.right.val != this.val)
                return p.right;
            else
                return SENTINEL;
        }
        
        public int getDigree() {
            int count = 0;
            if (!isEmpty(this.left)) count++;
            if (!isEmpty(this.right)) count++;
            return count;
        }
        
        public int getDepth() {
            int depth = 0;
            Node p = this.parent;
            while (p.val != -1) {
                depth++;
                p = p.parent;
            }
            return depth;
        }
        
        public int getHeight() {
            int heightL = -1;
            int heightR = -1;
            if (!isEmpty(this.left)) {
                heightL = this.left.getHeight();
            }
            if (!isEmpty(this.right)) {
                heightR = this.right.getHeight();
            }
            
            return Math.max(heightL, heightR) + 1;
        }
    }
    static boolean isEmpty(Node n) {
        return n == null || n.val == -1;
    }
}


Measured memory_bytes: 26412
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int x,y;
  cin >> x >> y;
  pr(x+y/2);
}

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


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int N, Y, x, y, z, dx, dy;
int main() {
  scanf("%d %d", &N, &Y);
  dx = Y/1000-5*N, dy = -Y/1000+10*N;
  for(z = 0; z <= N; z++) {
    x = (4*z+dx)/5, y = (-9*z+dy)/5;
    if(x < 0 || y < 0 || x+y+z != N) continue;
    if(10000*x+5000*y+1000*z == Y) break;
  }
  if(x+y+z != N) x = y = z = -1;
  printf("%d %d %d", x, y, z);
}

Measured memory_bytes: 128
from collections import Counter
N = int(input())
D = list(map(int, input().split()))
MOD = 998244353

def calc():
    if D[0] != 0:
        return 0
    if sum(D) < N-1:
        return 0
    
    c = Counter(D)
    ret = 1
    tmpkey = 0
    tmpvalue = 0
    for key in sorted(c.keys()):
        if key - tmpkey >= 2:
            return 0
        if key == 0:
            if c[key] >= 2:
                return 0
        else:
            ret *= (tmpvalue ** c[key]) % MOD
            ret %= MOD
        tmpkey = key
        tmpvalue = c[key]
    return ret

print(calc())


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

int main() {
  int A,B;
  cin >> A >> B;
  
  if (A >= 13){
    cout << B << endl;
  }
  else if (A >= 6){
    cout << B/2 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

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

int main() {
  string s;
  cin >> s;
  int m,d;
  m = stoi(s.substr(5,2));
  bool ans = false;
  if(m > 4) ans = true;
  puts(ans?"TBD":"Heisei");
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

//
//..#..
//..#..
//##.#.
//.###.
//...#.


int main(){
  int h,w,m;
  cin >> h >> w >> m;

  map<int,int> imp, jmp;
  set<pair<int,int>>st;
  rep(i,m){
    int H, W;
    cin >> H >> W;
    st.insert({H,W});
  }

  int imx=0;
  int jmx=0;
  for(auto p : st){
    imx = max(imx,++imp[p.first]);
    jmx = max(jmx,++jmp[p.second]);
  }

  vector<int> im(0), jm(0);
  for(auto p : imp){
    if(p.second == imx) im.push_back(p.first);
  }
  for(auto p : jmp){
    if(p.second == jmx) jm.push_back(p.first);
  }

  bool flag = 0;
  for(auto i : im){
    for(auto j: jm){
      if(st.find({i,j}) == st.end()) {
        cout << imx + jmx << endl;
        return 0;
      }
    }
  }
  cout << imx + jmx - 1 << endl;
}


Measured memory_bytes: 49456
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>

int main() {
  long long int N;
  std::cin >> N;

  std::vector<long long int> A(N);

  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
    A[i] -= i + 1;
  }

  std::sort(A.begin(), A.end());

  long long int answer = 0, mid = A[N / 2];

  for (int j = 0; j < N; j++) {
    answer += std::abs(A[j] - mid);
  }

  std::cout << answer << std::endl;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

inputAB = input().split()

inputA = int(inputAB[0])
inputB = int(inputAB[1])

# print(inputA, inputB)

if inputA > inputB:
    largeNum = inputA
    smallNum = inputB
else:
    largeNum = inputB
    smallNum = inputA

# print(largeNum, smallNum)

if ((largeNum - smallNum) % 2) == 1:
    print("IMPOSSIBLE")
else:
    answer = smallNum + int((largeNum - smallNum) / 2)
    print(answer)



Measured memory_bytes: 2940
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    ll a[n], sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    ll ans = 1ll<<60, tmp = 0;
    for(int i = 0; i+1 < n; i++){
        tmp += a[i];
        ans = min(ans, abs(sum-tmp-tmp));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#define ll long long
using namespace std;
int main(){
	int a,b,c,ans;
	scanf("%d%d",&a,&b);
	
	if(!a){ for(ans=1;b;ans++) if(ans%100!=0) b--;}
	else if(a==1){ for(ans=100;b;ans+=100) if(ans%100==0&&ans%10000!=0) b--;}
	else for(ans=10000;b;ans+=10000) if(ans%10000==0&&ans%1000000!=0) b--;
	
	printf("%d\n",ans-(a?(a==1?100:10000):1));
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)x.size())
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vi  = vector<int>;
constexpr int INF = 1001001001001001001LL;
/*
<NAME> 最長共通部分列 (Longest Common Subsequence)
<TRIGGER> LCS
<TAG> DP, etc
<*NOTE>
文字列の最長共通部分列を求める。$O(NM)$
<*CODE> */
int lcs(string a, string b) {
    int n = sz(a), m = sz(b);
    vvi dp(n + 1, vi(m + 1, 0));
    rep(i, 0, n) {
        rep(j, 0, m) {
            if (a[i] == b[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }
    return dp[n][m];
}

// hash : [59, 176, 206, 65, 188, 72, 103, 19]]

signed main() {
    int Q;
    cin >> Q;
    while (Q--) {
        string S, T;
        cin >> S >> T;
        cout << lcs(S, T) << endl;
    }
}



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


using namespace std;



int main(){

    int a,b;
    cin>>a>>b;
    if(a>=13){
        printf("%d\n",b);
    }else if(a>5){
        printf("%d\n",b/2);
    }else printf("0\n");

    return 0;
}



Measured memory_bytes: 256
L, R = map(int, input().split())
min_mod = 2019
flg=[0]*2019
flg2=[0]*2019
for i in range(L,R):
    idx=i%2019
    if flg[idx]==1:
        break
    if flg[idx]==0:
        for j in range(i+1,R+1):
            mod  = (i*j)%2019
            if flg2[mod]==1:
                break
            flg2[mod]=1
            if min_mod > mod:
                min_mod=mod
        flg[idx]=1
print(min_mod)

Measured memory_bytes: 3064
#include <stdio.h>
using namespace std;
#define MAX(a,b) (a>b?a:b)
#define MOD(a) (a>0?a:-(a))

int main(){
  int ndias;
  scanf("%d",&ndias);
  int ativ[ndias][3] , maxfor[ndias][3];
  for (size_t i = 0; i < ndias; i++) {
    scanf("%d %d %d", &ativ[i][0],&ativ[i][1],&ativ[i][2]);
  }
  // for (size_t i = 0; i < ndias; i++) {
  //   for (size_t j = 0; j < 3; j++) {
  //     printf("%d ",ativ[i][j]);
  //   }
  //   printf("\n");
  // }
  maxfor[0][0] = ativ[0][0];
  maxfor[0][1] = ativ[0][1];
  maxfor[0][2] = ativ[0][2];
  for (size_t i = 1; i < ndias; i++) {
    maxfor[i][0] = ativ[i][0] + MAX(maxfor[i-1][1],maxfor[i-1][2]);
    maxfor[i][1] = ativ[i][1] + MAX(maxfor[i-1][0],maxfor[i-1][2]);
    maxfor[i][2] = ativ[i][2] + MAX(maxfor[i-1][0],maxfor[i-1][1]);
  }
  // for (size_t i = 0; i < ndias; i++) {
  //   for (size_t j = 0; j < 3; j++) {
  //     printf("%d ",maxfor[i][j]);
  //   }
  //   printf("\n");
  // }
  printf("%d\n", MAX( MAX(maxfor[ndias-1][0],maxfor[ndias-1][1]) , maxfor[ndias-1][2] ) );
}

Measured memory_bytes: 2560
#pragma region Header

#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
#include <bitset>
#include <cstdint>
#include <stdexcept>
using namespace std;

// 整数型

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

// [0,n)を昇順/降順でループ

#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)

// [a,b)を昇順/降順でループ

#define FOR(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)

template <typename T>
int SZ(T x)
{
    return static_cast<int>(x.size());
}

#pragma endregion

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

    int n, k;
    cin >> n >> k;
    int ans = 0;
    while (n > 0)
    {
        n /= k;
        ++ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

std::string N;
int dp[20][2][2][2][2][2];
int dig[4] = { 0, 3, 5, 7 };

int main()
{
  std::cin >> N;

  dp[0][0][0][0][0][0] = 1;

  rep( i, N.size() ) rep( lim, 2 ) rep( zero, 2 ) rep( j, 2 ) rep( k, 2 ) rep( l, 2 ) rep( d, 4 ) if( lim || dig[d] <= N[i]-'0' ) if( d || !zero )
    dp[i+1][lim || dig[d] < N[i]-'0'][zero || d != 0][j || d == 1][k || d == 2][l || d == 3] += dp[i][lim][zero][j][k][l];

  int ans = 0;

  rep( i, 2 )
    ans += dp[N.size()][i][1][1][1][1];

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

  return 0;
}

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

int main() {
  int N, K;
  long long Sum=0;
  cin >> N >> K;
  vector<long long> H(N);
  rep(i, N) cin >> H.at(i);
  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());
  rep(i, min(K, N)) H.at(i)=0;
  rep(i, N) Sum+=H.at(i);
  cout << Sum << endl;
}

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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;
constexpr ll MOD = 1e9 + 7;


int main() {
    int N, M;
    cin >> N >> M;

    int ac = 0, wa = 0;
    vi f(N + 1);
    vi t(N + 1);
    for (int i = 0; i < M; i++) {
        int p;
        string s;
        cin >> p >> s;
        if (s == "AC") {
            if (f[p] == 0) {
                f[p] = 1;
                ac++;
            }
        } else if (s == "WA") {
            if (f[p] == 0) {
                t[p]++;
            }
        }
    }

    for (int i = 1; i < t.size(); i++) {
        if (f[i] == 1) {
            wa += t[i];
        }
    }
    cout << ac << " " << wa << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
      lint h,w,m;
      cin>>h>>w>>m;
      map<P,lint>mp;
      lint x[w];
      lint y[h];
      fill(x,x+w,0);
      fill(y,y+h,0);
      rep(i,m){
          lint a,b;
          cin>>a>>b;
          --a;--b;
          x[b]++;
          y[a]++;
          mp[{a,b}]++;
      }
      lint mxx=*max_element(x,x+w);
      lint myy=*max_element(y,y+h);
      vector<lint> xx;
      vector<lint> yy;
      rep(i,w){
          if(x[i]==mxx)xx.push_back(i);
      }
      rep(i,h){
          if(y[i]==myy)yy.push_back(i);
      }
      lint ans=0;
      lint count=0;
      rep(i,xx.size()){
          rep(j,yy.size()){
              if(!mp.count({yy[j],xx[i]})){
                  cout<<mxx+myy<<endl;
                  return 0;
              }
            else ans=max(ans,mxx+myy-1);
            count++;
            if(count>=9000000){
                cout<<ans<<endl;
                return 0;
            }
          }
      }
      cout<<ans<<endl;
  }
      
    
  

Measured memory_bytes: 35072
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	long long N, A, B;
	cin >> N >> A >> B;

	long long count = N / (A + B);
	long long remain = N % (A + B);

	remain = min(remain, A);

	cout << count * A + remain;

	return 0;
}

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

using namespace std;

int main(){
  long long N;
  cin >> N;
  
  long long ans = 0;
  if(N == 2) ans += 1;
  else ans += 2;
  
  for(long long K = 2; K * K <= N - 1; K++){
    if((N - 1) % K == 0){
      if(K * K == N - 1) ans += 1;
      else ans += 2;
    }
  }
  
  for(long long K = 2; K * K <= N; K++){
    if(N % K == 0){
      long long n = N;
      while(n % K == 0) n /= K;
      if((n - 1) % K == 0) ans++;
      
      if(K * K != N){
        n = N;
        while(n % (N / K) == 0) n /= (N / K);
        if((n - 1) % (N / K) == 0) ans++;
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/


int main(){
    int n, a, b; cin >> n >> a >> b;
    cout << min(a*n, b) << endl;
}

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

int main() {
	vector<int> b(10);
	for (int i = 0;i < 10;i++) {
		cin >> b[i];
	}
	sort(b.begin(),b.end());
	reverse(b.begin(), b.end());
	
	for (int i = 0;i < 3;i++) {
		cout<<b.at(i)<<endl ;
	}
	return 0;
}


Measured memory_bytes: 3148
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    final int shift = sc.nextInt();
    final String text = sc.next();
    final int offset = (int) 'A';
    int[] cpArray = text.codePoints().map(cp -> ((cp - offset + shift) % 26) + offset).toArray();
    System.out.println(new String(cpArray, 0, cpArray.length));
  }
}

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


int N, n, ans;
map<int, int> x;
vector<int> w;
const int MOD = 1e9 + 7;
const int MAX = 100;
ll fac[MAX], finv[MAX], inv[MAX];


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


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


// 素因数分解
void prime_factor(int n) {
    for (int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            x[i]++;
            n /= i;
        }
    }
    if(n != 1) x[n]++;
}


void solve_25_3() {
    int n25 = 0, n3 = 0;
    for (int x : w) {
        if (3 <= x) n3++;
        if (25 <= x) n25++;
    }
    ans += n25 * (n3 - 1);
}


void solve_15_5() {
    int n15 = 0, n5 = 0;
    for (int x : w) {
        if (5 <= x) n5++;
        if (15 <= x) n15++;
    }
    ans += n15 * (n5 - 1);
}


void solve_5_5_3() {
    int n5 = 0, n3 = 0;
    for (int x : w) {
        if (5 <= x) n5++;
        if (3 <= x) n3++;
    }
    ans += comb(n5, 2) * (n3 - 2);
}


int main() {
    comb_init();
    cin >> N;
    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 1; i <= N; i++) prime_factor(i);
    for (auto p : x) {
        if (p.second > 1) w.push_back(p.second + 1);
    }
    n = w.size();
    ans = 0;
    if (75 <= w[0]) ans++;
    solve_25_3();
    solve_15_5();
    solve_5_5_3();
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    X, K, D = MI()
    X = abs(X)
    z = X // D
    if z >= K:
        print(X - K * D)
        return
    # print(K, z)
    K -= z
    # print(K)
    X = X - z * D
    X2 = abs(X - D)
    # print(X, X2)
    if K % 2 == 0:
        print(X)
    else:
        print(X2)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9248
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    string ans = "Yes";
    int n = s.length();
    REP(i, n){
        if(i % 2 == 0){
            if(s[i] == 'L'){
                ans = "No";
            }
        }
        else {
            if(s[i] == 'R'){
                ans = "No";
            }

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

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


int main() {

	int n;
	cin >> n;
	vector <int> a(n);

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

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

	cout << a[n - 1] - a[0] << endl;

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int min_ans = 6;
const int N = 4;
int a[4][4];
struct Bubble{
  int x, y, r;
  Bubble() {}
  Bubble(int x, int y, int r) : x(x), y(y), r(r) {}
};
int dfs(int K){
  if(K >= min_ans) return INF;

  stack<Bubble> stk;
  do{
    stack<Bubble> nstk;
    while(!stk.empty()){
      Bubble b = stk.top(); stk.pop();
      int nx = b.x + dx[b.r];
      int ny = b.y + dy[b.r];
      if(!valid(nx, ny, N, N)) continue;
      if(a[ny][nx] > 0){
        a[ny][nx]++;
      }else{
        nstk.push(Bubble(nx, ny, b.r));
      }
    }
    stk = nstk;
    REP(y, N) REP(x, N) if(a[y][x] >= 5) {
      a[y][x] = 0;
      REP(r, 4) stk.push(Bubble(x, y, r));
    }
  }while(!stk.empty());

  bool end = true;
  REP(i, N) REP(j, N) if(a[i][j] != 0) end = false;
  if(end) return min_ans = K;

  int tmp[4][4];
  memcpy(tmp, a, sizeof(a));

  int res = INF;
  REP(i, N) REP(j, N) if(a[i][j] > 0) {
    a[i][j]++;
    res = min(res, dfs(K + 1));
    memcpy(a, tmp, sizeof(a));
  }
  return res;
}

int main(){
  while(true){
    min_ans = 6;
    REP(i, N) REP(j, N) cin >> a[i][j];
    if(cin.eof()) break;
    int ans = dfs(0);
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
 
#ifndef _WIN32
    #define getchar getchar_unlocked
#endif
 
#define MP make_pair
#define PB push_back
#define ST first
#define ND second
 
typedef long long int LLI;
typedef unsigned long long int LLU;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<int> vi;
 
template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<"="<<h<<",";
  _dbg(sdbg+1, a...);
}
 
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
const int MX = 100007;
 
vector<pii> G[MX];
int rp[MX];
LLI depth[MX];
int ojciec[MX][20];
 
void dfs1(int u, int p){
    rp[u] = 1;
    for(pii P : G[u]){
		int v = P.ST, w = P.ND;
        if(v != p){
            ojciec[v][0] = u;
            depth[v] = depth[u] + w;
            dfs1(v, u);
            rp[u] += rp[v];
        }
    }
}
 
inline int LCA(int a, int b){
    int d1 = depth[a], d2 = depth[b], pom = abs(d1 - d2);
    if(d1 > d2) swap(a, b);
    for(int i = 0; (1<<i) <= pom; ++i)
        if((pom & (1<<i)) > 0)
            b = ojciec[b][i];
    if(a == b) return a;
    for(int i = 19; i >= 0; --i)
        if(ojciec[a][i] != ojciec[b][i])
            a = ojciec[a][i], b = ojciec[b][i];
    return ojciec[a][0];
}
 
inline int odl(int a, int b){
    int l = LCA(a, b);
    return (depth[a] + depth[b] - 2*depth[l]);
}
 
int32_t main(){
    boost;
    int n; cin >> n;
	for(int i = 1; i < n; ++i){
		int a, b, c; cin >> a >> b >> c;
		G[a].PB({b, c}); G[b].PB({a, c});
	}
	int q, k; cin >> q >> k;
    dfs1(k, 0);
	while(q--){
		int a, b; cin >> a >> b;
		cout << depth[a] + depth[b] << '\n';
	}
}


Measured memory_bytes: 22528
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n, m; cin >> n >> m;
	vector<vector<int>> d(n, vector<int>(m));

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

	set<int> s;

	for (int i = 0; i < 10000; i++) {
		s.insert(i*i);
	}

	int ans = 0;

	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			int val = 0;

			for (int k = 0; k < m; k++) {
				val += (d[i][k] - d[j][k])*(d[i][k] - d[j][k]);
			}

			if (s.count(val))ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    string A, B, C;
    cin >> A >> B >> C;

    if (A.back() == B.front() && B.back() == C.front())
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e10;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};


int main(){
    ll K,A,B; cin>>K>>A>>B;
    ll a=A/K, b=B/K;
    if(a==b && A%K!=0) cout<<"NG"<<endl;
    else cout<<"OK"<<endl;
}

Measured memory_bytes: 3632
a,b,c=map(int, input().split()) 
k = b*c
l = abs(a)

if l > 0:
    if l > k:
        print(l-k)
    if l == k:
        print(0)
    if l < k:
        d = int(l//c)
        e = b - d
        if e%2== 0:
            print(l-c*d)
        else:
            f = d + 1
            print(f*c -l)
if l == 0:
    if b%2==0:
        print(0)
    else:
        print(c)

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  double ave = accumulate(v.begin(), v.end(), 0.0) / n;
  int m = 0;
  double sa = 1000000000;
  for (int i = 0; i < n; i++) {
    if (abs(v[i] - ave) < sa) {
      m = i;
      sa = abs(v[i] - ave);
    }
  }
  cout << m << endl;
}


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

int main() {
	int n,minv=1000002,maxv=-1000002,a=0;
	long long sumv=0;
	cin>>n;

	for (int i = 0; i < n; ++i) {
		cin>>a;
		minv=min(minv,a);
		maxv=max(maxv,a);
		sumv+=a;
	}
	cout<<minv<<" "<<maxv<<" "<<sumv<<endl;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    bool ret = true;
    rep(i,N) {
        if (A[i]%2==0 && (A[i]%3 != 0 && A[i]%5 != 0)) {
            ret = false;
            break;
        }
    }
    cout << (ret ? "APPROVED" : "DENIED") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;

vector<pair<ll,ll>> primeFactorDecomp(ll n){
      vector<pair<ll,ll>> ret;
      ll m=n;
      for(ll i=2;i*i<=m;i++){
            if(n%i!=0) continue;
            int cnt=0;
            while(n%i==0){
                  cnt++;
                  n/=i;
            }
            ret.push_back({i,cnt});
      }
      if(n>1){
            ret.push_back({n,1});
      }
      return ret;
}

int main(){
    int n;
    cin>>n;
    int a[n];
    rep0(i,n) cin>>a[i];
    bool ok=true;
    rep0(i,n) if(a[i]%2) ok=false;
    if(ok) cout<<"second"<<endl;
    else cout<<"first"<<endl;

      return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		char[][] s = new char[h][w];
		for (int i = 0; i < h; i++) {
			s[i] = br.readLine().toCharArray();
		}
		br.close();

		int[][] val1 = new int[h][w];
		for (int i = 0; i < h; i++) {
			int idx = -1;
			int cnt = 0;
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '.') {
					cnt++;
				} else {
					for (int k = idx + 1; k < j; k++) {
						val1[i][k] = cnt;
					}
					idx = j;
					cnt = 0;
				}
			}
			if (cnt > 0) {
				for (int k = idx + 1; k < w; k++) {
					val1[i][k] = cnt;
				}
			}
		}

		int[][] val2 = new int[h][w];
		for (int j = 0; j < w; j++) {
			int idx = -1;
			int cnt = 0;
			for (int i = 0; i < h; i++) {
				if (s[i][j] == '.') {
					cnt++;
				} else {
					for (int k = idx + 1; k < i; k++) {
						val2[k][j] = cnt;
					}
					idx = i;
					cnt = 0;
				}
			}
			if (cnt > 0) {
				for (int k = idx + 1; k < h; k++) {
					val2[k][j] = cnt;
				}
			}
		}

		int ans = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j] != '#') {
					int val = val1[i][j] + val2[i][j] - 1;
					ans = Math.max(ans, val);
				}
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;

int solve(int p, int q, int r) {
    return min({p+q, p+r, r+q});
}

int main(int argc, char const *argv[])
{
    int p = 0, q = 0, r = 0;


    cin >> p >> q >> r;

    auto ans = solve(p, q, r);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
from collections import deque
a=input()
b=input()
c=input()
aa = deque(a)
bb = deque(b)
cc = deque(c)
now = aa.popleft()
while 1:
    if now=='a':
        if len(aa)==0:
            res = 'A'
            break
        now = aa.popleft()
    if now=='b':
        if len(bb)==0:
            res = 'B'
            break
        now = bb.popleft()
    if now=='c':
        if len(cc)==0:
            res = 'C'
            break
        now = cc.popleft()
print(res)

Measured memory_bytes: 3316
import math
a, b, x = map(int, input().split())
if a*a*b/2 > x:
    y = x/a/b*2/b
    print(90-math.degrees(math.atan(y)))
else:
    y = (b-x/a/a)*2/a
    print(math.degrees(math.atan(y)))

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

int w,h;

int get_index(int x,int y){
  return x + y * w;
}

void add_edge(vector<vector<int>> &maze,int x1,int y1,int x2,int y2){
  const int a = get_index(x1,y1);
  const int b = get_index(x2,y2);
  maze[a].emplace_back(b);
  maze[b].emplace_back(a);
}

int bfs(int s,int g,vector<vector<int>> &maze){
  const int n = maze.size();
  vector<int> d(n,-1);
  d[s] = 1;
  queue<int> q;
  q.push(s);
  while(!q.empty()){
    const int now = q.front(); q.pop();

    if(now == g) return d[now];

    for(const auto &to : maze[now]){
      if(d[to] == -1){
        d[to] = d[now] + 1;
        q.push(to);
      }
    }
  }
  return -1;
}

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

  while(cin>>w>>h&&w){
    vector<vector<int>> maze(w*h);

    for(int i=0;i<h;++i){
      for(int j=0;j<w-1;++j){
        int wall; cin>>wall;
        if(!wall)
          add_edge(maze,j,i,j+1,i);
      }
      if(i==h-1) break;
      for(int j=0;j<w;++j){
        int wall; cin>>wall;
        if(!wall){
          add_edge(maze,j,i,j,i+1);
        }
      }
    }

    const int ans = bfs(get_index(0,0),get_index(w-1,h-1),maze);
    ans == -1 ? cout<<0<<endl : cout<<ans<<endl;
  }

  return EXIT_SUCCESS; 
}

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

using namespace std;
using ld = long double;
using ll = long long;

ll mod = 1e9 + 7;

int main() {
    cout.precision(20);
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    n++;
    vector<ll> pref(n + 1), suff(n, n - 1);
    for (int i = 1; i <= n; i++) {
        pref[i] = (pref[i - 1] + i) % mod;
    }
    for (int i = n - 2; i >= 0; i--) {
        suff[i] = (suff[i + 1] + i) % mod;
    }
    ll ans = 0;
    for (int i = k; i <= n; i++) {
        ans = (ans + suff[n - i] - pref[i - 1] + 1 + mod) % mod;
    }
    cout << ans;
}

Measured memory_bytes: 6296
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;
using uint64 = unsigned long long;
using int128 = __int128_t;
using uint128 = __uint128_t;
using float64 = long double;

template <typename T = int>
struct Range {
  struct RangeIterator {
    T i, step;

    RangeIterator(T i, T step) : i{i}, step{step} {}

    T &operator*() { return i; }
    RangeIterator &operator++() {
      i += step;
      return *this;
    }
    bool operator!=(const RangeIterator &rhs) const {
      return (step > 0 && i < rhs.i) || (step < 0 && i > rhs.i);
    }
  };

  T start, stop, step;

  Range(T start, T stop, T step) : start{start}, stop{stop}, step{step} {}
  Range(T start, T stop) : Range(start, stop, 1) {}
  Range(T stop) : Range(0, stop, 1) {}

  RangeIterator begin() const { return RangeIterator{start, step}; }
  RangeIterator end() const { return RangeIterator{stop, step}; }
};

template <typename T>
inline void ChooseMax(T &a, const T &b) {
  a = std::max(a, b);
}

template <typename T>
inline void ChooseMin(T &a, const T &b) {
  a = std::min(a, b);
}

template <typename T>
std::ostream& operator<<(std::ostream& ostr, const std::vector<T>& vec) {
  ostr << "[";
  for (auto itr = vec.begin(); itr != vec.end(); itr++) {
    if (itr != vec.begin()) {
      ostr << ", ";
    }
    ostr << *itr;
  }
  ostr << "]";
  return ostr;
}

template <typename K, typename V>
std::ostream& operator<<(std::ostream& ostr, const std::map<K, V>& map) {
  ostr << "{";
  for (auto itr = map.begin(); itr != map.end(); itr++) {
    if (itr != map.begin()) {
      ostr << ", ";
    }
    ostr << itr->first << " => " << itr->second;
  }
  ostr << "}";
  return ostr;
}

template <typename T>
std::ostream& operator<<(std::ostream& ostr, const std::set<T>& set) {
  ostr << "{";
  for (auto itr = set.begin(); itr != set.end(); itr++) {
    if (itr != set.begin()) {
      ostr << ", ";
    }
    ostr << *itr;
  }
  ostr << "}";
  return ostr;
}

template <typename F, typename S>
std::ostream& operator<<(std::ostream& ostr, const std::pair<F, S>& pair) {
  ostr << "(" << pair.first << ", " << pair.second << ")";
  return ostr;
}

void SolveProblem() {
  int n, m;
  std::cin >> n >> m;

  std::vector<int> as(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> as[i];
    sum += as[i];
  }

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (4 * as[i] * m >= sum) {
      cnt++;
    }
  }
  if (cnt >= m) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

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

  std::cout.setf(std::ios::fixed);
  std::cout.precision(10);

  SolveProblem();

  return 0;
}


Measured memory_bytes: 256