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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 1e9+7;

class mint
{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(::std::int_fast64_t _n):n(_n<0 ? MOD-(-_n)%MOD : _n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    mint operator==(const mint &m) const {return n==m.n;}
    mint operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

mint dp[51][52][3000];

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    dp[0][0][0] = 1;
    rep(i,50)rep(j,51)rep(k,2501){
        dp[i+1][j][k+2*j]+=dp[i][j][k];
        dp[i+1][j+1][k+2*j]+=dp[i][j][k];
        dp[i+1][j][k+2*j]+=dp[i][j][k]*2*j;
        if (j>0) dp[i+1][j-1][k+2*j]+=dp[i][j][k]*j*j;
    }
    cout<<dp[n][0][k]<<"\n";
    return 0;
}


Measured memory_bytes: 62464
def check(ss,t,i)
    if t[0]==ss[i]
        return true
    else
        return false
    end
        
end

ss=gets.chomp.chars
t=gets.chomp.chars

(ss.length-t.length).downto(0){|i|

    if check = ss[i..i+t.length-1].zip(t).all?{|a,b| a == b or a == "?"}
        ss[i..(i-1+t.length)]=t
        ss=ss.join.gsub("?","a")
        print ss
        exit
    else
    
    end
}

print "UNRESTORABLE"

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

vector<int> d;
vector<int> f;
int t;
void dfs(vector<vector<int>>Graph, int v) {
  d[v] = t;
  t++;
  if(Graph[v].size() == 0) {
    return;
  }
  for(auto next_v: Graph[v]) {
    if(d[next_v] != -1) {
      continue;
    }
    //cout << next_v << ":" << t << endl;
    dfs(Graph, next_v);
    f[next_v] = t;
    t++;
  }
  f[v] = t;
}

int main() {
  int n;
  cin >> n;
  vector<vector<int>> Graph(n);
  rep(i, n) {
    int u, k;
    cin >> u >> k;
    rep(j, k) {
      int a;
      cin >> a;
      Graph[i].push_back(a-1);
    }
  }
  d = f = vector<int>(n, -1);
  d[0] = 1;
  t = 1;
  dfs(Graph, 0);
  f[0] = t;
  rep(i, n) {
    if(d[i] == -1) {
      t++;
      dfs(Graph, i);
      //f[i] = t;
    }
  }
  rep(i, n) {
    cout << i + 1 << " ";
    cout << d[i] << " ";
    cout << f[i] << endl;
  }
}


Measured memory_bytes: 3616
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int N;
int p[20010];
int a[20010];
int b[20010];

int main(){
	scanf("%d" , &N);
	repp(i,1,N+1){
		scanf("%d" , p + i);
		a[i] = 1;
		b[i] = 1;
	}
	repp(i,1,N+1){
		a[p[i]+1] += N - i;
		b[p[i]-1] += N - i;
	}
	repp(i,2,N+1){
		a[i] += a[i-1];
	}
	repm(i,N-1,0){
		b[i] += b[i+1];
	}
	repp(i,1,N+1){
		printf("%d%c" , a[i] , i == N ? '\n' : ' ');
	}
	repp(i,1,N+1){
		printf("%d%c" , b[i] , i == N ? '\n' : ' ');
	}
	return 0;
}


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

int main(int argc, char const *argv[]) {
    for (int i = 0; i < 5; i++) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(void){
    int a,b,k;
    cin >> a >> b >> k;
    while(k > 0){
        if(a %2 == 1){
            a -= 1;
        }
        a /= 2;
        b += a;
        k--;
        if(k <= 0) break;
        if(b %2 == 1){
            b -= 1;
        }
        b /= 2;
        a += b;
        k--;
    }
    cout << a << " "<< b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mm(a,b) memset(a,b,sizeof(a))
#define ACCELERATE (ios::sync_with_stdio(false),cin.tie(0))
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<long long,long long>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pf(x) printf("%d\n",x)
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
#define E exp(1.0)
#define db double
#define ll long long
#define ld long double
#define ull unsigned long long
//#define io
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
//#define gc getchar
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
//inline int read()
//{
//    int ret=0,f=0;char c=gc();
//    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
//    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
//    if(f)return -ret;return ret;
//}
string s;
int main()
{
    #ifdef io
    freopen("in.txt","r",stdin);
    #endif
    cin>>s;
    printf("%s\n",s[0]=='S'?"Cloudy":(s[0]=='C'?"Rainy":"Sunny"));
    return 0;
}


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

ll count(string s, string g){
	ll cnt = 0;
	for(ll i=0;i<g.length();++i){
		if(s[i] != g[i]) ++cnt;
	}

	return cnt;
}


ll findans(string s, string p){
	ll ans;

	string g = s.substr(0,p.length());
	ans = count(g,p);

	for(ll i=g.length();i<s.length();++i){
		g.erase(g.begin());
		g += s[i];
		ans = min(ans, count(g,p));
	}
	return ans;
}

int main(){

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

	ll t=1;
	// cin>>t;

	while(t--){
		string s,p;
		cin>>s>>p;

		cout<<findans(s,p)<<"\n";

	}	

	return 0;
}

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

int main() {
  string text;
  map<string, int> table;
  string f_word, l_word;
  while (cin >> text) {
    table[text]++;
    if (table[text] > table[f_word])
      f_word = text;
    if (text.size() > l_word.size())
      l_word = text;
  }
  cout<<f_word<<" "<<l_word<<endl;
}



Measured memory_bytes: 3184
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
typedef long double ld;
const ld eps = 1e-8;
#define rep(i,n) for(int i=0;i<n;i++)
#define stop char nyaa;cin>>nyaa;
int main(){
	int n, m; cin >> n >> m;
	int x, y; cin >> x >> y;
	int ma = x; int mi = y;
	rep(i, n) {
		int a; cin >> a; ma = max(a, ma);
	}
	rep(i, m) {
		int a; cin >> a; mi = min(mi, a);
	}
	if (ma < mi) {
		cout << "No War" << endl;
	}
	else cout << "War" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String[] abStr = reader.readLine().split(" ");
    int a = Integer.parseInt(abStr[0]);
    int b = Integer.parseInt(abStr[1]);

    if (a < b)
      System.out.println("a < b");
    else if (a > b)
      System.out.println("a > b");
    else
      System.out.println("a == b");

  }

}

Measured memory_bytes: 17088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,A[1000000],B[1000000];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
        B[i] = A[i];
    }
    sort(A,A+N);

    int l = N-1;
    int med = (l+1)/2;
    for(int i=0; i<N; i++){
        if(B[i]<A[med]){
            cout << A[med] << endl;
        }else{
            cout << A[med-1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8832
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			int N = scan.nextInt();

			int M = scan.nextInt();
			int []a = new int[M];
			int []b = new int[M];

			for(int i = 0;i<M;i++) {
				a[i] = scan.nextInt()-1;
				b[i] = scan.nextInt()-1;
			}

			int count = 0;

			for(int k = 0;k<M;k++) {
				UnionfindTree T = new UnionfindTree(N);
				Set<Integer>set = new TreeSet<Integer>();
				for(int i = 0;i<M;i++) {
					if(i==k)continue;
					T.union(a[i], b[i]);
				}
				for(int i = 0;i<N;i++) {
					set.add(T.find(i));
				}

				if(set.size()>1)count++;
			}

			System.out.println(count);




		}


	}

	//unionfind は分割できない以下重要なこと。
/* 頂点は必ず0から
 * 繋げていく処理だけを考えるとき，繋げたものだけを考えれば良いので，連結かどうかの判定は簡単
 *
 * 辺を壊した後にグラフが連結がどうかは，遠くまで見ないと連結かどうかの判定が難しい．
 *
 * 上記の「難しい」というのは，グラフ上を遠くまで探索して連結かどうかを愚直に調べることのできるのは
 * DFS，BFS なので，制約が大きいと計算量的に判定が難しい，という意味．
 *
 * 以上 3 つを考えると意味が分かると思います．繋がっているかどうかの判定は，
 * ここまで見てきた通り，Union-Find 木を使えば簡単にできます
 * （DFS，BFS，ワーシャルフロイド法などでも繋がっているかの判定はできるが，制約が大きくなると計算量的に使えない）．
 * このポイントは，例えば「無向グラフが与えられてその辺を壊し
 * ，連結かどうかの判定」を行うという典型的な問題に対して適用することができます．
 */



//グループを作る、そしてそのグループについてどうなのかという問題に使えるUNIONFIND木
static class UnionfindTree{
	int [] parent;//配列番号＝頂点番号、値＝その点の親の頂点
	int [] rank;//その頂点を根とするグラフの深さの値、独立した頂点をランク１とする


	public UnionfindTree(int size){//size=グループ分けしたい頂点の数の合計
		this.parent = new int[size];
		this.rank = new int[size];
		for(int i = 0;i<size;i++) {
			parent[i] = i;
			rank[i] = 0; //集合の高さ
		}
	}

	public void union(int x, int y) {//計算量　O(logN)パス圧縮してるのでO(1/A(n,n))と相当小さくなる
		int xRoot = find(x);
		int yRoot = find(y);

		//xが属する木の方が大きい場合
		if (rank[xRoot] > rank[yRoot]) {
			parent[yRoot] = xRoot; //yの親をxに更新

		} else if(rank[xRoot] < rank[yRoot]) {
			parent[xRoot] = yRoot;

		} else if (xRoot != yRoot){//高さ一緒であるが、同じ値(グループ)ではない、同じ値(グループ)は無視していい
			parent[yRoot] = xRoot;
			rank[xRoot]++; //同じ高さの木がルートの子として着くから大きさ++;
		}
	}

	//引数の属する木のルートのidを返す
	public int find(int i) {//計算の工夫パス圧縮、これによりこのメソッドの計算量は  O(logN)  になる。(非自明)
		if (i != parent[i]) {//指定された頂点が根(親)なら無視してそのまま値を返せばいい
			parent[i] = find(parent[i]);//そうでないならその頂点がもつ親の値までいきそこでその値をもらいに行く
		}//それと同時に、指定された頂点のもつ値をそこで保存しておくことで、パス圧縮が行われ計算量が短縮される。
		return parent[i];
	}

	//同じ木に属しているか
	public boolean same(int x, int y) {//計算量O(logN)
		return find(x) == find(y);
	}
}


}


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

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

  vector<ll> dp1(N); {
    dp1[0] = v[0] - x[0];
    for (int i = 1; i < N; ++i) dp1[i] = dp1[i - 1] + v[i] - (x[i] - x[i - 1]);
    for (int i = 1; i < N; ++i) dp1[i] = max(dp1[i], dp1[i - 1]);
  }
  vector<ll> dp2(N); {
    dp2[N - 1] = v[N - 1] - (C - x[N - 1]);
    for (int i = N - 2; i >= 0; --i) dp2[i] = dp2[i + 1] + v[i] - (x[i + 1] - x[i]);
    for (int i = N - 2; i >= 0; --i) dp2[i] = max(dp2[i], dp2[i + 1]);
  }

  ll ans = 0LL; {
    for (int i = 0; i < N; ++i) {
      ll cur = dp1[i];
      if (i + 1 < N && dp2[i + 1] - x[i] > 0) cur += dp2[i + 1] - x[i];
      ans = max(ans, cur);
    }
    for (int i = N - 1; i >= 0; --i) {
      ll cur = dp2[i];
      if (i >= 1 && dp1[i - 1] - (C - x[i]) > 0) cur += dp1[i - 1] - (C - x[i]);
      ans = max(ans, cur);
    }
  }
  cout << ans << endl;
  return 0;
}


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

bool solve(string s, bool ok){
    string t; t = s;
    for(int i=0; i<s.size(); ++i){s[i]=t[t.size()-i-1];}
    for(int i=0; i<s.size(); ++i){
        
        if(s[i]!=t[i]){ok = false; break;}
    }
    
    return ok;
}

int main(){
    string s; cin >> s;
    bool ok = true;
    ok = solve(s, ok);
    if(!ok){cout << "No" << endl; return 0;}

    for(int i=0; i<s.size()/2; ++i){
        if(s[i]!=s[s.size()/2-1-i]){ok = false; break;}
    }

    if(ok){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
using P = pair<int,int>;
//int dy[4] = {-1,0,1,0};
//int dx[4] = {0,-1,0,1};


int main()
{
    int a,b,c,k;
    cin >> a>>b>>c>>k;
    
    int ans = 0;
    
    if(k<a)
    {
        ans += k;
        
    }
    else
    {
        ans += a;
        k -=a;
        
        if(k>b)
        {
            k-=b;
            ans-=k;
        }
    }
    
    
    cout << ans << endl;
    return 0;
}


/*
int main()
{
    int N;
    cin >> N;
    
 
 int ans;
 cout << ans << endl;
    return 0;
}
*/

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

using Graph = vector<vector<int>>;


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

	int N;
    cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    multiset<int> set1;
    rep(i,N){
        auto itr = set1.lower_bound(A[i]);
        if(itr != set1.begin()) set1.erase(--itr);
        set1.insert(A[i]);
    }
    cout << set1.size() << endl;
}

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


int main() {
	
	int N, M;
	cin >> N;
	vector<int> t(N);
	for (auto &i : t) cin >> i;
	cin >> M;
	vector<int> p(M), x(M);
	for (int i=0; i<M; i++)
		cin >> p.at(i) >> x.at(i);
		
	int sum = 0;
	for (auto i : t) sum += i;
	for (int i=0; i<M; i++) cout << sum - t.at(p.at(i)-1) + x.at(i) << endl; 
	
	
	return 0;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  map<int,int> mp;
  rep(i,6){
    ll a;
    cin>>a;
    mp[a]++;
  }
  vector<ll> v;
  for(auto c:mp){
    v.push_back(c.second);
  }
  sort(ALL(v));
  if(v[0]==1 && v[1]==1 && v[2]==2 && v[3]==2){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n;
  const int max_n = 1e5;
  string s[max_n + 1];

  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  sort(s, s+n);
  // for(int i = 0; i < n; i++) cout << s[i] << endl;
  long long now = 0;
  long long ans = 0;
  for(long long i = 1; i < n; i++){
    if(s[i] != s[i-1]){
      ans += (i-now) * (i-now-1) / 2;
      now = i;
      // cout << now << endl;
    }
    if(i == n - 1){
      ans += (i+1 - now) * (i+1 - now-1) / 2;
    }
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 6704
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1e9+5

int frog(int *a,int i, int n, int *dp){
    if(i>=n-1){
        return 0;
    }
    if(dp[i]!=inf) return dp[i];

    int op1=frog(a,i+1,n,dp) + abs(a[i]-a[i+1]);
    int op2=frog(a,i+2,n,dp) + abs(a[i]-a[i+2]);

    dp[i] = min(op1,op2);
    return dp[i];
}

int main() {
    ll n;cin>>n;
    int a[n]={0};
    for(int i=0;i<n;i++) cin>>a[i];
    int dp[n];
    for(int i=0;i<n;i++) dp[i] = inf;
    cout<<frog(a,0,n,dp)<<endl;
    // for(int i=0;i<n;i++) cout<<dp[i]<<" ";
}



Measured memory_bytes: 11964
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    vector<vector<int> > field;
    int H, W;
    cin >> H >> W;
    field.assign(H, vector<int>(W, -1));
    char c;
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
        cin >> c;
        if (c == '.') field[i][j] = 0;
    }
    vector<int> di{0, 1, 1, 1, 0, -1, -1, -1};
    vector<int> dj{1, 1, 0, -1, -1, -1, 0, 1};
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
        if (field[i][j] == -1) {
            for (int k = 0; k < 8; k++) {
                int ni = di[k] + i;
                int nj = dj[k] + j;
                if (ni < 0 || nj < 0 || ni >= H || nj >= W) continue;
                if (field[ni][nj] == -1) continue;
                field[ni][nj]++;
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (field[i][j] == -1) cout << '#';
            else cout << field[i][j];
        }
        cout << '\n';
    }
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  int bb = b;
  int now = a;
  while (b > 0) {
    now *= 10;
    b /= 10;
  }
  now += bb;
  if ((int)sqrt(now) == sqrt(now))
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll m,k;
  cin>>m>>k;

  if( 1LL << m <= k ){
    cout << -1 << endl;
  }
  else if(k==0){
    for(ll i=0;i< (1LL<<m) ; i++ ){
      cout << i << " " << i << " ";
    }
    cout << endl;
  }
  else if(m==1){
    if(k!=0)cout << -1 << endl;
  }
  else{
    cout << 0 << " " << k << " " << 0 << " ";

    for(ll i=1;i< (1LL<<m) ; i++ ){
      if(i!=k) cout << i << " ";
    }
    cout << k << " ";
    for(ll i= (1LL<<m)-1; i>=1 ; i-- ){
      if(i!=k) cout << i << " ";
    }
    cout << endl;
  }

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}


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

int main() {

    int a, b, c;

    std::cin >> a >> b >> c;

    if ( a > b ) std::swap(a, b);
    if ( b > c ) std::swap(b, c);
    if ( a > b ) std::swap(a, b);

    std::cout << a << " " << b << " " << c << std::endl;

    return 0;
}



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

int main() {
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	  {
	  	 if(s[i]=='1')
	  	   s[i]='9';
	  	 else if(s[i]=='9')
	  	   s[i]='1';
	  }
	 cout<<s; 
	// your code goes here
	return 0;
}

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

INF = float('inf')
dp = [[-INF] * N for i in range(2)]
dp[0][0] = A[0]
dp[1][0] = -A[0]

for i in range(1,N):
    dp[0][i] = max(dp[0][i-1] + A[i], dp[1][i-1] - A[i])
    dp[1][i] = max(dp[0][i-1] - A[i], dp[1][i-1] + A[i])
print(dp[0][-1])

Measured memory_bytes: 16800
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    long long num[210000] = {};
    long long count = 0;

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

    for(int i = 0; i <= n; i++) {
        count += num[i]*(num[i]-1)/2;
    }

    for(int k = 0; k < n; k++) {
        long long tmp = count;
        if(num[a[k]] > 1) {
            tmp -= num[a[k]]*(num[a[k]]-1)/2;
            tmp += (num[a[k]]-1)*(num[a[k]]-2)/2;
        }
        cout << tmp << endl; 
    }
    return 0;
}

Measured memory_bytes: 6036
#include<stdio.h>
int main(void)
{
	int i,k,n,x,y,min;
	scanf("%d",&n);



	scanf("%d",&k);
	for(i=1;i<=k;i++) {
		scanf("%d %d",&x,&y);
		min=n;
		if((n+1)-x <= min) {
			min=(n+1)-x;
		}
		if((n+1)-y <= min) {
			min=(n+1)-y;
		}
		if(x <= min) {
			min=x;
		}
		if(y <= min) {
			min=y;
		}



		if(min % 3 == 1) {
			printf("1\n");
		}
		if(min % 3 == 2) {
			printf("2\n");
		}
		if(min % 3 == 0) {
			printf("3\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

void Main(){

	ll N;
	cin >> N;
	vl v(N);
	rep(i, N) cin >> v[i];
	
	ll ans = 0;
	ll cnt = 0;
	ll ma = v[0];
	
	rep2(i, 1, N){
		if(ma >= v[i]) cnt += 1;
		else cnt = 0;
		ma = v[i];
		chmax(ans, cnt);
	}

	print(ans);
		
	
}

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





Measured memory_bytes: 4000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main(int argc, char const *argv[])
{
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d\n",(a + b + 1) / 2);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main (void)
{
  int A,B,max;
  
  scanf("%d %d",&A,&B);
  
  if(A>B){
    max=A;
    A--;
  }else{ 
    max=B;
    B--;
  }
  if(A>B)
    max+=A;
  else
    max+=B;
  
  printf("%d",max);
  
  return 0;
}

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

long long A[100005];

int main(){
	long long N;
	cin >> N;
	for(long long i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		A[tmp]++;
	}

	long long more = 0;
	long long uni = 0;
	for(long long i = 0; i < 100005; i++){
		if(A[i] > 1){
			more += A[i] - 1;
		}
		if(A[i] != 0){
			uni++;
		}
	}
	if(more%2 == 0){
		cout << uni << endl;
	}else{
		cout << uni - 1 << endl;
	}
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
#define N 100007
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ
 
 
int component[N];//連結成分の要素数
 
// 連結成分の番号を振る関数
void dfs(int n, int comp[], vector<int> G[]) {
    int i, j, vertex, neighbor, color[N] ,inst[N];
  stack<int> S;
  // 初期状態
    for (i = 0; i < n; i++) {
        color[i] = WHITE;
        inst[i]=WHITE;
    }
 
  for (i = 0; i < n; i++) {
    if (color[i] == WHITE) {
      // dfs
      S.push(i);
      while (!S.empty()) {
        vertex = S.top();
        S.pop();
        color[vertex] = BLACK;  // 訪問済みにする
        comp[vertex] = i;  // 連結成分の番号を振る
          if(inst[vertex]==WHITE){
              component[i]+=1;
              inst[vertex]=BLACK;
          }
          //cout << component[i] << endl;
        for (j = 0; j < (int) G[vertex].size(); j++) {
          neighbor = G[vertex][j]; // 隣接している頂点：友人
            if (color[neighbor] == WHITE) {
                S.push(neighbor);
                
            }
        }
      }
    }
  }
}
 
int main() {
for(int i=0;i<N;i++) component[i]=0;
    int i, n, m, s, t, v;
  int comp[N];  // 連結成分の番号
  vector<int> G[N];  // グラフを表現する隣接リスト
 
    cin >> n >> m ;
  // 隣接リストを作成
  for (i = 0; i < m; i++) {
      cin >> s >> t >>v;
    G[s-1].push_back(t-1);
    G[t-1].push_back(s-1);
  }
 
  // グラフを連結成分に分け
    dfs(n, comp, G);
    
    map<int,int> mp; //連結成分の番号から、要素数
  
    for(i = 0; i < n; i++) {
       if(mp.find(comp[i])!=mp.end()) mp[comp[i]]=1;
       else mp[comp[i]]++;
   }
    ll ans=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        ans++;
    }
    kaku(ans);
    
}



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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n;
	cin>>n;
	cout<<"A"<<"B"<<"C"<<n;
	return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> L(N);
    for(int i = 0; i < N; i++) cin >> L.at(i);

    sort(L.begin(), L.end());
    reverse(L.begin(), L.end());

    int sum = 0;
    for(int i = 0; i < K; i++){
        sum += L.at(i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
using namespace std;
using llong = long long;

llong table[16][16];

llong op(llong a, llong b) {
        return table[a][b];
}
llong check(string &ssn) {
        return op(op(op(op(op(0, ssn[0]-'0'), ssn[1]-'0'), ssn[2]-'0'), ssn[3]-'0'), ssn[4]-'0');
}
llong check_digits(string &basicID) {
        return op(op(op(op(0, basicID[0]-'0'), basicID[1]-'0'), basicID[2]-'0'), basicID[3]-'0');
}

string to_str(llong a) {
        string s;
        for (int i = 0; i < 4; i++) {
                s += (char)((a % 10) + '0');
                a /= 10;
        }

        reverse(s.begin(), s.end());
        return s;
}

bool typo_error(string &ssn) {
        for (int i = 0; i < 5; i++) {
                char b = ssn[i];
                for (char ch = '0'; ch <= '9'; ch++) {
                        if (ch == b) continue;
                        ssn[i] = ch;
                        if (check(ssn) == 0) return true;
                }
                ssn[i] = b;
        }
        return false;
}

bool trans_error(string &ssn) {
        string s = ssn;
        for (int i = 0; i < 4; i++) {
                swap(s[i], s[i + 1]);
                if (s == ssn) continue;
                else if (check(s) == 0) return true;
                swap(s[i], s[i + 1]);
        }
        return false;
}

int main() {
        for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                        cin >> table[i][j];
                }
        }

        llong ans = 0;
        for (int i = 0; i < 10000; i++) {
                string basicID = to_str(i);
                string ssn = basicID;
                ssn += (char)(check_digits(basicID) + '0');

                if (typo_error(ssn)) {
                        ans++;
                }
                else if (trans_error(ssn)) {
                        ans++;
                }
        }

        cout << ans << endl;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n;
  cin >> n;
  vector<int>ans(n);
  rep(i,n){
    int a;
    cin >> a;
    a--;
    ans[a]=i+1;
  }
  rep(i,n)cout << ans[i] << " " ;
  return 0;
}

Measured memory_bytes: 3704
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>

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

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    sort(a.begin(),a.end());

    rep(i,n-1) {
        if (a[i] == a[i+1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}

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

int main(){
  ll N;cin>>N;
  vector<string> S(N);rep(i,N)cin>>S[i];
  map<string,int> m;
  rep(i,N){
    m[S[i]]++;
  }
  ll ans=0;
  for(auto x : m){
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 25108
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  string S, T;
  cin >> S >> T;
  bool ans;
  ans = false;
  for(int i=0; i <= S.length(); ++i){
    if(S == T){
      ans = true;
      break;
    }
    S = S.back() + S.substr(0, S.length()-1);
  }


  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
say = [[] for _ in range(n)]
for i in range(n):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        say[i].append([x, y])
# print(say)
ans = 0
for i in range(1 << n):
    for j in range(n):
        count_j = True
        if i & 1 << j:
            for say_j in say[j]:
                if say_j[1] == 1:
                    if not i & 1 << (say_j[0] - 1):
                        count_j = False
                        break
                else:
                    if i & 1 << (say_j[0] - 1):
                        count_j = False
                        break
        if not count_j:
            break
    if  count_j:
        cnt = 0
        for j in range(n):
            if i & 1 << j:
                cnt += 1
        ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    int a,b,d,r;
    double x,y,f;
    scanf("%d %d",&a,&b);
    x=a; y=b;
    d=a/b; r=a%b; f=x/y;
    printf("%d %d %f\n",d,r,f);
}


Measured memory_bytes: 2144
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,x,y,now=0,whi=0,ai=0,bi=0;
vector <pair <int,pii> > v;
LL ans[2];

bool cmp(pair <int,pii> a,pair <int,pii> b)
{
	return a.fi>b.fi;
}

int main()
{
	cin>>n;
	rep(i,n)
	{
		scanf("%I64d%I64d",&x,&y);
		v.pb({x+y,{x,y}});
	}
	sort(v.begin(),v.end(),cmp);
	rep(i,n)
	{
		if(i%2==0) ans[0]+=v[i].se.fi;
		else ans[1]+=v[i].se.se;
	}
	cout<<ans[0]-ans[1];
	rt0;
}

Measured memory_bytes: 4724
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	vector<pair<long long int, long long int>>v(N);
	for (auto &i : v)cin >> i.first >> i.second;
	sort(v.begin(), v.end());
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		while (M&&v[i].second) {
			M--;
			v[i].second--;
			ans += v[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4780
N, A = [int(i) for i in input().split()]
xs = [int(i) for i in input().split()]

X = max(max(xs), A)
ys = [x - A for x in xs]
ys.sort(reverse=True)
dp = [[0] * (2 * N * X + 1) for i in range(N+1)]

dp[0][N * X] = 1
for j in range(1, N+1):
    for t in range(2 * N * X + 1):
        if 0 < t - ys[j-1] < 2 * N * X:
            dp[j][t] = dp[j-1][t] + dp[j-1][t-ys[j-1]]
        else:
            dp[j][t] = dp[j-1][t]

print(dp[N][N * X] - 1)

Measured memory_bytes: 5364
#include <iostream>
#include <vector>
 
using namespace std;
 
int main() {
    int n; cin >> n;
    vector<int> vc;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        vc.push_back(a);
    }
 
    int cnt = 0;
    int index = 1;
    bool ok = false;
    while (cnt < n) {
        index = vc[index - 1];
        ok = index == 2;
        ++cnt;
        if (ok == true) break;
    } 
 
    cout << (ok ? cnt : -1) << endl;
 
    return 0;
}

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

int isRightTriangle(int a, int b, int c)
{
	if ( a * a == b * b + c * c) {
		return 1;
	}
	return 0;
}

int isRT(int a, int b, int c)
{
	return isRightTriangle(a, b, c) || isRightTriangle(b, c, a) || isRightTriangle(c, a, b);
}


int main()
{
	int n, m, i;
	int a, b, c;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &a, &b, &c);
		if (isRT(a, b, c)) 
			puts("YES");
		else
			puts("NO");
	}
	return 0;
}

Measured memory_bytes: 0
object Main extends App {
  val n: Int = io.StdIn.readInt
  val heap: Array[Int] = io.StdIn.readLine().split(" ").map(_.toInt)
  for (i <- n/2 to 0 by -1) maxHeapify(i)
  println(heap.mkString(" ", " ", ""))

  def maxHeapify(i: Int): Unit = {
    val l: Int = i*2+1
    val r: Int = (i+1)*2
    val larger: Int = if (l < n && heap(l) > heap(i)) l else i
    val largest: Int = if (r < n && heap(r) > heap(larger)) r else larger
    if (largest != i) {
      val tmp: Int = heap(i)
      heap(i) = heap(largest)
      heap(largest) = tmp
      maxHeapify(largest)
    }
  }
}


Measured memory_bytes: 175492
#include<cstdio>
#include<algorithm>

int main(){
    int n;
    int sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int begin,end;
        scanf("%d%d",&begin,&end);
        sum+=end-begin+1;
    }
    printf("%d",sum);
}

Measured memory_bytes: 128
N,K=map(int, input().split())
if K==0:
	print(N*N)
else:
	count = 0
	for b in range(K+1, N+1):
		chk = (N//b)*max(0, b-K)+max(N%b-K+1, 0)
		count += chk
	print(count)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
using Point = complex<double>;

#define X real()
#define Y imag()
double dot(Point a, Point b) {
    return (a.X*b.X + a.Y*b.Y);
}
using Line = pair<Point, Point>;
Point Projection(Line s, Point p) {
    Point vase = s.second - s.first;
    p -= s.first;
    return s.first + dot(p, vase) / norm(vase)*vase;
}
Point Reflection(Line s, Point p) {
    return p + (Projection(s, p) - p) * 2.0;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Point p1, p2;
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    p1 = Point(x1, y1);
    p2 = Point(x2, y2);
    Line l = Line(p1, p2);
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        double xi, yi;
        cin >> xi >> yi;
        Point p = Point(xi, yi);
        printf("%.9f %.9f\n", Reflection(l, p).X, Reflection(l, p).Y);
    }
    return 0;

}



Measured memory_bytes: 3364
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<vector<int> >f(n);
  for(int i=0;i<n;i++)
  {
    f[i].resize(10);
    for(int j=0;j<10;j++)cin>>f[i][j];
  }
  vector<vector<int> >p(n);
  for(int i=0;i<n;i++)
  {
    p[i].resize(11);
    for(int j=0;j<11;j++)cin>>p[i][j];
  }
  long long ans=0;
  for(int i=1;i<=1023;i++)
  {
    long long count=0;
    for(int j=0;j<n;j++)
    {
      int t=0;
      for(int k=0;k<10;k++)
      {
        if((i&(1<<k))!=0 && f[j][9-k]==1)t++;
      }
      count+=p[j][t];
    }
    //cout<<count<<endl;
    if(i==1)ans=count;
    else if(ans<count)ans=count;
  }
 cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3608
n, m = map(int, input().split())
ks = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
c = 0
for i in range(2**n):
  li = []
  flag = False
  for j in range(n):
    if ((i>>j)&1):
      li.append(j+1)
  for j in range(m):
    s = set(li)
    ss = set(ks[j])
    s = s & ss
    if len(s) % 2 == p[j]:
      flag = True
    else:
      flag = False
      break
  if flag:
    c += 1
print(c)


Measured memory_bytes: 3064
#https://atcoder.jp/contests/dp/tasks/dp_b
N, K = list(map(int,input().split()))
h = list(map(int,input().split()))

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

Measured memory_bytes: 55392
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut gcd_l = vec![0; n];
    let mut gcd_r = vec![0; n];
    gcd_l[0] = a[0];
    for i in 1..n {
        gcd_l[i] = gcd(a[i], gcd_l[i-1]);
    }

    gcd_r[n-1] = a[n-1];
    for i in (0..n - 1).rev() {
        gcd_r[i] = gcd(a[i], gcd_r[i+1]);
    }

    let mut ans = Vec::new();
    for i in 0..n {
        if i == 0 {
            ans.push(gcd_r[1]);
        } else if i == n - 1 {
            ans.push(gcd_l[n-2]);
        } else {
            ans.push(gcd(gcd_l[i-1], gcd_r[i+1]));
        }
    }
    println!("{}", ans.into_iter().max().unwrap());
}

Measured memory_bytes: 10492
N=int(input())
A=list(map(int,input().split()))
whole=sum(A)
x1=whole
for n in range(1,N,2):
    x1-=A[n]*2
answers=[x1]
for n in range(N-1):
    x=2*A[n]-answers[-1]
    answers.append(x)
print(*answers)


Measured memory_bytes: 94984
package main

import (
  "fmt"
)

func main() {
  var a, b int
  fmt.Scan(&a, &b)
  if a > 12 {
    fmt.Println(b)
  } else if a > 5 {
    fmt.Println(b / 2)
  } else {
    fmt.Println(0)
  }
}

Measured memory_bytes: 512