akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,K;cin>>N>>K;
  vector<int> vec(N);
  for (int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int S=0;
  for (int j=0;j<K;j++){
    S = S + vec.at(j);
  }
  cout<<S<<endl;
    
}

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

int main() {
	char c;
	cin >> c;
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
	{
		cout << "vowel" << endl;
	}
	else
	{
		cout << "consonant" << endl;
	}

}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int dx = int.Parse(s[2]) - int.Parse(s[0]);
        int dy = int.Parse(s[3]) - int.Parse(s[1]);

        String path = new string('U', dy) + new string('R', dx)
                    + new string('D', dy) + new string('L', dx)
                    + 'L' + new string('U', dy + 1) + new string('R', dx + 1) + 'D'
                    + 'R' + new string('D', dy + 1) + new string('L', dx + 1) + 'U';
        Console.WriteLine(path);
    }
}

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

int main(){
  string w;
  cin >> w;
  sort(w.begin(), w.end());
  char pre=' ';
  int count = 0;
  for(auto& c : w){
    if(c==pre){
      count++;
    }else{
      if(count%2==1){
        cout << "No" << endl;
        return 0;
      }else{
        pre = c;
        count = 1;
      }
    }
  }
  cout << (count%2==1 ? "No" : "Yes") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for(int &b: B) cin >> b;
  int r=0;
  for(int i=0; i<N; i++){
    int s=C;
    for(int b: B){
      int a;
      cin >> a;
      s+=a*b;
    }
    if(s>0) r++;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define lengthof(array) (sizeof(array) / sizeof(*array))
#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)

template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

int ans;
vector<int> power;
vector<vector<int> > adj;

void dfs(char country, long long ng, int sum) {
	if(country == power.size()) {
		chmax(ans, sum);
		return;
	}

	if(ng & (1ll << country)) {
		dfs(country + 1, ng, sum);
		return;
	}

	if(adj[country].size() == 0) {
		dfs(country + 1, ng, sum + power[country]);
		return;
	}

	int mx = sum;
	for(int i = country; i < power.size(); ++i)
		if((ng & (1ll << i)) == 0)
			mx += power[i];

	if(mx <= ans)
		return;

	dfs(country + 1, ng, sum);

	for(int i = 0; i < adj[country].size(); ++i)
		ng |= (1ll << adj[country][i]);

	dfs(country + 1, ng, sum + power[country]);
}

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

	for(int n = 0; cin >> n, n;) {
		map<string, int> convert;
		vector<vector<string> > d(n);
		power.clear();
		power.resize(n);

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

			convert[a] = i;

			d[i].resize(c);
			for(int j = 0; j < c; ++j)
				cin >> d[i][j];
		}

		adj.clear();
		adj.resize(n);
		for(int i = 0; i < n; ++i)
			for(int j = 0; j < d[i].size(); ++j)
				if(i < convert[d[i][j]])
					adj[i].push_back(convert[d[i][j]]);

		long long ng = 0;
		for(int i = 0; i < adj[0].size(); ++i)
			ng |= (1ll << adj[0][i]);

		ans = power[0];
		dfs(1, ng, power[0]);
		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

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

int main() {
	int n;
	string s;
	cin >> n ;
	cin >> s;
	if(n%2==1){
		cout << "No" << endl;
		return 0;
	}
	int o=n/2;
	if(s.substr(0,o)==s.substr(o,o)){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    string s; cin >> s;

    int ans = 0;
    int g_cnt = 0;
    int p_cnt = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (i == 0) {
            g_cnt++;
            if (s[i] == 'p') ans--;
        } else {
            if (s[i] == 'g') {
                if (p_cnt < g_cnt) {
                    p_cnt++;
                    ans++;
                } else {
                    g_cnt++;
                }
            } else {
                if (p_cnt < g_cnt) {
                    p_cnt++;
                } else {
                    g_cnt++;
                    ans--;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int N;
ll A,B;
int p[5010],where[5010];
ll dp[5010][5010];
const ll inf = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	cin >> N >> A >> B;
	rep(i,N) cin >> p[i],p[i]--,where[p[i]] = i;

	rep(i,N+1) rep(j,N+1) dp[i][j] = inf;

	dp[0][0] = 0;
	rep(i,N){
		rep(j,N+1) if(dp[i][j] != inf){
			if(j != N){
				chmin(dp[i][j+1],dp[i][j]);
			}
			if(p[i] == j){
				chmin(dp[i+1][j+1],dp[i][j]);
			}
			if(p[i] < j){
				chmin(dp[i+1][j],dp[i][j] + B);
			}
			if(p[i] > j){
				chmin(dp[i+1][j],dp[i][j] + A);
			}
		}
	}
	ll ans = inf;
	rep(j,N+1) chmin(ans,dp[N][j]);
	cout << ans << endl;
}


Measured memory_bytes: 196096
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    // Your code here!
    double a;
    int b=0;
    cin>>a;
    for(int z=0;z<a;z++){
        if(z%2==0){
            b++;
        }
    }
    cout<<fixed<<setprecision(10)<<b/a<<endl;
}

Measured memory_bytes: 3776
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String[] str = new String[3];
    int[] len = new int[3];
    
    for(int i = 0; i < 3; i++){
      str[i] = scan.next();
      len[i] = str[i].length();
    }
    
    int a, b, c;
    char work;
    
    a = 0;
    b = 0;
    c = 0;
    
    work = str[0].charAt(0);
    len[0]--;
    a++;
    
    while(true){
      if(work == 'a'){
        if(len[0] == 0){
          System.out.println("A");
          return;
        }
        work = str[0].charAt(a);
    	len[0]--;
    	a++;
      }
      else if(work == 'b'){
        if(len[1] == 0){
          System.out.println("B");
          return;
        }
        work = str[1].charAt(b);
    	len[1]--;
    	b++;
      }
      else{
        if(len[2] == 0){
          System.out.println("C");
          return;
        }
        work = str[2].charAt(c);
    	len[2]--;
    	c++;
      }
    }
  }

}

Measured memory_bytes: 20948
import java.util.*;

public class Main {

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

        long judge = N % 10;

        if (judge == 2 || judge == 4 || judge == 5 || judge == 7 || judge == 9) {
            System.out.println("hon");
        } else if (judge == 0 || judge == 1 || judge == 6 || judge == 8) {
            System.out.println("pon");
        } else {
            System.out.println("bon");
        }

    }
}


Measured memory_bytes: 35664
n = gets.chomp.to_i
pp = gets.chomp.split.map(&:to_i)
qq = gets.chomp.split.map(&:to_i)

i = 0
a = nil
b = nil


(1..n).to_a.permutation(n) do |val|
  a = i if val == pp
  b = i if val == qq
  i += 1
end
p (a - b).abs

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

using namespace std;
int n,sum,x;
int A[200];
long long s;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d",A+i);sum+=A[i];
    }
    x=round((sum*1.0)/(n*1.0));
    for(int i=0;i<n;++i){
        s+=int(abs(x-A[i]))*int(abs(x-A[i]));
    }
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
int main(){
	int n,m;
	int a[50],b[50],c[50],d[50];
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++) scanf("%d %d",a+i,b+i);
	for(int i=0;i<m;i++) scanf("%d %d",c+i,d+i);
	for(int i=0;i<n;i++){
		int ans,mi;
		for(int j=0;j<m;j++){
			int dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
			if(j==0||dist<mi){
				mi = dist;
				ans = j + 1;
			}
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long LL;
using namespace std;
LL dp[50][(1<<17)]; // how many of the first k can make exactly the sequences in the dp (and can't make xyz)
int n, x, y, z;
int main(){
	//1, 2, ... x = 0,1,2,.. x-1
	//x1, x2, ... xy = 5,6,7,8,9,10,11
	//xy, ... xyz =  (sum - 1)
	cin >> n >> x >> y >> z;
	for(int i = 0; i < 50; i++){
		for(int j = 0; j < (1<<17); j++){
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < (1<<(x+y+z-1)); j++){
			for(int r = 1; r <= 10; r++){
				int b = 0;
				if(r <= x) b |= (1 << (r-1));
				if(r <= 7){
					for(int c = 0; c < (x+y+z-1); c++){
						if((j >> c) % 2 == 1){
							if(c < x-1){
								if((c+1+r) <= x){
									b |= (1 << (c + r));
								}
							} else if(c < x+y-1){
								if((c+1+r) <= x + y){
									b |= (1 << (c + r));
								}
							} else if(c < x+y+z-1){
								if((c+1+r) <= x + y + z){
									b |= (1 << (c + r));
								}
							}
						}
					}

				}
				dp[i+1][b] += dp[i][j];
				dp[i+1][b] %= MOD;
			}
		}
	}
	LL r = 1;
	for(int i = 0; i < n; i++) r = (10*r) % MOD;
	LL ans = 0;
	for(int j = 0; j < (1<<(x+y+z-1)); j++){
		ans = (ans + dp[n][j]) % MOD;
	}
	cout << (MOD + r - ans + MOD) % MOD << endl;

}

Measured memory_bytes: 51456
def examB():
    N = I()
    M = (N-1)**2//2
    ans = []
    for i in range(1,N+1):
        if N%2==0:
            for j in range(i+1,N+1):
                if i+j!=N+1:
                    ans.append([i,j])
        else:
            for j in range(i+1,N):
                if i+j!=N:
                    ans.append([i,j])
            if i!=N:
                ans.append([i,N])
    print(M)
    for v in ans:
        print(" ".join(map(str,v)))

from string import digits
import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int h, w, k;
vector<pair<int, int>> a;
int ans[305][305];
bool yes[305];
void solve() {

    cin >> h >> w >> k;
    rep(i, h) rep(j, w) ans[i][j] = -1;

    rep(i, h) rep(j, w) {
        char c; cin >> c;
        if (c == '#') {
            ans[i][j] = sz(a);
            yes[i] = true;
            a.emplace_back(i, j);
        }
    }

    rep(i, k) {
        auto x = a[i].first, y = a[i].second;
        int l = y, r = y;

        for (int j = y - 1; j >= 0; --j) {
            if (ans[x][j] != -1) break;
            l = j;
            ans[x][j] = i;
        }

        for (int j = y + 1; j < w; ++j) {
            if (ans[x][j] != -1) break;
            r = j;
            ans[x][j] = i;
        }

        ans[x][y] = i;
        for (int j = x - 1; j >= 0; --j) {
            if (yes[j]) break;
            for (int k = l; k <= r; ++k) ans[j][k] = i;
        }

        for (int j = x + 1; j < h; ++j) {
            if (yes[j]) break;
            for (int k = l; k <= r; ++k) ans[j][k] = i;
        }

    }

    rep(i, h) {
        rep(j, w) cout << ans[i][j] + 1 << " ";
        cout << endn;
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
//#include <set>
//#include <map>
//#include <ctime>
//#include <cmath>
//#include <utility>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define ii InputInteger( );
#define f for(int i=0; i<n; i++)
int InputInteger( ){ int x; cin >> x; return x; }
const int Inf = 2147483647;
const char e = '\n';

void iv( vi& p ){ for( int& x: p ) cin >> x; }
void sa( vi& p ){ sort( p.begin(), p.end() ); }
void sd( vi& p ){ sort( p.begin(), p.end(), [](int a, int b){ return a > b; } ); }
void pv( const vi& p ){ for( int x: p ) cout << x << ' '; cout << e; }

int main()
{
	ios_base::sync_with_stdio( false );
	//cin.tie( nullptr );
	int  n;
	while( cin >> n )
	{
	    int x = ii;
	    vector <int> a(n);
	    iv(a);
	    int sum = 0, bounce = 1;
	    int i;
	    for(i=0; sum < x && i<n; i++)
        {
            sum += a[i];
            bounce++;
        }
        if(sum > x) cout << bounce - 1;
        else
            cout << bounce;
        cout << e;
	}
	return 0;
}

// Kafe's Grandmaster Template 14th




Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;

    for(int i=0; ; ++i){
        bool ok = true;
        for(int j=0; j<n-i; ++j){
            if(s[j+i] != t[j])
                ok = false;
        }
        if(ok){
            int ans = n + i;
            cout << ans << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
s=input()
n=len(s)
ans=0
g_cnt=0
p_cnt=0
for i in range(n):
    # 判定
    if g_cnt>p_cnt:
        # パーを出す
        p_cnt+=1
        if s[i]=='g':
            ans+=1
    else:
        g_cnt+=1
        if s[i]=='p':
            ans-=1
print(ans)



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

using namespace std;

int main(){
    int N, Q;

    cin >> N >> Q;

    set<pair<int, int>> a2b, b2a;

    for(int i = 0; i < N - 1; i ++){
        int a, b;

        cin >> a >> b;

        a2b.insert(make_pair(a, b));
        b2a.insert(make_pair(b, a));
    }
    vector<int> ans(N, 0);

    for(int i = 0; i < Q; i ++){
        int p, x;

        cin >> p >> x;

        ans[p - 1] += x;
    }
    queue<pair<int, int>> next;

    next.push(make_pair(1, 0));

    while(! next.empty()){
        int root = next.front().first;
        int add_count = next.front().second;

        ans[root - 1] += add_count;

        for(auto it = a2b.lower_bound(make_pair(root, 1)); it != a2b.upper_bound(make_pair(root, N)); it ++){
            int child = (*it).second;

            next.push(make_pair(child, ans[root - 1]));
            b2a.erase(make_pair(child, root));
        }
        for(auto it = b2a.lower_bound(make_pair(root, 1)); it != b2a.upper_bound(make_pair(root, N)); it ++){
            int child = (*it).second;

            next.push(make_pair(child, ans[root - 1]));
            a2b.erase(make_pair(child, root));
        }
        next.pop();
    }
    for(int i = 0; i < N; i ++){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 23424
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi
#define se second
 
#define forz(i,n) for(long long int i=0;i<n;i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0) 
 
using namespace std;

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

	lli  q , count = 0;
	cin >>q;
	forz(i, q)
	{
		 lli t, num;
		 char c; 
		 cin >> t;
		 if (t==1)
		 {
		 	count++;
		 }
		 if (t == 2)
		 {
		 	cin >> num;
		 	cin >> c;
		 	if ((num ==1 && (count % 2) == 1) || (num ==2 && (count % 2) == 0))
		 	{
		 		s.pb(c);
		 	}
		 	else if((num ==2 && (count % 2) == 1) || (num ==1 && (count % 2) == 0))
		 	{
		 		s.insert(s.begin(), 1, c);
		 	}
		 }
	} 
	if ((count % 2) == 1)
	{
		reverse(s.begin(), s.end());
		cout << s << endl;
	}
	else
	{
	cout << s << endl;
	}
	// p1 = a/ 0.08;
	// p2 = b/ 0.1;
	// if (floor(p2*0.08) == a && floor(p1*0.1) == b)
	// {
	// 	cout << min(p1 , p2)<< endl;
	// }
	// else if (floor(p2*0.08) == a)
	// {
	// 	cout << p2<< endl;
	// }
	// else if(floor(p1*0.1) == b)
	// {
	// 	cout << p1 << endl;
	// }
	// else
	// {
	// 	cout << "-1" << endl;
	// }
	return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N, X;
    cin >> N >> X;
    int L[N];
    REP(i, N) cin >> L[i];
    int c = 0;
    int cur = 0;
    REP(i, N) {
        if (cur > X) break;
        cur += L[c];
        c++;
    }
    if (c == N) {
        if (cur <= X) c++;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
  	int n;
  	cin >> n;
  	string s[n];
  	int p[n];
  	int a[n];
  	for(int i =0 ; i < n; i++){
      cin >> s[i] >> p[i];
      a[i] = i;
    }
  	for(int i = 0; i < n - 1; i++){
      	for(int j = i + 1; j < n; j++){
          	int k = a[i];
          	int l = a[j];
          	if(s[k] > s[l]){
              a[i] = l;
              a[j] = k;
            }
          	if(s[k] == s[l] && p[k] < p[l]){
			  a[i] = l;
              a[j] = k;
            }	
        }
    }
  	for(int i = 0 ; i < n - 1 ;i++){
      cout << a[i] + 1 << endl;
    }
  	cout << a[n - 1] + 1;
  return 0;
       		
}

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

int N;
int s[100];
int main() {
	cin >> N;
	int answer = 0;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
		answer += s[i];
	}
	sort(s, s + N);
	for (int i = 0; i < N && answer % 10 == 0; i++) {
		if (s[i] % 10 != 0) {
			answer -= s[i];
			break;
		}
		if (i == N - 1) answer = 0;
	}
	cout << answer << endl;
}

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

using namespace std;

int main()
{
	int sq[10000];
	for(int n=1;n<10000;n++)	sq[n]=n*n;

	int n;
	while(scanf("%d",&n),n){
		vector<int> mod;
		for(int i=1;i<n;i++)	mod.push_back(sq[i]%n);
		sort(mod.begin(),mod.end());
		mod.erase(unique(mod.begin(),mod.end()),mod.end());

		int cnt[5000]={0};
		for(int i=0;i<mod.size();i++){
			for(int j=0;j<i;j++){
				int dif=mod[i]-mod[j];
				if     (dif<0)			dif+=n;
				else if(dif>(n-1)/2)	dif=n-dif;
				cnt[dif]++;
			}
		}

		for(int i=1;i<=(n-1)/2;i++)	printf("%d\n",2*cnt[i]);
	}

	return 0;
}

Measured memory_bytes: 976
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());

		int t = A / D;
		if (A % D != 0) {
			t++;
		}
		int a = C / B;
		if (C % B != 0) {
			a++;
		}
		if (a - 1 < t) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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



int main() {
    int s;
    vector<int> a;
    int ans = -1;
    int c;
    bool is_exist = false;
    
    cin >> s;
    a.push_back(s);
    c = s;
    
    while (true) {
        c = (((c % 2) == 0) ? (c / 2) : (3 * c + 1));
        
        /*for (int i = 0; i < a.size(); i++) {
            cout << ((i == 0) ? "a=" : ", ") << a[i] << ((i == (a.size() - 1)) ? "\n" : "");
        }*/
        
        for (int i = 0; i < a.size(); i++) {
            if (a[i] == c) {
                is_exist = true;
                break;
            }
        }
        
        if (is_exist) {
            ans = a.size() + 1;
            break;
        }
        
        a.push_back(c);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

nn = n // 26
amari = n % 26

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
        
ans = num2alpha(n)

print(ans.lower())

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

#define ll long long
#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()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    sort(all(a));
    int num = 0;
    int locate = a[0];
    int cnt=1;
    rep(i,1,n){
        if(locate==a[i]) cnt++;
        else{
            if(cnt%2==1) num++;
            cnt=1;
        }
        locate = a[i];
    }
    if(cnt%2==1) num++;
    cout << num << endl;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in range(n-m+1):
    for j in range(n-m+1):
        tmp = []
        for k in a[i:i+m]:
            tmp.append(k[j:j+m])
        if tmp == b:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 39280
<?php
fscanf(STDIN, '%d %d %d', $n, $a, $b);
$sum = 0;
for($i=1; $i<=$n; $i++){
    $total = 0;
    $ii = $i;
    while($ii){
        $total += $ii%10;
        $ii = intdiv($ii, 10);
    }
    if($a<=$total && $total<=$b){
        $sum += $i;
    }
}
print $sum;

Measured memory_bytes: 4604
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 13, 2020 23:02:56 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from collections import defaultdict
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  S = [input()[:-1] for _ in range(N)]

  dic = defaultdict(int)

  for i in range(N):
    dic[''.join(sorted(S[i]))] += 1

  ans = 0
  for n in dic.values():
    ans += int(n*(n-1)/2)
  print(ans)


if(__name__ == '__main__'):
  main()


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

using namespace std;
using pii = pair<int, int>;
using ppii = pair<int, pii>;

int n;
vector<pair<int, pii>> a;
vector<pii> edge[100010];

bool less_x(ppii s, ppii t) {
  return s.second.first < t.second.first;
}

bool less_y(ppii s, ppii t) {
  return s.second.second < t.second.second;
}

long long prim() {
  priority_queue<pii, vector<pii>, greater<pii>> q;
  vector<bool> visited(n, false);
  q.push(make_pair(0, 0));
  long long ans = 0;
  while (!q.empty()) {
    auto p = q.top();
    q.pop();
    int cost = p.first, u = p.second;
    if (visited[u]) {
      continue;
    }
    visited[u] = true;
    ans += cost;
    for (auto e: edge[u]) {
      int v = e.first, c = e.second;
      if (visited[v]) {
        continue;
      }
      q.push(make_pair(c, v));
    }
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  a = vector<ppii>(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a[i] = make_pair(i, make_pair(x, y));
  }
  sort(a.begin(), a.end(), less_x);
  auto p0 = a[0];
  for (int i = 1; i < n; i++) {
    auto p1 = a[i];
    int cost = abs(p0.second.first - p1.second.first);
    edge[p0.first].push_back(make_pair(p1.first, cost));
    edge[p1.first].push_back(make_pair(p0.first, cost));
    p0 = p1;
  }
  sort(a.begin(), a.end(), less_y);
  p0 = a[0];
  for (int i = 1; i < n; i++) {
    auto p1 = a[i];
    int cost = abs(p0.second.second - p1.second.second);
    edge[p0.first].push_back(make_pair(p1.first, cost));
    edge[p1.first].push_back(make_pair(p0.first, cost));
    p0 = p1;
  }
  cout << prim() << endl;
  return 0;
}

Measured memory_bytes: 10620
def main():
    n = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))

    ans = 0
    for i in range(n):
        diff = V[i]-C[i]
        if diff > 0:
            ans += diff
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main()
{
	string s;
	int sum;

	while(cin >> s)
	{
		if (s == "0") break;
		sum = 0;
		for(string::size_type i = 0; i < s.size(); ++i)
			sum += s[i] - '0';
		cout << sum << endl;
	}

	return 0;
}

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

#define rep(i,n) for( (i)=0;(i)<(n);++(i) )
#define repr(i,n) for( (i)=(n);(i)>0;==(i) )
#define FOR(i,j,n) for( (i)=(j);(i)<(n);++(i) )
#define forr(i,j,n) for( (i)=(j);(i)>(n);--(i) )
#define debg(a) cout<<(a)<<endl;
#define INF 9999999
#define Int long long 

int i,j,k;
int dx,dy;
int a,b,c;
string s,t;

int main(){ 
  int h,w;
  cin>>h>>w;
  string c[h];
  rep(i,h){
    cin>>c[i];
    cout<<c[i]<<"\n"<<c[i]<<endl;
  }
  
  


  return 0;
}


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

using namespace std;

int cnt;
int n[110];

void p() {
    for(int i = 0; i < cnt; i++) {
        if(i != 0) cout << " ";
        cout << n[i];
    }
    cout << endl;
}
int main() {
    cin >> cnt;
    for(int i =0; i < cnt; i++) cin >> n[i];
    p();
    for(int i = 1; i < cnt; i++) {
        int l = i - 1;
        int value = n[i];
        while(l >= 0 && n[l] > value) {
            n[l+1] = n[l];
            l--;
        }
        n[l+1] = value;
        p();
    }
}


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
 
int main(){
  char w[10], t[1000], c = 0, i;
  scanf("%s", w);
  while(scanf("%s", t) && strcmp(t, "END_OF_TEXT") != 0){
    for(i = 0;i < strlen(t);i++) t[i] = 'A' <= t[i] && 'Z' >= t[i] ? t[i] - 'A' + 'a' : t[i];
    if(strcmp(t, w) == 0) c++;
  }
  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 2040
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char s[15];
	while(cin>>s){
		int n=strlen(s),f=1,count=0,k;
		if(s[0]!='A') f=0;
		if(s[1]=='C' || s[n-1]=='C') f=0;
		for(int i=1;i<n;i++)
			if(s[i]<'a'){
				k=i;count++;
			} 
		if(f==1&&count==1&&s[k]=='C') cout<<"AC"<<endl;
		else cout<<"WA"<<endl;
	}	
	return 0;
}

Measured memory_bytes: 256
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]

a,b,x = mint()
if 2*x>a*a*b:
    h = 2*(a*a*b-x)/(a*a)
    print(degrees(atan(h/a)))
else:
    h = 2*x/(a*b)
    print(degrees(atan(b/h)))

Measured memory_bytes: 69500
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	std::vector<std::vector<int>> res;
	in >> N;
	int32_t k = 1;
	for (; k*(k-1) < 2*N; k++){}
	if (k*(k - 1) != 2*N) {
		out << "No" << endl;
		return 0;
	}

	out << "Yes" << endl;
	for (int32_t i = k; i > 0; --i)
	{
		std::vector<int> tmp;
		int step = k-2;
		int pos = k-1 - i;
		while (step >= i-1)
		{
			tmp.push_back(pos);
			pos += step;
			--step;
		}
		++pos;
		while (tmp.size() < k - 1) {
			tmp.push_back(pos);
			++pos;
		}
		res.emplace_back(std::move(tmp));
	}
	out << res.size() << endl;
	for (auto& i : res) {
		out << i.size();
		for (auto& j : i)
		{
			out << ' ' << j+1;
		}
		out << '\n';
	}

	return 0;
}
#endif


Measured memory_bytes: 2304
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

const int INF = 1 << 30;
int rec(const int id, map<int, int>& goods, const vector<vint>& table)
{
	int sum = INF;

	if(!table[id].empty())
	{
		sum = 0;
		rep(i, table[id].size())
			sum += rec(table[id][i], goods, table);
	}

	return min(goods[id], sum);
}

int main()
{
	int n;
	while(cin >> n && n)
	{
		map<string, int> namecon;
		map<int, int>    goods;
		vector<vint> d(n, vint(n));

		rep(i, n)
		{
			string name;
			int cost;

			cin >> name >> cost;

			namecon.insert(map<string, int>::value_type(name, i));
			goods.insert(map<int, int>::value_type(i, cost));
		}

		int m;
		cin >> m;
		vector<vint> table(n);

		rep(i, m)
		{
			int num;
			string name;
			cin >> name >> num;

			rep(j, num)
			{
				string mat;
				cin >> mat;
				table[namecon[name]].push_back(namecon[mat]);
			}
		}

		string item;
		cin >> item;

		cout << rec(namecon[item], goods, table) << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

int H,W;
ll d[81][81];

bool dp[81][81][13000];

int main(){
    cin>>H>>W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ll x; cin>>x;
            d[i][j]+=x;
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ll x; cin>>x;
            d[i][j]-=x;
            if(d[i][j]<0) d[i][j]*=(-1);
        }
    }
    dp[0][0][d[0][0]]=true;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            for(int k=0;k<13000;k++){
                if(dp[i][j][k]){
                    if(i<H-1){
                        dp[i+1][j][k+d[i+1][j]]=true;
                        dp[i+1][j][abs(k-d[i+1][j])]=true;
                    }
                    if(j<W-1){
                        dp[i][j+1][k+d[i][j+1]]=true;
                        dp[i][j+1][abs(k-d[i][j+1])]=true;
                    }
                }
            }
        }
    }

    ll ans=BIG;
    for(int i=0;i<13000;i++){
        if(dp[H-1][W-1][i]) {ans=i; break;}
    }

    cout<<ans<<endl;



}

Measured memory_bytes: 81664
n=int(input())
c=list(input())
l,r=0,n-1
ans=0
while l<r:
    while c[l]!='W':
        l+=1
        if l>n-1:
            break
    while c[r]!='R':
        r-=1
        if r<0:
            break
    if l<r:
        ans+=1
        l+=1
        r-=1
print(ans)

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

int main() {
	int n,p[51],q[51],count=0;
	cin>>n; for(int i=0;i<n;i++){
		cin>>p[i];
		q[i]=p[i];
	}
	sort(q,q+n);
	for(int i=0;i<n;i++){
		if(p[i]!=q[i]) count++;
	}
	if(count==0 || count==2) cout<<"YES";
	else cout<<"NO";
	return 0;
}

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


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

	string s;
	int n;

	cin >> s;

	n = s.length();

	int res = 0;

	for(int i=0;i<n;i++)
	{
		int cnt = 0;
		for(int j=i;j<n;j++)
		{
			if(s[j]=='A' || s[j]=='C' || s[j]=='G' || s[j]=='T')
			{
				cnt++;
			}
			else
			{
				res = max(cnt,res);
				cnt = 0;
			}
		}
		res = max(cnt,res);
	}

	cout << res << '\n';
	
	return 0;
}

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

#define ll long long
#define mod 1000000007
#define f(i, a, b) for (long long i = a; i < b; i++)
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define fm(i, a, b) for (long long i = a; i > b; i--)
#define repm(i, a, b) for (long long i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define pqmaxi priority_queue<int>
#define pqmaxl priority_queue<ll>
#define pqmini priority_queue<int, vi, greater<int>>
#define pqminl priority_queue<ll, vl, greater<ll>>
#define all(x) x.begin(), x.end()
#define test     \
    ll test;     \
    cin >> test; \
    while (test--)
#define pb(i) push_back(i)
#define mp(i, j) make_pair(i, j)
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL)

int main()
{
    fast;
    ll n;
    cin >> n;
    ll k1 = ceil(n / 1.08);
    ll k2 = floor(k1 * (1.08));
    if (k2 == n)
    {
        cout << k1;
    }
    else
    {
        cout << ":(";
    }
}

Measured memory_bytes: 3704
mojiretu = input()
nagasa = len(mojiretu)

zero_ichi = ''
ichi_zero = ''

for i in range(nagasa):
    if i % 2 == 0:
        zero_ichi += '0'
        ichi_zero += '1'
    if i % 2 == 1:
        zero_ichi += '1'
        ichi_zero += '0'

counter_0 = 0
counter_1 = 0
for i in range(nagasa):
    if zero_ichi[i] != mojiretu[i]:
        counter_0 += 1
    if ichi_zero[i] != mojiretu[i]:
        counter_1 += 1

if counter_0 <= counter_1:
    print(counter_0)
else:
    print(counter_1)

Measured memory_bytes: 3316
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
long long dp[42][1<<17];
int to[1<<17][10];
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	long long sub=1;
	for(int i=0;i<a;i++)sub=sub*10%mod;
	dp[0][1]=1;
	for(int i=0;i<(1<<(b+c+d));i++){
		for(int j=0;j<10;j++){
			int tmp=1;
			bool dame=false;
			for(int k=0;k<b+c+d;k++){
				if(!((1<<k)&i))continue;
				if(k<b&&k+j+1>b)continue;
				if(k<b+c&&k+j+1>b+c)continue;
				if(k<b+c+d&&k+j+1>b+c+d)continue;
				if(k+j+1==b+c+d){dame=true;break;}
				tmp+=1<<(k+j+1);
			}
			if(dame)tmp=-1;
			to[i][j]=tmp;
		}
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<(1<<(b+c+d));j++){
			if(!dp[i][j])continue;
		//	printf("%d %d: %lld\n",);
			for(int k=0;k<10;k++){
				if(to[j][k]==-1)continue;
				dp[i+1][to[j][k]]=(dp[i+1][to[j][k]]+dp[i][j])%mod;
			}
		}
	}
	long long ret=0;
	for(int i=0;i<(1<<(b+c+d));i++)ret=(ret+dp[a][i])%mod;
	printf("%lld\n",(mod+sub-ret)%mod);
}

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

int main(void){
    int n, m;
    int *h;
    int *a;
    int *b;
    int *is_good;
    int i;
    int result = 0;

    scanf("%d %d", &n, &m);
    h = (int*)malloc(sizeof(int) * n);
    is_good = (int*)malloc(sizeof(int) * n);
    a = (int*)malloc(sizeof(int) * m);
    b = (int*)malloc(sizeof(int) * m);

    for(i = 0; i < n; i++){
        scanf("%d", h + i);
        is_good[i] = 1;
    }
    for(i = 0; i < m; i++){
        scanf("%d %d", a + i, b + i);
    }

    for(i = 0; i < m; i++){
        int h1 = h[a[i] - 1];
        int h2 = h[b[i] - 1];
        if(h1 <= h2)
            is_good[a[i] - 1] = 0;
        if(h1 >= h2)
            is_good[b[i] - 1] = 0;
    }

    for(i = 0; i < n; i++){
        if(is_good[i] == 1)
            result++;
    }



    free(is_good);
    free(a);
    free(b);
    free(h);
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 3016
#include<stdio.h>
#include<map>
using namespace std;
typedef pair<int,int> P;
int r[4];
double dp[51][5001];
P m[51];
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int main(){
	int rn,n,k;
	int i,j;
	while(1){
	scanf("%d %d %d",&rn,&n,&k);
	if(rn==0)return 0;
	for(i=0;i<rn;i++)scanf("%d",&r[i]);
	for(i=0;i<=n;i++){
		m[i]=P(0,0);
		for(j=0;j<=n*100;j++)dp[i][j]=0.0f;
	}
	for(i=0;i<k;i++){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		m[a]=P(b,c);
	}
	dp[0][0]=1.0f;
	for(i=0;i<n;i++){
		for(j=0;j<=n*100;j++){
			if(dp[i][j]==0.0f)continue;
			for(k=0;k<rn;k++){
				int next=min(n,i+r[k]);
				int mon=j;
				if(m[next].first==1)next=min(n,next+m[next].second);
				else if(m[next].first==2)mon+=m[next].second;
				else if(m[next].first==3)mon=max(0,mon-m[next].second);
				dp[next][mon]+=dp[i][j]/rn;
			}
		}
	}
	double ans=0.0f;
	for(i=0;i<=n*100;i++)ans+=i*dp[n][i];
	printf("%d\n",(int)ans);
	}
}

Measured memory_bytes: 3020
a,b=[int(x) for x in input().split()]
i=1
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)
g=gcd(a,b)
l=[]
while(i*i<=g):
    if g%i==0 and i*i!=g:
        l.append(i)
        l.append(g//i)
    if i*i==g:
        l.append(i)
    i=i+1
l=sorted(l)
i=1
while(i<len(l)):
    if l[i]!=0:
        j=i+1
        while(j<len(l)):
            if l[j]%l[i]==0:
                l[j] = 0
            j=j+1
    i=i+1
l=list(filter ( lambda x:x!=0,l))
print(len(l))


Measured memory_bytes: 3316
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    String s;
    char[] c;
    LinkedList<Character> st;
    boolean ans;

    void run(){
	while(sc.hasNext()){
	    s = sc.nextLine();
	    if(s.length()==1 && s.equals(".")) break;

	    ans = true;
	    st = new LinkedList<Character>();
	    c = s.toCharArray();
	    for(int i=0; i<c.length && ans; i++){
		if(c[i]=='(' || c[i]=='[')
		    st.push(c[i]);
		else if(c[i]==')'){
		    if(st.size()==0) ans = false;
		    else{
			char x = st.pop();
			if(x!='(') ans = false;
		    }
		}
		else if(c[i]==']'){
		    if(st.size()==0) ans = false;
		    else{
			char x = st.pop();
			if(x!='[') ans = false;
		    }
		}
	    }
	    if(st.size()!=0) ans=false;


	    System.out.println(ans ? "yes" : "no");
	}
    }
}

Measured memory_bytes: 35472
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<Int> x(N);
	for (int i = 0; i < N; ++i) { cin >> x[i]; }

	Int ans = 1e18;
	for (int i = 1; i <= 100; ++i) {
		Int tmp = 0;
		for (int j = 0; j < N; ++j) {
			tmp += (x[j] - i) * (x[j] - i);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 768
def main():
    S = input()

    modN = 13
    modAns = 10**9+7
    dp_table = [[0 for idx in range(modN)] for _ in range(len(S)+1)]
    dp_table[0][0] = 1

    for digit in range(len(S)):
        if S[digit] == '?':
            for mod in range(modN):
                for add_num in range(10):
                    next_mod = (10*mod + add_num) % 13
                    dp_table[digit+1][next_mod] += dp_table[digit][mod]
        else:
            val = int(S[digit])
            for mod in range(modN):
                next_mod = (10*mod + val) % 13
                dp_table[digit+1][next_mod] += dp_table[digit][mod]
        for idx in range(modN):
            dp_table[digit+1][idx] %= modAns

    print(dp_table[-1][5])


if __name__ == "__main__":
    main()


Measured memory_bytes: 65884
#include <iostream>
using namespace std;
int main(void){
    int s1,s2,s3,s4,s5,s6,s7,s8,s9,s10;
    cin>>s1>>s2>>s3>>s4>>s5>>s6>>s7>>s8>>s9>>s10;
    cout<<s1+s2+s3+s4+s5+s6+s7+s8+s9+s10<<endl;
}



Measured memory_bytes: 3100
#include   <iostream>
#include    <cstring>
#include     <cstdio>
#include      <queue>
#include        <map>
#include      <cmath>
#include     <vector>
#include  <algorithm>
#include        <set>
#include      <stack>
#include    <climits>

#define mem(x,y) memset(x,y,sizeof(x))
#define INF   1e9
#define EPS   1e-6
#define MOD   1000000007
#define PI    3.141592654

typedef long long ll;


using namespace std;


int ans[2000][2000];

void init()
{
	ans[1][1]=1;
	ans[1][2]=1;
	ans[2][1]=1;
	ans[2][2]=-1;
	int ct=2;
	for(int i=2;i<=10;i++)
	{
		for(int j=1;j<=ct;j++)
		{
			for(int k=1;k<=ct;k++)
			{
				ans[k][j+ct]=ans[k][j];
				ans[k+ct][j]=ans[k][j];
				ans[k+ct][j+ct]=-ans[k][j];
			}
		}
		ct=ct*2;
	}
}

int main()
{
    //freopen("c.in", "r", stdin);
    //freopen("c.out", "w", stdout);\n|_
    int n;
    scanf("%d",&n);
    int tmp;
    int cnt=0;
	for(int i=1;i<=n;i++)
    {
    	scanf("%d",&tmp);
    	if(tmp!=i) cnt++;
	}
	if(cnt<=2) printf("YES\n");
	else printf("NO\n");
    //fclose(stdin);
    //fclose(stdout);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int N; cin >> N;
    vector<int> d(N);
    rep(i,N) cin >> d[i];
    sort(d.begin(),d.end());
    int ans = d[N/2]-d[N/2-1];
    cout << ans << endl;
}
    



Measured memory_bytes: 640
#include <iostream>
#include <math.h>

int main() {
    int N, ans = 0;
    double D;
    double X, Y;

    std::cin >> N >> D;
    for(int i = 0; i < N; i++) {
        std::cin >> X >> Y;

        if(sqrt(X * X + Y * Y) <= D) {
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3772
import math
n,d=input().split(" ")
n=int(n)
d=int(d)
cnt=0
for i in range(0,n):
    x,y=input().split(" ")
    x=int(x)
    y=int(y)
    dist=math.sqrt(x*x + y*y)
    if(dist<=d):
        cnt=cnt+1
print(cnt)

Measured memory_bytes: 9208
nums = input()
for i in range(2**3):
  case = bin(i)[2:].zfill(3).replace('0', '+').replace('1','-')
  str_eq = nums[0] + case[0] + nums[1] + case[1] + nums[2] + case[2] + nums[3]
  if eval(str_eq) == 7:
    print(str_eq + '=7')
    exit()

Measured memory_bytes: 3060
import math
a, b, h, m = map(int, input().split())

hh = (h/12)*360 + (m/60)*30
mm = (m/60)*360

rad = abs(hh-mm)

if rad > 180:
    rad = 360-rad

cos = math.cos(math.radians(rad))


print(math.sqrt(a**2 + b**2 - 2*a*b*cos))

Measured memory_bytes: 62536