akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main(){
  int i,n,l;
  char q[2][1001];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",q[0]);
    scanf("%s",q[1]);
    printf("%d\n",LCSLength(q[0],q[1],strlen(q[0]),strlen(q[1])));
  }
  return 0;
}
int LCSLength(char *X,char *Y,int m,int n){
  int i,j,c[1001][1001];
  for(i=1;i<=m;i++) c[i][0]=0;
  for(j=0;j<=n;j++) c[0][j]=0;
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i-1]==Y[j-1]) c[i][j] = c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1]) c[i][j] = c[i-1][j];
      else c[i][j] = c[i][j-1]; 
    }
  }
  return c[m][n];
}



Measured memory_bytes: 5680
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> s;
  for (int i = 0; i + 1 < n; ++i) {
    s.push_back(a[i + 1] - a[i]);
  }
  s.push_back(k - a[n - 1] + a[0]);
  sort(s.begin(), s.end());
  ll ans = 0;
  for (int i = 0; i < s.size() - 1; ++i) {
    ans += s[i];
  }
  cout << ans << endl;
  return 0;
}

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

int main(void) {

    int H1, M1, H2, M2, K;
    
    cin >>  H1 >> M1 >> H2 >> M2 >> K;

    int start = H1 * 60 + M1;
    int end = H2 * 60 + M2;

    cout << end - K - start;

    return 0;

}

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s, s2;
		int count = 0;
		
		s = sc.nextLine();
		s2 = sc.nextLine();
		
		for(int i = 0; i < s.length(); ++i) {
			if(s.charAt(i) == s2.charAt(s2.length()-1-i))
				++count;
		}
		
		if(count == s.length())
			System.out.println("YES");
		else
			System.out.println("NO");
		sc.close();
	}

}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 int i,n;
 map<int,int> m;
 cin >> n;
 int a[n-1];
 for(i=0;i<(n-1);i++)
 {
  cin >> a[i];
  m[a[i]]++;
 }
 for(i=1;i<=n;i++)
 cout << m[i] << '\n';
 return 0;
}

Measured memory_bytes: 13788
# AtCoder Beginner Contest 073
# C-Write and Erase
# 2019/11/11

$N = <STDIN>;
chomp($N);

for ($i=0; $i<$N; $i++) {
    $Ai = <STDIN>;
    chomp($Ai);
    $total{$Ai}++;
}

$count = 0;
while (($k, $v) = each(%total)) {
    if ($v%2 != 0) {
	$count++;
    }
}

print $count, "\n";




Measured memory_bytes: 13440
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int n;
	scanf("%d", &n);
	int last = 0, k = 0;
	for (int i = 1; i <= n; i++){
		int x, y; scanf("%d%d", &x, &y);
		if (x > last) last = x, k = x + y;
	}
	printf("%d\n", k);
	return 0;
}


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

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

using namespace std;

int n;

void dfs(string s){
	if(s.length()==n){
		puts(s.c_str());
		return;
	}
	char mx=*max_element(s.begin(),s.end());
	for(char c='a';c<=mx+1;c++) dfs(s+c);
}

int main(){
	cin>>n;
	dfs("a");
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll N; cin>>N;
    string s; cin>>s;
    ll r=0,b=0,g=0;
    rep(i,N){
        if(s[i]=='R')r++;
        else if(s[i]=='B')b++;
        else g++;
    }
    ll ans =r*b*g;
    //cout<<ans<<endl;
    for(int i=0;i<N;i++){
        for(int j=1;;j++){
            if(i+j+j<=N-1){
            if(s[i]!=s[i+j]&&s[i+j]!=s[i+j+j]&&s[i]!=s[i+j+j])ans--;
        }
        else break;
        }
    }
    cout<<ans<<endl;
    }


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define mod 1000000007
#define dbg if(debug)
using namespace std;
const bool debug = 0;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	vector<int> h(n),a(n);
	for(int &x: h)
		cin>>x;
	for(int &x: a)
		cin>>x;

	map<int,ll> mp;
	mp[0] = 0;

	for(int i=0;i<n;++i){
		int x = h[i];
		auto it = mp.lower_bound(x);
		--it;
		auto its = it;
		++it;
		while(it!=mp.end() && it->ss<=its->ss+a[i]){
			mp.erase(it);
			it = mp.lower_bound(x);
		}
		mp[x] = max(mp[x],its->ss+a[i]);
	}
	ll ans=0;
	for(auto it: mp){
		ans = max(ans,it.ss);
	}
	cout<<ans;

	// cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll N;
ll A[305000];
ll ans = 0;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
    }
    for(int bit = 0; bit < 60; bit++) {
        ll num[2] = {0, 0};
        for(int i = 1; i <= N; i++) {
            if((1LL << bit) & A[i]) num[0]++;
            else num[1]++;
        }
        ans += (num[0] * num[1] % mod) * ((1LL << bit) % mod);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
int main(int argc,char *argv[])
{
    int n;
    string s;
    cin>>n>>s;
    int cnt=0;
    for(int i=0; i<n-2; i++)
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        {
            cnt++;
            i+=2;
        }
    cout<<cnt;
}


Measured memory_bytes: 256
let g,w=Bytes.map(fun c->if c>='A'&&c<='Z'then Char.chr(Char.code c+32)else c),read_line()open List;;let rec f n=match read_line()with"END_OF_TEXT"->Printf.printf"%d
"n|t->f(n+length(filter(fun s->s=(g w))(Str.split(Str.regexp" ")(g t))));;f 0

Measured memory_bytes: 2420
//
//  main.cpp
//  task 1 C
//
//  Created by Aly Hesham on 08/08/2018.
//  Copyright © 2018 Aly Hesham. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;

int main()

{
    int rem=0;
    int n;
    int num[3000];
    
    cin>>n;
    cout<<endl;
    
    for (int i=0; i<n; i++)
        cin>>num[i];
    
    
        
        for (int i =0; i<n; i++)
        
            rem+=num[i];
    
    cout<< rem-n<<endl;
            
            
        
    
 
    return 0;
}


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

using namespace std; 

int main(){ 
  int a,b,c;
  cin>>a>>b>>c;
  bool x=false;
  for(int i=0;i<b+1;i++){
    int y=i*a%b;
    if(y==c){
      cout<<"YES";
      x=true;
      break;
    }
  }
  if(x==false) cout<<"NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

ll MX = 60;


bool kesenai(vll& v, vll& k, ll x){
  REP(jp,0,SIZE(v)-1){
    ll i = k[jp];
    ll bt = BIT(i);
    if(bt & x){
      x ^= v[jp];
    }
  }
  return x != 0;
}

void g(vll& v, vll& keta, ll x){
  if(kesenai(v, keta, x)){

    v.push_back(x);
    keta.push_back(0);
    ll cur = 0;
    PER(i,MX,0){
      ll bt = BIT(i);
      REP(j,cur,SIZE(v)-1){
        if(bt & v[j]){
          swap(v[j], v[cur]);
          REP(u,0,SIZE(v)-1){
            if((bt & v[u]) && (cur != u)){
              v[u] ^= v[cur];
              
            }
          }
          keta[cur] = i;
          cur++;
          break;
        }
      }
    }
    // REP(i,0,SIZE(v)-1){
    //   cout << v[i] << " ";
    // }cout << endl;
    // REP(i,0,SIZE(keta)-1){
    //   cout << keta[i] << " ";
    // }
    // cout << endl;
  }
  // REP(i,0,SIZE(v)-1){
  //   cout << v[i] << " ";
  // }
  // cout << endl;
}


ll f(){

  ll n;
  cin >> n;
  vll a;
  REP(i,1,n){
    ll t;
    cin >> t;
    a.push_back(t);
  }
  string s;
  cin >> s;
  vll vc, k;
  PER(i,n-1,0){
    if(s[i] == '0'){
      g(vc, k, a[i]);
      
    }else{
      if(kesenai(vc, k, a[i])){
        return 1;
      }
    }
  }
  return 0;
}

int main(){
  ll t;
  cin >> t;
  vll ans(t+1);
  REP(i,1,t){
    ans[i] = f();
  }
  REP(i,1,t){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 3628
import cmath
def norm(c):
    a = abs(c)
    return a*a
def dot_product(a,b):
    return (a.conjugate()*b).real
def cross_product(a,b):
    return (a.conjugate()*b).imag
def projection(p,b):
    return b*dot_product(p,b)/norm(b)
P = []
N = int(input().strip())
for _ in range(N):
    x,y = map(float,input().strip().split())
    P.append(complex(x,y))
total = 0.0
for i in range(1,N-1):
    a,b,c = P[0],P[i],P[i+1]
    total += cross_product(b-a,c-a)
print("%.1f" % (abs(total)/2.0))


Measured memory_bytes: 5692
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	vector<int> a(n+1, 0), b(n+1, 0);
	int cnt = 0;
	rep(i,n){
		if(s[i] == '<') ++cnt;
		else cnt = 0;
		a[i+1] = cnt;
	}
	cnt = 0;
	for(int i = n-1; i >= 0; --i){
		if(s[i] == '>') ++cnt;
		else cnt = 0;
		b[i] = cnt;
	}
	ll ans = 0;
	rep(i,n+1) ans += max(a[i], b[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7712
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define eps 1e-8
//#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int mod = 1e9+7;
long double PI = acosl(-1);
const ll infl = 3e18+100;
const int inf = 1e8+100;
const int nmax = 1e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

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

    ll n,k;
    cin>>n>>k;
    vector<int>v(n);
    for(int &x : v) cin>>x;
    ll ans = 0;
    for(int i=0; i<n; i++) for(int j=0; j<n; j++)if(v[i]>v[j]){
        if(i<j){
            ans = (ans + k*(k+1)/2 % mod) % mod;
        }
        else{
            ans = (ans + k*(k-1)/2 % mod) % mod;
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include<algorithm>
using namespace std;

int main(){
  int K, X;
  cin >> K >> X;
  
  int min_num, max_num;
  
  min_num = max(-100000,(X - K) + 1);
  max_num = min(100000,(X + K)  - 1);
  for(int i = min_num; i <= max_num; i++){
    cout << i << " ";
  }
  cout << endl;
}

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

typedef vector<int> vi;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, i, s;
	cin >> n;
	vi ord(n);
	for (i = 0; i < n; i++) {
		cin >> s;
		ord[s - 1] = i + 1;
	}
	for (i = 0; i < n; i++) {
		if (i > 0)
			cout << " ";
		cout << ord[i];
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 1280
#include <vector>
#include <iostream>
#include <set>
using namespace std;

int main(){
        int N, M;
        cin >> N;
        multiset<int> D;
        for(int i = 0; i < N; ++i) {
                int x;
                cin >> x;
                D.insert(x);
        }
        cin >> M;
        vector<int> T(M);
        for(int i = 0; i < M; ++i) cin >> T[i];

        for(int i = 0; i < M; ++i) {
                auto it = D.find(T[i]);
                if (it == D.end()){
                        cout << "NO" << endl;
                        return 0;
                }
                D.erase(it);
        }

        cout << "YES" << endl;
        return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 998244353;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll h, w;
	cin >> h >> w;
	ll ans = 0;
  
    if(h == 1 || w == 1) {
    	cout << 1 << "\n";
     	return 0;
    }
  
	if (h % 2 == 0 || w % 2 == 0) {
		cout << h * w / 2 << "\n";
	}
	else {
		ans += h * (w - 1) / 2;
		ans += h / 2 + 1;
		cout << ans << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let x: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut sorted: Vec<usize> = x.clone();
    sorted.sort();

    let median: usize = sorted[n / 2];
    let pre_median = sorted[n / 2 - 1];

    let mut result = String::new();
    for xi in x {
        if xi >= median {
            result.push_str(&format!("{}\n", pre_median));
        } else {
            result.push_str(&format!("{}\n", median));
        }
    }

    return result.trim().to_string();
}


Measured memory_bytes: 14588
#include <stdio.h>
int main()
{
    int a,b,i,j,d1,d2,ans=0,m=1;
    scanf("%d %d",&a,&b);
    i=b+1;
    d2=i+b;
    d1=d2;

    if((d2>a && a!=0)|| d2==a){
        printf("1");
    }
    else{

   while(d2<a){
    d2=d2+d1;
    m=m+1;
   }
    printf("%d",m);
     }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    map<string, int> m;
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    m[s] = a;
    m[t] = b;
    m[u]--;
    cout << m[s] << ' ' << m[t] << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

    int res = INF;
    for (int i = 1; i <= 100; ++i) {
        int tmp = 0;
        for (int j = 0; j < n; ++j) {
            tmp += (x[j] - i) * (x[j] - i);
        }
        chmin(res, tmp);
    }
    cout << res << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
#include <fstream>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--) {
    ll d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d)
        cout<<"Yes";
    else
        cout<<"No";
}
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt(), k = sc.nextInt(), c[] = new int[n], t = 0;

		for(int i = 0; i < k; i++) {
			int h = sc.nextInt();
			for(int j = 0; j < h; j++) {
				int idx = sc.nextInt();
				c[idx-1]++;
			}
		}

		for(int i = 0; i < n; i++) t += c[i] == 0 ? 1 : 0;

		System.out.println(t);
	}
}

Measured memory_bytes: 46152
#include<bits/stdc++.h>
using namespace std;
typedef struct node node;
long long dp[2005][2005];
struct node
{
    long long val,pos;
};
node a[2005];
bool compare(const node &n1,const node &n2)
{
    return n1.val>n2.val;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i].val);
        a[i].pos=i;
    }
    sort(a+1,a+1+n,compare);
    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
        for(int j=0;j<=i;j++)
    {
        if(dp[i-1][j]!=-1)
        {
            //cout<<i<<" "<<j<<endl;
            dp[i][j+1]=max(dp[i][j+1],dp[i-1][j]+a[i].val*(abs(a[i].pos-(j+1))));
            dp[i][j]=max(dp[i][j],dp[i-1][j]+a[i].val*abs(a[i].pos-(n-i+j+1)));
        }
    }
    long long ans=0;
    for(int j=0;j<=n;j++)
        {
            ans=max(ans,dp[n][j]);
            //cout<<dp[n][j]<<endl;
        }

    cout<<ans<<endl;
}


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

int main() {
    ios::sync_with_stdio(0);                                                                                                                               
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    t.pop_back();
    cout << (s == t ? "Yes\n" : "No\n");
    return 0;   
}

Measured memory_bytes: 3592
#include <cstdio>
using namespace std;
int bookin(int* books,int m,int w,int n);

int main(void)
{
  int n,m;
  for(;;){
    scanf("%d %d",&m,&n);
    if(n==0)return 0;
    int books[n];
    for(int i=0;i<n;i++){
      scanf("%d",&books[i]);
    }

    int low = 1,high=1500000;
    for(int i=0;i<100;i++){
      int mid = (low+high)/2;
      int midval = bookin(books,m,mid,n);

      if(midval==0)low = mid;
      else high = mid;
    }
    printf("%d\n",high); 
  }
}

int bookin(int* books,int m,int w,int n)
{
  int haba=w;
  for(int i=0;i<n;i++){
    haba-=books[i];
    if(haba<0){i--;m--;haba=w;}
    if(m<=0)return 0;
  }
  return 1;
}
  

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
const int N=1<<22;
int u[N],v[N],le[N];

int main()
{
	int l,m=0,n=1;
	scanf("%d",&l);
	for(int j=l;j;j/=3,n++);
	for(int i=0;l>=3;i++,l/=3)
	{
		for(int j=0;j<3;j++)
		{
			u[m]=i;
			v[m]=i+1;
			le[m++]=l/3*j;
		}
		for(int j=l/3*3;j<l;j++)
		{
			u[m]=i;
			v[m]=n-1;
			le[m++]=j;
		}
	}
	for(int i=0;i<l;i++)
	{
		u[m]=n-2;
		v[m]=n-1;
		le[m++]=i;
	}
	printf("%d %d\n",n,m);
	for(int i=0;i<m;i++)
	{
		printf("%d %d %d\n",u[i]+1,v[i]+1,le[i]);
	}
	return 0;
}

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

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

Measured memory_bytes: 3644
#include <stdio.h>
int main(void)
{
	int a, i;
	int x,y,z;
	int j,k,l;
	scanf("%d", &a);
	for (i=0;i<a;i++)
	{
		scanf("%d%d%d", &x, &y, &z);
		j=x*x+y*y;
		k=x*x+z*z;
		l=y*y+z*z;

		if (j==z*z || k==y*y || l==x*x)
		{
			printf("YES\n");
		}
		else
			printf("NO\n");

	}
	return 0;
}

Measured memory_bytes: 576
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	cout<<N/3<<endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
S=list(input())
#print(S)
#print(S[-(len(S)-1)//2+i])
#print(S[(len(S)//2)-1])
for i in range((len(S)//2)-1):
  if S[i]!=S[-(i+1)]:
    print('No')
    exit()
#print(S[((len(S)-1)//2)-1])    
for i in range((len(S)-1)//2):
  if S[i]!=S[((len(S)-1)//2)-(i+1)]:
    print('No')
    exit()
#for i in range((len(S)-1)//2+1,len(S)):
for i in range((len(S)-1)//2):
  if S[(len(S)-1)//2+1+i]!=S[-(i+1)]:
    print('No')
    exit()    
print('Yes')

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

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

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;

int main()
{
    ll N;
    cin >> N;
    const ll div = 1000;
    cout << (N + div - 1) / div * 1000 - N << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<sstream>
using namespace std;
typedef long long ll;
const ll maxn=1e6+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
void io(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
ll a[maxn];
int main()
{
	io();
	ll n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++)
		cin>>a[i];
	sort(a,a+k);
	ll mm=inf;
	for(int i=0;i<k;i++)
	{
		if(i==0)
		{
			mm=min(mm,a[k-1]-a[0]);
			mm=min(mm,a[0]+n-a[1]);
		}
		else if(i==k-1)
		{
			mm=min(mm,a[k-2]+n-a[k-1]);
		} 
		else
		{
			mm=min(mm,a[i]+n-a[i+1]);
			mm=min(mm,n-a[i]+a[i-1]);
		} 
		
	}
	cout<<mm<<endl;
	return 0;
}

Measured memory_bytes: 1792
/************************************/
/* NoobM							*/
/* File Name : chaa.cpp				*/
/* Date : 13.07.2020 02:37:00 +06	*/
/************************************/

#include <bits/stdc++.h>

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
	int n;
	cin >> n;
	
	vi(n, a);
	
	sort(a.rbegin(), a.rend());
	
	ll alice = 0;
	ll bob = 0;
	
	for(int i = 0; i < n; i++) {
		if(i % 2 == 0) alice += a[i];
		else bob += a[i];
	}
	
	cout << alice - bob << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
	
	int t = 1;
	//cin >> t;
	
	while (t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	string s;
	cin >> s;
	string ans;
	ans = ans + s[0];
	ans = ans + to_string(s.size() - 2);
	ans = ans + s[s.size() - 1];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		long d = p[1];
		long wa = 0;
		for(int i = 0; i <n; i++)
		{
			p = Input().ToInt();
			
			long x = p[0];
			long y = p[1];
			
			if(x * x + y* y <= d*d)
			{
				wa++;
			}
		}
		Console.WriteLine(wa);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 40696
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#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 forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    vi a(n);
    map<int,int> m;
    i64 s0=0;
    forn(i,n){
        cin>>a[i];
        m[a[i]]++;
        s0 += a[i];
    }
    int q;
    cin>>q;
    while(q--){
        int b,c;
        cin>>b>>c;
        if(m.count(b)){
            i64 d = c-b;
            i64 si = s0 + d*m[b];
            m[c] += m[b];
            m[b] = 0;
            s0=si;
            cout<<s0<<endl;
        }
        else{
            cout<<s0<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 7428
#include<cstdio>
#include<string>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;

int main(void) {
	std::ios::sync_with_stdio(false);
	int n;
	double f;
	while(cin >> n) {
		if(n == 1)
			cout << "1.0000000000" << endl;
		else if(n & 1) {
			f = double(n/2)+1;
			f /= double(n);
			cout << f << endl;
		}
		else {
			cout << "0.5000000000" << endl;
		}
	}
} 

Measured memory_bytes: 256
#pragma region header
#include <bits/stdc++.h>
#define int long long
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define mp make_pair
#define mt make_tuple
#define rep1(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define rrep1(i, n) for (auto i = n - 1; i > static_cast<decltype(i)>(-1); i--)
#define rep2(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep2(i, a, b) for (auto i = b - 1; i >= a; i--)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1) (__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep2, rrep1) (__VA_ARGS__)
#define each(i, a) for (auto &&i : (a))
using namespace std;

using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vd = vector<ld>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using vp = vector<pii>;
using vvp = vector<vp>;
using mii = map<int, int>;
using vm = vector<mii>;
using vvm = vector<vm>;
template <class T>
using less_queue = priority_queue<T>;
template <class T>
using greater_queue = priority_queue<T, vector<T>, greater<T>>;

constexpr int INF = 1e18;

template <class T>
void SORT(T &a) { stable_sort(all(a)); }
template <class T>
void RSORT(T &a) { stable_sort(rall(a)); }
template <class T>
void rev(T &a) { reverse(rall(a)); }
template <class T>
void uniq(T &a) { a.erase(unique(all(a)), end(a)); }
template <class T>
auto min_of(T a) { return *min_element(all(a)); }
template <class T>
auto max_of(T a) { return *max_element(all(a)); }
template <class T>
int sum_of(T a) { return accumulate(all(a), 0ll); }
template <class T, class U>
auto sum_of(T a, U init) { return accumulate(all(a), init); }
template <class T, class U>
int count_of(T a, U i) { return count(all(a), i); }
template <class T, class U>
bool has(T a, U i) { return find(all(a), i) != end(a); }
template <class T>
int sz(T a) { return a.size(); };

template <class T>
void COUT(T x) { cout << x << endl; }
template <class T, class U>
void COUT(T x, U y) { cout << x << ' ' << y << endl; }
template <class T, class U, class V>
void COUT(T x, U y, V z) { cout << x << ' ' << y << ' ' << z << endl; }
template <class T>
void CSP(T x) { cout << x << ' '; }
template <class T>
void CVEC(T v) {
  int c = v.size() - 1;
  for (size_t i = 0; i < c; i++) cout << v[i] << ' ';
  if (c > -1) cout << v[c];
  cout << endl;
}

template <class T>
bool amin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool amax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int ceil_div(int x, int y) { return (x - 1) / y + 1; }

#pragma endregion header

// no MOD


void solve(int n, int l) {
  int ans = (n - 1) * n / 2 + l * n;
  if(l > 0)ans -= l;
  else if(l + n - 1 < 0)ans -= l + n - 1;
  COUT(ans);
}


#pragma region main
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;
  int l;
  cin >> l;
  solve(n, l);
}
#pragma endregion main


Measured memory_bytes: 3492
def f(a, b):
    tmpA, tmpB = a, b
    countA = 0
    while tmpA:
        tmpA //= 10
        countA += 1
    digitA = countA

    countB = 0
    while tmpB:
        tmpB //= 10
        countB += 1
    digitB = countB

    return max(digitA, digitB)

n = int(input())

ans = 11
for a in range(1, int(n ** 0.5) + 1):
    b = n / a
    if f(a, b) < ans and n % a == 0:
        ans = f(a, b)

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};
int dx2[]={1, 1, 0, -1, -1, -1, 0, 1};
int dy2[]={0, -1, -1, -1, 0, 1, 1, 1};

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

    // dp[i] := i 番目まで操作したときの数列の場合の数
    vector<ll> dp(n+10, 0);
    vector<ll> dpsum(200010, 0);
    dp[0]=1;
    for(int i=0; i<n; i++){
        if(0<=i-1 && c[i]==c[i-1]){
            dp[i+1]=dpsum[c[i]];
        }
        else{
            dp[i+1]=dp[i]+dpsum[c[i]];
            dpsum[c[i]]+=dp[i];
        }
        dp[i+1]%=MOD;
        dpsum[c[i]]%=MOD;
    }

    cout << dp[n] << endl;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,h[200005],a[200005];
int bit[200005];
void update(int x,int y=1){
    for(;x<=n;x+=x&(-x)) bit[x]=max(bit[x],y);
}
int query(int x){
    int res=0;
    for(;x>0;x-=x&(-x)) res=max(res,bit[x]);
    return res;
}
void solve(){
    int ans=0;
    cin>>n;
    rep(i,1,n+1) cin>>h[i];
    rep(i,1,n+1) cin>>a[i];
    rep(i,1,n+1){
        int cur=query(h[i])+a[i];
        ans=max(ans,cur);
        update(h[i],cur);
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int r; cin >> r;
    if (r < 1200) {
        cout << "ABC" << endl;
    } else if (r < 2800) {
        cout << "ARC" << endl;
    } else cout << "AGC" << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
template< typename T >
struct SparseTable {
  vector< vector< T > > st;
  vector< vector< T > > stb;
  vector< int > lookup;

  SparseTable(const vector< T > &v) {
    int b = 0;
    while((1 << b) <= v.size()) ++b;
    st.assign(b, vector< T >(1 << b));
    stb.assign(b, vector< T >(1 << b));
    for(int i = 0; i < v.size(); i++) {
      st[0][i] = v[i];
      stb[0][i] = v[i];
    }
    for(int i = 1; i < b; i++) {
      for(int j = 0; j + (1 << i) <= (1 << b); j++) {
        st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
        stb[i][j] = max(stb[i - 1][j], stb[i - 1][j + (1 << (i - 1))]);
      }
    }
    lookup.resize(v.size() + 1);
    for(int i = 2; i < lookup.size(); i++) {
      lookup[i] = lookup[i >> 1] + 1;
    }
  }

  inline T rmq(int l, int r) {
    int b = lookup[r - l];
    return min(st[b][l], st[b][r - (1 << b)]);
  }
  inline T rmr(int l, int r) {
    int b = lookup[r - l];
    return max(stb[b][l], stb[b][r - (1 << b)]);
  }
};

int main(){
  int n,k;
  cin>>n>>k;
  int ans;
  int x=0;
  if(k==n){
    cout<<1<<endl;
    return 0;
  }
  ans=n-k+1;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  SparseTable<int> table(vec);
  string z="";
  string p="";
  for(int i=0;i<n-1;i++){
    if(vec.at(i)<vec.at(i+1)){
      z+='<';
    }
    else{
      z+='>';
    }
  }
  for(int i=0;i<k-1;i++){
    p+='<';
  }
  map<int,int> ma;
  for(int i=0;i<n-k+1;i++){
    if(z.substr(i,k-1)==p){
      x++;
      ma[i]++;
    }
  }
  for(int i=0;i<n-k;i++){
    int j=i+k;
    if(ma[i]!=1||ma[i+1]!=1){
      if(table.rmq(i,j+1)==vec.at(i)&&table.rmr(i,j+1)==vec.at(j)){
        ans--;
      }
    }
  }
  if(x>1){
    ans++;
  }
  cout<<ans-x<<endl;
}

Measured memory_bytes: 48380
#include <iostream>
#include <algorithm>
using namespace std;
int a[1000], sum;
int main() {
    int n;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    sort(a, a + n, greater<int>());
    for(int i=0; i<n; i++) {
        if(i % 2 == 0) sum += a[i];
        else sum -= a[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if (b==1) {
        cout << 0 << endl;
    }
    else {
        for (int i = 1; i < 100; i++) {
            if (a * i - (i-1) >= b) {
                cout << i << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var count = S.Count(z => z == 'o');

            Console.WriteLine(700 + count * 100);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
int m,f,b;
cin>>m>>f>>b;
if(m>=b){
         cout<<"0"<<endl;
        }
else if((m+f)>=b){
                  cout<<(b-m)<<endl;
                 }
else{
    cout<<"NA"<<endl;
}
}


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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define MOD (int)10e9+7

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

int n;
string s,t;


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


    cin >> n;
    vector<char> temp(2*n);
    cin >> s >> t;
    for(int i = 0; i<n; i++)
        temp[2*i]=s[i], temp[2*i+1]=t[i];

    for(int i = 0; i<2*n;i++)
        cout << temp[i];
    cout << endl;
    return 0;

}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy" << endl;
    }
    if (s == "Cloudy") {
        cout << "Rainy" << endl;
    }
    if (s == "Rainy") {
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  vvll dp(n, vll(n, INF));

  vll p(n + 1);
  rep(i, n) {
    cin >> p[i] >> p[i + 1];
    dp[i][i] = 0;
  }

  for (ll h = 1; h <= n - 1; h++) {
    for (ll i = 0; i <= n - 1 - h; i++) {
      ll j = i + h;
      for (ll k = i; k <= j - 1; k++) {
        chmin(dp[i][j], dp[i][k] + dp[k+1][j] + p[i] * p[k + 1] * p[j + 1]);
      }  // k
    }    // i
  }      // h

  cout << dp[0][n - 1] << endl;

  return 0;
}



Measured memory_bytes: 3240
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    N, M = map(int, input().split())
    adj = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    seen = [0] * (N+1)
    num = 0
    for v0 in range(1, N+1):
        if seen[v0]:
            continue
        num += 1
        que = deque()
        que.append(v0)
        while que:
            v = que.popleft()
            for u in adj[v]:
                if seen[u] == 0:
                    seen[u] = 1
                    que.append(u)
    print(num - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81656
s=input()
t=input()

#sを一番若く､tを一番老いさせたい listにしてソート？
ss=list(s)
tt=list(t)
ss.sort()
tt.sort(reverse=True)
#print(ss,tt)
s,t=map(''.join,[ss,tt])
#print(s,t)
if s<t:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);

ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
 /*struct cmp{ bool operator() ( const, const )const{}};
  use as set<ll> ,cmp> a*/
int main()
{
  Summon_Tourist;
  //freopen("input.txt" , "r" , stdin );
  ll n,m;
  cin>>n>>m;
  vector<ll> elev(n+1,0);
  for( ll i = 1 ; i<=n ; i++ )
    cin>>elev[i];
  vector<ll> a[n+1];
  for( ll i = 0 ; i<m ; i++ )
  {
      ll x,y;
      cin>>x>>y;
      a[x].push_back(y);
      a[y].push_back(x);
  }
  queue<ll> q;
  ll ans = 0;
  vector<ll> visited(n+1,0);
  for( ll i = 1 ; i<=n ; i++ )
  {
      if(visited[i]) continue;
      else
      {
          if(a[i].size()==0)
          {ans++;continue;}
          q.push(i);
          while(!q.empty())
          {
              ll p = q.front();
              q.pop();
              if(visited[p]) continue;
              visited[p] = 1;
              bool ok = true;
              for( ll i = 0 ; i<a[p].size() ; i++ )
              {
                  if( elev[p] > elev[a[p][i]] )
                  {
                      visited[a[p][i]] = 1 ;
                  }
                  else if( elev[p] < elev[a[p][i]] )
                  {
                      ok = false ;
                      q.push(a[p][i]);
                  }
                  else
                  {
                      ok = false;
                      visited[a[p][i]] = 1;
                  }
              }
              if(ok)
                ans++;
          }
      }
  }
  cout<<ans;
  return 0;

}



Measured memory_bytes: 10596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include<functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	map<int, int> prices;
	int t, n;
	
	prices[1] = 6000;
	prices[2] = 4000;
	prices[3] = 3000;
	prices[4] = 2000;
	
	REP(4)
	{
		cin >> t >> n;
		cout << prices[t] * n << endl;
	}
	
	return 0;
}

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

int main(){
    long n,q;cin>>n>>q;
    vector<vector<long>> graph(n+1);
    for(int i=1;i<n;i++){
        long a,b;cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    
    vector<long> score(n+1,0);
    vector<long> scoredp(n+1,0);
    for(long i=0;i<q;i++){
        long p,x;cin>>p>>x;
        scoredp[p]+=x;
    }
    stack<long> s;s.push(1);
    vector<long> prev(n+1,0);
    while(s.size()!=0){
        long a=s.top();
        s.pop();
        score[a]+=scoredp[a];
        prev[a]=1;
        for(int i=0;i<graph[a].size();i++){
            if(prev[graph[a][i]]==0){
                score[graph[a][i]]+=score[a];
                s.push(graph[a][i]);
            }
        }
    }
    for(long i=1;i<n;i++)cout<<score[i]<<" ";
    cout<<score[n]<<endl;
}

Measured memory_bytes: 22140