akhauriyash/Code-Regression huggingface dataset:
//C - Be Together: 
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, media1, media2, ans1, ans2;
    double soma;
    bool equal = false;

    cin >> n;
    vector<int> nums(n);
    soma = 0;
    loop(i, 0, n) {
        cin >> nums[i];
        soma += nums[i];
    }
    if((soma / n) == nums[0]) equal = true;
    media1 = ceil(soma / n);
    media2 = soma / n; 
    ans1 = ans2 = 0;
    loop(i, 0, n) {
        ans1 += pow((nums[i] - media1), 2);
        ans2 += pow((nums[i] - media2), 2);
    }
    if(equal) cout << "0\n";
    else cout << min(ans1, ans2) << '\n';
}

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

map<int,bool> has;

int main()
{
	int n,a,ans=0;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&a);
		if(has[a]==1) ans--;
		else ans++;
		has[a]^=1;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 4864
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var hs=new Dictionary<string,int>();
		int p=1,o=n;
		for(int i = 0;i<n;i++) {
			var e=sc.S;
			if(hs.ContainsKey(e)){
				hs[e]++;
				int z=hs[e];
				if(p<z){p=z;o=1;}
				else if(p==z){o++;}
			}
			else{hs.Add(e,1);}
		}
		var a=new string[o];
		int j=0;
		foreach(var e in hs){
			if(e.Value==p){
				a[j]=e.Key;
				j++;
			}
		}
		a=a.OrderBy(x=>x,StringComparer.Ordinal).ToArray();
		Console.WriteLine(String.Join("\n",a));
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 52472
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0012
{
    class Program
    {
        static void Main(string[] args)
        {
            string str;
            while ((str = Console.ReadLine()) != null)
            {
                string[] strList = str.Split(' ');
                double x1 = double.Parse(strList[0]);
                double y1 = double.Parse(strList[1]);
                double x2 = double.Parse(strList[2]);
                double y2 = double.Parse(strList[3]);
                double x3 = double.Parse(strList[4]);
                double y3 = double.Parse(strList[5]);
                double xp = double.Parse(strList[6]);
                double yp = double.Parse(strList[7]);
                double t = 0;
                double s = 0;
                if (x1 == x2)
                {
                    t = (((yp - y3) * (x2 - x3) - (xp - x3) * (y2 - y3)) / ((y1 - y3) * (x2 - x3) - (x1 - x3) * (y2 - y3)));
                    s = (((xp - x3) - t * (x1 - x3)) / (x2 - x3));
                }
                else
                {
                    t = (((yp - y1) * (x2 - x1) - (xp - x1) * (y2 - y1)) / ((y3 - y1) * (x2 - x1) - (x3 - x1) * (y2 - y1)));
                    s = (((xp - x1) - t * (x3 - x1)) / (x2 - x1));
                }
                if ((0 < s && s < 1) && (0 < t && t < 1) && (0 < 1 - s - t && 1 - s - t < 1))
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }

            }
        }
    }
}



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

const int MAX = 3e5 + 5;
pair <int, int> v[MAX];

int main() {
	int n; scanf("%d", &n);

	vector <int> a(n + 1);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);

	reverse(a.begin() + 1, a.end());

	int m = 0;
	for(int i = 1; i <= n; i++) {
		int p = lower_bound(v + 1, v + m + 1, make_pair(a[i], (int) 1e9 + 5)) - v; //para permitir elementos iguales cambiar el 0 por INF, ej: 1e9
		v[p] = { a[i], i };

		if(p == m + 1)
			m++;

	}

	printf("%d\n", m);

	return 0;
}

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

std::vector<int>::iterator find(std::vector<int>, int);

int main()
{
    int n, m, count{};
    std::set<int> vertice[50];
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        vertice[a - 1].insert(b - 1);
        vertice[b - 1].insert(a - 1);
    }
    bool updated{true};
    while (updated)
    {
        updated = false;
        for (int i = 0; i < n; i++)
        {
            if (vertice[i].size() == 1)
            {
                updated = true;
                count++;

                int b = *vertice[i].begin();
                vertice[b].erase(i);
                vertice[i].erase(b);
            }
        }
    }
    printf("%d\n", count);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int n,x,a[110];
int main() {
	scanf("%d%d",&n,&x);
	rep(i,0,n) scanf("%d",a+i);
	ll s=0;
	sort(a,a+n);
	rep(i,0,n) {
		s+=a[i];
		if (s>x) {
			printf("%d\n",i);
			return 0;
		}
	}
	if (s==x) printf("%d\n",n); else printf("%d\n",n-1);
}


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

int main()
{
    int H, W, N;
    int Sr, Sc;
    scanf("%d %d %d", &H, &W, &N);
    scanf("%d %d", &Sr, &Sc);
    char *S = (char*)malloc(sizeof(char)*N + 1);
    char *T = (char*)malloc(sizeof(char)*N + 1);
    scanf("%s", S);
    scanf("%s", T);

    int dir[4] = {Sc, Sc, Sr, Sr};
    for(int i = 0; i < N; i++){
      
      switch (S[i]) {
        case 'L':
          dir[0]--;
          if(dir[0] <= 0){
            printf("NO\n");
            return 0;
          }
          break;
        case 'R':
          dir[1]++;
          if(dir[1] > W){
            printf("NO\n");
            return 0;
          }
          break;
        case 'U':
          dir[2]--;
          if(dir[2] <= 0){
            printf("NO\n");
            return 0;
          }
          break;
        case 'D':
          dir[3]++;
          if(dir[3] > H){
            printf("NO\n");
            return 0;
          }
          break;
      }

      switch (T[i]) {
        case 'L':
          if( dir[1] > 1 ) 
            dir[1]--;
          break;
        case 'R':
          if( dir[0] < W )
            dir[0]++;
          break;
        case 'U':
          if( dir[3] > 1 )
            dir[3]--;
          break;
        case 'D':
          if( dir[2] < H )
            dir[2]++;
          break;
      }
    }
    // 出力
    printf("YES\n");
    return 0;
}

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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  ll n;
  cin>>n;
  vector<P> v;
  rep(i,n){
    ll a,b; cin>>a>>b;
    v.eb(make_pair(b,a));
  }
  sort(all(v));
  ll time=0;
  bool f=true;
  rep(i,n){
    time+=v[i].se;
    if(v[i].fi<time) f=false;
  }
  //outvp(v);
  YesNo(f);
}

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


Measured memory_bytes: 6512
#include <stdio.h>

int main(void) {
	int m[1024],d[1024],l,t,n,i;
	while(scanf("%d %d",&l,&t) , l != 0){
		n = 1;
		for(i = 1;i <= l;i++){
			scanf("%d",&m[i]);
		}
		for(i = 1;i <= t;i++){
			scanf("%d",&d[i]);
		}
		for(i = 1;i <= t;i++){
			n+=d[i];
			if(n >= l){
				printf("%d\n",i);
				break;
			}
			else{
				n+=m[n];
			}
			if(n >= l){
				printf("%d\n",i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 608
package main

import "fmt"

func main() {
	// Code for B - Digital Gifts
	var N int
	fmt.Scanf("%d", &N)

	var x float64
	var u string
	var answer float64 = 0
	for i := 0; i < N; i++ {
		fmt.Scanf("%f %s", &x, &u)
		if u == "JPY" {
			answer += x
		} else {
			answer += x * 380000
		}
	}
	fmt.Printf("%f\n", answer)
}


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

int main(){
	int count[26];/*出現回数を数える変数を文字の種類分だけ用意*/
	for(int i=0;i<26;i++){
		count[i] = 0;
	}
	while(1){ //
		char s[1201];
		//int ret = scanf("%[^\n]",s);
		if(fgets(s,10000,stdin) == NULL){ //一行の入力制限
			break;
		}

		int n = strlen(s); //文字列の長さを返す
		//while (s[i] == true){/*配列strのi番目の文字がNULL文字(文字列の終端)ではない間*/
		for(int i = 0;i<n;i++){
			if (s[i] >= 'a' && s[i] <= 'z'){
				count[(int)s[i] - 'a']++;/*小文字*/
			}
			else if (s[i] >= 'A' && s[i] <= 'Z'){
				count[(int)s[i] - 'A']++;/*大文字*/

			}
		}
	}
	for (int i=0; i<26; i++) {
		printf("%c : %d\n", 'a' + i, count[i]);
	}
	return 0;
}


	/*
	   与えられた英文に含まれる
	   各アルファベットの数を数えるプログラムを作成して下さいなお
	   小文字と大文字は区別しません。
	   */





Measured memory_bytes: 2032
N,M = map(int,input().split())
info_lst=[]
for _ in range(N):
	a,b = map(int,input().split())
	info_lst.append((a,b))

cost = 0
for a,b in sorted(info_lst):
	cost += a*min(b,M)
	M -= b
	if M <= 0:
		break
print(cost)

Measured memory_bytes: 17680
#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	vector<vector<int> > G(n, vector<int>(n));
	for (int i = 0; i < n; ++i)
	{
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; ++j)
		{
			int v;
			cin >> v;
			G[u - 1][v - 1] = 1;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n - 1; ++j)
		{
			cout << G[i][j] << " ";
		}
		cout << G[i][n - 1] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1256
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

bool check(ll ans, vector<ll> &a, ll k)
{

    if(ans == 0)
    {
        return false;
    }

    ll count = 0;
    int n = a.size();
    for(int i = 0; i < n; i++)
    {
        count += a[i] / ans - 1;
        if(a[i] % ans)
        {
            count++;
        }
    }

    if(count <= k)
    {
        return true;
    }

    return false;

}

void solve()
{
    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);

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

    ll lo = 0;
    ll high = 1e9;
    ll ans = high;
    
    while(lo <= high)
    {
        ll mid = lo + (high - lo) / 2;
        bool is_valid = check(mid, a, k);

        if(is_valid)
        {
            ans = mid;
            high = mid - 1;
        }
        else {
            lo = mid + 1;
        }
    }

    cout << ans << "\n";

}

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

    int T = 1;
    //cin >> T;
    
    while (T--)
    {
        solve();
    }
    
    return 0;
}




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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;
const int MOD=1e9+7;

const int MAX_H=30,MAX_W=30;

int H,W,K;
char C[MAX_H][MAX_W+1];

char temp[MAX_H][MAX_W+1];

int solve(int h,int w){
	bool flg=false;
	int res=0;
	int b=1;
	memcpy(temp,C,sizeof(C));
	for(int i=h;i>0;i--){
		temp[i][w]=temp[i-1][w];
	}
	temp[0][w]='0';
	do{
		flg=false;
//		fprintf(stderr,"%d\n",b);
		REP(y,H){
			for(int x=0;x<W;){
//				fprintf(stderr,"%d %d\n",x,y);
				if (temp[y][x]=='0'){
					x++;
					continue;
				}
				int l,u;
				l=x;
				u=l+1;
				while(u<W && temp[y][u]==temp[y][l]) u++;
				if (u-l>=K){
					res+=(temp[y][l]-'0')*(u-l)*b;
					FOR(i,l,u){
						temp[y][i]='0';
					}
					flg=true;
				}
				x=u;
			}
		}
		REP(x,W){
			int a=H-1;
			REP(y,H){
				if (temp[H-y-1][x]!='0'){
					temp[a--][x]=temp[H-y-1][x];
				}
			}
			REP(y,a+1){
				temp[y][x]='0';
			}
		}
		b*=2;
	}while(flg);
	return res;
}

int main(){
	scanf("%d %d %d",&H,&W,&K);
	REP(i,H){
		scanf("%s",C[i]);
	}
	int ans=0;
	FOR(y,1,H){
		REP(x,W){
			ans=max(ans,solve(y,x));
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
vector<int> s1(100005),s2(100005);
void gen(int n)
{
    for(int i=0;i<n;i++)
    {
        if(i%2) {s1[i]=0;s2[i]=1;}
        else {s1[i]=1;s2[i]=0;}
    }
}

int main()
{
    while(cin>>s)
    {
        gen(s.length());
        int dif1=0,dif2=0;
        for(int i=0;i<s.length();i++)
        {
            if(s[i]-'0'!=s1[i]) dif1++;
            if(s[i]-'0'!=s2[i]) dif2++;
        }
        cout<<min(dif1,dif2)<<"\n";
    }

}


Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

// BIT (Fenwick Tree) with 0-indexed query
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0) : n(n), d(n+1) {}
  void add(int i, T x=1) {
    i++; // 0-indexed to 1-indexed
    for (; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  // The sum of [0, i]
  T sum(int i) {
    i++; // 0-indexed to 1-indexed
    T x = 0;
    for (; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  // The sum of [l, r)
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

// int main(int argc, char** argv) {
//   int N;
//   cin >> N;
//   vector<int> v(N);
//   rep(i, N) {
//     cin >> v[i];
//   }
//
//   BIT<int> bit(N);
//   rep(i, N) {
//     bit.add(i, v[i]);
//   }
//
//   cout << bit.sum(4) << endl; // sum of [0,4]. 24
//   cout << bit.sum(9) << endl; // sum of [0,9]. 55
// }

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n,q;
  cin >> n >> q;
  BIT<ll> bit(n+1);
  while (q--) {
    ll type;
    cin >> type;
    if (type == 0) {
      ll s,t,x;
      cin >> s >> t >> x;
      bit.add(s,x);
      bit.add(t+1,-x);
    } else { // type == 1
      ll i;
      cin >> i;
      cout << bit.sum(i) << endl;
    }
  }
}



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

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

	int n[2] = { 0,0 };
	string s[2] = { "", "" };
	for (int i = 0; i < S.size(); ++i)
	{
		string str = S.substr(i, 1);
		if (s[0] == "")
		{
			s[0] = str;
			n[0] = 1;
		}
		else if (s[0] == str)
		{
			n[0]++;
		}

		else if (s[1] == "")
		{
			s[1] = str;
			n[1] = 1;
		}
		else if (s[1] == str)
		{
			n[1]++;
		}
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}

	if (n[0] == 2 && n[1] == 2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;

ll getFirst(ll n)
{
	ll ans = n;
	while(n>0)
	{
		ans = n;
		n/=10;
	}

	return ans;
}

int main()
{
	speedup_IO;
	ll n;
	cin>>n;

	map<pll,ll>Map,Map2;

	forn(i,1,n+1)
	{
		Map[{getFirst(i),i%10}]++;
	}

	ll ans = 0;
	for(auto x:Map)
	{
		ans += x.second*(Map[{x.first.second,x.first.first}]);
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 01.01.2018 23:47:18       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  int tt;
  cin >> tt;
  while (tt--) {
    long long a, b, from, to;
    cin >> a >> b >> from >> to;
    long long x = (a + b) / (min(a, b) + 1);
    long long low = 0, high = a;
    while (low < high) {
      long long mid = (low + high + 1) >> 1;
      long long remB = b - max(0LL, mid - 1) / x;
      long long remA = a - mid;
      if (remB <= (remA + 1) * x) {
        low = mid;
      } else {
        high = mid - 1;
      }
    }
    long long bound = low + max(0LL, low - 1) / x;
    for (long long pos = from; pos <= to; pos++) {
      char res;
      if (pos <= bound) {
        res = (pos % (x + 1) == 0 ? 'B' : 'A');
      } else {
        res = ((a + b - pos + 1) % (x + 1) == 0 ? 'A' : 'B');
      }
      cout << res;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	int a[n];
	for (int i = 0; i < n; i++)cin >> a[i];	

	int b[n] = { };
	for (int i = 0; i < n; i++) {
		b[a[i]-1]++;
	}
	sort(b, b + n);
	int count = 0;
	for (int i = 0; i < n - k; i++)count += b[i];
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main(void)
{
    long long n;
    cin >> n;
    for (int i = 1; i <= 9; i++)
    {
        long long ans = i * 100 + i * 10 + i;
        if (n <= ans)
        {
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <iomanip>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
int main(void){
    int k,p,r;
    ll n,cnt = 0;
    cin >> n >> k;
    if(k == 0){
        cout << n*n << endl;
        return 0;
    }
    for(int b = 1;b <= n;b++){
        r = (n%b);
        p = (n/b);
        cnt += (p*max(b-k,0)+max(r+1-k,0));
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string s,t,u;
    int a,b;
    cin >> s>>t>>a>>b>>u;
    if(u==s){
        a--;
    }else{
        b--;
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

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

int main(){
    int k,x; cin >> k >> x;
    int range = 2 * (k-1) + 1;
    for(int i = 1; i <= range; ++i){
    	  int ans = x -k +i;
          cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 384
/**
 * @author pr4shan7 (प्रशांत)
 */
// everything has a cost!

#ifdef _MAVERICK
#define _DEBUG
#else
#pragma GCC optimize("O2", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx,avx2,fma")
// #pragma GCC reset_options
#endif

#ifndef _DEBUG
#define NDEBUG
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'
// #define cerr cout
// #define int long long
// #define double long double

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_set;
typedef unordered_set<int> usi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef set<int> si;
typedef long long ll;
#define pb push_back
#define x first
#define y second
#define cai static_cast<int>
#define cad static_cast<double>
#define cal static_cast<long long>
#define all(z) z.begin(), z.end()
#define tr(cont, itm) for (auto&& itm : cont)
#define rep(in, beg, sz) for (int in = beg; in < sz; in++)
#define rrep(in, sz, beg) for (int in = sz - 1; in >= beg; in--)
#define rtr(cont, itr) for (auto itr = cont.end() - 1; itr >= cont.begin(); itr--)

#ifdef _DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

template <typename... T> inline void debug_out(const T&...);
#else
#define debug(...) 42
#endif

template <typename T> inline istream& operator>>(istream& in, vector<T>& ar);
template <typename T> inline ostream& operator<<(ostream& out, const vector<T>& ar);
template <typename T> constexpr inline T pow(long long, long long, const T);

const int N = 1e5 + 5;
const int INF = 1e9;
const int MV = 1e9 + 7;

// beautiful things don't ask for attention

string rev(string s) {
	string n; n.resize(s.length());
	rep(i,0,s.length()) {
		n[i]=s[s.length()-1-i];
	}
	return n;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

#ifdef _MAVERICK
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif

	string s; cin >> s;
	bool b{false};
	int n = s.length();
	if(s==rev(s) && s.substr(0,(n-1)/2)==rev(s.substr(0,(n-1)/2)) && s.substr((n+1)/2,(n-1)/2)==rev(s.substr((n+1)/2,(n-1)/2)))
		b=true;

	if(b) cout << "Yes";
	else cout << "No";

	return 0;
}


#ifdef _DEBUG
template <typename... T>
inline void debug_out(const T&... args) { ((cerr << ' ' << args), ...); cerr << endl; }
#endif

template <typename T>
inline istream& operator>>(istream& in, vector<T>& ar) {
	for (auto& i : ar) in >> i;
	return in;
}

template <typename T>
inline ostream& operator<<(ostream& out, const vector<T>& ar) {
	for (int i = 0; i < ar.size() - 1; i++) out << ar[i] << ' ';
	out << ar[ar.size() - 1];
	return out;
}

template <typename T>
constexpr inline T pow(long long a, long long b, const T mv) {
	long long res = 1;
	a %= mv;
	while (b) {
		if (b & 1)
			res = (res * a) % mv;
		b >>= 1;
		a = (a * a) % mv;
	}
	return res;
}

// get busy living or get busy dying


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

const int INF = 500000000;
int n, r;
vector<int> et[1500];
vector<int> ec[1500];
bool flag[1500];

int dijkstra(int s, int maxDist) {
	int i, dist[1500];
	typedef pair<int, int> P;
	priority_queue<P, vector<P>, greater<P> > que;
	
	for (i = 0; i < n; i++) dist[i] = INF;
	que.push(P(0, s));
	
	while (!que.empty()) {
		P now = que.top(); que.pop();
		int cst = now.first;
		int v = now.second;
		
		if (dist[v] <= cst) continue;
		dist[v] = cst;
		
		for (i = 0; i < et[v].size(); i++) {
			que.push(P(cst + ec[v][i], et[v][i]));
		}
	}
	
	//?????§?????¢????±???????
	int ret = 0;
	for (i = 0; i < n; i++) ret = max(ret, dist[i]);
	if (maxDist != ret) return ret;
	
	//??????????????¢?´¢?????????????????¨????????????
	queue<int> qu;
	bool visit[1500] = {false};
	
	for (i = 0; i < n; i++) if (dist[i] == maxDist) qu.push(i);
	while (!qu.empty()) {
		int v = qu.front(); qu.pop();
		flag[v] = true;
		
		for (i = 0; i < et[v].size(); i++) {
			if (dist[et[v][i]] + ec[v][i] == dist[v] && !visit[et[v][i]]) {
				qu.push(et[v][i]);
				visit[et[v][i]] = true;
			}
		}
	}
	return ret;
}

int main() {
	int i;
	
	cin >> n >> r;
	for (i = 0; i < r; i++) {
		int s, t, d;
		cin >> s >> t >> d;
		s--; t--;
		et[s].push_back(t);
		et[t].push_back(s);
		ec[s].push_back(d);
		ec[t].push_back(d);
	}
	
	int maxDist = -1;
	for (i = 0; i < n; i++) {
		maxDist = max(maxDist, dijkstra(i, INF));
	}
	
	for (i = 0; i < n; i++) {
		dijkstra(i, maxDist);
	}
	
	vector<int> ans;
	for (i = 0; i < n; i++) {
		if (!flag[i]) ans.push_back(i + 1);
	}
	
	cout << ans.size() << endl;
	for (i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3448
#54 ABC134E

n=int(input())
a=[int(input()) for _ in range(n)]

def LIS(L):
    from bisect import bisect
    seq=[]
    for i in L:
        pos=bisect(seq,-i)
        if len(seq)<=pos:
            seq.append(-i)
        else:
            seq[pos]=-i
    return len(seq)

print(LIS(a))

Measured memory_bytes: 11004
def main():
    n = int(input())
    inlis = list(map(int, input().split()))

    tmp = inlis[0]
    ans = 0

    for i in range(1, n):
        if inlis[i] < tmp:
            ans += tmp - inlis[i]
        else:
            tmp = inlis[i]
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 94304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        class Submission
        {
            public readonly int p;
            public readonly string S;
            public Submission(string[] args)
            {
                p = int.Parse(args[0]);
                S = args[1];
            }
        }

        static int[] Solve(int N, int M, Submission[] submissions)
        {
            var ac = new bool[N];
            var wa = new int[N];
            foreach (var s in submissions)
            {
                switch (s.S)
                {
                case "AC": ac[s.p - 1] = true;  break;
                case "WA": if (!ac[s.p - 1]) { ++wa[s.p - 1]; } break;
                }
            }
            return new[] { ac.Count(a => a), Enumerable.Range(0, N).Where(i => ac[i]).Sum(i => wa[i]) };
        }

        static void Main(string[] args)
        {
            var V = ReadInts();
            int N = V[0], M = V[1];
            var submissions = new Submission[M];
            for (int i = 0; i < M; ++i) { submissions[i] = new Submission(Read().Split()); }
            var ans = Solve(N, M, submissions);
            Console.WriteLine(string.Join(" ", ans));
        }
    }
}


Measured memory_bytes: 26412
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



int main(){
    int n; cin >> n;
    vi w(n);
    cin >> w;

    vi s(n+1);


    rep(i,n){
        s[i+1] = s[i] + w[i];
    }

    int ans = INF;
    rep(i,n-1){
        int l = s[i+1];
        int r = s[n] - s[i+1];
        ans = min(ans,abs(l-r));
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using vi = vector<int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void maxi(T &a, T &b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T &b) {
	a = min(a, b);
}

vi tate;
vi yoko;
bool dp[4000][50000];//a番目までの要素から、bを作れるか。
int X, Y;

int main() {
	string s;
	cin >> s;
	cin >> X >> Y;
	bool flag = true;
	int cnt = 0;
	auto it = s.begin();
	while (it != s.end() && *(it++) == 'F') --X;
	for (; it != s.end(); ++it) {
		if (*(it) == 'F')++cnt;
		else {
			if (cnt > 0) {
				if (flag)tate.push_back(cnt);
				else yoko.push_back(cnt);
			}
			cnt = 0;
			flag = !flag;
		}
	}
	if (cnt > 0) {
		if (flag)tate.push_back(cnt);
		else yoko.push_back(cnt);
	}
	rep(50000) {
		dp[0][i] = false;
	}
	tate.push_back(0);
	yoko.push_back(0);
	if (tate.size() > 0)dp[0][25000 + tate[0]] = dp[0][25000 - tate[0]] = true;
	FOR(i, 1, tate.size()) {
		FOR(j, 0, 50000) {
			dp[i][j] = dp[i - 1][j + tate[i]] || dp[i - 1][j - tate[i]];
		}
	}
	flag = dp[tate.size() - 1][Y + 25000];

	rep(50000) {
		dp[0][i] = false;
	}
	dp[0][25000 + yoko[0]] = dp[0][25000 - yoko[0]] = true;
	FOR(i, 1, yoko.size()) {
		FOR(j, 0, 50000) {
			dp[i][j] = dp[i - 1][j + yoko[i]] || dp[i - 1][j - yoko[i]];
		}
	}
	flag &= dp[yoko.size() - 1][X + 25000];
	if (flag)say("Yes");
	else say("No");
}

Measured memory_bytes: 131328
from collections import deque
def main():
    N = int(input())
    A = deque(sorted(list(map(int, input().split()))))
    ans = A.pop()
    for i in range(N - 2):
        if i%2 == 0:
            x = A.pop()
        ans += x
    print(ans)
            
if __name__ == '__main__':
    main()

Measured memory_bytes: 32400
#include<stdio.h>
#include<math.h>

int main(){
	long long dan[32];
	int n,i;
	
	dan[0]=0;
	dan[1]=1;
	dan[2]=2;
	dan[3]=4;
	for(i=4;i<32;i++){
		dan[i]=dan[i-1]+dan[i-2]+dan[i-3];
	}
	for(i=0;i<32;i++){
		dan[i]=((dan[i]+9)/10+364)/365;
	}
	while(0<=scanf("%d",&n)){
		if(n==0)break;
		printf("%lld\n",dan[n]);
	}
	
	return 0;
}

Measured memory_bytes: 0
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

struct KochCurve {
    x: f32,
    y: f32,
}

impl KochCurve {
    fn new() -> KochCurve {
        KochCurve { x: 0.0, y: 0.0 }
    }

    fn koch(&mut self, n: usize, a: &mut KochCurve, b: &mut KochCurve) {
        if n == 0 {
            return;
        }

        let mut s: KochCurve = KochCurve::new();
        let mut t: KochCurve = KochCurve::new();
        let mut u: KochCurve = KochCurve::new();

        let th: f32 = std::f32::consts::PI * 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) * th.cos() - (t.y - s.y) * th.sin() + s.x;
        u.y = (t.x - s.x) * th.sin() + (t.y - s.y) * th.cos() + s.y;

        KochCurve::new().koch(n - 1, a, &mut s);
        println!("{} {}", s.x, s.y);
        KochCurve::new().koch(n - 1, &mut s, &mut u);
        println!("{} {}", u.x, u.y);
        KochCurve::new().koch(n - 1, &mut u, &mut t);
        println!("{} {}", t.x, t.y);
        KochCurve::new().koch(n - 1, &mut t, b);
    }
}

fn main() {
    let n: usize = read();

    let mut a: KochCurve = KochCurve::new();
    let mut b: KochCurve = KochCurve::new();

    a.x = 0.0;
    a.y = 0.0;
    b.x = 100.0;
    b.y = 0.0;

    println!("{} {}", a.x, a.y);
    KochCurve::new().koch(n, &mut a, &mut b);
    println!("{} {}", b.x, b.y);
}



Measured memory_bytes: 5036
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(1,len(s)+1), key=lambda k: s[k-1])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    l=[]
    for _ in range(N):
        s,n=input().split()
        n=int(n)
        l.append((s,-n))
    li=argsort(l)
    printl(li)






if __name__ == "__main__":
    main()

Measured memory_bytes: 77344
#include <stdio.h>
#include <math.h>

//double x[0][0]=0.0;
//double y=100.0;

int Koch(double x1,double y1,double x3,double y3,int n){
    double x2=0,y2=0;
    double px=0,py=0,tx=0,ty=0;
    
    
    if(n==0){
        printf("%f %f\n",x3,y3);
        return 0;
    }else{
        
        px=((x3-x1)/3)+x1;
        py=((y3-y1)/3)+y1;
       // x2=px+(x3-x1)/6;
       // y2=px+sqrt(-(x2-px)*(x2-px)+px*px);
       x2 = (x1+x3)/2 -sqrt(3.0)*(y3-y1)/6;
       y2 = (y1+y3)/2 +sqrt(3.0)*(x3-x1)/6;
       // x2 = sqrt(3.0)*(-y3+y1)/2.0+(x3-x1)/2.0;
      //  y2 = sqrt(3.0)*(x3-x1)/2.0+(y3-y1)/2.0;
       // y2=(py-y1)+(y3-y1)/3;
        tx=((x1-x3)/3)+x3;
        ty=((y1-y3)/3)+y3;
        
        Koch(x1,y1,px,py,n-1);
        Koch(px,py,x2,y2,n-1);
        Koch(x2,y2,tx,ty,n-1);
        Koch(tx,ty,x3,y3,n-1);
        //Koch(size/3+size/3,n-1);
        
        
        
       // printf("%f %f\n",x1,y1);
      //  printf("%f %f\n",px,py);
      //  printf("%f %f\n",x2,y2);
       // printf("%f %f\n",tx,ty);
        
        
        
    }
    return 0;
}



int main(int argc , char *argv[]){
    
    int n;
    double x1=0,x3=100;
    double y1=0,y3=0;
    
    scanf("%d",&n);
    printf("%f %f\n",0.0,0.0);
    Koch(x1,y1,x3,y3,n);
    return 0;
 }

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line1 = sc.nextLine();
        String line2 = sc.nextLine();
        line2 = line2.substring(0,line2.length()-1);
        if(line1.equals(line2)){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	 printf
#define sf			 scanf
#define pb(a)        push_back(a)
#define mp			 make_pair
#define ff			 first
#define ss			 second
#define for0(i,n)    for(int i=0;i<n;i++)
#define for1(i,n)    for(int i=1;i<=n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define sq(a)		 (a)*(a)
#define endl		     "\n"
#define abs(x)		 fabs(x)
#define all(v) 		 v.begin(),v.end()
#define pcase(z,x)   cout<<"Case "<<z<<": "<<x<<"\n"
#define WakandaForever     ios_base::sync_with_stdio(0); cin.tie(0);

int main()
{
    WakandaForever
    int x;
    cin>>x;
    cout<<(x^1)<<endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define DEBUG true
#define coutd if(DEBUG) cout
#define debugf if(DEBUG) printf
#define ff first
#define ss second
#define len(x) int(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	double ans=0;
	for(int i=1; i<=n; i++){
		int num = ceil(log2(k/double(i)));
		double f2 = pow(0.5, num);
		if(i>=k)f2=1;
		if(f2>1) coutd << i  << " " << f2 << endl;
		ans+=(1/double(n))*f2;
	}
	printf("%.15lf\n", ans);

}



Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
  int N, K;
  cin >> N >> K;
  int A;
  REP(i, N)
  {
    int b;
    cin >> b;
    if(b==1){
      A = i;
    }
  }
  cout << ((N-1)-1) / (K-1) +1<< endl;
}


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

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long k, x;
	cin >> k >> x;
	if(500*k >= x) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int i,j,n,m,a[100][100],b[100],c[100];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++)
			scanf("%d",&a[i][j]);
	}
	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	for(i=0;i<n;i++){
		c[i]=0;
		for(j=0;j<m;j++){
			c[i]=c[i]+a[i][j]*b[j];
		}
		printf("%d\n",c[i]);
	}
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
	int N;
	scanf("%d", &N);
	VI a;
	int t;
	for(int i = 0; i < 3 * N; i++) {
		scanf("%d", &t);
		a.PB(t);
	}
	sort(ALL(a));
	reverse(ALL(a));
	ll ans = 0;
	for(int i = 1; i < 2 * N; i += 2)
		ans += a[i];
	cout << ans << endl;
	return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    int n,k;
    cin>>n>>k;
    vector<int> snukes(n);
    for(int i=0;i<k;i++) {
        int num;
        cin>>num;
        for(int j=0;j<num;j++) {
            int snack;
            cin>>snack;
            snukes[snack-1]++;
        }
    }

    int ans=0;
    for(int i=0;i<n;i++) {
        if(snukes[i]==0) {
            ans++;
        }
    }
    cout<<ans<<endl;
    
}




Measured memory_bytes: 3636