akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main extends App {
  val in = new Scanner(System.in)
  val H = in.nextInt()
  val W = in.nextInt()
  val T = in.nextInt()
  val Q = in.nextInt()

  var queries = new ArrayBuffer[(Int, Int, Int, Int, Int, Int)]()
  for (_ <- 0 until Q) {
    val t = in.nextInt()
    val c = in.nextInt()
    val h = in.nextInt()
    val w = in.nextInt()
    val (h2, w2) = if (c == 2) {
      (in.nextInt(), in.nextInt())
    } else {
      (0, 0)
    }
    queries.append((t, c, h, w, h2, w2))
    if (c == 0) {
      // ???????????????
      queries.append((t + T, -1, h, w, h2, w2))
    }
  }
  queries = queries.sortBy(q => (q._1, q._2))

  val f1 = new Fenwick2D(H, W)
  val f2 = new Fenwick2D(H, W)
  queries.foreach { case (_, c, h, w, h2, w2) =>
    c match {
      case -1 =>
        // 1->2
        if (f1.get(h, w) != 0) {
          f1.update(h, w, 0)
          f2.update(h, w, 1)
        }
      case 0 =>
        // 0->1
        f1.update(h, w, 1)
      case 1 =>
        // 2->0
        f2.update(h, w, 0)
      case 2 =>
        // count
        val a = f2.sum(h, w, h2, w2)
        val b = f1.sum(h, w, h2, w2)
        println(s"$a $b")
    }
  }


}

/**
  * 1-indexed 2-dimensional Fenwick's tree
  *
  * @param h height
  * @param w width
  */
class Fenwick2D(h: Int, w: Int) {
  val N: Int = h + 1
  val M: Int = w + 1
  val data: Array[Array[Long]] = Array.fill[Long](N + 1, M + 1)(0)

  def add(x: Int, y: Int, v: Long): Unit = {
    var i = x
    while (i <= N) {
      var j = y
      while (j <= M) {
        data(i)(j) += v
        j += j & -j
      }
      i += i & -i
    }
  }

  def update(x: Int, y: Int, v: Long): Unit = add(x, y, v - sum(x, y, x, y))

  def get(x: Int, y: Int): Long = sum(x, y, x, y)

  def sum(x0: Int, y0: Int, x1: Int, y1: Int): Long = {

    def partialSum(x: Int, y: Int): Long = {
      var res = 0L
      var i = x
      while (i > 0) {
        var j = y
        while (j > 0) {
          res += data(i)(j)
          j -= j & -j
        }
        i -= i & -i
      }
      res
    }

    partialSum(x1, y1) - partialSum(x0 - 1, y1) - partialSum(x1, y0 - 1) + partialSum(x0 - 1, y0 - 1)
  }


}

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

const int INF = 2e9;
vector<int> to[100005];

int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n,INF);
    vector<int> pre(n,-1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()){
        int v = q.front(); q.pop();
        for(int u : to[v]){
            if (dist[u] != INF) continue;
            dist[u] = dist[v]+1;
            pre[u] = v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    rep(i,n){
        if(i == 0) continue;
        int ans = pre[i];
        ans++;
        cout << ans << endl;
    }
}

Measured memory_bytes: 10572
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define fo(i,n) for(int i=0;i<n;++i)
#define Fo(i,k,n) for(int i=k;i<n;++i)
typedef long long int lli;
int main(){
    FIO
    lli n; cin>>n;
    lli a[n],mx=0,ans=0,i;
    fo(i,n){
        cin>>a[i];
        mx=a[0];
    }
    Fo(i,1,n){
        if(a[i]<mx) ans+=mx-a[i];
        else mx=max(mx,a[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5228
#include <stdio.h>
int gcd(int a,int b);

int main(int argc, const char * argv[]) {
  int a,b;
  scanf("%d %d",&a,&b);
  printf("%d\n",gcd(a,b));
}

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


Measured memory_bytes: 2072
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long totalPair = 0;
        
        int[] ball = new int[n];
        long[] pairs = new long[n];

        for(int i = 0;i < n;i++){
            ball[i] = sc.nextInt()-1;
            pairs[ball[i]]++;
        }

        for(int i = 0;i < pairs.length;i++){
            if(pairs[i] >= 2)
                totalPair += pairs[i]*(pairs[i]-1)/2;
            
        }

        for(int i = 0;i < pairs.length;i++){
            long minus = 0;
            if(pairs[ball[i]] >= 2)
                minus = pairs[ball[i]]-1;
            System.out.println(totalPair - minus);
        }
    }
}

Measured memory_bytes: 102432
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s, t;  
  cin >> s >> t;
  bool ans = false;
  
  int L = s.size();
  for(int i = 0; i < L; i++) {
    if(s == t) ans = true;
    else {
      string str = s.substr(L-1, 1);
      s.insert(0, str);
      s.erase(L);
    }
  }
  
  cout << ( ans ?"Yes" :"No") << "\n";

}


Measured memory_bytes: 256
n = int(input())
result = [input() for _ in range(n)]
result_ref = ["AC", "WA", "TLE", "RE"]
count = [0, 0, 0, 0]
for i in result:
    if i==result_ref[0]:
        count[0]+=1
    elif i==result_ref[1]:
        count[1]+=1
    elif i==result_ref[2]:
        count[2]+=1
    else:
        count[3]+=1
print("AC x "+str(count[0]))
print("WA x "+str(count[1]))
print("TLE x "+str(count[2]))
print("RE x "+str(count[3]))

Measured memory_bytes: 16184
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(int &x){
	x=0;static char ch;static bool flag;flag = false;
	while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
	while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const int maxn = 100010;
struct Node{
	int to,next;
}G[maxn<<1];
int head[maxn],cnt;
void add(int u,int v){
	G[++cnt].to = v;
	G[cnt].next = head[u];
	head[u] = cnt;
}
int siz[maxn],fa[maxn],dep[maxn];
#define v G[i].to
void dfs(int u){
	siz[u] = 1;
	for(rg i = head[u];i;i=G[i].next){
		if(v == fa[u]) continue;
		fa[v] = u;dep[v] = dep[u] + 1;
		dfs(v);siz[u] += siz[v];
	}return ;
}
#undef v
int main(){
	int n;read(n);
	int u,v;
	rep(i,2,n){
		read(u);read(v);
		add(u,v);add(v,u);
	}dfs(1);
    int d = dep[n];
	if(d&1){
		int x = d/2,a = siz[n],u = n;
		while(x-- > 0){
			a += siz[fa[u]] - siz[u];
			u = fa[u];
		}
		if(a >= n-a) puts("Snuke");
		else puts("Fennec");
	}else{
		int x = d/2-1,a = siz[n],u = n;
		while(x-- > 0){
			a += siz[fa[u]] - siz[u];
			u = fa[u];
		}
		if(a >= n-a) puts("Snuke");
		else puts("Fennec");
	}
	return 0;
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  ll N; cin >> N;
  vector<ll> v(N); 
  rep(i,N) cin >> v[i];
  sort(all(v));

  double pow2 = powl(2,N-1);
  double retval = 1.0*v[0]/pow2;
  for (int i=1;i<N;i++){
    retval += v[i]/pow2;
    pow2 /= 2.0;
  }
  
  cout << fixed << setprecision(6);
  cout << retval << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

ll MOD;
ll add(ll x, ll y)
{
    x += y;
    if (x >= MOD)
        return x - MOD;
    return x;
}
ll sub(ll x, ll y)
{
    x -= y;
    if (x < 0)
        return x + MOD;
    return x;
}
ll mult(ll x, ll y)
{
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p)
{
    if (p == 0)
        return 1;
    if (p & 1)
        return mult(x, bin_pow(x, p - 1));
    return bin_pow(mult(x, x), p / 2);
}

signed main()
{
    int n;
    cin >> n >> MOD;
    string s;
    cin >> s;
    reverse(ALL(s));
    if(MOD!=2 && MOD!=5){
        vector<int> v(n+1);
        int r = 0;
        v[0] = 0;
        for (int i = 0; i < n; i++)
        {
            r+= mult(s[i]-'0',bin_pow(10 , i));
            r %= MOD;
            v[i+1] = r;
        }
        //show(v);
        map<int, int> mp;
        for (int i = 0; i <=n; i++)
        {
            mp[v[i]]++;
        }
        int ans = 0;
        for (auto &u : mp)
        {
            //cerr << u.first << " " << u.second << endl;
            ans += u.second * (u.second - 1) / 2;
        }
        cout << ans << endl;
    }
    else if(MOD==2){
        int ans = n * (n + 1) / 2;
        for (int i = 0; i < n; i++)
        {
           if( (s[i] -'0')%2==1){
               ans -= n - i;
           }
       }
       cout << ans << endl;
    }
    else{
        int ans = n * (n + 1) / 2;
        for (int i = 0; i < n; i++)
        {
           
            if ((s[i] - '0') != 5 && (s[i] - '0') != 0)
            {
                ans -= n - i;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2564
import sys
input = sys.stdin.readline

N, K, C = map(int, input().split())
S = input()[:-1]
l = []

for i in range(N):
    if S[i]=='o':
        l.append(i)

prev = -10**18
L = []

for li in l:
    if li-prev>C:
        L.append(li)
        prev = li

prev = 10**18
R = []

for li in l[::-1]:
    if prev-li>C:
        R.append(li)
        prev = li

for i in range(K):
    if L[i]==R[K-i-1]:
        print(L[i]+1)

Measured memory_bytes: 61304
/*---> praveenojha33 <---> 01 September 2019 <--- > 10:51:25 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
void add(int &a,int b){
	a+=b;
	if(a>=mod)
		a-=mod;
}
int mul(int a,int b){
	return (a*b)%mod;
}
struct M{
	vvi mat;
	int n,m;
	M(int _n,int _m):n(_n),m(_m){
		mat.resize(n,vi (m));
	}
	M operator*(const M &b){
		int _n=sz(mat),_m=sz(b.mat[0]);
		int com=sz(b.mat);
		M res(_n,_m);
		for(int i=0;i<_n;i++){
			for(int j=0;j<_m;j++){
				for(int k=0;k<com;k++){
					add(res.mat[i][j],mul(mat[i][k],b.mat[k][j]));
				}
			}
		}
	return res;
	}
};
int32_t main(){__
	int n,k;
	cin>>n>>k;
	M a(n,n),I(n,n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a.mat[i][j];
		}
		I.mat[i][i]=1;
	}
	while(k>0){
		if(k&1){
			I=I*a;
			// debug()<< imie(I.mat);
		}
		k/=2;
		a=a*a;
		// debug()<< imie(a.mat);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			add(ans,I.mat[i][j]);
		}
	}
	cout<<ans<<"\n";
return 0;
}

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


#define INF 1000000000000
  signed main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
      cin>>a[i];
    }
    int Max=0,Min=INF;
    rep(i,n){
      Max=max(a[i],Max);
      Min=min(a[i],Min);

    }
    cout<<abs(Max-Min);
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}

vector<ll> countal(string ST){
  vector<ll> num(26);
  rep(i,ST.size()){
    if(ST[i]=='A')num.at(0)++;
    if(ST[i]=='B')num.at(1)++;
    if(ST[i]=='C')num.at(2)++;
    if(ST[i]=='D')num.at(3)++;
    if(ST[i]=='E')num.at(4)++;
    if(ST[i]=='F')num.at(5)++;
    if(ST[i]=='G')num.at(6)++;
    if(ST[i]=='H')num.at(7)++;
    if(ST[i]=='I')num.at(8)++;
    if(ST[i]=='J')num.at(9)++;
    if(ST[i]=='K')num.at(10)++;
    if(ST[i]=='L')num.at(11)++;
    if(ST[i]=='M')num.at(12)++;
    if(ST[i]=='N')num.at(13)++;
    if(ST[i]=='O')num.at(14)++;
    if(ST[i]=='P')num.at(15)++;
    if(ST[i]=='Q')num.at(16)++;
    if(ST[i]=='R')num.at(17)++;
    if(ST[i]=='S')num.at(18)++;
    if(ST[i]=='T')num.at(19)++;
    if(ST[i]=='U')num.at(20)++;
    if(ST[i]=='V')num.at(21)++;
    if(ST[i]=='W')num.at(22)++;
    if(ST[i]=='X')num.at(23)++;
    if(ST[i]=='Y')num.at(24)++;
    if(ST[i]=='Z')num.at(25)++;
    if(ST[i]=='a')num.at(0)++;
    if(ST[i]=='b')num.at(1)++;
    if(ST[i]=='c')num.at(2)++;
    if(ST[i]=='d')num.at(3)++;
    if(ST[i]=='e')num.at(4)++;
    if(ST[i]=='f')num.at(5)++;
    if(ST[i]=='g')num.at(6)++;
    if(ST[i]=='h')num.at(7)++;
    if(ST[i]=='i')num.at(8)++;
    if(ST[i]=='j')num.at(9)++;
    if(ST[i]=='k')num.at(10)++;
    if(ST[i]=='l')num.at(11)++;
    if(ST[i]=='m')num.at(12)++;
    if(ST[i]=='n')num.at(13)++;
    if(ST[i]=='o')num.at(14)++;
    if(ST[i]=='p')num.at(15)++;
    if(ST[i]=='q')num.at(16)++;
    if(ST[i]=='r')num.at(17)++;
    if(ST[i]=='s')num.at(18)++;
    if(ST[i]=='t')num.at(19)++;
    if(ST[i]=='u')num.at(20)++;
    if(ST[i]=='v')num.at(21)++;
    if(ST[i]=='w')num.at(22)++;
    if(ST[i]=='x')num.at(23)++;
    if(ST[i]=='y')num.at(24)++;
    if(ST[i]=='z')num.at(25)++;
  }
  return num;
}
int main()
{
  string S,T;
  cin>>S>>T;
  vector<ll> A(26);
  A=countal(S);
  vector<ll> B(26);
  B=countal(T);
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  bool ans=true;
  rep(i,26){
    if(A.at(i)!=B.at(i))ans=false;
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

bool check(int n){
  int dig[3];
  dig[0] = n%10;
  n/=10;
  dig[1] = n%10;
  n/=10;
  dig[2] = n%10;
  
  if(dig[0]==dig[1]&&dig[1]==dig[2])
    return true;
  else
    return false;
}

int main(){
  int N;cin >> N;
  
  while(!check(N)){
    N++;
  }
  cout << N << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;



int main()
{
    fastInp;

    ll n;
	cin >> n;

	for (ll i = 0; i <= n; i++) {
		if ((i * 108) / 100 == n) {
			cout << i;
			return 0;
		}
	}

	cout << ":(";

    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>

int main() {
    int x, a, b;
    scanf("%d%d%d", &x, &a, &b);
    if (abs(x - a) < abs(x - b)) {
        puts("A");
    } else {
        puts("B");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
map<string, int> mp;
int main(){
    int n; cin >> n;
    vector<string> vs(n);
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    int ans = 0;
    for(map<string, int>::iterator it = mp.begin(); it != mp.end(); it++)ans++;
    cout << ans << endl;

    return 0;
}  

Measured memory_bytes: 25172
a = input()
line = ""
for i in range(len(a)):
    if i == len(a)-1:
        if a[-1]== "A":
            line += "X"
        elif a[-1] == "B":
            line += "Y"
        elif a[-1]== "C":
            line += "Z"
        else:
            line += str(chr(ord(a[-1])-3))
    
    else:
        if a[i]== "A":
            line += "X"
        elif a[i] == "B":
            line += "Y"
        elif a[i]== "C":
            line += "Z"
        else:
            line += str(chr(ord(a[i])-3))
print(line)

Measured memory_bytes: 7392
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k, q;
	cin >> n >> k >> q;
	vi a(n, k);
	vi b(n, 0);
	for (int i = 0; i < q; i++)
	{
		int cur = 0;
		cin >> cur;
		b[cur - 1]++;
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] - q + b[i] > 0)
			cout << "Yes";
		else
			cout << "No";
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
import sys
input = sys.stdin.readline

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

# 正負が混在するか判定
plus = False
minus = False
for a in A:
    if a > 0:
        plus = True
    elif a < 0:
        minus = True

ans = []

# 正負が混在する場合、符号を揃える
if plus == True and minus == True:
    max_a = max(A)
    min_a = min(A)
    max_idx = A.index(max_a)
    min_idx = A.index(min_a)
    # 正に揃える
    if abs(max_a) >= abs(min_a):
        for i in range(N):
            A[i] += max_a
            ans.append([max_idx + 1, i + 1])
    # 負に揃える
    if abs(max_a) < abs(min_a):
        for i in range(N):
            A[i] += min_a
            ans.append([min_idx + 1, i + 1])
# print(A)

# 正に揃っている場合
if min(A) >= 0:
    # 前から累積和
    for i in range(1, N):
        A[i] += A[i - 1]
        ans.append([i, i + 1])
# 負に揃っている場合
else:
    # 後ろから累積和
    for i in range(N - 2, -1, -1):
        A[i] += A[i + 1]
        ans.append([i + 2, i + 1])

print(len(ans))
for a in ans:
    print(*a)
# print(A)


Measured memory_bytes: 62608
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>

using namespace std;
const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int dp[100100][13];

    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 13; ++j) {
            for (int k = 0; k <= 9; ++k) {
                if (s[i] != '?' && s[i] != ('0' + k)) continue;
                int after = (j * 10 + k) % 13;
                dp[i + 1][after] += dp[i][j];
                dp[i + 1][after] %= MOD;
            }
        }
    }
    int ans = dp[n][5];
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5504
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

vi G[101];
int dis[101], N;
void dfs(int u, int p, int d) {
    smax(dis[u], d);
    each(v, G[u]) if(v!=p) dfs(v, u, d + 1);
}

ll bfs(int s1, int s2) {
    queue<pii> Q;
    Q.push({ s1,0 });
    if (s2 != -1)Q.push({ s2,0 });
    MEM(dis, -1);
    int ma = 0;
    while (sz(Q)) {
        int u, d;
        tie(u, d) = Q.front();
        Q.pop();
        if (dis[u] != -1)continue;
        ma = dis[u] = d;
        each(v, G[u])Q.push({ v,d + 1 });
    }
    vi madeg(ma + 1);
    rep(a, N)smax(madeg[dis[a]], sz(G[a]) - 1);
    if (s2 == -1)madeg[0]++;
    ll re = 1;
    rep(a, ma)re *= madeg[a];
    if (s2 != -1)re *= 2;
    return re;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    cin >> N;
    rep(a, N - 1) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    rep(a, N)if (sz(G[a]) == 1)dfs(a, -1, 0);
    int mi = *min_element(dis, dis + N);
    vi C;
    rep(a, N)if (dis[a] == mi)C.push_back(a);
    ll colorful = -1, re = LLONG_MAX;
    if (sz(C) == 1) {
        colorful = mi + 1;
        smin(re, bfs(C[0], -1));
        each(v, G[C[0]]) smin(re, bfs(C[0], v));
    } else {
        colorful = ((mi - 1) * 2 + 1) / 2 + 1;
        re = bfs(C[0], C[1]);
    }
    cout << colorful << ' ' << re << endl;
}

Measured memory_bytes: 256
s = list(input())

for i in range(2 ** 3):
    cal = int(s[0])
    temp_s = s[0]
    for j in range(3):
        if (i >> j)&1:
            cal += int(s[j + 1])
            temp_s += '+' + s[j + 1]
        else:
            cal -= int(s[j + 1])
            temp_s += '-' + s[j + 1]

    if cal == 7:
        print(temp_s + '=7')
        exit()


Measured memory_bytes: 3060
import bisect as bs
s=input()
t=input()
ss={}
ind={}
j=0
for i in s:
    try:
        ss[i].append(j)
    except:
        ss[i]=[j]
        ind[i]=0
    j+=1
c=0
st=False
for i in t:
    try:
        x=ss[i]
    except:
        st=True
        break
if st:
    print(-1)
else:
    p=-1
    for i in t:
        x=bs.bisect_right(ss[i],p)
   #     print(i,ss[i],x,p)
        try:
            p=ss[i][x]
    #        print("yes")
        except:
     #       print(i,"error")
            c+=1
            p=ss[i][0]
    tot=c*len(s)
    if p!=-1:
        tot+=p+1
    print(tot)


Measured memory_bytes: 7668
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////

int f(string S) {
    int N = S.size();
    int k = 1;
    int res = 0;
    rep(i,N) {
        if (0 <= S[i] - '0' && S[i] - '0' <= 9) {
            k = S[i] - '0';
            continue;
        }
        if (S[i] == 'm') res += k*1000;
        else if (S[i] == 'c') res += k*100;
        else if (S[i] == 'x') res += k*10;
        else if (S[i] == 'i') res += k;
        k = 1;
    }
    return res;
}

const vector<char> c = {'i','x','c','m'};
string g(int x) {
    string res = "";

    int k = 0;
    while (x > 0) {
        int p = x%10;
        if (p > 0) {
            res += c[k];
            if (p > 1) res += char(p + '0');
        }
        x /= 10;
        k++;
    }
    reverse(all(res));
    return res;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    while (N--) {
        string S,T; cin >> S >> T;
        cout << g(f(S) + f(T)) << endl;
    }
}


Measured memory_bytes: 3132
import java.util.Scanner;

class Main {
    private void rightTriangle() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- != 0) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            if (a * a + b * b == c * c ||
                b * b + c * c == a * a ||
                c * c + a * a == b * b )
                System.out.println("YES");
            else
                System.out.println("NO");
        }
    }

    public static void main(String[] args) {
        (new Main()).rightTriangle();
    }
}

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

int main() {
  int N;
  cin>>N;
  int data[N];
  int ans;
  ans=0;
  for(int i=0;i<N;i++){
    cin>>data[i];
  }
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      ans=ans+data[i]*data[j];
    }
  }
  cout<<ans<<endl;
}


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

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

int main() {
	int N;
	while (cin >> N, N) {
		int xma = 0, xmi = 0, yma = 0, ymi = 0;
		vector<pair<int, int>>v;
		v.push_back(pair<int, int>(0, 0));
		for (int i = 0; i < N - 1; i++) {
			int n, d;
			cin >> n >> d;
			v.push_back(pair<int, int>(v[n].first + dx[d], v[n].second + dy[d]));
			xma = max(v[n].first + dx[d], xma); xmi = min(v[n].first + dx[d], xmi);
			yma = max(v[n].second + dy[d], yma); ymi = min(v[n].second + dy[d], ymi);
		}
		cout << xma - xmi + 1 << " " << yma - ymi + 1 << endl;
	}
}

Measured memory_bytes: 3092
#include<iostream>
int main()
{
    int a,b,c,k;
    int sum=0;
    std::cin >> a >> b >> c >> k;

    if(a>=k){
        std::cout << k << std::endl;
        return 0;
    }
    if(a+b>=k){
        std::cout << a << std::endl;
        return 0;
    }
    std::cout << a-(k-a-b) << std::endl;
}
    


Measured memory_bytes: 3640
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int n;
int main() {
	cin >> n;
	for (int i = 0; i < 1000000; i++) {
		if (i * (i + 1) >= 2 * n) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a;cin>>a;
	if(a<2) cout<<1<<endl;
	else if(a<4)  cout<<2<<endl;
	else if(a<8)  cout<<4<<endl;
	else if(a<16) cout<<8<<endl;
	else if(a<32) cout<<16<<endl;
	else if(a<64) cout<<32<<endl;
	else          cout<<64<<endl;
	return 0;
} 

Measured memory_bytes: 256
import sys
N,K = map(int,input().split())
array_hight = list(map(int,input().split()))

if not ( 1 <= N <= 10**5 and 1 <= K <= 500 ): sys.exit()

count = 0
for I in array_hight:
    if not ( 1 <= I <= 500): sys.exit()
    if I >= K:
        count += 1
print(count)

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint
{
    long long x; // typedef long long ll;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(long long t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

int main()
{
    int X, Y;
    cin >> X >> Y;
    if ((X + Y) % 3 != 0)
    {
        cout << 0 << endl;
        return 0;
    }

    int n = (X + Y) / 3;
    X -= n;
    Y -= n;
    if (X < 0 || Y < 0)
    {
        cout << 0 << endl;
        return 0;
    }

    combination c(X + Y);
    mint ans = c(X + Y, X);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 10624
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n; cin>>n;
    vector<int> h(n,0),dp(n,inf);
    rep(i,n) cin>>h[i];
    dp[0]=0; dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<dp[n-1]<<endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  

  

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<ll, int>;

#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vll arr (3 * N);
	F0R(i, 3 * N) cin >> arr[i];

	ordered_set lhs, rhs;
	for (int i = 0; i < N; ++i) lhs.insert({arr[i], i});
	for (int i = N; i < 3 * N; ++i) rhs.insert({arr[i], i});

	ll lhsBest = 0;
	ll rhsBest = 0;

	auto i1 = lhs.begin(), i2 = rhs.begin();
	for (int i = 0; i < N; ++i) {
		lhsBest += (*i1).first;
		rhsBest += (*i2).first;
		i1 = next(i1), i2 = next(i2);
	}

	ll best = lhsBest - rhsBest;

	for (int i = N; i < 2 * N; ++i) {
		pii swap = {arr[i], i};
		if (rhs.order_of_key(swap) < N) {
			rhsBest -= swap.first; 
			rhsBest += (*rhs.find_by_order(N)).first;
		}
		if ((*lhs.find_by_order(lhs.size() - N)).first < swap.first) {
			lhsBest -= (*lhs.find_by_order(lhs.size() - N)).first;
			lhsBest += swap.first;
		}

		lhs.insert(swap);
		rhs.erase(rhs.find(swap));

		best = max(best, lhsBest - rhsBest);
	}
	print(best);
}

Measured memory_bytes: 21376
#include <bits/stdc++.h>
using namespace std;
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();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#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 SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int N,M;
    cin >> N >> M;
    VI L(M);
    VI R(M);
    REP(i,M){
        cin >> L[i] >> R[i];
    }

    int lm=L[0],rm=R[0];
    REP(i,M){
        lm = max(lm,L[i]);
        rm = min(rm,R[i]);
    }
    int ans=0;
    if(lm<=rm){
        ans=rm-lm+1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,b,c,y,n,ans,x;
    cin>>a>>b>>c>>y>>n;
    x=min(min((ll)2*a,b)*(ll)2,c);
    if(x*(ll)2>y){
        ans=((n/(ll)2)*y);
        if(n%2)ans+=x;
    }
    else ans=n*x;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m,k;
   cin>>n>>m>>k;
   vi a(n);
   vi b(m);
   rep(i,0,n)cin>>a[i];
   rep(i,0,m)cin>>b[i];
   int pre[n+1];
   pre[0]=0;
   for(int i=1;i<=n;i++)
   {
       pre[i]=pre[i-1]+a[i-1];
   }
   int pre1[m+1];
   pre1[0]=0;
   for(int i=1;i<=m;i++)
    pre1[i]=pre1[i-1]+b[i-1];
   int mx=0;
   for(int i=0;i<=n;i++)
   {
       int ans=0;
       if(pre[i]<=k)
        ans+=(i);
       int temp=(k - pre[i]);
       //debug(temp,i);
       int x=upper_bound(pre1,pre1+m+1,temp)-pre1;
       //debug(x,i);
       ans+=(x-1);
       mx=max(mx,ans);
   }
   cout<<mx<<endl;

}


Measured memory_bytes: 9532
#include <iostream>
#include <stdio.h>

int x, y;

int gcd (int x, int y) {
    if (x == 0) {
        return y;
    }
    if (x <= y) std::swap(x, y);
    return gcd(x % y, y);
}

int main() {
    scanf("%d %d", &x, &y);
    
    int t = gcd(x, y);
    printf("%d\n", t);
    
    
    return 0;
}

Measured memory_bytes: 3216
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const int INF = 2000000000;
std::pair<string,pair<int,int>> Q[101];
    ll N,M;
    ll A,B,C;
    bool F[5][5];
    bool ad=false;
    ll ans=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>A>>B;
    if(A%2==0){
        if(B%2==0)ans=A*B/2;
        else ans=(A/2)*(B/2+1)+(A/2)*(B/2);
    }else{
        if(B%2==0)ans=(A/2+1)*(B/2)+(A/2)*(B/2);
        else ans=(A/2+1)*(B/2+1)+(A/2)*(B/2);
    }
    if(A==1||B==1)ans=1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter
import kotlin.math.*

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

/** point of coordinate */
data class Point(val x: Double, val y: Double) {
    fun distanceTo(p: Point) = sqrt((p.x - this.x) * (p.x - this.x) + (p.y - this.y) * (p.y - this.y))
}

fun solve(out: PrintWriter) {
    val (a, b, h, m) = readIntegerList()
    val aRad = (PI / 6.0) * (h + m / 60.0) // ((2 * PI) / 12 * h) + (2 * PI) / 12 *  m / 60
    val bRad = PI * m / 30.0 // 2 * PI * m / 60

//    余弦定理
//    val rad = aRad - bRad
//    val ans = sqrt(a * a + b * b - 2 * a * b * cos(rad))
//    println(ans)

//    極座標変換
    val pointA = Point(a * sin(aRad), a * cos(aRad))
    val pointB = Point(b * sin(bRad), b * cos(bRad))
    println(pointA.distanceTo(pointB))


}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 36700
#include<bits/stdc++.h> 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;

#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)


const int MAXN = 1e6;
const int mod = 1e9 + 7;
const int inf = 1e9;



int main(){

	
	fastio;
	int n,a,b;
	cin >> n >> a >> b;

	int ans = min(b,n*a);

	cout << ans << endl;

	return 0;
 }	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll a,b,c;
  cin >> a >> b >> c;
  printf("%lld",a-b+1);
}

Measured memory_bytes: 256
//
// Created by moono on 2018/10/27.
//

#include <iostream>
#include <string>
#include <cmath>
using namespace std;


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


    //
    int a, date;
    for (int i = 0; i < N; ++i) {
        cin >> a;

        date = 0;
        while(date < D){
            X++;
            date += a;
        }
    }


    //
    cout << X << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
vector <int> p(0);
 
void Prime(int n){
 
  bool flg[(int)sqrt( pow(10,9) ) +1];
  int indx=2;
 
  flg[0]=flg[1]=0;
  for(int i=0; i<sqrt(n)+1; i++)flg[i]=0;
   
 
  while(indx<=sqrt(n)){
    flg[indx]=1;
    p.push_back(indx);
    for(int i=2; i*indx<sqrt(n); i++){
      flg[i*indx]=1;
    }
 
    while(flg[indx]==1 && indx<=sqrt(n))indx++;
 
  }
   
 
}
 
 
int main(){
 
  int n;
 
  cin >> n;
 
  Prime(n);
 
  cout << n << ':';
 
  int i=0;
  while(n!=1 && i<(int)p.size()){
     
    while(n%p[i]==0){
      cout << ' ' << p[i];
      n /= p[i];
    }
 
    i++;
     
  }
 
  if(i==(int)p.size() && n!=1)cout << ' '<<n;
  cout << endl;
 
  return 0;
}

Measured memory_bytes: 3208
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <cassert>
#include <string.h>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n-1;i>=0;i--)///n-1番目からn回
#define  REP(i,a,b) for(int i=a;i<b;i++) ///a番目からb回
#define  RREP(i,a,b) for(int i=a;i<b;i--)
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;

#define MOD 1000003

//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///*min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();
///(10-(n%10))%10  1桁目取得

#define Ru(n)  ( ((n)+9)/10*10  ) //切りあげ
#define Rd(n)  ( ((n)-10)/10*10 +10 )	切り捨て

int gcd(int a,int b);
size_t length(const std::string& str) {
	return str.length();
}



int main() {
	int n,sum=0,sum1=0;
	int m=0;
	vi w(1000);
	cin>>n;
	rep(i,n){
		cin>>w[i] ;
		sum+=w[i];
	}
	m=sum-sum1-sum1;
	rep(i,n){
		sum1+=w[i];
		//cout<<sum-sum1<<endl;
		if((m>abs(sum-sum1-sum1)))
			m=abs(sum-sum1-sum1);
	}
	cout<<m;


	return 0;


}
__int64_t product(ll m, ll d, ll n)
{
	if (n == 0)
		return 1;
	else
		return ((m %MOD)* product(m + d, d, n - 1)%MOD)%MOD;
}




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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
 
    int l[15];
    int i,a,b;
 
    while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&a,&b)!=EOF){
 
        double sum=0;
        for(i=0;i<10;i++){
            sum+=(double)l[i];
        }
 
    double c=0,d=0;
    for(i=0;i<10;i++){
        c+=l[i];
        d+=(double)l[i]/a*b;
        if(c+d>=sum)break;
    }
    cout<<i+1<<endl;
 
    }
    return 0;
}

Measured memory_bytes: 1208