akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        
        long n = sc.nextLong();
      pw.println(n*(n-1)/2);
        
      sc.close();
        pw.close();
    }
    static class FastScanner {
    	private InputStream stream;
    	private byte[] buf = new byte[1024];
    	private int curChar;
    	private int numChars;
    	private FastScanner.SpaceCharFilter filter;
    	
    	public FastScanner(InputStream stream) {
    		this.stream = stream;
    	}
    	
    	public int read() {
    		if (numChars == -1) {
    			throw new InputMismatchException();
    		}
    		if (curChar >= numChars) {
    			curChar = 0;
    			try {
    				numChars = stream.read(buf);
    			} catch (IOException e) {
    				throw new InputMismatchException();
    			}
    			if (numChars <= 0) {
    				return -1;
    			}
    		}
    	return buf[curChar++];
    	}
    	
    	public int nextInt() {
    		int c = read();
    		while (isSpaceChar(c)) {
    			c = read();
    		}
    		int sgn = 1;
    		if (c == '-') {
    			sgn = -1;
    			c = read();
    		}
    		int res = 0;
    		do {
    			if (c < '0' || c > '9') {
    				throw new InputMismatchException();
    			}
    			res *= 10;
    			res += c - '0';
    			c = read();
    		} while (!isSpaceChar(c));
    		return res * sgn;
    	}
    	
    	public String nextString() {
    		int c = read();
    		while (isSpaceChar(c)) {
    			c = read();
    		}
    		StringBuilder res = new StringBuilder();
    		do {
    			if (Character.isValidCodePoint(c)) {
    				res.appendCodePoint(c);
    			}
    			c = read();
    		} while (!isSpaceChar(c));
    			return res.toString();
    	}
    	
    	public boolean isSpaceChar(int c) {
    		if (filter != null) {
    			return filter.isSpaceChar(c);
    		}
    		return isWhitespace(c);
    	}
    	
    	public static boolean isWhitespace(int c) {
    		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    	}
    	
    	public int[] nextIntArray(int n) {
    		int[] array = new int[n];
    		for (int i = 0; i < n; ++i) array[i] = nextInt();
    		return array;
    	}
    	
    	public interface SpaceCharFilter {
    	public boolean isSpaceChar(int ch);
    	
    	}
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
      using namespace std;
      #define ll long long
      #define pb push_back
      #define pll  pair <long long,long long>
      #define mp make_pair
      #define ss second
      #define ff first
      #define maa 1000000007
      #define endl '\n'
      #define ld long double
      #define all(x) x.begin(),x.end()
      ll  power(ll  i,ll  j)
      {
        if(j==0)
        return 1 ;
        ll t=power(i,j/2)%maa ;
        if(j%2==0)
        return (t%maa*t%maa)%maa ;
        else
        return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
      }
      bool is(ll  i)
      {
        if(i==1)
            return 0 ;
        ll  f=0 ;
        for(ll  j=2;j<=sqrt(i);j++)
        {
            if(i%j==0)
            {
                f=1 ;
                break ;
            }
        }
        return !f ;
      }
      ll ans[51][51],mat[51][51] ;
      void mul(ll a[51][51],ll b[51][51])
      {
          ll t[51][51] ;
          for(ll i=0;i<51;i++)
          {
              for(ll j=0;j<51;j++)
              {
                  t[i][j]=0 ;
                  for(ll k=0;k<51;k++)
                  {
                      t[i][j]+=(a[i][k]*b[k][j])%maa ;
                      t[i][j]%=maa ;
                  }
              }
          }
          for(ll i=0;i<51;i++)
          {
              for(ll j=0;j<51;j++)
              {
                  ans[i][j]=t[i][j]%maa  ;
              }
          }
      }
      void po(ll k)
      {
          if(k==1)
          return ;
          
          po(k/2) ;
          mul(ans,ans) ;
          if(k%2)
          mul(ans,mat) ;
      }
      int main()
      {

        /// 50-4
        /// freopen("input.txt","r",stdin);
        /// freopen("output.txt","w",stdout);
        ll n,k ;
        cin>>n>>k ;
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<n;j++)
            {cin>>mat[i][j] ;
             ans[i][j]=mat[i][j] ;
            }
        }
        po(k) ;
        ll an=0 ;
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<n;j++)
            {
                an+=ans[i][j] ;
                an%=maa ;
            }
        }
        cout<<an ;
       
        
        

      }








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
  cin >>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++)cin>>vec[i];
      sort(vec.begin(), vec.end()); 
    reverse(vec.begin(), vec.end()); 
 int sum=0;
  for(int i=1;i<n;i++){sum += vec[i];}
  if(sum > vec[0])cout<<"Yes"<<endl;
  else cout << "No"<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;

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

  ll n,k; cin >> n >> k;
  ll ans = 0;
  for(ll i = k; i <= n + 1; ++i) {
    ll minv = i * (i - 1) / 2;
    ll maxv = i * (2 * n - i + 1) / 2;
    ans = (ans + maxv - minv + 1) % MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3656
def prize(num)
    case num
    when 1
        return 300000
    when 2
        return 200000
    when 3
        return 100000
    else
        return 0
    end
end

x, y = gets.chomp.split.map(&:to_i)
if x == 1 && y == 1 then
    puts 1000000
else
    puts prize(x) + prize(y)
end

Measured memory_bytes: 14312
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def Eratosthenes(N):
    r = [True]*(N+1)
    r[0] = False
    r[1] = False
    i = 2
    while i*i<=N:
        if r[i]: 
            j = i
            while i*j<=N:
                prime[i*j]=False
                j+=1
        i+=1
    return(r)

def main():
    H,W,A,B = LI()

    ans = [0]*(W-B)

    ans[0] = 1

    for i in range(1,B+H-A):
        ans[0] *= i
        ans[0] %= mod
    for i in range(1,A-1+W-B):
        ans[0] *= i
        ans[0] %= mod
    for i in range(1,H-A):
        ans[0] *= pow(i,mod-2,mod)
        ans[0] %= mod
    for i in range(1,B+1):
        ans[0] *= pow(i,mod-2,mod)
        ans[0] %= mod
    for i in range(1,W-B):
        ans[0] *= pow(i,mod-2,mod)
        ans[0] %= mod
    for i in range(1,A):
        ans[0] *= pow(i,mod-2,mod)
        ans[0] %= mod

    for i in range(1,W-B):
        ans[i] = ans[i-1]
        ans[i] *= (B+H-A-1+i)
        ans[i] %= mod
        ans[i] *= (W-B-i)
        ans[i] %= mod
        ans[i] *= pow(B+i,mod-2,mod)
        ans[i] %= mod
        ans[i] *= pow(A-1+W-B-i,mod-2,mod)
        ans[i] %= mod

    return(sum(ans)%mod)


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


Measured memory_bytes: 41200
n,k=map(int,input().split())
l=list(map(int,input().split()))
if k==1:
    print(0)
    exit()
nl=[]
for i in range(n):
    nl.append((l[i]-1)%k)
r=[0]*(n+1)
for i in range(n):
    r[i+1]=(r[i]+nl[i])%k
p=[]
for i in range(n+1):
    p.append([r[i],i])
p.sort()
s=0
e=0
ans=0
f=0
while e<n+1:
    if p[s][0]!=p[e][0]:
        ans+=f*(f-1)//2
        s=e
        f=0
    else:
        if p[s][1]+k-1>=p[e][1]:
            f+=1
            e+=1
        else:
            ans+=f-1
            f-=1
            s+=1
print(ans+f*(f-1)//2)


Measured memory_bytes: 113564
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());

        if (d <= s * t) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i,n)cin >> v[i];
    sort(ALL(v));
    double ans = v[0];

    REPS(i,n - 1){
        ans = (v[i] + ans) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF  numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()

using namespace std;
using ll = long long;
using Edge = vector<vector<pair<int, int>>>; // src -> dst, weight

/**
 *  全ての頂点を通過するパスの数をDFSで求める
 *  @vertex       : 現在着目している頂点のindex
 *  @edge         : 辺の情報
 *  @vertex_label : 頂点の情報(到達済み : 1, 未到達 : 0)
 *  @Return       : 全ての頂点を通過するパスの数
 */
int graph_dfs(int          vertex,
              const Edge&  edge,
              vector<int>& vertex_label) {
    if(accumulate(vertex_label.begin(), vertex_label.end(), 0) == (int)vertex_label.size()) {
        return 1;
    }

    int ret = 0;
    REP(i, edge[vertex].size()) {
        int dst = edge[vertex][i].first;

        if(vertex_label[dst] == 0) {
            vertex_label[dst] = 1;
            ret += graph_dfs(dst, edge, vertex_label);
            vertex_label[dst] = 0;
        }
    }

    return ret;
}

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

    int N, M;
    std::cin >> N >> M;

    Edge        edge(N);
    vector<int> vertex_label(N, 0);

    REP(i, M) {
        int u, v;
        std::cin >> u >> v;

        // 重み無し無向グラフ
        edge[u - 1].emplace_back(v - 1, 0);
        edge[v - 1].emplace_back(u - 1, 0);
    }

    vertex_label[0] = 1;
    std::cout << graph_dfs(0, edge, vertex_label) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define fs first
#define ss second



int main(){

  int k,n;
  cin >> k >> n;
  int a[n];
  for(int i =0;i<n;i++) cin >> a[i];
  
  int ans = -1;
  for(int i =0;i<n-1;i++){
       ans = max(ans,abs(a[i] - a[(i+1)%n]));
  }
  ans = max(ans, abs(k-a[n-1] + a[0]));
 
 cout << k - ans << endl;

}

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

using namespace std;
//}
int main() {
    //freopen("inp.inp", "r", stdin);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int& i : a) {
        cin >> i;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        ans++;
        while (a[i] == a[i+1]) {
            ++i;
        }
        if (i + 1 == n) break;
        if (a[i] < a[i+1] )
            while (a[i] <= a[i+1] and i + 1 < n) {
                ++i;
            }
        else
            while (a[i] >= a[i+1] and i + 1 < n) {
                ++i;
            }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int main(){
int a=0,b=0,c=0;
int ans =0;
 
cin >>a>>b>>c;
 
int len=b+c;
 
for(int i=1;len*i<=a-c;i++){
ans =i;
}
 
cout << ans<<endl;
 
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<vector>
#include<map>
#include<set>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

ll n,m,s,t,x,y;
vector<ll> g[100100];
ll ds[100100], dt[100100];
vector<ll> nums[100100];
set<ll> numt[100100];
const ll INF = 1e12;

int main(){
  cin >> n >> m >> s >> t;
  rep(i,m){
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  queue<ll> q;
  q.push(s);
  rep(i,n+1)ds[i] = INF;
  ds[s] = 0;
  nums[0].push_back(s);

  while(q.size()){
    ll v = q.front(); q.pop();

    for(int i=0;i<g[v].size();i++){
      if(ds[g[v][i]] > ds[v] + 1){
	ds[g[v][i]] = ds[v] + 1;
	q.push(g[v][i]);
	nums[ds[g[v][i]]].push_back(g[v][i]);
      }
    }
  }

  q.push(t);
  rep(i,n+1)dt[i] = INF;
  dt[t] = 0;
  numt[0].insert(t);

  while(q.size()){
    ll v = q.front(); q.pop();
    for(int i=0;i<g[v].size();i++){
      if(dt[g[v][i]] > dt[v] + 1){
	dt[g[v][i]] = dt[v] + 1;
	q.push(g[v][i]);
	numt[dt[g[v][i]]].insert(g[v][i]);
      }
    }
  }


  ll res = 0;
  ll len = ds[t]-1;
  /*
  rep(i,len+1){
    cout << "---" << i << "---" << endl;
    rep(j,nums[i].size())cout << nums[i][j] << " ";cout << endl;
  }

  rep(i,len+1){
    cout << "---" << i << "---" << endl;
    for(set<ll>::iterator it=numt[i].begin();it!=numt[i].end();it++){
      cout << *it << " ";cout << endl;
    }
  }
  */
  for(int i=0;i<len;i++){
    res += (ll)nums[i].size()*numt[len-i-1].size();
    rep(j,nums[i].size()){
      rep(k,g[nums[i][j]].size()){
	int nxt = g[nums[i][j]][k];
	if(numt[len-i-1].find(nxt)!=numt[len-i-1].end()){
	  res--;
	}
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 22752
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int K; cin >> K;
    string S; cin >> S;
    if (S.size() <=K) OUT(S)
    else OUT(S.substr(0,K) + "...")

    return 0;
}

Measured memory_bytes: 3640
# exhaustive.rb
#

s=Array.new(20)
table=Array.new(2000,0)
table[0]=1
table2=Array.new(2000,0)

n=STDIN.gets.split[0].to_i
str=STDIN.gets.split
sum=0
0.upto(n-1) {|i|
  table2=Marshal.load(Marshal.dump(table))
  num = str[i].to_i
  0.upto(sum){|j|
    break if j+num > 2000 
    if table[j]==1
      table2[j+num]=1 
#     printf("%d %d %d\n",j,num,j+num)
    end
  } 
  sum += num
  table=Marshal.load(Marshal.dump(table2))
}

q  =STDIN.gets.split[0].to_i
str=STDIN.gets.split

0.upto(q-1){|i|
  m=str[i].to_i
  puts (table[m]==1)?"yes":"no"
}
  

Measured memory_bytes: 9472
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <ctime>
#include <list>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef pair<int,int> PI;
#ifndef M_PI
const double M_PI=acos(-1);
#endif
#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)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int((a).size()))
#define F first
#define S second
int dx[]={0,1,0,-1,0,0},dy[]={1,0,-1,0,0,0};
int dz[]={0,0,0,0,1,-1};

int n;
double sx[30],sy[30],sz[30];

double dist(double x,double y,double z,int id){
  double tx=x-sx[id];
  double ty=y-sy[id];
  double tz=z-sz[id];
  return sqrt(tx*tx+ty*ty+tz*tz);
}

double rad(double x,double y,double z){
  double ret=dist(x,y,z,n-1);
  rep(i,n-1)ret=max(ret,dist(x,y,z,i));
  return ret;
}

typedef struct _node{
  double x,y,z,r;
  int wh;
  _node(double x,double y,double z,int wh):
    x(x),y(y),z(z),wh(wh),r(rad(x,y,z)){};

  bool operator<(const _node& rn)const{
    if(rn.wh!=wh)return rn.wh<wh;
    return rn.r<r;
  }
}node;

int tx[]={1,1,1,1,-1,-1,-1,-1};
int ty[]={1,1,-1,-1,1,1,-1,-1};
int tz[]={1,-1,1,-1,1,-1,1,-1};
double len[1000];

void solve(){
  rep(i,n)scanf("%lf%lf%lf",sx+i,sy+i,sz+i);
  len[0]=100;
  for(int i=1;i<1000;++i)
    len[i]=len[i-1]/2;
  double ans=10000;
  rep(i,n)rep(j,i)
    ans=min(ans,rad((sx[i]+sx[j])/2,
                    (sy[i]+sy[j])/2,
                    (sz[i]+sz[j])/2));

  priority_queue<node> q;
  q.push(node(50,50,50,0));
  int cu=0;
  int bwh=-1;
  while(!q.empty()){
    node cur=q.top();
    q.pop();
    if(cu==800 && cur.wh==bwh)continue;
    if(cu==800)cu=0,bwh=cur.wh;
    ++cu;
    double rr=len[cur.wh];    
    if(ans<cur.r-rr*sqrt(3)*2+EPS)continue;
    ans=min(ans,cur.r);
    if(cur.wh>25)continue;
    //printf("%.5f %.5f %.5f %.5f %.7f %d\n",cur.x,cur.y,cur.z,cur.r,ans,cur.wh);

    rep(i,8)
      q.push(node(cur.x+rr*tx[i],cur.y+rr*ty[i],cur.z+rr*tz[i],cur.wh+1));
  }

  printf("%.5f\n",ans);
}

main(){
  while(cin>>n,n)
    solve();
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
string s;
cin >> s;
for(ll i = 0; i < s.size(); i++){
    if(i == 5 || i == 13)
    cout << " ";
    else
    {
        cout << s[i];
    }
}
cout << endl;
}

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

int main() {
  long H, W;
  cin >> H >> W;
  if (H == 1 || W == 1) return cout << 1 << "\n", 0;
  if (H % 2 && W % 2) return cout << H * W / 2 + 1 << "\n", 0;
  cout << H * W / 2 << "\n";
}


Measured memory_bytes: 256
/** Bismillahir Rahmanir Rahim **/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define Fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(x) cout << "x " << x;

int main()
{
    int x, n;
    cin >> x >> n;
    if (500 * x >= n) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

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


using namespace std;

#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 REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


ll n, mu, a[100], b[100], ans[100],m[100];
int main() {
	REP(i, 100) m[i] = INF;
	cin >> n >> mu;
	REP(i, n) {
		cin >> a[i] >> b[i];
	}
	REP(i, mu) {
		ll x, y;
		cin >> x >> y;
		REP(j, n) {
			if (m[j] > abs(a[j] - x) + abs(b[j] - y)) {
				ans[j] = i + 1;
				m[j] = abs(a[j] - x) + abs(b[j] - y);
			}
		} 
	}
	REP(i, n)cout << ans[i] << endl;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
using namespace std;
template <typename T> inline T LCM(T a,T b)
{
    return (a*b)/__gcd(a,b);
}
map<int,string> mp;
map<int,string> mp2;
map<string,int> mpc;
vector<string>vp;
int main()
{
    ll a,b,c,m,f=0,g=0,n,t;
    //freopen("input.txt","r",stdin);
    cin>>n>>m;
    f=max(n,m)*12;
    double d,e;
    for(int i=1; i<=1200; i++)
    {
        a=(i*8)/100.0;
        b=(i*10)/100.0;
       // cout<<a<<" "<<b<<endl;
        if(a==n&&b==m)
        {
            cout<<i<<endl;
           return 0;
        }
    }
    cout<<-1<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    long long A,B,K;
    cin >> A >> B >> K;
    
    if(A > K){
            A -= K;
        }
    else{
        if(B > K - A){
            B -= K - A;
            A = 0;
        }
        else{
            A = 0;
            B = 0;
        }
        
    }
    
    
    cout << A <<" " << B << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main() {
	int a, b, c; cin >> a >> b >> c;
	printf("%d", min({ a + b,b + c,c + a }));
	return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (a==b && b==c) cout << 1 << endl;
  else if (a==b || b==c || c==a) cout << 2 << endl;
  else cout << 3 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[100001];
int main(){
    int n,l;
    cin>>n>>l;
    rep(i,n) cin>>a[i];
    int cur=-1;
    rep(i,n-1){
        if(a[i]+a[i+1]>=l) cur=i;
    }
    if(cur==-1){
        cout<<"Impossible"<<endl;
        return 0;
    }
    cout<<"Possible"<<endl;
    rep(i,cur) cout<<i+1<<endl;
    for(int i=n-2;i>=cur;--i) cout<<i+1<<endl;
    return 0;
}


Measured memory_bytes: 1152
#include <cmath>
#include <cstdio>
#include <deque>
#include <vector>

using namespace std;

template <typename T,
          template <typename V, typename = std::allocator<V>> class U>
void p(const U<T>& v)
{
    for (size_t i = 0; i < v.size() - 1; ++i) {
        printf("%d ", v[i]);
    }
    printf("%d\n", v[v.size() - 1]);
}

int insertionSort(vector<int>& v, int g, int cnt)
{
    for (size_t i = g; i < v.size(); ++i) {
        int e = v[i];
        int j = i - g;
        while (j >= 0 && v[j] > e) {
            v[j + g] = v[j];
            j = j - g;
            ++cnt;
        }
        v[j + g] = e;
    }
    return cnt;
}

int main()
{
    int N;
    scanf("%d", &N);
    vector<int> v;
    int t;
    for (int i = 0; i < N; ++i) {
        scanf("%d", &t);
        v.push_back(t);
    }
    int cnt = 0;

    deque<int> g;
    auto lim = static_cast<int>(ceil(v.size() / 3.0));
    auto pow = [](int base, int ex) {
        int r = 1;
        for (auto i = 0; i < ex; ++i) {
            r *= base;
        }
        return r;
    };
    auto e = [pow](int n) { return (pow(3, n) - 1) / 2; };
    for (int i = 1; true; ++i) {
        auto r = e(i);
        if (r > lim) {
            break;
        }
        g.push_front(r);
    }

    for (size_t i = 0; i < g.size(); ++i) {
        cnt = insertionSort(v, g[i], cnt);
    }
    printf("%ld\n", g.size());
    p(g);
    printf("%d\n", cnt);
    for (auto&& i : v) {
        printf("%d\n", i);
    }
}

Measured memory_bytes: 6532
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int bc,ta;
    cin >> bc >> ta;
    for (int yc = 0; yc <= bc; yc++) {
        for (int hc = 0; yc + hc <= bc; hc++) {
            int nc = bc - yc - hc;
            if (10000 * yc + 5000 * hc + 1000 * nc == ta ) {
                cout << yc << " " << hc << " " << nc << endl;
                return 0;
            }
        }
    }
    
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>

//FILE *fin = fopen("a.in", "r");
#define fin stdin

#define MAXN 109
#define MAXT 21000

char m[MAXN + 2][MAXN + 10];
std::vector < int > g[MAXT];
bool viz[MAXT];
int lin[MAXN], col[MAXN];

bool dfs(int x) {
    if (x == 1)
        return 1;
    if (viz[x])
        return 0;
    viz[x] = 1;
    int p =0;
    while (p < (int)g[x].size() && !dfs(g[x][p]))
        p++;
    if (p == (int)g[x].size())
        return 0;
    g[g[x][p]].push_back(x);
    std::swap(g[x][p], g[x].back());
    g[x].pop_back();
    return 1;
}

int main() {
    int nrlin, nrcol;
    fscanf(fin, "%d%d ", &nrlin, &nrcol);

    int linS = 0, colS = 0, linD = 0, colD = 0;
    for (int i = 1; i <= nrlin; i++) {
        fgets(m[i] + 1, MAXN + 5, fin);

        for (int j = 1; j <= nrcol; j++)
            if (m[i][j] == 'S') linS = i, colS = j;
            else if (m[i][j] == 'T') linD = i, colD = j;
    }

    if (linS == linD || colS == colD)
        printf("-1\n");
    else {
        lin[linS] = 0;
        col[colS] = 0;
        lin[linD] = 1;
        col[colD] = 1;
        int t = 1;
        for (int i = 1; i <= nrlin; i++)
            if (i != linS && i != linD)
                lin[i] = ++t;
        for (int i = 1; i <= nrcol; i++)
            if (i != colS && i != colD)
                col[i] = ++t;
        for (int i = 1; i <= nrlin; i++) {
            for (int j = 1; j <= nrcol; j++) {
                if (m[i][j] == 'o') {
                    t++;
                    g[lin[i]].push_back(t);
                    g[col[j]].push_back(t);
                    g[t].push_back(t + 1);
                    t++;
                    g[t].push_back(lin[i]);
                    g[t].push_back(col[j]);
                }
            }
        }
        int ans = 0;
        while (dfs(0)) {
            memset(viz, 0, sizeof viz);
            ans++;
        }
        printf("%d\n", ans);
    }

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;

int main(){
	ll n, x;
	cin >> n >> x;
	vll l(n);
	vin(l);
	ll ans = 1;
	while(ans <= n){
		x -= l.at(ans - 1);
		if(x < 0) break;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 1;
    int ansi = 0;
    for (int i = 1; i <= n; i++) {
      int tmp = i;
      int cnt = 0;
      while (tmp % 2 == 0) {
        int x = tmp / 2;
        tmp = x;
        cnt++;
        if (ansi <= cnt) {
          ansi = cnt;
          ans = i;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
import java.util.*;
public class Main{
  public static void main(String[] augs){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int count = 0;
    
    if (a > b){
      count += a;
      a = a-1;
    } else {
      count += b;
      b = b-1;
    }
    if (a > b){
      count += a;
      a = a-1;
    } else {
      count += b;
      b = b-1;
    }
    
    System.out.println(count);
  }
}

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

using Lint=long long;
using P=pair<Lint,Lint>;

Lint mydiv(Lint a,Lint b)
{
   if(a>=0 or a%b==0) return a/b;
   return a/b-1;
}
Lint mymod(Lint a,Lint b)
{
   if(a>=0 or a%b==0) return a%b;
   return a%b+b;
}
Lint sum(Lint a,Lint b)
{
   return (a+b)*(b-a+1)/2;
}

int main()
{
   int N,X,D; cin>>N>>X>>D;
   if(D==0){
      if(X==0) cout<<1<<endl;
      else cout<<N+1<<endl;
      return 0;
   }
   if(D<0) X=-X,D=-D;

   map<int,vector<P>> mp;
   mp[0].push_back({0,0});
   for(int k=1;k<=N;k++){
      Lint l=mydiv((Lint)k*X,D)+sum(0,k-1);
      Lint r=mydiv((Lint)k*X,D)+sum(N-k,N-1);
      mp[mymod((Lint)k*X,D)].push_back({l,r});
   }

   Lint ans=0;
   for(auto p:mp){
      auto events=p.second;
      /*
      printf("%d: ",p.first);
      for(auto q:events) printf("(%lld,%lld) ",q.first,q.second); puts("");
      */
      sort(events.begin(),events.end());
      Lint s,t; tie(s,t)=events[0];
      for(auto q:events){
         if(q.first<=t) t=max(t,q.second);
         else ans+=t-s+1,tie(s,t)=q;
      }
      ans+=t-s+1;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 22144
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define INF 2000000000
#define MOD 1000000007

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    int ans = 0, tap=1;
    while (b > tap) {
        tap += a-1;
        ans++;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    llint a, b;
    cin >> a >> b;
    
    REP(i, N-1){
        llint at, bt;
        cin >> at >> bt;
        llint rat;
        if(a/at > b/bt){
            rat = a/at;
            if(a%at != 0) rat++;
        }else{
            rat = b/bt;
            if(b%bt != 0) rat++;
        }
        a = at*rat;
        b = bt*rat;
        // cout << a << " " << b << "\n";
    }
    cout << a+b << "\n";
    return 0;
}

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

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

  vector<string> a(n),b(m);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++)
  {
    cin >> b[i];
  }

  for (int i = 0; i <= n-m; i++)
  {
    for (int j = 0; j <= n-m; j++)
    {
      bool flg = true;
      for (int k = 0; k < m; k++)
      {
        for (int l = 0; l < m; l++)
        {
          if(a[i+k][j+l]!=b[k][l]) flg=false;
        }         
      }
      if(flg){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


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

int main(){
    int n;
    cin >> n;
    string s;
    int j=0;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s=="Y"){
            j=1;
        }
    }
    if(j==0)
        cout << "Three"<< endl;
    if(j==1)
        cout << "Four" << endl;
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
pii food[3009];
int T, n;
int dp1[3009][3009], dp2[3009][3009];
bool vis[3009];

int main() {
    scanf("%d%d", &n, &T);
    for (int i = 1; i <= n; i++)scanf("%d%d", &food[i].first, &food[i].second);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= T - 1; j++) {
            dp1[i][j] = dp1[i - 1][j];
            if (j >= food[i].first)
                dp1[i][j] = max(dp1[i][j], dp1[i - 1][j - food[i].first] + food[i].second);
        }
    }
    for (int i = n; i >= 1; i--) {
        for (int j = 1; j <= T - 1; j++) {
            dp2[i][j] = dp2[i + 1][j];
            if (j >= food[i].first)
                dp2[i][j] = max(dp2[i][j], dp2[i + 1][j - food[i].first] + food[i].second);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= T - 1; j++) {
            ans = max(ans, dp1[i - 1][j] + dp2[i + 1][T - 1 - j] + food[i].second);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 70912
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		// 計算
		int result = (a + b )* h/2;
		
		// 出力
		System.out.println(result);
		
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<ll,ll>
#define vint vector<ll>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const ll N=55;
ll n,f[N][N],maxn,a[N],b[N],ans,can[N];
ll ksm(ll x,ll y){
	ll re=1;
	while(y){
		if(y&1)re=re*x;
		x=x*x;y>>=1;
	}return re;
}
bool check(){
	for(ll i=1;i<=n;i++){
		memset(f,0,sizeof(f));
		f[maxn+1][a[i]]=1;
		for(ll j=maxn;j>=1;j--){
			if(can[j])for(ll k=0;k<=a[i];k++)f[j][k%j]|=f[j+1][k],f[j][k]|=f[j+1][k];
			else swap(f[j],f[j+1]);
		}
		if(!f[1][b[i]])return false;
	}return true;
}
signed main(){
	n=read();
	for(ll i=1;i<=n;i++)a[i]=read();
	for(ll i=1;i<=n;i++)b[i]=read();
	for(ll i=1;i<=n;i++)maxn=max(a[i],maxn);
	for(ll i=1;i<=maxn;i++)can[i]=1;
	if(!check())return puts("-1"),signed();
	for(ll i=maxn;i>=1;i--){
		can[i]=0;if(check())continue;
		can[i]=1;ans+=ksm(2,i);
	}return cout<<ans,signed();
}

Measured memory_bytes: 3664
#include <stdio.h>
#include <stdio.h>

typedef struct _element {
	int p;
	int l;
	int r;
} element;

#define MAX 100005
#define NIL -1

element A[MAX];
int cache[MAX];

const char mes[3][20] = {
	"root",
	"internal node",
	"leaf"
};

int get_height(int i) {
	if(cache[i] != NIL) return cache[i];

	if(A[i].r == NIL && A[i].l == NIL) return cache[i] = 0;
	
	if(A[i].r != NIL) {
		cache[A[i].r] = get_height(A[i].r);
		if(A[i].l == NIL) {
			return cache[i] = cache[A[i].r] + 1;
		}
	}
	if(A[i].l != NIL) {
		cache[A[i].l] = get_height(A[i].l);
		if(A[i].r == NIL) {
			return cache[i] = cache[A[i].l] + 1;
		}
	}
	
	if(cache[A[i].r] > cache[A[i].l]) {
		return cache[i] = cache[A[i].r] + 1;
	} else {
		return cache[i] = cache[A[i].l] + 1;
	}
}

void print(int i) {
	int parent = A[i].p;	// parent
	int sibling = NIL; // sibling -> A[A[i].p].r or A[A[i].p].l
	int degree = 0;	// exists A[i].l, A[i].r
	int depth = 0;	// while A[A[i].p] == NIL depth ++
	int height = 0;	// f(n)
	int type = 2;	// 0:root 1:internal node 2:leaf
	int t = A[i].p;
	
	if(parent != NIL)
		if(A[parent].l == i)
			sibling = A[parent].r;
		else
			sibling = A[parent].l;
	
	if(A[i].l != NIL) degree++;
	if(A[i].r != NIL) degree++;
	
	while(t!=NIL) {
		depth ++;
		t = A[t].p;
	}
	
	height = get_height(i);
	
	if(A[i].p == NIL) {
		type = 0;
	} else if(height > 0) {
		type = 1;
	}
	
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", i, parent, sibling, degree, depth, height, mes[type]);
}

int main(void) {
	int n,r,l,i,m;
	
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		A[i].p = NIL;
	}	
	
	for(i=0;i<n;i++) {
		scanf("%d %d %d\n", &m, &l, &r);
		A[m].l = l;
		A[m].r = r;
		if(l != NIL) A[l].p = m;
		if(r != NIL) A[r].p = m;
		cache[m] = NIL;
	}
	
	for(i=0;i<n;i++)
		if(A[i].p == NIL) 
			get_height(i);

	for(i=0;i<n;i++) print(i);
	
	return 0;
}

Measured memory_bytes: 608
# ABC 054
def getIntList(): return [int(x) for x in input().split()]

N, M = getIntList()
A = []
for i in range(N):
    A.append(input())
B = []
for i in range(M):
    B.append(input())
#print(N,M)#
#print(A)#
#print(B)#
for i in range(N-M+1):
    for j in range(N-M+1):
        match = True
        for p in range(M):
            for q in range(M):
                if B[p][q]!=A[i+p][j+q]:
                    match = False
                    break
            if not match: break
        if match: break
    if match: break
#print(i,j)#
if match: print('Yes')
else: print('No')



Measured memory_bytes: 3064
n,m=map(int,input().split())
ab=[list(map(int,input().split()))for i in range(n)]
ab=sorted(ab, key=lambda x:x[0])
i=0
money=0
while True:
    if m-ab[i][1]>0:
        m-=ab[i][1]
        money+=ab[i][0]*ab[i][1]
        i+=1
    else:
        break
money+=m*ab[i][0]
print(money)

Measured memory_bytes: 29788
import java.util.*;
import java.util.Map.Entry;
 
 

class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static int N;
	 static long K;
	 static long[]a;
   public static void main(String[] args) {
	   
       Scanner sc = new Scanner(System.in);
       N = sc.nextInt();
       K = sc.nextLong();

       a = new long[(int)N];
       long max=0;
       for (int i=0 ; i<N; i++) {
           a[i] = sc.nextLong();
           max=Math.max(max, Math.abs(a[i]));
       }

       Arrays.sort(a);
       
       long left=0;
       long right=0;
	   right=Math.abs(max)*Math.abs(max);
	   left=-1*Math.abs(max)*Math.abs(max);
	   while(right-left>1) {
		   long mid=left+(right-left)/2;
		   if(IsOK(mid)) right=mid;
		   else left=mid;
	   }
       

       System.out.println(right);
   }
   
   public static boolean IsOK(long p) {
	   long cnt=0;
	   for(int i=0;i<N;i++) {
		   if(a[i]>0) {
			   int left=-1;
	    	   int right=N;
	    	   while(right-left>1) {
	    		   int mid=left+(right-left)/2;
	    		   if(a[i]*a[mid]<=p) left=mid;
	    		   else right=mid;
	    	   }
		       cnt=cnt+right;
		   } else if(a[i]==0){
			   if(p>=0)cnt=cnt+N;
		   } else {
			   int left=-1;
	    	   int right=N;
	    	   while(right-left>1) {
	    		   int mid=left+(right-left)/2;
	    		   if(a[i]*a[mid]<=p) right=mid;
	    		   else left=mid;
		       }
		       cnt=cnt+N-right;			   
		   }
	   }
	   for(int i=0;i<N;i++) {
		   if(a[i]*a[i]<=p)cnt--;
	   }
	   return cnt/2>=K;
   }
}

Measured memory_bytes: 87996
#include <iostream>
#include <map>
using namespace std;
typedef long long int ll;

map<ll, ll> M;

ll N, P, ans = 1;

void disassemble(ll p)
{
    for (ll i = 2; i * i <= p; i++)
    {
        ll cnt = 0;
        while (p % i == 0)
        {
            cnt++;
            p /= i;
            if (cnt == N)
            {
                ans *= i;
                cnt = 0;
            }
        }
    }
}

int main()
{
    cin >> N >> P;
    disassemble(P);
    if (N == 1)
    {
        cout << P << endl;
    }
    else
    {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(){

    int N,K;
    int h[100000];
    int i;
    unsigned int dif=0;
    unsigned int ans=1000000000;
    
    scanf("%d",&N);
    scanf("%d",&K);
    
    for(i=0;i<N;i++){
        scanf("%d",&h[i]);
    }
    
    qsort(h,N,sizeof(int),compare_int);
    
    
    for(i=0;i<=N-K;i++){
        
        dif = h[i+K-1]-h[i];

        if(ans > dif){
            ans = dif;
        }
        
    }
    
    printf("%d",ans);
    
    return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
int main(void){
  int sosu[250000];
  int i,j,k;
  int ans[256];
  sosu[2] = 1;
  for(i=3;i<250000;i+=2){
    sosu[i] = 1;
  }
  for(i=3;i*i<250000;i+=2){
    if(sosu[i] == 1){
      for(j=i*i;j<250000;j+=i*2){
	sosu[j] = 0;
      }
    }
  }
  for(k=0;k>=0;k++){
    int n;
    int count = 0;
    scanf("%d",&n);
    if(n == 0)break;
    for(i=n+1;i<=n*2;i++){
      if(sosu[i] == 1){
	count++;
      }
    }
    ans[k] = count;
  }
  for(i=0;i<k;i++){
    printf("%d\n",ans[i]);
  }
  return 0;
}

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

using namespace std;
 
int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

#ifdef LOCAL_DEFINE
	freopen("input.txt", "r", stdin);
#endif

	int x;
	cin >> x;
	if (x == 3 or x == 5 or x == 7) {
		cout << "YES" << '\n';
	} else cout << "NO" << '\n';

#ifdef LOCAL_DEFINE
	cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int h,n;
cin>>h>>n;
pair<int,int> arr[n];
for(int i=0;i<n;i++)
{
    cin>>arr[i].ff>>arr[i].ss;
}
int prev[h+10];
int dp[h+10];
dp[0]=0;
for(int i=1;i<=h;i++)
    dp[i]=INT_MAX;
prev[0]=0;
for(int i=1;i<=h;i++)
{
    if(arr[0].ff>=i)
        prev[i]=arr[0].ss;
        else
            prev[i]=prev[i-arr[0].ff]+arr[0].ss;

}

for(int i=1;i<n;i++)
{
    for(int j=1;j<=h;j++)
    {
        if(j<=arr[i].ff)
        {
            dp[j]=min(arr[i].ss,prev[j]);
        }
        else
        {
            dp[j]=min(prev[j-arr[i].ff]+arr[i].ss,prev[j]);
            dp[j]=min(dp[j],arr[i].ss+dp[j-arr[i].ff]);
        }
    }
    for(int j=1;j<=h;j++)
    {
        prev[j]=dp[j];
        dp[j]=INT_MAX;
    }

}

int ans=prev[h];
cout<<ans<<endl;












    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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 T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------

int main(void){
    // Your code here!
    int a,b,c; cin >> a >> b >> c;
    if ((a < c && c < b) || (b < c && c < a)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>

int main()
{
   char s[100];
   char t[100];
   int len = 0;
  
  scanf("%s",s);
  scanf("%s",t);
  len = strlen(s);

  for(int i=0;i<len;i++){
    if(s[i]!=t[i]){
      printf("No");
      break;
    }else if(i==len-1){
      printf("Yes");
    };
  };
  return 0;
};




Measured memory_bytes: 2072
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
using namespace std;

const ll mod = 1e9+7;

int main() {
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);

    ll moves = x / d; // possible moves available

    if(moves >= k){
        cout << x - (k * d) << "\n";
    }else{
        k -= moves;
        x = x - (d * moves);

        if(k % 2 == 1){
            // you will end up on ( x - d )th step
            x = abs(x-d);
            cout << x << "\n";
        }else{
            cout << x << "\n";
        }
    }

}






Measured memory_bytes: 3568
N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort.reverse
MAX_V = A.max

RUI = [0]
COUNTER = Array.new(MAX_V + 1, 0)

A.each do |a|
  COUNTER[a] += 1
  RUI << RUI.last + a
end

(MAX_V - 1).downto(0) do |i|
  COUNTER[i] = COUNTER[i] + COUNTER[i + 1]
end

def f(x)
  cnt = 0

  A.each do |a|
    t = x - a

    next if MAX_V < t

    if t <= 0
      cnt += N
    else
      cnt += COUNTER[t]
    end
  end

  cnt
end

ok = 0
ng = MAX_V * 2 + 1

while (ok - ng).abs > 1
  mid = (ok + ng) / 2

  if f(mid) >= M
    ok = mid
  else
    ng = mid
  end
end

ans = 0

A.each do |a|
  t = [0, ok - a].max

  cnt = COUNTER[t] || 0

  next if cnt <= 0

  ans += RUI[cnt] + (a * cnt)
end

ans -= (f(ok) - M) * ok

puts ans


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

int main() {
    string S, ans = "No";
    cin >> S;
    sort(S.begin(), S.end());

    if(S[0] == S[1] && S[1] != S[2] && S[2] == S[3]){
        ans ="Yes";
    } else {
        ans = "No";
    }

    cout  << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int dp[100001];
int main( void )
{
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for( int i=0; i<N; i++ ) dp[i] = N;
  dp[N] = 0;
  int a[12] = {6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049, 1};
  for( int i=N; i>=0; i-- ){
    for( int j=0; j<12; j++ ){
      if( i-a[j] >= 0 ){
        dp[i-a[j]] = min( dp[i-a[j]], dp[i]+1 );
      }
    }
  }
  cout << dp[0] << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, A[100005];

// g++ a.cpp -std=gnu++17

int main() {
  INCANT;
  cin >> N;
  int a;
  rep(i, N) {
    cin >> a;
    A[i] = a-1;
  }
  int cur = 0;
  int cnt=-1;
  rep(i, N+3) {
    if (cur==1) {
      cnt=i;
      break;
    } else cur=A[cur];
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4012
#include <iostream>
    using namespace std;
    int A,B,C,X;
    int hyaku(int);
    int gojyuu(int);
    int gohyaku(){
        int a;
        int re=0;
        a=min(X/500,A);
        for(int i=a;i>=0;i--){
           re += hyaku(X-i*500);
        }
        return re;
    }
    int hyaku(int n){
        int a;
        int re=0;
        a=min(n/100,B);
        for(int i=a;i>=0;i--){
           re += gojyuu(n-i*100);
        }
        return re;
    }
     
    int gojyuu(int n){
        if(n/50<=C) {
            return 1;
        }
        return 0;
    }
     
    int main(){
        cin>>A>>B>>C>>X;
        cout<<gohyaku()<<endl;
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a[101];
int n;
int main()
{
    scanf("%d%*d",&n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
        cout<<a[i];
    return 0;
}

Measured memory_bytes: 256