akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    int a, b, len;
    string s, ans;
    ans = "Yes";
    cin >>a >>b;
    cin >>s;

    len = a + b + s.size();
    for (int i=0; i < len; i++) {
        if (i == a && s[i] != '-') {
            ans = "No";
        }
        if (i < a && s[i] == '-') {
            ans = "No";
        } else if (i > a+1 && s[i] == '-') {
            ans = "No";
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>M>>S;
    vec ans(0);
    ll last = N;
    bool bre = false;
    while(last != 0 && !bre){
        bre = true;
        reps(i,max(0LL,last - M),last){
            //cout<<i<<endl;
            if(S[i] == '0'){
                ans.push_back(last - i);
                last = i;
                bre = false;
                break;
            }
        }
    }
    if(bre){
        cout<<-1<<endl;
    }else{
        reverse(ALL(ans));
        rep(i,ans.size()){
            cout<<ans[i];
            (i == ans.size() - 1 ? cout<<endl : cout<<' ');
        }
    }
}


Measured memory_bytes: 1528
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n+m){
    vector<int>tr(n);
    vector<int>ha(m);
    int tsum=0,hsum=0;
    for(int i=0;i<n;i++){
      cin>>tr[i];
      tsum+=tr[i];
    }
    for(int i=0;i<m;i++){
      cin>>ha[i];
      hsum+=ha[i];
    }
    bool flag=false;
    int ct=1e9,ht=1e9;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if((hsum-ha[j]+tr[i])==(tsum-tr[i]+ha[j])&&(ct+ht)>(ha[j]+tr[i])){
	  flag=true;
	  ct=tr[i];ht=ha[j];
	}
      }
    }
    if(flag)
      cout<<ct<<" "<<ht<<endl;
    else
      cout<<-1<<endl;
  }
  return 0;
}



Measured memory_bytes: 3080
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int s[100] = {0};
        
    for (int i = a; i < b; i++) {
        s[i]++;
    }
    for (int i = c; i < d; i++) {
        s[i]++;
    }

    int count = 0;
    for (int i = 0; i < 100; i++) {
        if (s[i] == 2) {
            count++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s=input()
n=len(s)
D=["x"]*n
print(*D,sep="")

Measured memory_bytes: 38256
def main():
    N = int(input())
    A = [a for a in input().split()]
    odd = [A[i] for i in range(N) if (i+1) % 2 == 1]
    even = [A[i] for i in range(N) if (i+1) % 2 == 0]

    if len(A) % 2 == 1:
        print(*(odd[::-1]+even))
    else:
        print(*(even[::-1]+odd))
if __name__ == "__main__":
    main()

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // sx = tx 

    int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
    string s = "";
    s.push_back('L');
    rep(i,ty-sy+1) s.push_back('U');
    rep(i,tx-sx+1) s.push_back('R');
    s.push_back('D');
    s.push_back('R');
    rep(i,ty-sy+1) s.push_back('D');
    rep(i,tx-sx+1) s.push_back('L');
    rep(i,ty-sy+1) s.push_back('U');
    rep(i,tx-sx) s.push_back('R');
    rep(i,ty-sy) s.push_back('D');
    rep(i,tx-sx) s.push_back('L');
    cout << s << '\n';
}

Measured memory_bytes: 256
N = int(input())
vals = [1]

tmp = 6
while tmp <= 100000:
  vals.append(tmp)
  tmp *= 6

tmp = 9
while tmp <= 100000:
  vals.append(tmp)
  tmp *= 9

vals.sort()

dp = [0] + [float('inf')] * N
for n in range(1, N+1):
  i = 0
  while i < len(vals) and vals[i] <= n:
    dp[n] = min(dp[n], dp[n-vals[i]]+1)
    i += 1

print(dp[N])

Measured memory_bytes: 4596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

struct data{
	int l,r;
	data():l(0),r(0){}
	data(int x,int y):l(x),r(y){}
	friend bool operator<(const data &dt1,const data &dt2){if(dt1.l==dt2.l)return dt1.r>dt2.r;return dt1.l<dt2.l;}
};

vector<int> vec;
priority_queue<int,vector<int>,greater<int>> pq;
int n,m,ans;
data a[200001];

int main(){
	scanf("%d%d",&n,&m);for(int i=1;i<=n;++i)scanf("%d%d",&a[i].l,&a[i].r);
	sort(a+1,a+n+1);
	int head=1,tail=m;
	for(int i=1;i<=n;++i){
		pq.push(a[i].r);
		if(head<=tail&&head<=a[i].l)++head;else vec.push_back(pq.top()),pq.pop();
	}
	sort(vec.begin(),vec.end());
	for(int i=vec.size()-1;~i;--i)if(head<=tail&&vec[i]<=tail)--tail;else ++ans;
	printf("%d",ans);
}

Measured memory_bytes: 3320
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

map<char,string> cs;
map<string,char> sc;

void add(){
  
  cs[' '] = "11010";
  cs['\''] = "11110";
  cs[','] = "11100";
  cs['-'] = "11101";
  cs['.'] = "11011";
  cs['?'] = "11111";
  cs['A'] = "00000";
  cs['B'] = "00001";
  cs['C'] = "00010";
  cs['D'] = "00011";
  cs['E'] = "00100";
  cs['F'] = "00101";
  cs['G'] = "00110";
  cs['H'] = "00111";
  cs['I'] = "01000";
  cs['J'] = "01001";
  cs['K'] = "01010";
  cs['L'] = "01011";
  cs['M'] = "01100";
  cs['N'] = "01101";
  cs['O'] = "01110";
  cs['P'] = "01111";
  cs['Q'] = "10000";
  cs['R'] = "10001";
  cs['S'] = "10010";
  cs['T'] = "10011";
  cs['U'] = "10100";
  cs['V'] = "10101";
  cs['W'] = "10110";
  cs['X'] = "10111";
  cs['Y'] = "11000";
  cs['Z'] = "11001";
  
  sc["100101"] = 'A';
  sc["10011010"] = 'B';
  sc["0101"] = 'C';
  sc["0001"] = 'D';
  sc["110"] = 'E';
  sc["01001"] = 'F';
  sc["10011011"] = 'G';
  sc["010000"] = 'H';
  sc["0111"] = 'I';
  sc["10011000"] = 'J';
  sc["0110"] = 'K';
  sc["00100"] = 'L';
  sc["10011001"] = 'M';
  sc["10011110"] = 'N';
  sc["00101"] = 'O';
  sc["111"] = 'P';
  sc["10011111"] = 'Q';
  sc["1000"] = 'R';
  sc["00110"] = 'S';
  sc["00111"] = 'T';
  sc["10011100"] = 'U';
  sc["10011101"] = 'V';
  sc["000010"] = 'W';
  sc["10010010"] = 'X';
  sc["10010011"] = 'Y';
  sc["10010000"] = 'Z';
  sc["101"] = ' ';
  sc["010001"] = '.';
  sc["000011"] = ',';
  sc["10010001"] = '-';
  sc["000000"] = '\'';
  sc["000001"] = '?';
}

int main(void){
  add();
  string s;
  while(getline(cin,s)){
    string bit;
    rep(i,s.size()){
      bit += cs[s[i]];
    }
    //cout<<bit<<endl;

    int st = 0;
    string ret = "";
    rep(i,bit.size()){
      //cout<<ret<<endl;
      if(sc[bit.substr(st,i-st+1)]){
	ret += sc[bit.substr(st,i-st+1)];
	st = i + 1;
      }
    }
    cout<<ret<<endl;
  }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n;i>=0;i--)
#define rep_a(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define debug(x) do { std::cerr << #x << ": " << x << std::endl; } while (0);
#define debugg(x,y) do { std::cerr << #x << ": " << x << "  "<< #y << ": " << y << std::endl; } while (0);
#define debugggg(i,j,k,ans) std::cerr << #i << ": " << i << "  "<< #j << ": " << j <<#k << ": " << k <<#ans << ": " << ans << std::endl;
const long long mod = 998244353;
const long long MOD = 1000000007;

typedef vector<ll>              vll;
typedef vector<string>          vstr;
typedef vector<char>            vchar;
typedef vector<pair<ll,ll> >    vpll;
typedef set<ll>                 sll;
typedef set<string>             sstr;
typedef set<pair<ll,ll> >       spll;
typedef map<ll,ll>              mllll;
typedef map<string,ll>          mstrll;
typedef queue<ll>               qll;
int solve()
{
  string s;cin>>s;
  if(s[2] == s[1] &&s[0] == s[1]&&s[1] == 'R')return 3;
  if(s[0] == s[1] && s[0] == 'R')return 2;
  if(s[2] == s[1] && s[1] == 'R')return 2;
  if(s[1] == 'R' || s[0] == 'R' || s[2] == 'R')return 1;
    return 0;
}
 
int main()
{
  fast;
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #else
	// #endif
	cout<<solve()<<endl;;
	// #ifndef ONLINE_JUDGE
	// cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC <<" Sec\n";
	// #endif
	return 0;
}

Measured memory_bytes: 3636
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main
{
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    int H, W;
    boolean[][] board;
    int sx, sy, gx, gy;

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        H = sc.nextInt(); W = sc.nextInt();
        board = new boolean[H + 10][W + 10];
        sy = sc.nextInt() + 3; sx = sc.nextInt() + 3;
        gy = sc.nextInt() + 3; gx = sc.nextInt() + 3;

        for (int i = 4; i < H + 4; i++) {
            String s = sc.next();
            for (int j = 4; j < W + 4; j++) {
                board[i][j] = s.charAt(j - 4) == '.';
            }
        }

        debug(sx, sy, gx, gy);

        out.println(dijkstra());

        out.flush();
    }

    int dijkstra() {
        int[][] d = new int[H + 10][W + 10];
        for (int[] a : d) Arrays.fill(a, 1 << 28);

        PriorityQueue<Pair> q = new PriorityQueue<>();
        q.add(new Pair(sx, sy, 0));
        d[sy][sx] = 0;


        int[] dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
        while (!q.isEmpty()) {
            Pair cur = q.remove();
            if (d[cur.y][cur.x] != cur.c) continue;

            if (cur.x == gx && cur.y == gy) return cur.c;

            for (int i = 0; i < 4; i++) {
                if (board[cur.y + dy[i]][cur.x + dx[i]] && d[cur.y + dy[i]][cur.x + dx[i]] > cur.c) {
                    q.add(new Pair(cur.x + dx[i], cur.y + dy[i], cur.c));
                    d[cur.y + dy[i]][cur.x + dx[i]] = cur.c;
                }
            }

            for (int h = -2; h < 3; h++) {
                for (int w = -2; w < 3; w++) {
                    if (board[cur.y + h][cur.x + w] && d[cur.y + h][cur.x + w] > cur.c + 1) {
                        q.add(new Pair(cur.x + w, cur.y + h, cur.c + 1));
                        d[cur.y + h][cur.x + w] = cur.c + 1;
                    }
                }
            }
        }
        return -1;
    }

    class Pair implements Comparable<Pair> {
        int x, y, c;
        Pair(int x, int y, int c) {
            this.x = x;
            this.y = y;
            this.c = c;
        }

        @Override
        public int compareTo(Pair o) {
            return c - o.c;
        }
    }

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

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

Measured memory_bytes: 63116
#include<stdio.h>
int main()
{
    int h,w,i,j;
    while(1)
    {
     scanf("%d%d",&h,&w);
     if(h==0&&w==0)
        break;
     for(i=1;i<=h;i++)
     {
         for(j=1;j<=w;j++){
            printf("#");
     }
        printf("\n");
    }
    printf("\n");
    }

    return 0;
}



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

using namespace std;

int main()
{
    vector<long long>sv(1e7+1);
    for(int i=1;i<=1e7;i++){
        for(int j=i;j<=1e7;j+=i)
            sv[j]++;
    }
    long long n;
    cin>>n;
    long long ttl=0ll;
    for(long long i=1ll;i<=n;i++){
        ttl+=sv[i]*i;
    }
    cout<<ttl<<'\n';
    return 0;

}
/***
5 4 1
1000000000 1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000
3 4 730
60 90 120
80 150 80 150
*/


Measured memory_bytes: 81204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,c=0;
  cin>>n;
  ll a[n];
  cin>>a[0];
  if(a[0]!=0){
    cout<<-1;
    return 0;
  }
  for(int i=1;i<n;i++){
    cin>>a[i];
    if(a[i-1]+1==a[i]){
      c++;
    }else if(a[i-1]+1>a[i]){
      c+=a[i];
    }else{
      cout<<-1;
      return 0;
    }
  }
  cout<<c;
}

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

int main(){
    string s;
    cin >> s;
    if(s[0] == 'S'){
        cout << "Cloudy";
    }else if(s[0] == 'C'){
        cout << "Rainy";
    }else{
        cout << "Sunny";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
#define INF 1000000
using namespace std;

int main(){
	int n;
	cin >> n;
	int w[n];
	int rui[n] = {};
	rep(i,0,n){
		cin >>w[i];
	}
	rui[0] = w[0];
	rep(i,1,n){
		rui[i] = rui[i-1] + w[i];
	}
	int min = INF;
	rep(i,0,n){
		if(min > abs(rui[n-1]-2*rui[i])){
			min = abs(rui[n-1] - 2*rui[i]);
		}
	}
	cout << min << endl;
}


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


int main(){
	int n;
	double x1, y1;
	double x2, y2;
	double x3, y3;
	double x4, y4;

	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		double xa = x2 - x1, ya = y2 - y1;
		double xc = x4 - x3, yc = y4 - y3;
		double cp = xa*yc - xc*ya;
		if(abs(cp) < 0.0000000001) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
   ll n,p;
   cin >> n >> p;
   ll ans = 1;
   queue<pair<ll,ll>>que;
   for(ll i=2;i*i<=p;i++){
      if(p%i==0){
         ll che =0;
         while(p%i==0){
            p/=i;
            che++;
         }
         que.push(make_pair(i,che));
      }
   }
   if(p!=1){
      que.push(make_pair(p,1));
   }
   while(!que.empty()){
      ll num = que.front().first;
      ll che = que.front().second;
      que.pop();
      if(che/n==0)continue;
      che = che/n;
      ans = ans*pow(num,che);
   }  
   cout << ans << endl;
}
    



Measured memory_bytes: 256
dic = {} #?????????"??????????¨???? ??????"??????????????°

for cardtype in ['S','H','C','D']:
    for i in range(1,13+1):
        dic["{0} {1}".format(cardtype,i)] = 0

n = int(input())
for i in range(n):
    dic[input()] += 1

for cardtype in ['S','H','C','D']:
    for i in range(1,13+1):
        if dic["{0} {1}".format(cardtype,i)] == 0:
            print("{0} {1}".format(cardtype,i))

Measured memory_bytes: 7676
a = int(input())    #500
b = int(input())    #100
c = int(input())    #50
x = int(input())    

cnt=0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if (i*500+j*100+k*50)==x:
                cnt+=1

print(cnt)

Measured memory_bytes: 3060
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int data = scanner.nextInt();
			if (data == 0) {
				scanner.close();
				break;
			}

			char[][] symbols = new char[data][];
			symbols[0] = scanner.next().toCharArray();
			for (int i = 1; i < data; i++) {
				symbols[i] = scanner.next().toCharArray();
				for (int j = 0; j < symbols[i].length; j++) {
					if (symbols[i][j + 1] != '.') {
						symbols[i][j] = '+';
						for (int k = i - 1; k >= 0; k--) {
							if (symbols[k][j] == ' ') {
								symbols[k][j] = '|';
							} else {
								break;
							}
						}
						break;
					} else {
						symbols[i][j] = ' ';
					}
				}
			}

			for (int i = 0; i < symbols.length; i++) {
				System.out.println(symbols[i]);
			}

		}

	}
}

Measured memory_bytes: 71468
#define	Rd(s) scanf("%d", &s)
#define	Rs(s) scanf("%s", &s)
#define	Rf(s) scanf("%f", &s)

#define RTNd(n, s, i) for (int i = 0;(i<n) ? scanf("%d", &s), true : false;i++)
#define RTNf(n, s, i) for (int i = 0;(i<n) ? scanf("%lf", &s), true : false;i++)

#define RTEs(s) while (fgets(s, sizeof(s), stdin) != NULL)
#define RTEc(s) while ((s = scanf("%c")) != EOF)

#define Pd(s) printf("%d", s);
#define Pf(s) printf("%f", s);

#define Pn printf("\n");

#define SORTV(v) sort(v.begin(), v.end())
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
typedef long long lli;
using namespace std;

int main() {
	lli n, a, b;
	lli ax = 1, bx = 1;

	Rd(n);
	for (int i = 0;i < n;i++) {
		scanf("%d %d", &a, &b);
		double atb = (double)a / b, axtbx = (double)ax / bx;
		if (atb>axtbx) {
			if (bx%b != 0)bx = (bx / b)*b + b;
			ax = bx / b*a;
		}
		else if (axtbx>atb) {
			if (ax%a != 0)ax = (ax / a)*a + a;
			bx = ax / a*b;
		}
	}
	printf("%lld\n", ax + bx);

}
//改行注意




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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    int l = 0, r = 1e9;
    while (r-l>1) {
        int x = (l+r)/2;
        auto f = [&] (int d) {
            ll res = 0;
            rep(i, n) res += (a[i]-1) / d;
            return (res <= k);
        };
        if (f(x)) r = x;
        else l = x;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e16
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ii>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1000003;
ll i,s,g,c = 2;
map<ll,ll> mp;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>s;
    mp[s] = 1;
    g = s;
    while(1){
        if(g & 1)
            g = 3 * g + 1;
        else
            g /= 2;
        i = ++mp[g];
        if(i > 1){
            cout<<c;
            break;
        }
        c += 1;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define sqr(x) (x) * (x)
#define cube(x) (z) * (z) * (x)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define itn int

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}

signed main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
  }
  int ans = 0;
  if (a[0] > x) {
    ans += a[0] - x;
    a[0] = x;
  }
  FOR(i, 1, N) {
    if (a[i] + a[i - 1] > x) {
      ans += a[i] + a[i - 1] - x;
      a[i] = x - a[i - 1];
    }
  }
  cout << ans << endl;
}


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

#define llong long long 
typedef struct data{
	int rig;
	int rigrig;
	int up;
	int upup;
	int score;
}data;

int w, h;
data Free = {0, 0, 0, 0, -1};
data start = {1, 0, 1, 0, 1};
data no = {0, 0, 0, 0, 0};
data area[101][101];

void solve(){
	for(int i = 1; i <= w; i++){
		for(int j = 1; j <= h; j++){
			if(i == 1 && j == 1) continue;
			if(area[i][j].score != -1) continue;

			data left;
			data down;
			if(i - 1 == 0) left = no;
			else left = area[i - 1][j];
			if(j - 1 == 0) down = no;
			else down = area[i][j - 1];

			area[i][j].rig = left.upup;
			area[i][j].rigrig = (left.rigrig + left.rig) % 100000;
			area[i][j].up = down.rigrig;
			area[i][j].upup = (down.up + down.upup) % 100000;
			area[i][j]. score = (area[i][j].rig + area[i][j].rigrig + area[i][j].up + area[i][j].upup) % 100000;
		}
	}

	return;
}

int main(){
	fill_n(*area, 101 * 101, Free);
	area[1][1] = start;
	while(cin >> w >> h, w){
		solve();
		cout << area[w][h].score << endl;
	}

	return 0;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;cin>>s;
  for(int i=0;i<s.size();i++){
    if(i==5||i==13){
      cout<<' ';
    }
    else cout<<s[i];
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;



int main()
{
    int h,w;
    cin >> h >> w;
    int f[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> f[i][j];
        }
    }
    vector<string> v;
    for(int i = 0; i < h; i++){
        
        if(i % 2 == 0){
            for(int j = 0; j < w; j++){
                string s = "";
                if(f[i][j] % 2 == 1){
                    if(j != w-1){
                        s += to_string(i+1);
                        s += ' ';
                        s += to_string(j+1);
                        s += ' ';
                        s += to_string(i+1);
                        s += ' ';
                        s += to_string(j+2);
                        f[i][j]--;
                        f[i][j+1]++;
                        v.push_back(s);
                    }else if(i != h-1){
                        s += to_string(i+1);
                        s += ' ';
                        s += to_string(j+1);
                        s += ' ';
                        s += to_string(i+2);
                        s += ' ';
                        s += to_string(j+1);
                        f[i][j]--;
                        f[i+1][j]++;
                        v.push_back(s);
                    }
                    
                }
                
            }
        }else{
            for(int j = w-1; j >= 0; j--){
                string s = "";
                if(f[i][j] % 2 == 1){
                    if(j != 0){
                        s += to_string(i+1);
                        s += ' ';
                        s += to_string(j+1);
                        s += ' ';
                        s += to_string(i+1);
                        s += ' ';
                        s += to_string(j);
                        f[i][j]--;
                        f[i][j-1]++;
                        v.push_back(s);
                    }else if(i != h-1){
                        s += to_string(i+1);
                        s += ' ';
                        s += to_string(j+1);
                        s += ' ';
                        s += to_string(i+2);
                        s += ' ';
                        s += to_string(j+1); 
                        f[i][j]--;
                        f[i+1][j]++;
                        v.push_back(s);
                    }
                }
            }
        }
    }
    cout << v.size() << endl;
    for(int i = 0; i < v.size(); i++){
        cout << v[i] << endl;
    }
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long

using namespace std;

typedef pair<int, int> P;

int main(){
	ll N, T;
	ll min_c = 1001;
	cin >> N >> T;
	ll c, t;
	REP(i, N){
		cin >> c >> t;
		if (c<min_c && t<=T){
			min_c = c;
		}
	}
	if (min_c == 1001){cout << "TLE" << endl;}
	else {cout << min_c << endl;}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int k, n;

bool d(int mid) {
    if(mid * (mid + 1) / 2 >= k) return true;
    else return false;
}

signed main() {
    cin >> n;
    k = n;
    while(1) {
        // cout << k << endl;
        if(k <= 0) break;
        int ub = n+1, lb = 0;
        while(ub - lb > 1) {
            int mid = (ub + lb) / 2;
            if(d(mid)) ub = mid;
            else lb = mid;
        }
        cout << ub << endl;
        k -= ub;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

ll comb2(ll a) {
    ll ret = (a*(a-1))/2;
    return ret;
}

int main() {
    // input, ready
    int N;
    cin >> N;
    map<ll,ll> amap;
    vector<ll> A(N);
    for (int i=0; i<N; i++) {
        ll a;
        cin >> a;
        A[i] = a;
        amap[a]++;
    }

    // resolve
    ll default_total = 0;
    for (auto a: amap) {
        default_total += comb2(a.second);
    }

    // output
    for (int i=0; i<N; i++) {
        cout << default_total - (comb2(amap[A[i]]) - comb2(amap[A[i]]-1)) << endl;
    }

    return 0;
}


Measured memory_bytes: 12416
#include<iostream>
using namespace std;
int main()
{
	int b1,b2,b3;
	cin >> b1 >> b2 >> b3;
	if((b1==1 && b2==1) || (b3==1)){
		cout << "Open\n";
	}else{
		cout << "Close\n";
	}
	return 0;
}

Measured memory_bytes: 1124
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    if n<10:
        print(n)
    elif 10<=n<100:
        print(9)
    elif 100<=n<1000:
        print(9+n-100+1)
    elif 1000<=n<10000:
        print(909)
    elif 10000<=n<100000:
        print(909+n-10000+1)
    else:
        print(90909)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
from collections import deque


def topologicalSort(v,e):
    global color,out,indeg
    color=["white" for _ in range(v)]
    indeg=[[0,[]] for _ in range(v)]
    out=[]

    for i in range(e):
        s,t=map(int,input().split())
        indeg[s][0] +=1
        indeg[t][1] +=[s]

    for i in range(v):
        if indeg[i][0]==0 and color[i]=="white":
            BFS(i)

    return out[::-1]


def BFS(s):
    Q=deque([])
    Q.append(s)
    color[s]="gray"
    while len(Q)!=0:
        u=Q.popleft()
        out.append(u)

        for i in indeg[u][1]:
            indeg[i][0] -=1
            if indeg[i][0]==0 and color[i]=="white":
                color[i]="gray"
                Q.append(i)


v,e=map(int,input().split())
for i in topologicalSort(v,e):
    print(i)


Measured memory_bytes: 10028
# coding: utf-8
from collections import deque

n = int(input())

lw = [[] for _ in range(n+1)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    lw[u].append((v,w))
    lw[v].append((u,w))

#print(lw)

ans = [-1] * (n+1)
q = deque()
ans[1] = 0
q.append(1)
while q:
    r = q.popleft()
    prev = ans[r]
    
    for x in lw[r]:
        #print(x)
        y = x[0]
        if ans[y] >= 0:
            continue
        q.append(y)
        if x[1]%2==0:
            ans[y] = ans[r]
        else:
            ans[y] = 1 - ans[r]

for x in ans[1:]:
    print(x)


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

/*class Queen {
public:
	int Q[8][8], J[8][8];

	Queen() {
		for (int i = 0; i < 8; i++)	{
			for (int j = 0; j < 8; j++)	{
				Q[i][j] = 0; //???????????????
				J[i][j] = 0;			
			}
		}
	}

	void setQ(int x, int y) {
		Q[x][y] = 1;

		for (int i = 0; i < 8; i++)	{ //????????§????¶????????????§?????¨???????????§??????????????§??????
			J[i][y] = J[x][i] = 1;
			if ((x + i < 8 && y + i < 8) || (x + i >= 8 && y + i >= 8)) {
				J[(x + i) % 8][(y + i) % 8] = 1;
			}
			if ((x + i < 8 && y - i >= 0) || (x + i >= 8 && y - i < 0)) {
				J[(x + i) % 8][(y + 8 - i) % 8] = 1;
			}
		}
	}

	void search() {
		for (int i = 0; i < 8; i++)	{
			for (int j = 0; j < 8; j++)	{
				if (J[i][j] == 0) {
					setQ(i, j);
				}
			}
		}
	}

	void displayQ() {
		for (int i = 0; i < 8; i++)	{
			for (int j = 0; j < 8; j++)	{
				cout << (Q[i][j] ? 'Q' : '.');
			}
			cout << endl;
		}
	}

	void displayJ() {
		for (int i = 0; i < 8; i++)	{
			for (int j = 0; j < 8; j++)	{
				if (J[i][j]) cout << '*';
				else cout << '.';
			}
			cout << endl;
		}
	}

};*/

class Queen {
public:
	int Q[8][8], row[8], col[8], dpos[8 * 2 - 1], dneg[2 * 8 - 1]; //?\??????§??¨???

	 Queen() {
	 	for (int i = 0; i < 8; i++)	{
	 		for (int j = 0; j < 8; j++)	{
	 			Q[i][j] = 0;
	 		}
	 	}
		for (int i = 0; i < 8; i++)	{
			row[i] = 0; //?????????????????????
			col[i] = 0;
		}
		for (int i = 0; i < 2 * 8 - 1; i++)	{
			dpos[i] = 0;
			dneg[i] = 0;
		}
	}

	void recursive(int i) {
		if (i == 8) {
			displayQ();
			return;
		}

		for (int j = 0; j < 8; j++)	{ //???????????????
			if (col[j] || dpos[i + j] || dneg[i - j + 8 - 1]) { //i?????????j?????????????????£????????????continue
				continue;
			}
			row[i] = j; //row???Q?????????????¨????
			col[j] = dpos[i + j] = dneg[ i - j + 8 - 1] = 1; //row??\???????\?????????±????¨????
			recursive(i + 1);
			row[i] = col[j] = dpos[i + j] = dneg[ i - j + 8 - 1] = 0; //??¨??¨continue????????????????????????????????????
		}
	}

	void setQ(int x, int y) {
		Q[x][y] = 1;
	}

	void displayQ() {
		for (int i = 0; i < 8; i++)	{
			for (int j = 0; j < 8; j++)	{
				if (Q[i][j] && row[i] != j) return; //i == N??§??? 
			}
		}

		for (int i = 0; i < 8; i++)	{
			for (int j = 0; j < 8; j++)	{
				cout << ((row[i] == j) ? 'Q' : '.');
			}
			cout << endl;
		}
	}
};

int main() {
	int k;
	cin >> k;
	Queen q = Queen();
	int x, y;
	for (int i = 0; i < k; i++) {
		cin >> x >> y;
		q.setQ(x, y);
	}
	
	q.recursive(0);

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n=100000;
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for (int p=2; p*p<=n; p++)
        if (prime[p] == true)
            for (int i=p*2; i<=n; i += p)
                prime[i] = false;
    int c[100001];
    memset(c,0,sizeof(c));
    for(int i=3;i<=100000;i++)
        if(i%2==1 && prime[i] && prime[(i+1)/2])
            c[i]++;
    for(int i=3;i<=100000;i++)
        c[i]=c[i]+c[i-1];
 
    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;
        cout<<c[b]-c[a-1]<<endl;
    }
 
}

Measured memory_bytes: 1152
A,B,C,X,Y=map(int,input().split())
if A+B > 2*C:
  cost = 2*C*min(X,Y)
  if X >= Y and A < 2*C:
      cost += A*(X-Y)
  elif X >= Y:
      cost += 2*C*(X-Y)
  elif Y >= X and B < 2*C:
      cost += B*(Y-X)
  else:
      cost += 2*C*(Y-X)
else:
  cost = A*X+B*Y
print(cost)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
ll n;
const ll N = 100000+10;
ll num[3][N];
ll dp[3][N];

ll q(ll x, ll y){
    if(dp[x][y]!=-1) return dp[x][y];

    dp[x][y] = -LINF;

    for(ll i=0;i<3;i++){
        if(i!=x){
            ll tmp = q(i,y-1) + num[x][y];
            dp[x][y] = max(dp[x][y],tmp);
        }
    }

    return dp[x][y];
}

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

    cin >> n;

    REP(i,n){
        REP(j,3){
            cin >> num[j][i];
        }
    }

    REP(i,3){
        REP(j,N){
            dp[i][j] = -1;
        }
    }
    dp[0][0] = num[0][0];
    dp[1][0] = num[1][0];
    dp[2][0] = num[2][0];

    cout << max({q(0,n-1),q(1,n-1),q(2,n-1)}) << endl;

    
    return 0;
}



Measured memory_bytes: 14536
N = int(input())
alpha = "abcdefghijklmnopqrstuvwxyz"
al = [26 for _ in range(50)]
for i in range(49):
    al[i+1] = 26 * al[i]
for i in range(49):
    al[i+1] += al[i]
bl = [1 for _ in range(50)]
for i in range(49):
    bl[i+1] = 26 * bl[i]
def f(n):
    if 0 <= n and n <= 25:
        return alpha[n]
    cnt = 1
    while al[cnt-1] <= n:
        cnt += 1
    nn = n - al[cnt-2]
    s = ""
    for i in range(cnt):
        s = alpha[nn % 26] + s[:]
        nn //= 26
    return s
    
print(f(N-1))

Measured memory_bytes: 62024
#include <iostream>
#include <queue>

#include <cstdio>
#include <cstring>

#define REP(i, n) for(typeof(n) i = 0; i < (n); ++i)

using namespace std;

const int offset = 100;

int memo[200][200];

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

int main(){
  int t, n;

  while(scanf("%d%d", &t, &n), t + n){
    int sx, sy;
    int ans = 1;
    queue<pair<int, int> > q;

    REP(i, 200) REP(j, 200) memo[i][j] = -1;

    REP(i, n){
      int x, y;
      scanf("%d%d", &x, &y);
      memo[y + offset][x + offset] = 0;
    }

    scanf("%d%d", &sx, &sy);

    q.push(make_pair(sx, sy));
    memo[sy + offset][sx + offset] = 0;

    while(q.size()){
      int x = q.front().first;
      int y = q.front().second;
      int turn = memo[y + offset][x + offset];

      q.pop();

      if(turn == t) continue;

      REP(i, 6){
        int xx = x + dx[i];
        int yy = y + dy[i];

        if(memo[yy + offset][xx + offset] == -1){
          memo[yy + offset][xx + offset] = turn + 1;
          q.push(make_pair(xx, yy));
          ans++;
        }
      }
    }

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

  return 0;
}

Measured memory_bytes: 0
import math
a, b, h, m = map(int, input().split())
a_kakudo = math.degrees(math.pi)*2/12 * h
a_kakudo = a_kakudo + math.degrees(math.pi/6)/60 * m
b_kakudo = math.degrees(math.pi)*2/60 * m
mx = max(a_kakudo, b_kakudo)
mn = min(a_kakudo, b_kakudo)
cc = a*a + b*b - 2*a*b*math.cos(math.radians(mx-mn))
print(math.sqrt(cc))

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(100);
  for(int i = 0; i < H; i++)
    cin >> a.at(i);
  for(int i = -1; i <= H; i++) {
    for(int j = -1; j <= W; j++) {
      if(i == -1) cout << '#';
      else if((j == -1) || (j == W)) cout << '#';
      else if(i == H) cout << '#';
      else cout << a.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N, A;
ll x[60];
ll d[60][60][3000];

int main () {
  cin >> N >> A;
  rep(i, N) cin >> x[i];

  Rep(i, N+1) {
    d[i][0][0] = 1;
  }

  rep(i, N) {
    rep(j, N) {
      Rep(k, N * 50 + 1) {
        d[i][j][k + x[i]] += d[i-1][j-1][k];
      }
    }

    rep(j, N) {
      Rep(k, N * 50 + 1) {
        d[i][j][k] += d[i-1][j][k];
      }
    }
  }

  ll ans = 0;

  rep(i, N) {
    ans += d[N][i][i * A];
  }

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

Measured memory_bytes: 70528
#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 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>;

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

ll lcm(ll x, ll y) {
    return x / gcd(x,y) * y;
}

int main(void)
{
    IOS
    ll n, m;
    cin >> n >> m;

    ll ans = 1;
    if (n == 1) ans = m;
    else {
        ll d = min(m/n,gcd(m,n));
        while(d*n <= m) {
            if (m % d == 0 && m / d >= n) {
                ans = d;
            }
            d++;
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}

int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(a%500<=b)printf("Yes\n");else printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

long long int N, A[100010] = {}, B[100010] = {}, C[100001] = {}, B2[100001] = {}, C2[100001] = {}, num = 1, ans = 0, num2 = 1;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++)cin >> A[i];
	stable_sort(A, A + N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> B[i];
	}
	stable_sort(B, B + N + 1);
	for (int i = 1; i <= N; i++) {
		B2[i] = B2[i - 1];
		for (int j = num; A[j] < B[i]; j++) {
			if (j > N)break;
			B2[i]++;
		}
		num = B2[i] + 1;
	}
	num = 1;
	for (int i = 1; i <= N; i++) {
		cin >> C[i];
	}
	stable_sort(C, C + N + 1);
	for (int i = 1; i <= N; i++) {
		C2[i] = C2[i - 1];
		num2 = num - 1;
		for (int j = num; B[j] < C[i]; j++) {
			if (j > N)break;
			C2[i] += B2[j];
			num2 = j;
		}
		num = num2 + 1;
		ans += C2[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4600
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	vector<int> v1;
	int n, i, v;
	cin >> n;
	while (n--) {
		cin >> v;
		v1.push_back(v);
	}
	vector<int> v2 = v1;
	sort(v2.begin(), v2.end());
	int c1 = 0;
	for (i = 0; i < v1.size(); i++) {
		if (v1[i] != v2[i]) c1++;
	}
	if (c1 <= 2) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)
int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);
    rep(i,0,n){
        int a, b;
        cin >> a >> b;
        if(m < a) continue;
        jobs[a-1].push_back(b);
    }
    priority_queue<int> q;
    ll ans = 0;
    rep(i,0,m) {
        for(int j: jobs[i]){
            q.push(j);
        }
        if(q.empty()) continue;
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	string s1;
	cin >> s1;

	char a = s1[0];
	char b = s1[1];
	char c = s1[2];

	if (a == '7' || b == '7' || c == '7') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;

	}
}

Measured memory_bytes: 3624
def ave_ten(T,x):
    return T - x*0.006

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

min_ten = 9999999999

for i in range(len(li)):
    if abs(min_ten - A) > abs(ave_ten(T,li[i])-A):
        min_ten = ave_ten(T,li[i])
        min_in = i+1

print(min_in)

Measured memory_bytes: 9212
#include <iostream>

int main()
{
	int a, b;
	std::string s;
	std::cin >> a >> b >> s;
	
	if (s[a] != '-') {
		std::cout << "No" << std::endl;
		return 0;
	}
	s.erase(s.begin() + a);
	for (char c : s) {
		if (c < '0' || c > '9') {
			std::cout << "No" << std::endl;
			return 0;
		}
	}
	
	std::cout << "Yes" << std::endl;
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

int main(){
	ll n, ans;
	double t, h, a, min=INF;
	cin >> n >> t >> a;
	
	REP(i,n){
		cin >> h;
		// debug((t-h*0.006));
		if (min>abs(a-(t-h*0.006))){
			ans = i+1;
			// debug(ans);
			min = abs(a-(t-h*0.006));
		}
	}
	
	cout << ans << endl;
	
	return 0;
	
}


Measured memory_bytes: 256