akhauriyash/Code-Regression huggingface dataset:
/*Writer : Md. Shafiur Rahman Dipu */

#include <bits/stdc++.h>
using namespace std;

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define pi acos(-1.0)
#define INF 2e12

#define ull unsigned long long
#define ll long long
#define ld long double

#define pb push_back

#define mx 5000005
#define mod 1000000007

long long poW(long long base, long long power) {
    long long result = 1;
    while(power > 0) {

        if(power & 1) {
            result = (result*base) ;
        }
        base = (base * base);
        power = power / 2;
    }
    return result;
}

int ar[100005][4];
ll dp[100005][4];
int n;
int k;
ll func(int pres, int nibo){
    if(pres >= n){
        return 0;
    }
    if(dp[pres][nibo] > 0){
        return dp[pres][nibo];
    }
    if(pres == n-1){
        return dp[pres][nibo] = ar[pres][nibo];
    }

    for(int i=0; i<3; i++){
        if(i==nibo){continue;}
        dp[pres][nibo] = max(dp[pres][nibo], (ar[pres][nibo] + func(pres+1,i)));
    }

    return dp[pres][nibo];

}


int main()
{
    #ifdef dipu
    //freopen("inp.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    while(1){
    #endif
    FASTER
    cin >> n ;
    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            cin >> ar[i][j];
        }
    }

    ll res = LONG_LONG_MIN;
    memset(dp,0,sizeof dp);
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if(i==j){continue;}
            res = max(res, func(0,j));
        }
    }

    cout << res << endl;

    #ifdef dipu
    }
    #endif // dipu


    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    int x[N], y[N];
    for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];

    double sum = 0;
    for (int i = 0; i < N - 1; ++i) {
        for (int j = i + 1; j < N; ++j) {
            // calculate the distance between i and j
            int dd = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
            sum += sqrt((double)dd);
        }
    }

    printf("%f\n", (sum * 2) / (double)(N));

    return 0;
}


Measured memory_bytes: 256
import itertools
n = int(input())
boulist = list(map(int,input().split()))
com = list(itertools.combinations(boulist,3))
ans = 0
if len(com) == 0:
  print(0)
else:
  for i in range(len(com)):
    if com[i][0] + com[i][1] > com[i][2] and com[i][1] + com[i][2] > com[i][0] and com[i][2] + com[i][0] > com[i][1] and com[i][0] != com[i][1] and com[i][1] !=com[i][2] and com[i][0] != com[i][2]:
      ans = ans + 1
  print(ans)

Measured memory_bytes: 20640
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
bool isprime(ll x){
    for(int i=2;i*i<=x;i++){
        if(x%i==0)return false;
    }
    return true;
}

int main()
{
    vector<ll>common;
    ll a,b;
    cin>>a>>b;
    set<ll>f,g;
    bool ok=false;
    while (a % 2 == 0)
    {
        f.insert(2);
        a = a/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(a); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (a % i == 0)
        {
            f.insert(i);
            a = a/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (a > 2)
        f.insert(a);

         while (b % 2 == 0)
    {
        g.insert(2);
        b = b/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(b); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (b % i == 0)
        {
            g.insert(i);
            b = b/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (b > 2)
        g.insert(b);


      ll ans=0;
      for(auto x:g){
        if(f.count(x))ans++;
      }
      ans++;
      cout<<ans;

    return 0;

}


Measured memory_bytes: 3608
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll a, b, c;
    cin >> a >> b >> c;
    cout << max(c - a + b, 0);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

 int a,b,c,k;
 cin>>a>>b>>c;
 if (a>b) {
    k=a; 
    a=b; 
    b=k;
   }
 if (b>c) {
   k=b;
   b=c;
   c=k;
   }
 if (a>b) {
    k=a; 
    a=b; 
    b=k;
   }
 cout<<a<<" "<<b<<" "<<c<<endl;
 return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>

int main(void)
{
    int n , t , sum=0, q;

    scanf( "%d" , &n);

    q=n;

    while( n){
        t = n%10;
        sum += t;
        n = n/10; 
    }

    if((q%sum) ==0 )
     printf("Yes\n");
    else
     printf("No\n");


}

Measured memory_bytes: 128
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s,t,u;
  cin >> s;
  for(int i=0; i<7; i++) {
    t=s.substr(0,i+1);
    u=s.substr(s.size()-6+i,6-i);
    if(t+u=="keyence") {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=200010;
int n;
int a[N],b[N];
void readData(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
}
void solve(){
	sort(b+1,b+1+n);
	int x=b[n>>1],y=b[(n>>1)+1];
	for(int i=1;i<=n;i++)
		printf("%d\n",a[i]<=x?y:x);
}
int main(){
	readData();
	solve();
	return 0;
}


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

int main()
{
    int n, q, l, r;
    string s;
    cin >> n >> q >> s;
    int p[n];
    p[0] = 0;
    for (int i = 1; i < n; i++) {
        p[i] = p[i - 1] + (s[i - 1] == 'A' && s[i] == 'C');
    }
    while (q--) {
        cin >> l >> r;
        l--; r--;
        cout << p[r] - p[l] << "\n";
        //if (l == 0) cout << p[r] << "\n";
        //else cout << p[r] - p[l - 1] << "\n";
    }
}


Measured memory_bytes: 4148
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; // 998'244'353LL
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

ll A;
double B;

signed main(){
    cin >> A >> B;
    cout << A * (ll)floor(B * 100 + 1e-9) / 100 << endl;
}


Measured memory_bytes: 3844
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;



int main() {
  int n,k,r,s,p;
  string t;
  cin>>n>>k>>r>>s>>p>>t;
  
  vector<int> cr(n,0),cs(n,0),cp(n,0);
  int tr=0,ts=0,tp=0;
  rep(i,k){
    if(t[i]=='r'){
      tr++;
      cr[i]=1;
    }
    else if(t[i]=='s'){
      ts++;
      cs[i]=1;
    }
    else if(t[i]=='p'){
      tp++;
      cp[i]=1;
    }
  }
  for(int i=k;i<n;i++){
    if(t[i]=='r' && cr[i-k]==0){
      tr++;
      cr[i]=1;
    }
    else if(t[i]=='s' && cs[i-k]==0){
      ts++;
      cs[i]=1;
    }
    else if(t[i]=='p' && cp[i-k]==0){
      tp++;
      cp[i]=1;
    }
  }
  
  cout<<tr*p+ts*r+tp*s<<endl;
    
  return 0;
}

Measured memory_bytes: 1664
S = input()
white_cnt = black_cnt = 0
ans = 0
for i in range(len(S)):
    if S[i]=="0":
        black_cnt += 1
        white_cnt = 0
    else:
        white_cnt += 1
        black_cnt = 0
    if black_cnt==2:
        ans += 1
        black_cnt = 0
        white_cnt += 1
    elif white_cnt == 2:
        ans += 1
        white_cnt = 0
        black_cnt += 1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;

template<class T>bool chmax(T &a, const T &b) { if( a < b ) { a = b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) { if( b < a ) { a = b; return 1; } return 0;}

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))
//#define int long long int //dont forget to change int to signed

int main() {
	int n;
	scanf("%d", &n);
	int a[2*100100];
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}

	int index;
	for (index = n; index >= 1; index -= 2) {
		printf("%d ", a[index]);	
	}
	if (index == -1) index = 2;
	else index = 1;
	for (; index <= n-1; index += 2) {
		printf("%d ", a[index]);	
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        string s,t,u;
        cin >> s >> t;
        u=t;
        int flag=0;
        char k;
        rep(i,s.size()){
                if(s==u) {
                        flag=1;
                        break;
                }else{
                        k=u[0];

                        for(int j=0; j<s.size(); j++) {
                                u[j]=u[j+1];
                        }
                        u[s.size()-1]=k;
                }
        }

        if(flag==1) cout <<"Yes"  << endl;
        else cout << "No" << endl;

        return 0;
}


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

#define pb push_back
#define ll long long
#define inf 1e9

using namespace std;


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

	int n;
	cin>>n;
	long long dp[n][3];
	for (int i = 0; i < n; ++i)
	{
		for (int k = 0; k < 3; ++k)
		{
			cin>>dp[i][k];
		}
	}

	for (int i = 1; i < n; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			dp[i][j] += max(dp[i-1][(j+1)%3] , dp[i-1][(j+2)%3]);
		}
	}

	long long nax = -1;
	for (int i = 0; i < 3; ++i)
	{
		nax = max(nax, dp[n-1][i]);
	}
	
	printf("%lld\n", nax);
}




Measured memory_bytes: 2560
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  long double a,b,c;
  cin >> a >> b >> c;
  if(2*sqrt(a*b)<c-a-b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// Problem : C - Poll
// Contest : AtCoder Beginner Contest 155
// URL : https://atcoder.jp/contests/abc155/tasks/abc155_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);
#define endl "\n"
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;

int32_t main()
{
	IOS;
	int t = 1;
	//cin >> t;	
	for(int msi = 1; msi <= t; msi++)
	{
		int n;
		cin >> n;
		map<string, int> mp;
		int maxi = -1;
		for(int i = 0; i < n; i++){
			string s; cin >> s;
			mp[s]++;
			maxi = max(maxi, mp[s]);
		}
		for(auto it : mp){
			if(it.second == maxi){
				cout << it.first << endl;
			}
		}
	}	
	return 0;
}


Measured memory_bytes: 23808
import sys
from collections import Counter
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = Counter(list(map(int, input().split())))
    
    ans = 0;
    for k, v in a.items():
        if k < v:
            ans += v - k
        elif k > v:
            ans += v
            
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 22304
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, w;
	cin>>n>>w;
	//dp[i]= minimum weight for i value
	vector<pair<int,int>> items(n);
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>items[i].first>>items[i].second;
		sum+=items[i].second;
	}
	#define ll long long int
	vector<ll> dp(sum+1,1e18);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int current_value=sum;current_value>=items[i].second;current_value--)
			dp[current_value]=min(dp[current_value],dp[current_value-items[i].second]+items[i].first);
	}
	int ans=0;
	for(int i=0;i<=sum;i++)
		if(dp[i]<=w)
			ans=i;
	cout<<ans;
}

Measured memory_bytes: 1024
using System;

class B{
  static void Main(){
    int N = int.Parse(Console.ReadLine());
    int AC = 0, WA = 0, TLE = 0, RE = 0;
    string Temp = "";
    for (int i = 0; i < N; i++){
      Temp = Console.ReadLine();
      if (Temp == "AC"){
        AC++;
      }
      else if(Temp == "TLE"){
        TLE++;
      }
      else if(Temp == "WA"){
        WA++;
      }
      else RE++;
    }
    Console.WriteLine("AC x " + AC);
    Console.WriteLine("WA x " + WA);
    Console.WriteLine("TLE x "+ TLE);
    Console.WriteLine("RE x " + RE);
  }
}

Measured memory_bytes: 20844
# DP(貰うDP)
def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    dp = [0] * N
    for i in range(1, N):
        dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(0, i - K), i))
    print(dp[N - 1])


main()


Measured memory_bytes: 13980
from collections import deque
n = int(input())
tree = [[] for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append((b, c))
    tree[b].append((a, c))
q, k = map(int, input().split())
k -= 1

visited = [-1]*n
todo = deque()
visited[k] = 0
todo.append(k)

while todo:
    v = todo.pop()
    d = visited[v]
    for to, cost in tree[v]:
        if visited[to] == -1:
            visited[to] = d+cost
            todo.append(to)
            
ans = []
for _ in range(q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    ans.append(visited[x] + visited[y])

print(*ans, sep="\n")


Measured memory_bytes: 50084
# ABC-142-D
A, B = map(int, input().split())
ans = 1

#最大公約数
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def factorize(x):
    factor = []
    for num in range(2, int(x**0.5)+1):
        while x % num == 0:
            x //= num
            factor.append(num)
    if x != 1:
        factor.append(x)
    return set(factor)
    
gcd_AB = gcd(A, B)
prime = factorize(gcd_AB)
ans += len(prime)
print(ans)

Measured memory_bytes: 3064
// I am Varun Das from Jadavpur University
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define INF LLONG_MAX
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//cout<<fixed<<setprecision(12);
int n,w;
cin>>n>>w;
vector<ll>dp(w+1,0);
loop(i,0,n){
    ll weight,val;
    cin>>weight>>val;
    for(int weight_already = w-weight; weight_already >= 0; --weight_already){
        dp[weight_already + weight] = max(dp[weight_already + weight],dp[weight_already] + val); 
    }
}
ll ans=0;
loop(i,0,w+1) ans=max(ans,dp[i]);
// cout<<endl;
// loop(i,0,w+1) cout<<dp[i]<<" ";
cout<<ans;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;

const int N = 2e5+1;
const int NN = 2 * N;
char s[N+1];
int n, m;
vector<int> g[NN];
int in[NN];
inline void add(int x, int y)
{
  g[x].pb(y);
  ++in[y];
}
int main()
{
  scanf("%d %d %s", &n, &m, s+1);
  for (int i = 1; i <= m; ++i)
    {
      int a, b; scanf("%d %d", &a, &b);
      if (s[a] != s[b])
        add(2*a-1, 2*b), add(2*b-1, 2*a);
      else
        add(2*a, 2*b-1), add(2*b, 2*a-1);
    }
  queue<int> q;
  for (int i = 1; i <= 2*n; ++i)
    if (in[i] == 0) q.push(i);
  int vis = 0;
  while (!q.empty())
    {
      ++vis;
      int cur = q.front(); q.pop();
      for (auto nxt : g[cur])
        if (--in[nxt] == 0)
          q.push(nxt);
    }
  puts(vis == 2*n?"No":"Yes");

}


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

using namespace std;

int ans;
string s, t;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> s >> t;
	for (int i = 0; i < s.size(); ++i)
		if (s[i] != t[i])
			++ans;

	cout << ans << endl;
}


Measured memory_bytes: 3840
//解説より

#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i > (b); i--)

typedef long double ld;

using namespace std;

int main(void) {
	ld W, H;
	int x, y;
    scanf("%Lf %Lf %d %d", &W, &H, &x, &y);

    ld area = (W * H) / 2;

    int ans = 0;

    if ( x + x == W && y + y == H ) ans = 1;
    
    printf("%0.10Lf %d\n", area, ans);

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

struct date{
	int year, month, day;
};

int era_trans(struct date d);

int era_year[4] = {1868, 1912, 1926, 1989}; //各eraの最初の年
int era_month[4] = {9, 7, 12, 1}; //各eraの最初の月
int era_day[4] = {8, 30, 25, 8}; //各eraの最初の日
char era_name[4][20] = {"meiji", "taisho", "showa", "heisei"};

int main(void)
{
	struct date d;
	int n, ans_year;

	while (scanf("%d%d%d", &d.year, &d.month, &d.day) != EOF) {
		n = era_trans(d);
		if (n == -1) {//n == -1 <-> pre-meijiだったら
			printf("pre-meiji\n");
		} else {
			ans_year = d.year - era_year[n] +1;
			printf("%s %d %d %d\n", era_name[n], ans_year, d.month, d.day);
		}
	}
}
int era_trans(struct date d)
{//eraに応じた数字を返す
	int i;
	for (i=0; i<4; i++) {
        //時代iより前の日付ならbreak
		if (d.year < era_year[i]) {
			break;
		} else if (d.year == era_year[i] && d.month < era_month[i]){
			break;
		} else if (d.year == era_year[i] && d.month == era_month[i] && d.day < era_day[i]) {
			break;
		}
	}
    i--;//era_---とインデックスをそろえるため
	//i = -1 :: pre-meiji
	//i = 0  :: meiji
	//i = 1  :: taisho
	//i = 2  :: showa
	//i = 3  :: heisei
	return i;
}

Measured memory_bytes: 1036
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
       
        int c = sc.nextInt();
		int d = sc.nextInt();
        int e,f;
        if(a%d==0){e = a/d;}
        else{e=a/d+1;}
         if(c%b==0){f = c/b;}
        else{f=c/b+1;}
		if(e>=f){System.out.println("Yes");}
        else{System.out.println("No");}
	}
}

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

#define N 1000
/*void makeFibnacci(int *,int);

void makeFibnacci(int *a,int n){
	int i;
	
}*/

int main(){
	int n,i;
	int a[N];

	scanf("%d",&n);

	//a = (int *)malloc(n+1);

	//makeFibnacci(a,n+1);

	a[0] = 1;
	a[1] = 1;
	for( i = 2 ; i <= n ; i++ ) a[i] = a[i-2] + a[i-1];


	printf("%d\n",a[n]);

	//free(a);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <queue>
#include <string>

using namespace std;

struct process{
    string name;
    int time;
};

int main(){
    int n,p;
    cin>>n>>p;
    int i;
    queue<process> q;
    for (i=0;i<n;i++){
        process temp;
        cin>>temp.name>>temp.time;
        q.push(temp);   //?????\????????????
    }
    int t=0;    //????????????
    while(!q.empty()){
        //???????????????????????????
        process pro=q.front();
        q.pop();
        if (pro.time>p){
            //?????????????????£???????????????
            pro.time-=p;
            q.push(pro);    //?????\????????????
            t+=p;   //??????????????????
        }
        else{
            //????????????????????????
            //?????????????????¨?????????????????????
            cout<<pro.name<<" "<<t+pro.time<<endl;
            t+=pro.time;    //??????????????????
        }
    }
    return 0;
}

Measured memory_bytes: 4404
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int a, b, x;
    cin >> a >> b >> x;
    if (x <= b + a && x >= a)
    {
        cout << "YES" << endl;
        return 0;
    }
    else
    {
        cout << "NO" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
def g_c_d(x, y):
    if y == 0:
        return x
    else:
        return g_c_d(y, x % y)


def l_c_m(x, y):
    return x * y // g_c_d(x, y)


a, b, c, d = map(int, input().split())
e = l_c_m(c, d)
f = b // c - (a - 1) // c + b // d - (a - 1) // d - (b // e - (a - 1) // e)
print(b - a + 1 - f)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 2000005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long  ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
	ll x = 0;
	char c = getchar();
	bool f = false;
	while (!isdigit(c)) {
		if (c == '-') f = true;
		c = getchar();
	}
	while (isdigit(c)) {
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	return f ? -x : x;
}

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; }


/*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
	if (!b) {
		x = 1; y = 0; return a;
	}
	ans = exgcd(b, a%b, x, y);
	ll t = x; x = y; y = t - a / b * y;
	return ans;
}
*/

int h, w;
ll minn = 99999999999;
int main() {
//	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> h >> w;
	for (ll i = 1; i < h; i++) {
		ll tmps = i * w;
		ll pos = (h - i) / 2;
		ll tmps1 = (pos)*w;
//		cout << ">>" << tmps1 << endl;
		ll tmps2 = (h - i - pos)*w;
//		cout << ">>"<<tmps2 << endl;
		ll mins = min(min(tmps, tmps1), tmps2);
		ll maxs = max(max(tmps, tmps2), tmps1);
		minn = min(minn, maxs - mins);
		
		pos = w / 2;
		tmps1 = pos * (h - i);
//		cout << ">>" << tmps1 << endl;
		tmps2 = (w - pos)*(h - i);
//		cout << ">>" << tmps2 << endl;
		mins = min(min(tmps, tmps1), tmps2);
		maxs = max(max(tmps, tmps2), tmps1);
		minn = min(minn, maxs - mins);
	//	cout << minn << endl;
	}
	for (ll i = 1; i < w; i++) {
		ll tmps = i * h;
		ll pos = (w - i) / 2;
		ll tmps1 = (pos)*h;
		ll tmps2 = (w - i - pos)*h;
		ll mins = min(min(tmps, tmps1), tmps2);
		ll maxs = max(max(tmps, tmps2), tmps1);
		minn = min(minn, maxs - mins);
	//	cout << minn << endl;
		pos = h / 2;
		tmps1 = (w - i)*pos;
		tmps2 = (w - i)*(h - pos);
		mins = min(min(tmps, tmps1), tmps2);
		maxs = max(max(tmps, tmps2), tmps1);
		minn = min(minn, maxs - mins);
	//	cout << minn << endl;
	}
	cout << minn << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int n,mn=0;
	cin >> n;
	vector<int> a(n), c(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	for (int i = 0;i < n;i++) {
		c[a[i] - 1] = i + 1;
	}
	for (int i = 0;i < n;i++) {
		cout << c[i];
		if (i < n)cout << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1664
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;
import std.traits;

struct Magic
{
    int a;
    int b;
}

struct Input
{
	int h;
	int n;
	Magic[] m;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		auto hn = readln().strip().split();
		h = hn[0].to!int;
		n = hn[1].to!int;

        foreach (i; 0..n)
        {
            auto ab = readln().strip().split().map!(to!int).array;
            Magic temp;
            temp.a = ab[0];
            temp.b = ab[1];
            m ~= temp;
        }
	}
}

auto main2(Input* input)
{
    int[10000+1] dp;
    dp[1..$] = int.max;

    for (int hp = 1; hp <= input.h; hp++)
    {
        foreach (m; input.m)
        {
            auto prevMp = m.a > hp ? 0 : dp[hp - m.a];
            auto newMp = prevMp + m.b;
            if (newMp < dp[hp])
                dp[hp] = newMp;
        }
    }

	return dp[input.h];
}

alias retType = ReturnType!main2;
static if (!is(retType == void))
{
	unittest { writeln("begin unittest"); }
	auto _placeholder_ = ReturnType!main2.init;

	unittest // example1
	{
		string example =
`9 3
8 3
4 2
2 1`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 4);
	}

	unittest // example2
	{
		string example =
`100 6
1 1
2 3
3 9
4 27
5 81
6 243`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 100);
	}

	unittest // example3
	{
		string example =
`9999 10
540 7550
691 9680
700 9790
510 7150
415 5818
551 7712
587 8227
619 8671
588 8228
176 2461`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 139815);
	}

	unittest { writeln("end unittest"); }

	void parseExample(out Input input, string example)
	{
		struct Adapter
		{
			string[] _lines;
			this(string input) { _lines = input.splitLines(); }
			string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
		}
		parseInput(input, Adapter(example));
	}
}

void printResult(T)(T result)
{
	static if (isFloatingPoint!T) writefln("%f", result);
	else writeln(result);
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	alias retType = ReturnType!main2;
	static if (is(retType == void))
		main2(&input);
	else
	{
		auto result = main2(&input);
		printResult(result);
	}
}


Measured memory_bytes: 380
import Control.Monad

main :: IO ()
main = do
  rs <- liftM read getLine
  let h = rs `div` 3600
  let m = (rs - (h * 3600)) `div` 60
  let s = rs - (h * 3600) - (m * 60)
  putStr (show h)
  putStr  ":"
  putStr (show m)
  putStr ":"
  putStrLn (show s)

Measured memory_bytes: 3672
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
    int n,a[100005],m;
    long long sum=0;;
    priority_queue<int> b;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        b.push(a[i]);
    }
    for(int i=m;i>0;i--)
    {
        int x=b.top();
        b.pop();
        x=x/2;
        b.push(x);
    }
    for(int i=0;i<n;i++)
    {
        int x=b.top();
        b.pop();
        sum+=x;
    }
    printf("%lld\n",sum);
    return 0;

}


Measured memory_bytes: 1148
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
        int n;cin>>n;
      cout<<3*n*n;
    }
    


Measured memory_bytes: 256
import random
d=int(input())
c=list(map(int,input().split()))
num=[0]*26
ans=[]
numans=0
s=[]
for i in range(1,d+1):
    num1=1
    num2=-(10**100)
    num3=[0]*26
    for j in range(26):
        num3[j]=-1*((i-num[j])*c[j])
    s.append(list(map(int,input().split())))
    for j in range(26):
        num5=s[i-1][j]-num3[j]
        if num5>num2:
            num1=j+1
            num2=num5
    ans.append(num1)
    numans+=num2+s[i-1][num1-1]
    num[num1-1]=i
def sco(n1,n2,n3):
    n0=0
    n01=[0]*26
    old=ans[n1]
    ans[n1]=n2
    for k in range(n3):
        n0+=s[k][ans[k]-1]
        n01[ans[k]-1]=k+1
        for l in range(26):
            n0-=(k+1-n01[l])*c[l]
    return n0
for i in range(1400):
    num6=random.randint(1,26)
    num7=random.randint(1,365)
    num100=sco(num7-1,num6,d)
    if num100>numans:
        ans[j]=num6
for i in range(d):
    print(ans[i])


Measured memory_bytes: 9796
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

ll modinv(ll a, ll n) {
  // 法nにおけるaの逆元 (ax≡1 mod nのx)を求める関数
  // modinv(a, MOD)でaの逆元(=a^(-1))が求まる
  ll q, s, t, u, v, w;
  s = a; t = n; u = 1; v = 0;
  while (s > 0) {
    q = t/s;
    w = t - q*s;
    t = s;
    s = w;
    w = v - q*u;
    v = u;
    u = w;
  }
  return (v + n) % n;
}

int main() {
  ll n, m, k; cin >> n >> m >> k;
  ll ans = 0;
  rep(i, 1, n) {
    ans += (i*(n-i)*m*m) % MOD;
    ans %= MOD;
  }
  rep(i, 1, m) {
    ans += (i*(m-i)*n*n) % MOD;
    ans %= MOD;
  }
  ll nm = n*m-2, kk = k-2;
  if (nm-kk < kk) kk = nm-kk;
  ll mi = 1;
  for (ll j=0; j<kk; j++) {
    mi *= nm--;
    mi %= MOD;
  }
  for (ll j=1; j<=kk; j++) {
    mi *= modinv(j, MOD);
    mi %= MOD;
  }
  cout << (ans * mi) % MOD << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[10]={0};

bool fun(int n)
{
    int i=0;
    while(n)
    {
        i=n%10;
        if(a[i]==1)
        {
            return 0;
        }
        n=n/10;
    }
    return 1;
}

int main()
{
    int n,k;
    memset(a,0,sizeof(a));
    while(cin>>n>>k)
    {
        int i,j;
        for(i=0;i<k;i++)
        {
            int x;
            cin>>x;
            a[x]=1;
        }
        for(j=n;;j++)
        {
            if(fun(j))
            {
                break;
            }
        }
        cout<<j<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
var input: string = require('fs').readFileSync('/dev/stdin', 'utf8');
var parts = input.split(" ");
var D = parseInt(parts[0]);
switch (D) {
    case 25:
        console.log("Christmas");
        break;
    case 24:
        console.log("Christmas Eve");
        break;
    case 23:
        console.log("Christmas Eve Eve");
        break;
    case 22:
        console.log("Christmas Eve Eve Eve");
        break;
    default:
        break;
}

Measured memory_bytes: 7372
def powerset_generator(provided_set):
  if len(provided_set) > 0:
    for c in powerset_generator(provided_set[1:]):
      yield [provided_set[0]] + c
      yield c
  else:
    yield []

H, W, K = map(int, input().split())
masu = [list(input()) for _ in range(H)]

hw_list = ['h'+ str(i) for i in range(H)] + ['w'+ str(j) for j in range(W)]

res = 0
for red_list in powerset_generator(hw_list):
    red_h_list = []
    red_w_list = []
    for red in red_list:
        if red.startswith('h'):
            red_h_list.append(int(red[1:]))
        else:
            red_w_list.append(int(red[1:]))
    count = 0
    for i in range(H):
        if i in red_h_list:
            continue
        for j in range(W):
            if j in red_w_list:
                continue
            if masu[i][j] == '#':
                count += 1
    if K == count:
        res += 1

print(res)


Measured memory_bytes: 9240
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static readonly List<int> pow2 = new List<int>() { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608 };
    static void Main()
    {
        int l = int.Parse(Console.ReadLine());
        //有向グラフ
        //多重辺あってもいいよ
        //頂点数が20以下
        //辺は60以下
        //パスl個

        //頂点を通る/通らないでbit化してOK
        //つーか0辺とn辺みたいなのを頂点毎に貼るとそれは経路の値が一意に定まる
        //異なるパスを貼る戦略
        //終わりまでの0辺をぴーってするとそこまでの2進数が足される

        bool[] b = Convert.ToString(l, 2).Select(x => x == '1').Reverse().ToArray();

        List<Tuple<int, int, int>> edges = new List<Tuple<int, int, int>>();

        int index = pow2.FindIndex(x => l < x);
        //まずは2進数の基本グラフを貼る これは2^indexを持つ
        for (int i = 0; i < b.Length - 1; i++)
        {
            edges.Add(new Tuple<int, int, int>(i, i + 1, 0));
            edges.Add(new Tuple<int, int, int>(i, i + 1, pow2[i]));
        }
        //最上位以外のbitで1になっているところに対応する辺を貼る 辺の長さは重複しないようにpossibleを作っておく
        int currentHighest = pow2[b.Length - 1] - 1;
        for (int i = 0; i < b.Length - 1; i++)
        {
            if (b[i])
            {
                //辺を貼るのは
                edges.Add(new Tuple<int, int, int>(i, b.Length - 1, currentHighest + 1));
                currentHighest += pow2[i];
            }
        }

        Console.WriteLine($"{b.Length} {edges.Count}");
        foreach (var edge in edges)
        {
            Console.WriteLine($"{edge.Item1 + 1} {edge.Item2 + 1} {edge.Item3}");
        }
    }
}

Measured memory_bytes: 13396
import java.util.*;
import java.io.*;

public class Main {

  void solve(InputReader in, PrintWriter out) {
    int[][] arr = new int[3][3];
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        arr[i][j] = in.nextInt();
      }
    }

    Set<Integer> li = new HashSet<>();
    int n = in.nextInt();
    for (int i = 0; i < n; ++i) {
      li.add(in.nextInt());
    }

    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (li.contains(arr[i][j])) {
          arr[i][j] = -1;
        }
      }
    }

    boolean ans = false;
    for (int i = 0; i < 3 && !ans; ++i) {
      if (arr[i][0] == -1 && arr[i][1] == -1 && arr[i][2] == -1) {
        ans = true;
      } else if (arr[0][i] == -1 && arr[1][i] == -1 && arr[2][i] == -1) {
        ans = true;
      } 
    }

    if (arr[0][0] == -1 && arr[1][1] == -1 && arr[2][2] == -1) {
      ans = true;
    } else if (arr[2][0] == -1 && arr[1][1] == -1 && arr[0][2] == -1) {
      ans = true;
    }

    out.println(ans ? "Yes" : "No");
  }

  public static void main(String[] args) throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Main solver = new Main();
    solver.solve(in, out);
    out.close();
  }

  static class InputReader {
    BufferedReader in;
    StringTokenizer st;

    public InputReader(InputStream is) {
      in = new BufferedReader(new InputStreamReader(is));
    }

    public String next() {
      try {
        while (st == null || !st.hasMoreTokens()) {
          st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
  }
}


Measured memory_bytes: 20948
num = gets.split.map(&:to_i)
arr = []
ans = []
key = 0
zero = 0
tmp = 0
num[1].times do |i|
	arr[i] = gets.split.map(&:to_i)
	if arr[i] == [1, 0]
		zero = 1
	end
end
arr = arr.sort.uniq
len = arr.length
 
if num[0] != 1
	if zero == 1
		key = 1
	end
end
	
len.times do |i|
	len.times do |j|
		if arr[i][0] == arr[j][0] && arr[i][1] != arr[j][1]
			key = 1
		end
	end
end
	
num[0].times do |i|
	ans[i] = 0
end
len.times do |i|
	tmp = arr[i][0] - 1
	ans[tmp] = arr[i][1]
end
if ans[0] == 0 && num[0] != 1
	ans[0] = 1
end
 
if key == 0
	puts ans.join('')
else
	p -1
end	

Measured memory_bytes: 1788
def ispalindrome(str):
    if str==str[::-1]:
        return 1
    else:
        return 0

S=input()
N=len(S)
score=0
score += ispalindrome(S)
score += ispalindrome(S[0:int((N-1)/2):1])
score += ispalindrome(S[int((N+3)/2):N-1:1])

if score==3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
s = input()

if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)
elif s == 'SAT':
    print(1)

Measured memory_bytes: 9024
using System;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int ans = 0;
        int cont = 0;
        for (int i = 1; i < a.Length; i++)
        {
            if (a[i - 1] == a[i]) cont++;
            else
            {
                ans += (cont + 1) / 2;
                cont = 0;
            }
            if (i == a.Length - 1) ans += (cont + 1) / 2;
        }
        Console.WriteLine(ans);
    }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

struct info{
    int idx;
    ll a;
    ll b;
};

bool func(info u,info v){
    return u.a+u.b>v.a+v.b;
}

int main(){
    int N; cin>>N;
    info p[N];
    REP(i,N){
        ll a,b; cin>>a>>b;
        p[i] = {i,a,b };
    }
    sort(p,p+N,func);
    ll ans = 0;
    REP(i,N){
        if(i%2==0){
            ans += p[i].a;
        }else{
            ans -= p[i].b;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 2560
n = int(input())
fld = [list(map(int, input().split())) for _ in range(2)]
score_max = 0

for i in range(n):
  score = fld[0][0]
  y = x = 0
  for j in range(n):
    if j == i:
      y += 1
    else:
      x += 1
    score += fld[y][x]
  score_max = max(score_max, score)

print(score_max)

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

using namespace std;

typedef long long ll;

int main() {
  int n; cin >> n;
  double sum = 0.0;
  for(int i = 0; i < n; i++) {
    double x; cin >> x;
    sum += (1.0 / x);
  }
  printf("%0.8lf\n", 1.0 / sum);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
	char x[1002];
	int num = 0,i;
	char tmp;
	long sum = 0;
	while(1){
		fgets(x,sizeof(x),stdin);
		if(x[0] == '0')break;
		for(i = 0;i < strlen(x)-1;i++){
            tmp = x[i];
			num = atoi(&tmp);
			sum += num;
		}
		printf("%ld\n",sum);
		sum = 0;
		memset(x,1002,0);
	}
	
	return 0;
}

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

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

    int cnt[26];
    for (int i = 0; i < 26; i++) cnt[i] = 0;

    for (int i = 0; i < s.length(); i++) {
        int j = s[i] - 'a';
        cnt[j]++;
    }

    set<string> st;
    for (int i = 0; i < 26; i++) {
        if (cnt[i] == 0) continue;
        char c = 'a' + i;
        for (int j = 0; j < s.length(); j++) {
            if (s[j] != c) continue;
            for (int p = 0; p < K; p++) {
                string sub = s.substr(j, p + 1);
                st.insert(sub);
            }
        }
        if (st.size() >= K) break;
    }

    vector<string> sv;
    for (string subs : st) sv.push_back(subs);
    sort(sv.begin(), sv.end());

    cout << sv.at(K - 1) << endl;
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;

    int min_sum = 1000, max_sum = -1;
  
    for (int i = 0; i < n; i++) {
      int sum = 0, s;
      for (int j = 0; j < 5; j++) {
	cin >> s;
	sum += s;
      }

      if (min_sum > sum) min_sum = sum;
      if (max_sum < sum) max_sum = sum;
    }

    printf("%d %d\n", max_sum, min_sum);
  }

  return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#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 per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
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;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	ll a,v,b,w,t; cin >> a >> v >> b >> w >> t;
	if(abs(a-b) <= (v-w)*t) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 3608
n, m = map(int, input().split())

graph = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)


def dfs(s, a, b):
    flag[s] = 1
    for v in graph[s]:
        if s == a and v == b or s == b and v == a:
            continue
        if flag[v] == 1:
            continue
        dfs(v, a, b)

ans = 0
for i in range(n):
    for v in graph[i]:
        flag = [0 for i in range(n)]
        dfs(0, i, v)
        num = 0
        for j in flag:
            if j == 0:
                num = 1
        if num == 1:
            ans += 1
print(ans//2)

Measured memory_bytes: 3064
str = input()
str2 = input()
nums  = str.split()
nums2  = str2.split()
if len(nums2) != int(nums[1]):
    print("error")
else:
   totalDamege = 0
   for num in nums2:
       totalDamege += int(num)
   if int(nums[0]) <= totalDamege:
       print("Yes")
   else:
       print("No")


Measured memory_bytes: 83616
#include <cstdio>
#include <unordered_set>

int main() {
  int n;
  scanf("%d", &n);
  int xor_sum = 0;
  std::unordered_set<int> s;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    xor_sum ^= a;
    a = a ^ (a - 1);
    for (int bit = 29; bit >= 0; bit--) {
      int x = (1 << (bit + 1)) - 1;
      if (a == x) {
        s.insert(bit);
      }
    }
  }

  int ans = 0;
  for (int bit = 29; bit >= 0; bit--) {
    if (((1 << bit) & xor_sum) == 0) {
      continue;
    }
    int x = (1 << (bit + 1)) - 1;

    if (s.find(bit) != s.end()) {
      xor_sum ^= x;
      ans += 1;
    }
  }

  if (xor_sum != 0) {
    printf("-1\n");
  } else {
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 256