akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
char arr[100000];
int abc[4];
int k[3];
int f(int a, int b){
    return a>b?a-b:b-a;
}
int main(){
    bool t=false;
    int arrlen;
    scanf("%s", arr);
    int a, b, c;
    arrlen=strlen(arr);
    for(int i=0; i<arrlen; ++i){
        abc[arr[i]-'a']++;
    }
    abc[3]=abc[0];
    for(int i=0; i<3; ++i){
        if(f(abc[i], abc[i+1])>1) t=true;
    }
    //printf("%d %d %d %d\n", abc[0], abc[1], abc[2], abc[3]);
    if(t==true) printf("NO");
    else printf("YES");
    return 0;
}

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

const int MAXN = 16;
const int INF = 1<<28;

int n, m, W;
vector<vector<int> > w;
int N;
vector<int> weight;
int sum[1<<MAXN], mem[1<<MAXN];

int rec(int b) {
  int &res = mem[b];
  if(res != -1) return res;
  if(b == 0) return res = 0;
  res = INF;
  for(int k = b; k > 0; k = k-1&b) {
    if(sum[k] <= W) res = min(res, rec(b - k) + 1);
  }
  return res;
}

int main() {
  while(cin >> n >> m >> W) {
    int top = 0;
    --m;
    weight.clear();
    w = vector<vector<int> >(n);
    for(int i = 0; i < n; ++i) {
      int k; cin >> k;
      w[i].resize(k);
      if(k) top = i;
      for(int j = 0; j < k; ++j) {
        cin >> w[i][j];
        weight.push_back(w[i][j]);
        w[i][j] = weight.size()-1;
      }
    }
    N = weight.size();

    if(top == 0) {
      cout << 0 << endl;
    } else {
      for(int b = 0; b < (1<<N); ++b) {
        sum[b] = 0;
        for(int j = 0; j < N; ++j) {
          if(b >> j & 1) sum[b] += weight[j];
        }
      }
      memset(mem, -1, sizeof(mem));
      int res = abs(top - m);
      for(int i = top, b = 0; i > 0; --i) {
        for(int j = 0; j < w[i].size(); ++j) {
          b |= 1 << w[i][j];
        }
        res += rec(b) * 2 - 1;
      }
      cout << res << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1608
S = input()
K = int(input())

ans = ""
cnt = 0
for i in range(len(S)):
    #最後の文字で操作回数が余ってるなら使い切る
    if i == len(S) - 1:
        if ord(S[i]) + (K-cnt)%26 > ord("z"):
            tmp = ord(S[i]) + (K-cnt)%26 - ord("z")
            ans += chr(96+tmp)
        #print(K,cnt,(K-cnt)%26)
        else:
            ans += chr(ord(S[i]) + (K-cnt)%26)
    else:
        #先頭からなるべくaにしていく。回数が足りないならその文字は飛ばす
        if cnt >= K:
            ans += S[i]
        else:
            if S[i] == "a":
                ans += "a"
            else:
                if cnt + (123 - ord(S[i])) <= K:
                    ans += "a"
                    cnt += (123 - ord(S[i]))
                else:
                    ans += S[i]

print(ans)

Measured memory_bytes: 3572
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

int n,p,a[200010],mp[10010];
string s;

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>p;
	cin>>s;
	if(p==2){
		long long sum=0;
		for(int i=0;i<s.size();i++){
			if((s[i]-'0')%2==0) sum+=i+1;
		}
		cout<<sum<<endl;
	}
	else if(p==5){
		long long sum=0;
		for(int i=0;i<s.size();i++){
			if((s[i]-'0')%5==0) sum+=i+1;
		}
		cout<<sum<<endl;
	}
	else{
		for(int i=0;i<s.size();i++){
			a[i+1]=(a[i]*10+s[i]-'0')%p;
		}
		long long sum=0,t=1;
		for(int i=s.size();i>=0;i--){
			sum+=mp[(a[i]*t)%p];
			mp[(a[i]*t)%p]++;
			t=(t*10)%p;
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1428
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://abc088.contest.atcoder.jp/tasks/abc088_c>
問題文============================================================

 3×3 のグリッドがあります.
 上から i 番目で左から j 番目のマスを (i,j) で表すとき, マス (i,j) には数 ci,j が書かれています.
 高橋君によると, 整数 a1,a2,a3,b1,b2,b3 の値が決まっており,
 マス (i,j) には数 ai+bj が書かれているらしいです.
 高橋君の情報が正しいか判定しなさい.
=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll c[4][4];
    for(int i = 1; i <= 3;i++)for(int j = 1; j <= 3;j++) cin >> c[i][j];
    ll a[4],b[4];
    a[1] = 0;
    b[1] = c[1][1] - a[1];
    b[2] = c[1][2] - a[1];
    b[3] = c[1][3] - a[1];
    a[2] = c[2][2] - b[2];
    a[3] = c[3][3] - b[3];
    for(int i = 1; i <= 3;i++){
        for(int j = 1; j<= 3;j++){
            if(c[i][j] != a[i]+b[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
	return 0;
}


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

using namespace std;
int main(){
  vector<int> a;
  for(int i = 0; i < 3; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  } 

  sort(a.begin(), a.end());
  if(a[0] == a[1] && a[1] != a[2]) {
    cout << "Yes" << endl;
  } else if(a[0] != a[1] && a[1] == a[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  bool a=false,b=false;
  string s;
  cin>>s;
  if(s[0]=='0'){
    if(s[1]!='0')a=true;
  }else if(s[0]=='1'){
    if(s[1]>='0'&&s[1]<='2')a=true;
  }
  if(s[2]=='0'){
    if(s[3]!='0')b=true;
  }else if(s[2]=='1'){
    if(s[3]>='0'&&s[3]<='2')b=true;
  }
  if(a&&b)cout<<"AMBIGUOUS";
  else if(a)cout<<"MMYY";
  else if(b)cout<<"YYMM";
  else cout<<"NA";
}


Measured memory_bytes: 256
N = gets.to_i
As = gets.split.map(&:to_i)

@a = As.inject([0]){|r, a| r << r.last + a}.drop(1)
@b = As.reverse.inject([0]){|r, a| r << r.last + a}.drop(1)

def cut(a)
  (2 .. N - 3).each_with_object({1 => 0}) do |i, h|
    h[i] = (h[i - 1] ... i).find{|j| (a[i] - 2*a[j]).abs < (a[i] - 2*a[j + 1]).abs}
  end
end

def md(i, j, k)
  [@a[i], @a[j] - @a[i], @a[k] - @a[j], @a.last - @a[k]].minmax.inject(:-).abs
end

l = cut(@a)
r = cut(@b).map{|k, v| [N - 2 - k, N - 2 - v]}.to_h
puts (1 .. N - 3).map{|i| md(l[i], i, r[i])}.min

Measured memory_bytes: 70284
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
using namespace std;
typedef pair<int,int>pii;
int n,K,tot;
int add;
int main(){
	cin>>n>>K;
	if(K%2!=0){
		int t=n/K;
		cout<<1LL*t*t*t<<endl;
		return 0;
	}else{
		// if(n%K==0){
		// 	int x=n/K;
		// 	cout<<x*x*x*2<<endl;
		// }else{
			int x=n/K,y=(n+K/2)/K;
			cout<<1LL*x*x*x+1LL*y*y*y<<endl;
		// }
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

set<ll> divisor(ll n) {
    set<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.insert(i);
            if(i * i != n)
                ret.insert(n / i);
        }
    }
    return ret;
}

ll simulate(ll N, ll num) {
    while(N >= num) {
        if(N % num == 0) {
            N /= num;
        } else {
            N %= num;
        }
    }
    return N;
}

int main() {
    ll N;
    cin >> N;
    auto div = divisor(N);
    auto div2 = divisor(N - 1);
    set<ll> res;
    for(auto d : div) {
        if(d == 1)
            continue;
        if(simulate(N, d) == 1)
            res.insert(d);
    }
    for(auto d : div2) {
        if(d == 1)
            continue;
        if(simulate(N, d) == 1)
            res.insert(d);
    }

    cout << res.size() << endl;
    return 0;
}

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

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 1000000007
#define MAXR 1000003 4
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)

using namespace std;
typedef long long ll;

int main() {
    long double A, B, H, M;
    cin >> A >> B >> H >> M;

    long double H_theta;
    long double M_theta;

    H_theta = (30.0 * H) + (M / 2.0);
    M_theta = 6.0 * M;

    long double theta;
    theta = abs(H_theta - M_theta);
    if (theta > 180.0){
        theta = 360.0 - theta;
    }
    long double result = sqrtl(powl(A, 2.0) + powl(B, 2.0) - 2*A*B*cosl(deg_to_rad(theta)));
    cout << setprecision(64) << result;
}

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n) i++)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9+7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int n;
   cin>>n;
   bool a=false;

   for(int i=1; i<=9; i++){
      for(int j=i; j<=9; j++){
         if(n==i*j) a++;
      }
   }

   if(a==true) cout<<"Yes"<<'\n';
   else cout<<"No"<<'\n';
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
#a = [int(i) for i in readline().split()]
#b = [int(i) for i in readline().split()]

if n%2==0:
    print(n//2-1)
else:
    print(n//2)















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

int check(char *a,char *b,int n){
	int i;

	for(i=0;i<n;i++){
		if(a[i]<b[i]){
			return 0;
		}
		else if(a[i]>b[i]){
			return 1;
		}
	}
	return 2;
}

void copy(char *s,char *a,int n){
	int i;

	for(i=0;i<6;i++){
		if(i<n)
			a[i]=s[i];
		else{
			a[i]='\0';
		}
	}
}


int main(void){
	char s[5005]={0};
	char r[5][6];
	char a[6];
	int rn[5];
	int x,i,j,k,l;

	scanf("%s",s);
	scanf("%d",&x);

	i=0;
	j=0;
	l=1;
	while(i<5){
		if(s[j+l-1]!='\0'){
			copy(&s[j],r[i],l);
			i++;
			l++;
		}
		else if(s[j]=='\0'){
			break;
		}
		else{
			j++;
			l=1;
		}
	}

	for(i=1;s[i]!='\0';i++){
		l=1;
		for(j=0;j<5;j++){
			if(check(r[j],&s[i],l)==0){
				break;
			}
			else{
				if(check(r[j],&s[i],l)==2&&s[i+l]=='\0'){
					break;
				}
				if(check(r[j],&s[i],l)==1){
					for(k=4;k>j;k--){
						copy(r[k-1],r[k],5);
					}
					copy(&s[i],r[j],l);
					if(s[i+l]=='\0'){
						break;
					}
				}
				l++;
			}
		}
	}

	printf("%s\n",r[x-1]);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int N;
    cin >> N;

    map<string, int> mp;

    rep(i, N)
    {
        string s;
        cin >> s;

        mp[s]++;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
 
using namespace std;
 
#define debug(a) cerr << #a << ": " << a << endl
 
typedef long long ll;
typedef pair<int, int> ii;
 
#define x first
#define y second
 
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int n;
char s[2 * N];
int a[2 * N];
ll ans = 1LL;

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
 
	cin >> n;
	scanf("%s", s + 1);
	for (int i = 1; i <= 2 * n; i++) a[i] = (s[i] == 'B');

	int k = 0;
	for (int i = 1; i <= 2 * n; i++) {
		if (a[i] % 2 != k % 2) k++;
		else {
			if (k == 0) {
				ans = 0;
				break;
			}

			ans *= k;
			ans %= MOD;
			k--;
		}
	}
	if (k != 0) ans = 0;

	for (int i = 1; i <= n; i++) {
		ans *= i;
		ans %= MOD;
	}

	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string
 
#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair
 
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>
 
#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >
 
#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>
 
 
#define forr(i,a,b) for (i = (a); i < (b); ++i)
#define rrof(i,a,b) for (i = (b)-1; i >= (a); --i)
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
 
const ll md = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);
 
ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}
 
ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}

int main()
{
    fast;
    ll n,d,a;
    cin>>n>>d>>a;
    vpll v;
    vll cor;
    for(int i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        v.pb({x,y});
        cor.pb(x);
    }
    sort(v.begin(),v.end());
    sort(cor.begin(),cor.end());
    ll dec=0;
    ll cnt=0;
    ll arr[n+1];
    for(int i=0;i<=n;i++)
     arr[i]=0;
    for(int i=0;i<n;i++)
    {
        dec-=arr[i];
        //cout<<"t "<<dec<<"\n";
         ll x,h;
         x=v[i].fr;
         h=v[i].se;
        h-=dec;
        if(h>0)
        {
           ll s=x+2*d;
           ll ind=ub(cor.begin(),cor.end(),s)-cor.begin();
           //cout<<ind<<"\n";
           ll c;
           if((h%a)==0)
            c=h/a;
            else
             c=(h/a)+1;
             arr[ind]+=a*c;
             cnt+=c;
             dec+=a*c;
        }
    }
    cout<<cnt<<"\n";
    return 0;
}

Measured memory_bytes: 9324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N, W;
    cin >> N >> W;
    int w[N], v[N];
    for(int i = 0; i < N; i++) cin >> w[i] >> v[i];

    ll dp[W + 1];
    for(int i = 0; i < W + 1; i++) dp[i] = -1;
    dp[0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = W; j >= 0; j--) {
            if(dp[j] == -1) continue;
            if(j + w[i] <= W) {
                dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i <= W; i++) ans = max(ans, dp[i]);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4412
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

string S;

int main() {

	cin >> S;



	cout << S.substr(0, 3) << endl;

	return 0;
}


Measured memory_bytes: 3628
# coding: utf-8
import fractions
N=int(input())
A=list(map(int,input().split()))
GL=[0]*N
GR=[0]*N
#初期値
GL[0]=A[0]
GR[N-1]=A[N-1]
#左から累積gcd
for i in range(N-1):
    GL[i+1]=fractions.gcd(GL[i],A[i+1])
#右から累積gcd
for i in range(N-1,0,-1):
    GR[i-1]=fractions.gcd(GR[i],A[i-1])

#print(GL,GR)

G=0
for i in range(1,N-1):
    G=max(fractions.gcd(GL[i-1],GR[i+1]),G)
    
print(max(G,GR[1],GL[N-2]))

Measured memory_bytes: 16120
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int h = std.nextInt();
        int w = std.nextInt();
        
        List<List<String>> tables = new ArrayList<>();
        for (int i = 0; i < h; i++) {
            tables.add(new ArrayList<>());
        }
        
        for (int i = 0; i < h; i++) {
            String line = std.next();
            String[] split = line.split("");
            for (int j = 0; j < split.length; j++) {
                tables.get(i).add(split[j]);
            }
        }
        
        for (int i = h - 1; i >= 0; i--) {
            List<String> lines = tables.get(i);
            if (!lines.contains("#")) {
                tables.remove(i);
            }
        }

        for (int i = w - 1; i >= 0; i--) {
            boolean none = true;
            for (List<String> line : tables) {
                if (line.get(i).equals("#")) {
                    none = false;
                    break;
                }
            }

            if (none) {
                for (List<String> line : tables) {
                    line.remove(i);
                }
            }
        }

        tables.forEach(it -> {
            System.out.println(String.join("", it));
        });
    }
}


Measured memory_bytes: 26836
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
using namespace std;
#define REP(i,n); for(int i = 0;i < (int)(n);i++)

int main() {
	int n;
	vector<int> a;
	
	cin >> n;
	a.resize(n);

	REP(i,n){
		cin >> a[i];
	}

	REP(i,n){
		if(a[i]%2 ==1){
			continue;
		}else if(a[i]%3==0){
			continue;
		}else if(a[i]%5==0){
			continue;
		}else{
			cout << "DENIED" <<endl;
			return 0;
		}
	}

	cout << "APPROVED" <<endl;

	return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin>>n;
	vector<int>vec(n*2);
	for(int i=0;i<2*n;i++) cin>>vec[i];
	sort(vec.begin(),vec.end());
	int sum=0;
	for(int i=0;i<2*n;i+=2){
		sum+=vec[i];
	} 
	cout<<sum<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 1000005
#define P 998244353
#define LL long long
using namespace std; 
struct node{
	int x,y;
}s[M];
bool cmpx(node A,node B){
	return A.x<B.x;
}
bool cmpy(node A,node B){
	return A.y<B.y;
}
int F2[M];
void Add(LL &x,int y){
	x+=y;
	if(x<0)x+=P;
	if(x>=P)x-=P;
}
int X[M],Y[M],n;
struct BIT{
	int C[M];
	void clear(){
		for(int i=1;i<=n;i++)C[i]=0;
	}
	void Add(int x){
		while(x<=n){
			C[x]++;
			x+=x&-x;
		}
	}
	int Query(int x){
		int res=0;
		while(x>0){
			res+=C[x];
			x-=x&-x;
		}
		return res;
	}
}bit;
int main(){ 
	cin>>n;
	F2[0]=1;
	for(int i=1;i<=n;i++)F2[i]=F2[i-1]*2%P;
	for(int i=0;i<n;i++){
		scanf("%d %d",&s[i].x,&s[i].y);
		X[i]=s[i].x;
		Y[i]=s[i].y;
	}
	sort(X,X+n);sort(Y,Y+n);
	for(int i=0;i<n;i++){
		s[i].x=lower_bound(X,X+n,s[i].x)-X+1;
		s[i].y=lower_bound(Y,Y+n,s[i].y)-Y+1; 
	} 
	LL ans=1LL*n*(F2[n]-1)%P; 
	bit.clear(); 
	for(int i=0;i<n;i++){ 
		Add(ans,-(F2[i]-1));
		Add(ans,-(F2[n-1-i]-1)); 
	}
	sort(s,s+n,cmpy);
	for(int i=0;i<n;i++){
		Add(ans,-(F2[i]-1));
		Add(ans,-(F2[n-1-i]-1));
	} 
	for(int i=0;i<n;i++){ 
		Add(ans,F2[bit.Query(s[i].x)]-1);//<x,<y
		Add(ans,F2[i-bit.Query(s[i].x)]-1);//>x,<y
		bit.Add(s[i].x);
	}
	bit.clear(); 
	for(int i=n-1;i>=0;i--){  
		Add(ans,F2[bit.Query(s[i].x)]-1);//<x,>y
		Add(ans,F2[n-1-i-bit.Query(s[i].x)]-1);//>x,>y;
		bit.Add(s[i].x); 
	} 
	cout<<ans<<endl; 
	return 0;
}

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

int a, b, c;

int main(){
  cin >> a >> b >> c;
  set<int> res;
  res.insert(a);
  res.insert(b);
  res.insert(c);
  if(res.size() == 2){
    cout << "Yes" <<endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
using namespace std;

struct Point { double x, y; };

void koch(int n, Point a, Point b) {
	if (n == 0) return;

	Point s, t, u;
	double th = 3.141592653589793 * 60.0 / 180.0;

	s.x = (2.0*a.x + 1.0*b.x) / 3.0;
	s.y = (2.0*a.y + 1.0*b.y) / 3.0;
	t.x = (1.0*a.x + 2.0*b.x) / 3.0;
	t.y = (1.0*a.y + 2.0*b.y) / 3.0;
	u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;
	u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;

	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, b);
}

int main() {
	Point a, b;
	int n;

	scanf("%d", &n);

	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;

	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);

	return 0;
}


Measured memory_bytes: 2600
#include <iostream>
#define LIMIT 51
using namespace std;

void dfs(int v, int n, bool **graph, bool *visited) {
    visited[v] = true;
    for(int v2 = 0; v2 < n; ++v2) {
        if (graph[v][v2] == false) { continue; }
        if (visited[v2] == true) { continue; }
        dfs(v2, n, graph, visited);
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    int *a = (int*)malloc(LIMIT * sizeof(int));
    int *b = (int*)malloc(LIMIT * sizeof(int));
    bool **graph = (bool**)malloc(LIMIT * sizeof(bool*));
    for(int i = 0; i < LIMIT; ++i) {
        graph[i] = (bool*)malloc(LIMIT * sizeof(bool));
    }
    bool *visited = (bool*)malloc(LIMIT * sizeof(bool));

    for(int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for(int i = 0; i < m; ++i) {
        //辺を切り離す
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        for(int j = 0; j < n; ++j) { visited[j] = false; }

        dfs(0, n, graph, visited);

        bool bridge = false;
        for(int j = 0; j < n; ++j) {
            if(visited[j] == false) { bridge = true; }
        }
        if(bridge) { ans += 1; }
        //辺をもとに戻す
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << ans << endl;
    free(a); free(b); free(graph); free(visited);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

ll N, K;
string S;
int main() {
    cin >> N >> K >> S;

    ll score = 0;
    rep(i, N - 1) {
        if (S[i] == S[i + 1]) score++;
    }

    // K 回で +2 できる
    ll ans = min(N - 1, score + 2 * K);
    cout << ans << endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

cnt = {}

for a in A:
    cnt.setdefault(a, 0)
    cnt[a] += 1

cnt_filter = list(filter(lambda x: x[1] >= 2, cnt.items()))
cnt_filter.sort(key=lambda x: x[0], reverse=True)

x = 0
y = 0

if len(cnt_filter) >= 2:
    x = cnt_filter[0][0]
    y = cnt_filter[1][0]
    if cnt_filter[0][1] >= 4:
        y = x

ans = x * y

print(ans)


Measured memory_bytes: 18060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    string s;
    cin>>s;
    if(s[s.size()-1] == 's'){
        cout<<s<<"es"<<endl;
    }
    else{
        cout<<s<<"s"<<endl;
    }

}

Measured memory_bytes: 3668
N = int(input())
a = [[0 for _ in range(10)] for _ in range(10)]
ans = 0

for i in range(1, N+1):
    a[int(str(i)[0])][int(str(i)[-1])] += 1

for i in range(10):
    for j in range(10):
        ans += a[i][j]*a[j][i]

print(ans)

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

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;
const int MOD = 1000000007;

typedef long long ll;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

using Graph = vector<vector<int>>;

// typedef pair<int, int> P;
int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 1;
    rep(i, n - 1)
    {
        if (s.at(i) != s.at(i + 1))
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*

//

fun main() {
    abc176e()
}

fun abc176e() {
    val (h, w, m) = readLine()!!.split(" ").map { it.toInt() }
    val bom = mutableMapOf<Int, MutableSet<Int>>()
    val countH = IntArray(h + 1) { 0 }
    val countW = IntArray(w + 1) { 0 }
    var maxH = 0
    val maxHIndices = mutableSetOf<Int>()
    var maxW = 0
    val maxWIndices = mutableSetOf<Int>()
    repeat(m) {
        val (ih, iw) = readLine()!!.split(" ").map { it.toInt() }
        if (ih in bom) {
            bom[ih]!!.add(iw)
        } else {
            bom[ih] = mutableSetOf(iw)
        }
        countH[ih]++
        if (countH[ih] > maxH) {
            maxH = countH[ih]
            maxHIndices.clear()
            maxHIndices.add(ih)
        } else if (countH[ih] == maxH) {
            maxHIndices.add(ih)
        }
        countW[iw]++
        if (countW[iw] > maxW) {
            maxW = countW[iw]
            maxWIndices.clear()
            maxWIndices.add(iw)
        } else if (countW[iw] == maxW) {
            maxWIndices.add(iw)
        }
    }
    for (th in maxHIndices) {
        for (tw in maxWIndices) {
            if (bom[th]?.contains(tw)?.not() ?: false) {
                println(maxH + maxW)
                return
            }
        }
    }
    println(maxH + maxW - 1)
}


Measured memory_bytes: 219988
#include <iostream>
using namespace std;
int cmb(int n, int x) {
  int i, j, k;
  int cnt = 0;
  for(i = 1; i <= n - 2; i++) {
	for(j = i + 1; j <= n - 1; j++) {
	  for(k = j + 1; k <= n; k++) {
		  if(i + j + k == x) {
			cnt++;
		  }
	  }
	}
  }
  return cnt;
}
int main() {
  int  n, x;
  while(cin >> n >> x) {
	if(n == 0 && x == 0) { break; }
	cout << cmb(n, x) << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'
#define INF (1ll << 60)

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
const int MOD = 1e9 + 7;

int n;

signed main() {
  cin >> n;
  int cnt = n % 10;

  if (cnt == 2 || cnt == 4 || cnt == 5 || cnt == 7 || cnt == 9) {
    cout << "hon" << endl;
  } else if (cnt == 3) {
    cout << "bon" << endl;
  } else {
    cout << "pon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
N = int(input())
if N % 2 == 0:
    ans = []
    for i in range(1, N+1):
        for j in range(1, i):
            if i + j != N + 1:
                ans.append((i, j))
else:
    ans = []
    for i in range(1, N+1):
        for j in range(1, i):
            if i + j != N:
                ans.append((i, j))
print(len(ans))
for s in ans:
    print(*s)

Measured memory_bytes: 44784
#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
#define MAX 200200
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,a[MAX],Q[MAX],top;
int l[MAX],r[MAX];
ll ans;
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=read(),l[i]=1,r[i]=n;
	top=0;
	for(int i=1;i<=n;++i)
	{
		while(top&&a[Q[top]]>a[i])--top;
		if(top)l[i]=Q[top]+1;
		Q[++top]=i;
	}
	top=0;
	for(int i=n;i>=1;--i)
	{
		while(top&&a[Q[top]]>a[i])--top;
		if(top)r[i]=Q[top]-1;
		Q[++top]=i;
	}
	for(int i=1;i<=n;++i)ans+=1ll*(i-l[i]+1)*(r[i]-i+1)*a[i];
	cout<<ans<<endl;
	return 0;
}


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

 int main()
{
    std::string str;
    int N;
    cin >> N;
    str = std::to_string(N);
    if (str.find("7") != std::string::npos) {
   cout << "Yes" << endl; }
   else{
       cout << "No" << endl;
   }
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int n, d, x;
    cin >> n >> d >> x;
    VV p(d, V(n));
    rep(k, d) rep(i, n) cin >> p[k][i];

    rep(k, d - 1) {
        // cout << "day " << k << ":" << endl;
        V dp(x + 1, -inf);
        dp[x] = 0;
        rep(i, n) {
            for (int j = x - p[k][i]; j >= 0; j--) {
                // cout << i << " " << j << endl;
                dp[j] = max(dp[j], dp[j + p[k][i]] + p[k + 1][i]);
            }
            // rep(j, x + 1) {
            //     cout << dp[j] << " ";
            // }
            // cout << endl;
        }



        int t = -1;
        rep(j, x + 1) t = max(t, j + dp[j]);
        x = t;

        // cout << x << endl;

        // V dp(x + 1, -inf);
        // dp[0] = 0;
        // rep(i, n) {
        //     for (int j = p[k][i]; j <= x; j++) {
        //         cout << i << " " << j << endl;
        //         dp[j] = max(dp[j], dp[j - p[k][i]] + p[k + 1][i]);
        //     }
        // }

        // rep(j, x + 1) {
        //     cout << (dp[j] < 0 ? -1 : dp[j]) << " ";
        // }
        // cout << endl;
        //
        // x = max(x, *max_element(all(dp)));


    }
    cout << x << endl;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(ALL(a)); sort(ALL(c));
    ll ans = 0;
    rep(j, n) {
        auto i = lower_bound(ALL(a), b[j]) - a.begin();
        auto k = upper_bound(ALL(c), b[j]) - c.begin();
        ans += (ll)i*(ll)(n-k);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <cstdio>

int main(){
    char s[4];
    scanf("%s",s);
    int count = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'o'){
            count++;
        }
    }
    printf("%d\n",700 + 100 * count);

    return 0;
}

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

using namespace std;

int main()
{
    long long n,a[51],x,s=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            s=s+(a[i]*a[j]);
        }
    }
    cout<<s;
    return 0;
}


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

int main()
{
  double n;
  cin >> n;
  n /= 3.0;
  cout << fixed << setprecision(20) << n * n * n << endl;

  return 0;
}

Measured memory_bytes: 3720
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

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

using namespace std;
long long int x;
long long int ans;

int main(){
  cin >> x;
  ans = x / 11 * 2;
  x = x % 11;
  if(1<=x&& x<=6) ans ++;
  else if (7<=x) ans += 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    
    int n,x;
    cin >> n;
    for (int i = 1; i<=n ; i++) {
        x=i;
        if (x%3 == 0) {
            cout << " " << i;
        }
        else{
            do  {
                if  (x%10 == 3) {
                    cout << " " << i;
                    break;
                }else{
                x /=10;
                }
            
            }while (x);
            }
    }
            cout << endl;
    // insert code here...
   // std::cout << "Hello, World!\n";
    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
    int main(void){
     int count=1;
     long long X,Y,i,j;
     scanf("%lld",&X);
     scanf("%lld",&Y);
     i=X;
     while(Y>=i){
     j=2*i;
     if(j<=Y) count++;
     i=j;
     }
     printf("%d",count);
     return 0;
    }

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define int long long
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 5, MOD1 = 1e9 + 7, MOD2 = 998244353;
const lint INF = 1e18;

signed main()
{
    int x;
    cin >> x;
    int g = gcd(x, 360);
    cout << 360/g << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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 OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// n個までの部分問題、重さの総和w以下、価値の最大
vvll dp(100, vll(100001, 0));

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll N, W;
    cin >> N >> W;
    vll w(N), v(N);
    rep(i, N){
        cin >> w[i] >> v[i];
    }
    rep(i, W+1){
        if(i >= w[0]){
            dp[0][i] = v[0];
        }
    }
    repr(i, 1, N){
        rep(j, W+1){
            if(j >= w[i]){
                dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << dp[N-1][W] << endl;
    return 0;
}

Measured memory_bytes: 79360
import math

n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())

    s = 0.5*((x1-x3)*(y2-y3) - (x2-x3)*(y1-y3))
    a = (x2-x3)**2 + (y2-y3)**2
    b = (x1-x3)**2 + (y1-y3)**2
    c = (x2-x1)**2 + (y2-y1)**2

    rx = (a*(b+c-a)*x1 + b*(c+a-b)*x2 + c*(a+b-c)*x3)/(16*s**2)
    ry = (a*(b+c-a)*y1 + b*(c+a-b)*y2 + c*(a+b-c)*y3)/(16*s**2)
    r = math.sqrt((rx-x1)**2 + (ry-y1)**2)
    print( "{0:.3f} {1:.3f} {2:.3f}".format(rx+0, ry+0, r+0))

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

int main(){
  int N;
  cin >>N;
  
  vector<int> x(N+1,0), y(N+1,0), t(N+1,0);
  for (int i=0; i<N; i++){
    cin >>  t.at(i+1) >>x.at(i+1) >>y.at(i+1);
  }
  
  string ans = "Yes";
    bool flag = false;
  for (int i=1; i<N+1; i++){
    int sum = 0;
    sum += x.at(i) - x.at(i-1);
    sum += y.at(i) - y.at(i-1);
    if( (t.at(i)-t.at(i-1) != sum) && ((t.at(i)-t.at(i-1)-sum)%2) != 0){
      ans = "No";
      flag =true;
    }
    if(t.at(i)-t.at(i-1)-sum < 0){
      ans = "No";
      flag =true;
    }
    if (flag) break;
  }
  
  cout << ans <<endl;
  
}

Measured memory_bytes: 1408
let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readIntArray() = readStringArray() |> Array.map (fun x -> int x)

let a, b, c = readIntArray() |> fun x -> (x.[0], x.[1], x.[2])

if b - a = c - b then "YES" else "NO"
|> printfn "%s"

Measured memory_bytes: 14040
x1,y1,x2,y2=map(int,input().split())
X,Y=x2-x1,y2-y1
print('U'*Y+'R'*X+'D'*Y+'L'*X+'L'+'U'*(Y+1)+'R'*(X+1)+'D'+\
      'R'+'D'*(Y+1)+'L'*(X+1)+'U')

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

int main() {
  int a;
  cin >> a;
  int b = a/1000;
  int c = a%1000/100;
  int d = a%1000%100/10;
  int e = a%1000%100%10;
  if (b == c && c == d ){
    cout << "Yes" << endl;
  }
  else if (c == d && d == e ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
x1, y1, x2, y2 = map(int, input().split())
x = abs(x1 - x2)
y = abs(y1 - y2)
a = ""
a += ("U" * y + "R" * x + "D" * y + "L" * x)
a += ("L" + "U" * (y + 1) + "R" * (x + 1) + "D" + "R" + "D" * (y + 1) + "L" * (x + 1) + "U")
print(a)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define fo(i,a) for(i = 0;i < a;i++)
using namespace std;

int main(void)
{
	int t,h,s[4]={0};
	
	fo(t,4){
		cin >> s[t];
	}
	sort(s,s+4);
	cin >> h;
	cin >> t;
	s[0] = max(h,t);
	cout << s[0]+s[1]+s[2]+s[3] << endl;
	
	return 0;
}

Measured memory_bytes: 3104
/*input
3
a
b
c
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
string s[maxn];
int main()
{
	IOS;
	int n,l;
	cin>>n>>l;
	REP(i,n) cin>>s[i];
	sort(s,s+n);
	REP(i,n) cout<<s[i];
	return 0;
}


Measured memory_bytes: 2688
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int t[n];
  int s = 0;
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    s += t[i];
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int p, x;
    cin >> p >> x;
    cout << s - t[p - 1] + x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=jp
#????????¢?´¢
#???????????§???????????°????????????????????¢?????´????????????????????????????????¢?????´???????????¨????????????????????????
def binary_search(list_1, list_2):
    count = 0

    for b in list_2:
        left_index = 0
        right_index = len(list_1)
        
        while left_index < right_index:
            center = int((left_index + right_index) / 2)
            if list_1[center] == b:
                count += 1
                break
            elif b < list_1[center]:
                right_index = center
            elif b > list_1[center]:
                left_index = center + 1
                
    return count

if __name__ == "__main__":
    n_listA = int(input())
    a = sorted(set([n for n in input().split()]))
    n_listB = int(input())
    b = [n for n in input().split()]
    print(binary_search(a,b))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  string s, t;
  cin>>s>>t;
  bool ok=true;
  REP(i, s.size()){
    if(s[i]!=t[i]){
      ok=false;
      break;
    }
  }
  cout<<(ok ? "Yes" : "No")<<'\n';
  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define printV(v) for(int i=0;i<v.size();i++){cout << v[i]<< " ";} cout << endl
#define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
#define sortV(v) sort(v.begin(),v.end())
#define revV(v) reverse(v.begin(),v.end())
#define FOR(i,n) for(int i=0;i<n;i++)
    
    ll a,b,c,d,e,f,g,n,m,k,t,p,x,h,w,q;
    ll curr = 1;
    ll mod = 998244353;


    void solve(){
       cin >> n >>m;
       ll sum = 0;
       vector<ll> v(n);
       FOR(i,n){
           cin >> v[i];
           sum += v[i];
       }
       sortV(v);
       revV(v);
       FOR(i,m){
           if(4 * m * v[i]<  sum ){
               cout << "No";
               return;
           }
       }
       cout << "Yes";
    }
  
   
    int main(){
    ios_base::sync_with_stdio(false);
   
    int cases = 1;
    //cin >> cases;
  
    while(cases--){ 
        solve();
    }

    return 0;

    }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

int vis[100100];
ll val[100100];
vector<vector<pii> > E;
pll rng(0,1e9+10);

void dfs(int n, int p, int s, ll a) {
	//cout << n<< " " << p << endl;
	if(vis[n]) {
		//cout << "hoge" << endl;
		if(vis[n] == s) {
			if(val[n] != a)
				rng.se = -1;
		}
		else {
			ll tmp = val[n] - a;
			if(s < 0)
				tmp = -tmp;

			if(tmp % 2 || tmp <= 0)
				rng.se = -1;
			else {
				rng.fi = max(rng.fi, tmp / 2);
				rng.se = min(rng.se, tmp / 2);
			}
		}
		return;
	}
	else {
		vis[n] = s;
		val[n] = a;
		if(s > 0)
			rng.fi = max(rng.fi, 1-a);
		else
			rng.se = min(rng.se, a-1);
	}
	rep(i,E[n].size()) {
		if(E[n][i].fi != p) {
			dfs(E[n][i].fi, n, -s, E[n][i].se - a);
		}
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	E.resize(n);
	rep(i,m) {
		int u, v, s;
		cin >> u >> v >> s;
		u--; v--;
		E[u].push_back(pii(v,s));
		E[v].push_back(pii(u,s));
	}
	/*
	rep(i,n) {
		cout << "*" << i << ": ";
		rep(j,E[i].size())
			cout << E[i][j].fi << " ";
		cout << endl;
	}
	// */
	dfs(0,-1,1,0);
	//cout << rng.fi << " " << rng.se << endl;
	if(rng.fi <= rng.se) {
		cout << rng.se - rng.fi + 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 13184