akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> b(n),ans;
    rep(i,n) cin>>b[i];
    int now=n-1;
    while(true){
      bool flag=false;
      int ind;
      for(int i=now;i>=0;i--){
        if(b[i]==i+1 && !flag){
          ind=i;
          ans.push_back(b[i]);
          flag=true;
          b.erase(begin(b)+i);
          break;
        }
      }
      if(!flag) break;
      now--;
      if(now==-1) break;
    }
    if(now!=-1){
      cout<<-1<<endl;
    }else{
      reverse(begin(ans),end(ans));
      for(auto itr:ans){
        cout<<itr<<endl;
      }
    }
}

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

// 1indexed1dimention[l,r]
class imos1d{
    public:
    vector<ll>t, v;
    ll num;
    ll flg;
    imos1d(ll NUM = 0){
        flg = 0;
        num = NUM + 10;
        v = vector<ll>(num, 0);
        t = vector<ll>(num, 0);
    }
    void add(ll idx, ll x){
        flg = 0;
        t[idx] += x;
    }
    void make(){
        flg = 1;
        for(ll i = 1; i < num; i++)v[i] = v[i - 1] + t[i];
    }
    ll sum(ll l, ll r){
        if(!flg)make();
        return v[r] - v[l - 1];
    }
};

class bit1d{
    public:
    vector<ll>v;
    ll num;
    bit1d(ll NUM = 0){
        num = NUM + 10;
        v = vector<ll>(num, 0);
    }
    void add(ll idx, ll x){
        if(idx == 0)return;
        while(idx <= num){
            v[idx] += x;
            idx += idx & -idx;
        }
    }
    ll sum_of_1_to_idx(ll idx){
        if(idx <= 0)return 0;
        ll s = 0;
        while(idx > 0){
            s += v[idx];
            idx -= idx & -idx;
        }
        return s;
    }
    ll sum(ll l, ll r){
        return sum_of_1_to_idx(r) - sum_of_1_to_idx(l - 1);
    }
};

int main(){
    
    for(ll N, K; cin >> N >> K, N;){
        imos1d data(N);
        for(ll i = 1; i <= N; i++){
            ll x;
            cin >> x;
            data.add(i, x);
        }
        ll ans = data.sum(1, K);
        for(ll l = 1, r = K; r <= N; l++, r++){
             ll tmp = data.sum(l, r);
             ans = max(ans, tmp);
        }
        cout << ans << endl;
    }
    
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0; i<n; i++) cin >> p[i];
    int ans = 0;
    for(int i=0; i<n-2; i++){
        if (p[i] < p[i+1] && p[i+1] < p[i+2]) {
            ans += 1;
        } else if(p[i] > p[i+1] && p[i+1] > p[i+2]) {
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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


signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int n;
    cin>>n;

    int last = 1e9+5;
    vector<int> v;
    vector<int> r;
    for (int i=0; i<n; i++){
        int x, y;
        cin>>x>>y;
        r.push_back(last-x+y);
        v.push_back(x+y);
    }
    sort(v.begin(), v.end());
    sort(r.begin(), r.end());
    int ans = 0;
    ans = max(ans, v[n-1]-v[0]);
    ans = max(ans, r[n-1]-r[0]);

    cout<<ans<<endl;

    return 0;
}






Measured memory_bytes: 6636
from sys import stdin
N = int(stdin.readline().rstrip())
input = stdin.readline().split()
mem = 0
cnt = 0
for i in range(N):
    if i == 0:
        continue
    if i == N-1:
        continue
    if int(input[i]) > int(input[i-1]) and int(input[i+1]) > int(input[i]):
        # print(input[i])
        cnt += 1
    if int(input[i]) < int(input[i-1]) and int(input[i+1]) < int(input[i]):
        # print(input[i])
        cnt += 1
print(cnt)

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

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b == 0) return b;
  else gcd(b, a%b);
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

vector<string> st;

int main(){

  string s;cin >> s;
  int n;cin >> n;

  for(int c = 0 ; c < 26 ; c++){
   for(int j = 0 ; j < s.length() ; j++){
     string t = "";
      if(s[j] == 'a' + c){
        t += s[j];
        st.pb(t);
        for(int k = j + 1 ; k < s.length(); k++){
          t += s[k];
          if(t.length() > n)break;
          st.pb(t);
          if(st.size() > s.length() * n)break;
        }
      }
    }
  }

  sort(all(st));
  unique(all(st));

  pr(st[n-1]);

  return 0;

}


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

using namespace std;

const int MAXN = 100 + 5;

int n;
string a, b;

bool check(char aa, char bb){
	a += aa;
	b += bb;
	cout << a << endl;
	cout << b << endl;
	char t;	cin >> t;
	if (t == 'T')	return true;
	a.pop_back();
	b.pop_back();
	return false;
}

bool check2(char aa, char bb){
	a = aa + a;
	b = bb + b;
	cout << a << endl;
	cout << b << endl;
	char t;	cin >> t;
	if (t == 'T')	return true;
	a.erase(a.begin());
	b.erase(b.begin());
	return false;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	bool fail = 0;
	while (a.size() < n){
		bool done = 0;
		if (!fail){
			if (check('#', '.'))	done = 1;
			else if (check('#', '#'))	done = 1;
			else if (check('.', '#'))	done = 1;
			else if (check('.', '.'))	done = 1;
		}
		if (!done)	fail = 1;
		if (fail){
			if (check2('#', '.'))	done = 1;
			else if (check2('#', '#'))	done = 1;
			else if (check2('.', '#'))	done = 1;
			else if (check2('.', '.'))	done = 1;
		}
	}
	return 0;
}


Measured memory_bytes: 596
/*
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,n)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
using li = long int;
using ull= unsigned long long;
using vi = vector<li>;
using vs = vector<string>;


int main()
{
    string s;
    cin>>s;
    for(int i=s.size()-s.size()%2-2;i>0;i-=2) if(s.substr(0,i/2)==s.substr(i/2,i/2)) { cout<<i<<endl; break;}
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    #define int long long  
    typedef long double ld;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
    #define INF 1e10
    const double pi=3.14159265358979323;
    const int mod=998244353;
    int gcd(int a, int b) 
    { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
    } 
    void swap(int a,int b)
    {
      int temp=a;
      a=b;
      b=temp;
    } 
    int  binpow(int  a,int  b) 
    {
    int res = 1;
    while (b > 0) {
        if (b%2 == 1)
            res = (res * a)%mod;
        a = (a* a)% mod;
        b >>= 1;
    }
    return res;
}
    int modinv(int y)
    {
        return binpow(y,mod-2);
    }

    int fact[500000+5];
    void precal()
    {
    fact[0]=1;
    for(int i=1;i<500000+5;i++)
    {
        fact[i]=(i*fact[i-1])%mod;
    }
}
    signed main() {

 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout); 
      }
    #endif  
    // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1; 
    //cin>>t;
    while(t--)
    {
        int x,y;
        cin>>x>>y;
        if(y%2!=0)
            cout<<"No"<<endl;
        else
        {
            int b=y/2-x;
            int a=2*x-y/2;
            if(a<0 || b<0)
                cout<<"No"<<endl;
            else
                cout<<"Yes"<<endl;
        }

    }
}


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

using namespace std;


#define M_DEBUG if(0)


int main() {
    /*
        a - b - c - a
          P   Q   R
      
    */

    int p, q, r;
    cin >> p >>  q >> r;
    assert(1 <= p && p <= 100); 
    assert(1 <= q && q <= 100);
    assert(1 <= r && r <= 100);

    // 3C2 (逆に行く場合は変わらない)
    int pq = p + q;
    int pr = p + r;
    int qr = q + r;
    int min = 200; // 超えない
    if (min > pq) min = pq;
    if (min > pr) min = pr;
    if (min > qr) min = qr;
    assert(min > -1);
    cout << min << endl;

	return 0;
}


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

int main() {
  int K;
  cin >> K;
  
  if (K % 2 == 0) cout << (K / 2) * (K / 2) << endl;
  else {
    K = (K - 1) / 2;
    cout << K * K + K << endl;
  }
}

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

//---------- べき乗 ----------
Int power(Int a, Int n, Int MOD){
    if(a == 0) return 0;
    if(n == 0) return 1;
    if(MOD == 0) return 0;
    
    Int res = 1;
    while(n > 0){
        if(n % 2 == 1) res = res * a % MOD;
        a = a * a % MOD; n /= 2;
    }
    return res;
}

int main(){
    Int N; string X;
    cin >> N >> X;

    Int popcount = count(X.begin(), X.end(),'1');
    Int rem1 = 0, rem2 = 0;
    rep(i,N){
        if(X[i] == '1'){
            rem1 += power(2,N-1-i,popcount+1);
            rem2 += power(2,N-1-i,popcount-1);
        }
    }
    //cout << rem1 << " "<< rem2 << endl;

    rep(i,N){
        

        if(popcount == 1 && X[i] == '1'){
            cout << 0 << endl;
            continue;
        }

        Int ans = 1, rem_now;
        if (X[i] == '0'){
            rem_now = rem1;
            rem_now += power(2,N-1-i,popcount+1);
            rem_now %= (popcount+1);
        } else {
            rem_now = rem2;
            rem_now += (popcount-1) - power(2,N-1-i,popcount-1);
            rem_now %= (popcount-1);
        }

        //cout << rem_now << endl;
        while(rem_now > 0){
            Int ppc = 0;
            rep(i,20){
                if(rem_now >> i & 1) ppc++;
            }

            rem_now %= ppc;
            ans++;
        }

        cout << ans << endl;
    }
}  

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    ll N, A, B; cin >> N >> A >> B;

    if ((N == 1) && (A != B)) {
        cout << 0 << endl;
        return 0;
    }

    ll x = (N - 1) * A + B;
    ll y = (N - 1) * B + A;

    cout << max(y - x + 1, (ll) 0) << endl;
}


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

namespace abc007_3
{
    class Program
    {
        static void Main(string[] args)
        {
            Queue<int> wherex = new Queue<int>(); Queue<int> wherey = new Queue<int>();
            int[] banmen = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[,] visit = new int[banmen[0] + 2,banmen[1] + 2];
            char[,] maiz = new char[banmen[0] + 2,banmen[1] + 2];
            int white = 0;
            for (int j = 0; j < banmen[1] + 2; j++) maiz[0,j] = '#';
            for (int i = 1; i <= banmen[0]; i++)
            {
                string s = Console.ReadLine();
                for (int j = 1; j <= banmen[1]; j++)
                {
                    if (s[j - 1] == '.') white++;
                    maiz[i,j] = s[j - 1];
                }
            }
            for (int j = 0; j < banmen[1] + 2; j++) maiz[banmen[0] + 1,j] = '#';
            int[] xidou = new int[] { 1,-1,0,0 }; int[] yidou = new int[] { 0,0,1,-1 };
            wherex.Enqueue(-1); wherey.Enqueue(-1);
            wherex.Enqueue(1); wherey.Enqueue(1);
            int deep = 0;
            while (wherex.Count() != 1 && (!(wherex.Peek() == banmen[0] && wherey.Peek() == banmen[1])))
            {
                int nowx = wherex.Dequeue(); int nowy = wherey.Dequeue();
                if (nowx == -1 && nowy == -1)
                {
                    deep++;
                    wherex.Enqueue(-1); wherey.Enqueue(-1);
                }
                else
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (maiz[nowx + xidou[i],nowy + yidou[i]] == '.')
                        {
                            visit[nowx + xidou[i],nowy + yidou[i]] = deep;
                            maiz[nowx + xidou[i],nowy + yidou[i]] = '#';
                            wherex.Enqueue(nowx + xidou[i]); wherey.Enqueue(nowy + yidou[i]);
                        }
                    }
                }
            }
            Console.WriteLine(visit[banmen[0],banmen[1]] > 0 ? white - visit[banmen[0],banmen[1]] - 1 : -1);
        }
    }
}

Measured memory_bytes: 13504
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = n - 2; j >= i; j--) {
                if (arr[j] > arr[j + 1]) {
                    int tmp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = tmp;
                    count++;
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                sb.append(" ");
            }
            sb.append(arr[i]);
        }
        System.out.println(sb);
        System.out.println(count);
    }
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	int N, M;

	cin >> N >> M;

	double cost = 1900.0*M + 100.0*(N-M);

	double p = 1.0;
	rep(i,M) p /= 2.0;
	double q = 1.0 - p;

	double ans = 0, cur = 1.0, k = 1.0;
	rep(i,10004){
		ans += cur * p * cost * k;
		cur *= q;
		k += 1.0;
		//cout << cur << endl;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int nxt[200005][26];
int dp[200005];
pair<char,int> r[200005];

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

  int N = A.size();
  
  rep(i,26){
    nxt[N][i] = N;
  }

  for(int i=N-1; i>=0; i--){
    rep(j,26){
      nxt[i][j] = nxt[i+1][j];
      if(A[i] == 'a'+j){
        nxt[i][j] = i;
      }
    }
  }

  dp[N] = 1;
  for(int i=N-1; i>=0; i--){
    dp[i] = N+1;
    rep(j,26){
      if(nxt[i][j] == N){
        if(dp[i] > 1){
          dp[i] = 1;
          r[i] = make_pair('a'+j,N);
        }
      }else{
        if(dp[i] > dp[nxt[i][j]+1] + 1){
          dp[i] = dp[nxt[i][j]+1] + 1;
          r[i] = make_pair('a'+j,nxt[i][j]+1);
        }
      }
    }
  }

  string ret;
  int idx = 0;
  while(idx < N){
    ret += r[idx].first;
    idx = r[idx].second;
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 23172
import java.util.*;
  public class Main{
    public static void main(String[]args){
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      String t = sc.next();
      char [] a = s.toCharArray();
      char [] b = t.toCharArray();
      if(a[0]==b[0]&&a[1]==b[1]&&a[2]==b[2]){
        System.out.println("3");
      }else if((a[0]==b[0]&&a[1]==b[1])||(a[1]==b[1]&&a[2]==b[2])||(a[0]==b[0]&&a[2]==b[2])){
        System.out.println("2");
      }else if(a[0]==b[0]||a[1]==b[1]||a[2]==b[2]){
        System.out.println("1");
      }else{
        System.out.println("0");
      }
    }
  }

Measured memory_bytes: 21972
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int n,m;

inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

inline void print(int x){
	if (x<0){putchar('-'); x=-x;}
	if (x>=10) print(x/10);
	putchar(x%10+'0');
}

long long l,r;

int main(){
	scanf("%lld%lld",&l,&r);
	int ans=0;
	for (;l<=r;l<<=1) ans++;
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
	bool f[30];

	memset(f, 0, sizeof(f));

	for (int i = 0; i < 28; i++) {
		int n;
		cin >> n;
		f[n - 1] = 1;
	}

	for (int i = 0; i < 30; i++) {
		if (!f[i])
			cout << i + 1 << endl;
	}

	return 0;
}


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

int main() {
    ll N, T;
    cin >> N >> T;

    ll t[N];
    rep(i, N) cin >> t[i];

    ll ans = 0;
    rep(i, N-1) ans += min(T, t[i+1]-t[i]);
    ans += T;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

ll fact(int n) {
    ll res = 1;
    for (int i = 1; i <= n; i++) {
        res *= i;
        res %= MOD;
    }
    return res;
}

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

    cout << fact(n) << endl;
}

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

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

using namespace std;

int main() {
  int x;
  std::cin >> x;
  if (x >= 30) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


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

int main() {

  string s;
  cin >> s;

  vector<int> l(s.size()+1);
  vector<int> r(s.size()+1);

  int count = 0;

  for (int i = 0; i < s.size(); i++) {
    l[i] = count;
    if (s[i] == '<') {
      count++;
    } else {
      count = 0;
    }
  }
  l[s.size()] = count;

  count = 0;

  for (int i = s.size(); 0 <= i; i--) {
    r[i+1] = count;
    if (s[i] == '>') {
      count++;
    } else {
      count = 0;
    }
  }
  r[0] = count;

  long answer = 0;

  for (int i = 0; i <= s.size(); i++) {
    answer += max(l[i], r[i]);
  }
  
  cout << answer << endl;
  
}


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

//{{{
#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

const int M = 2e5 + 10;
const int mod = 1e9 + 7;
LL p[M];
LL inv[M];

LL cal(int x, int y, int xx, int yy)
{
    if (xx < x || yy < y) return 0;
    int dx = xx - x;
    int dy = yy - y;
    if (dx == 0 || dy == 0) return 1;

    LL ret = p[dx + dy];
    ret = ret * inv[dx] % mod;
    ret = ret * inv[dy] % mod;
    return ret;
}

const int N = 3000 + 10;
LL dp[N];
LL h, w;
int n;
vector<pair<int, int>> grid;

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    int lim = 2e5;
    p[0] = 1;
    for (int i = 1; i <= lim; i++) p[i] = p[i - 1] * i % mod;
    inv[1] = 1;
    for (int i = 2; i <= lim; i++) inv[i] = inv[mod % i] * (mod - mod / i) % mod;

    // for (int i = 2; i <= lim; i++) p[i] = p[i - 1] * p[i] % mod;
    for (int i = 2; i <= lim; i++) inv[i] = inv[i - 1] * inv[i] % mod;

    while (~scanf("%lld%lld%d", &h, &w, &n))
    {
        grid.clear();
        int r, c, pr, pc;
        for (int i = 0; i < n; i++)
        {
            scanf("%d%d", &r, &c);
            grid.push_back({r, c});
        }
        sort(all(grid));

        for (int i = 0; i < n; i++)
        {
            // dp[i]
            r = grid[i].first;
            c = grid[i].second;

            LL tot = cal(1, 1, r, c);

            for (int j = 0; j < i; j++)
            {
                pr = grid[j].first;
                pc = grid[j].second;

                LL v1 = dp[j];

                LL v2 = cal(pr, pc, r, c);
                LL v = v1 * v2 % mod;

                tot -= v;
                if (tot < 0) tot = tot + mod;
            }
            dp[i] = tot;
        }

        LL ans = cal(1, 1, h, w);
        for (int i = 0; i < n; i++)
        {
            r = grid[i].first;
            c = grid[i].second;

            LL v1 = dp[i];
            LL v2 = cal(r, c, h, w);
            LL v = v1 * v2 % mod;

            ans -= v;
            if (ans < 0) ans += mod;
        }
        printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 6924
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

int A,B,C, k;
bool fg = false;
void func(int a, int b, int c, int cnt){
    if(c > b && b > a)fg = true;
    if(cnt==k){
        return;
    }

    func(a*2, b, c, cnt+1);
    func(a, b*2, c, cnt+1);
    func(a, b, c*2, cnt+1);
}

int main(){
    cin >> A >> B >> C >> k;
    func(A, B, C, 0);
    if(fg)cout << "Yes" << ln;
    else cout << "No" << ln;
}
    


Measured memory_bytes: 3616
#include<iostream>
#include<string>
using namespace std;
int N_MAX = 100001;
int main()
{
  int n,k,res,i,j,tmp,tmp2;
  int c[N_MAX];
  string s,t,u;
  cin >> n >> k;
  cin >> s;
  t=s.substr(0,1);
  if(t=="0"){
    c[0]=0;
    j=1;
  } else {
    j=0;
  }
  tmp=1;
  u=t;
  for(i=1;i<n;i++){
    t=s.substr(i,1);
    if(u==t){
      tmp++;
    } else {
      c[j]=tmp;
      if(j==k*2) tmp2=i;
      j++;
      tmp=1;
      u=t;
    }
  }
  c[j]=tmp;
  if(t=="0"){
    j++;
    c[j]=0;
  }
  if(j<=k*2){
    cout << n << endl;
    return 0;
  }
  res=tmp2;
  for(i=k*2+1;i<j;i+=2){
    tmp2=tmp2-c[i-k*2-1]-c[i-k*2]+c[i]+c[i+1];
    res=max(res,tmp2);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-3;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

long long int to_int(string S){
    int n = S.size();
    long long int ans = 0;
    vector<ll> B(n);
    for(int i = 0;i < n;i++){
      bool frag = 1;
        for(ll j = 0;j < 10;j++){
            char a = '0' + j;
            if(S[i] == a){
                B[i] = j;
                frag = 0;
                break;
            }
        }
        if(frag) return -1;
    }
    for(ll i = 0;i < n;i++){
        ans += B[i]*pow(10LL,(n-i-1));
    }
    return ans;
}

ll N;
string A[200010];
ll B[200010];

ll cnt[110][110]; //two,five;

int main(){
    cin >> N;
    rep(i,N){
        cin >> A[i];
        rep(j,A[i].size()){
            if(A[i][j] == '.'){
                string S = A[i].substr(0,j) + A[i].substr(j+1,A[i].size()-j-1);
                rep(k,9 - (A[i].size()-j-1)){
                    S += '0';
                }
                B[i] = to_int(S);
                break;
            }else if(j == A[i].size() - 1){
                B[i] = to_int(A[i] + "000000000");
            }
        }
    }
    ll ans = 0;
    rep(i,N){
        ll T = 0,F = 0;
        ll n = B[i];
        while(n % 2 == 0){
            T++;
            n /= 2;
        }
        n = B[i];
        while(n % 5 == 0){
            F++;
            n /= 5;
        }
        FOR(j,max(18-T,0LL),80){
            FOR(k,max(18-F,0LL),80){
                ans += cnt[j][k];
            }
        }
        cnt[T][F]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11792
N = input()
digit = len(N)

N = int(N)

import itertools

ans = 0
for i in range(1, digit + 1):
  for prod in itertools.product(("3","5","7"), repeat = i):
    if int("".join(prod)) <= N and len(set(prod)) == 3:
      ans += 1

print(ans)

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  string S;
  cin>>S;
  S[5]=' ';
  S[13]=' ';
  cout<<S<<endl;
  }


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

//フィボナッチ数 mod p
vector<long long> fibmemo(100000, 0);
long long fib(long long n, long long p) {
  if (n == 0) return 0;
  if (n == 1) return 1;
  if (0 <= n && n <= 99999 && fibmemo.at(n) != 0)
    return fibmemo.at(n) % p;
  if (0 <= n && n <= 99999)
    fibmemo.at(n) = fib(n - 1, p) + fib(n - 2, p) % p;
  return fib(n - 1, p) % p + fib(n - 2, p) % p;
}

int main() {
  long long n, m, p = 1000000007;
  cin >> n >> m;
  vector<long long> a(m + 1);
  a.at(0) = - 1;
  for (long long i = 0; i < m; i++) {
    cin >> a.at(i + 1);
    if (i > 0 && a.at(i) + 1 == a.at(i + 1)) {
      cout << 0 << endl;
      return 0;
    }
  }
  a.push_back(n + 1);
  vector<long long> b(m + 1);
  for (long long i = 0; i < m + 1; i++) 
    b.at(i) = a.at(i + 1) - a.at(i) - 1;
  long long cnt = 1;
  for (long long i = 0; i < m + 1; i++) {
    cnt *= fib(b.at(i), p);
    cnt %= p;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define repi(i, a, b) for (long long i = (long long)(a); i < (long long)(b); i++)
#define drep(i, n) for (long long i = n - 1; i > 0; i--)
#define pb push_back
#define pb push_back
#define all(x) (x).begin(), (x).end()

using namespace std;

int main()
{
    int n, m, X, Y, ans, x[100], y[100], xmax = -1000, ymin = 1000;

    cin >> n >> m >> X >> Y;
    xmax = X;
    ymin = Y;
    rep(i, n)
    {
        cin >> x[i];
        xmax = max(xmax, x[i]);
    }
    rep(i, m)
    {
        cin >> y[i];
        ymin = min(ymin, y[i]);
    }

    if (xmax < ymin)
        cout << "No War" << endl;
    else
        cout << "War" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;

int main() {long N;
cin >> N;
vector<long> x(N + 1); long k; long dev;
for(long i = 1; i <= N; i++){
    k = i;
    dev = 2;
    while(k != 1){
        while(k % dev == 0){
            k = k / dev;
            x.at(dev)++;
        }
        dev++;
    }
}
erep(i, N) x.at(i)++;
long ans = 1;
erep(i, N) ans = ans * x.at(i) % MOD;

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



Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			if(a==-1 && b==-1 && c==-1)break;
			
			int total = (a*60+b)*60+c;
			
			int d = 120*60 - total;
			int e = 120*60*3 - total*3;
			
			int[] ans = new int[3];
			
			ans[2] = d%60;
			d /= 60;
			ans[1] = d%60;
			d /= 60;
			ans[0] = d%60;
			
			System.out.printf("%02d:", ans[0]);
			System.out.printf("%02d:", ans[1]);
			System.out.printf("%02d", ans[2]);
			System.out.println();
			
			ans[2] = e%60;
			e /= 60;
			ans[1] = e%60;
			e /= 60;
			ans[0] = e%60;
			
			System.out.printf("%02d:", ans[0]);
			System.out.printf("%02d:", ans[1]);
			System.out.printf("%02d", ans[2]);
			System.out.println();
			
		}

	}
}

Measured memory_bytes: 19220
import math 

A,B,H,M = map(int,input().split())
PI = math.pi
Aradi = float(PI/6*H + PI*M/360)
#print(math.degrees(Aradi))
Bradi = float(PI * M /30.0)
#print(math.degrees(Bradi))
if abs(Aradi - Bradi) <= PI:
    theta =  abs(Aradi - Bradi)
else:
    theta = 2*PI - abs(Aradi - Bradi)
#print(math.degrees(theta))
length = math.sqrt(A**2+B**2 - 2*A*B*math.cos(theta))

print(length)


Measured memory_bytes: 9572
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <fstream>
    #include <string>
    #include <math.h>
    #include <cstdlib>
    #include <istream>
    #include <sstream>
    #include <cctype>
    using namespace std;
    int main()
    {
    	int N;
    	double S=0;
    	vector<double> A;
    	cin >> N;
     
    	for(int i=0;i<N;i++){
    		double t;
    		cin >> t;
    		S=S+(1/t);
    	}
    	cout << 1/S << endl;
    }

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

struct points{
    double x;
    double y;
};

points p[300];

double get_square(points a, points b){
    return pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0);
}

double get_dist(points a, points b){
    return sqrt(get_square(a, b));
}

int find_max_cover(int n){
    int count, max_cover = 1;
    int sign[2] = {1, -1};
    double d, e;
    points m, q, v;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i+1; j < n; j++) {
            d = get_dist(p[i], p[j]);
            if (d > 2.0){
                continue;
            }
            m.x = (p[i].x + p[j].x) / 2.0;
            m.y = (p[i].y + p[j].y) / 2.0;
            v.x = (p[i].x - p[j].x) / d;
            v.y = (p[i].y - p[j].y) / d;
            e = sqrt(1.0 - d * d / 4.0);
            for (int s = 0; s < 2; s++) {
                q.x = m.x + sign[s] * e * v.y;
                q.y = m.y - sign[s] * e * v.x;
                count = 0;
                for (int k = 0; k < n; k++) {
                    if (k == i || k == j || get_square(q, p[k]) <= 1.0) {
                        count++;
                    }
                }
                max_cover = max(max_cover, count);
            }
        }
    }
    return max_cover;
}

int main()
{
    int n;
    while (true) {
        cin >> n;
        if (n == 0) {
            break;
        }
        for (int i = 0; i < n; i++) {
            cin >>p[i].x >> p[i].y;
        }
        cout << find_max_cover(n) << endl;
    }
    return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  vint A(n);
  rep(i,n) cin >> A[i];
  int FIRST = 0;
  int sum = 0;
  for(int i = 0;i < n;i++){
    if(i % 2 == 0) sum += 2*A[i];
    else sum -= 2*A[i];
  }
  FIRST = sum/2;
  int ans = FIRST;
  rep(i,n){
    cout << ans << " ";
    if(i != n - 1) ans = 2*A[i] - ans;
    else ans = 2*A[0] - ans;
  }
}

Measured memory_bytes: 2048
#include<iostream>
#include<cstring>
using namespace std;
long long n,a[55],b[55],ans,dp[55][55];
bool f[55],flag;
int main()
{
	cin>>n;
	for (long long i=1;i<=n;i++) cin>>a[i];
	for (long long i=1;i<=n;i++) cin>>b[i];
	for (long long h=1;h<=50;h++)
	{
		memset(dp,0,sizeof(dp));
		dp[51][a[h]]=1;
		for (long long j=50;j>=1;j--)
		{
			for (long long k=0;k<=50;k++)
			{
				if (dp[j+1][k])
				{
					dp[j][k]=1;
					dp[j][k%j]=1;
				}
			}
		}
		if (!dp[1][b[h]])
		{
			flag=1;
			break;
		}
	}
	if (flag) 
	{
		cout<<-1<<endl;
		return 0;
	}
	for (long long i=50;i>=1;i--)
	{
		flag=0;
		for (long long h=1;h<=50;h++)
		{
			memset(dp,0,sizeof(dp));
			dp[51][a[h]]=1;
			for (long long j=50;j>=1;j--)
			{
				if (j>=i && !f[j])
				{
					for (long long k=0;k<=50;k++) dp[j][k]=dp[j+1][k];
			 		continue;
				}
				for (long long k=0;k<=50;k++)
				{
					if (dp[j+1][k])
					{
						dp[j][k]=1;
						dp[j][k%j]=1;
					}
				}
			}
			if (!dp[1][b[h]])
			{
				flag=1;
				break;
			}
		}
		if (flag)
		{
			ans+=(1ll<<i);
			f[i]=1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

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

    vector<vector<vector<int>>> num(10, vector<vector<int>>(10));
    for(int i=1; i<=n; i++){
        int a = i;
        int bottom = a % 10;
        if(bottom == 0) continue;

        while(a >= 10){
            a /= 10;
        }
        int top = a;
        
        num[top][bottom].push_back(i);
    }

    int ans = 0;
    for(int i=1; i<=n; i++){
        int a = i;
        int bottom = a % 10;
        if(bottom == 0) continue;
        while(a >= 10){
            a /= 10;
        }
        int top = a;
        
        ans += num[bottom][top].end() - num[bottom][top].begin();
    }
    cout << ans << endl;
    return 0;
}

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

#define inf 10000000000000
#define ll long long
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)




int main() {
    IOS;
    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
    
    int a,b;
    cin>>a>>b;

    int c = a*b;
    cout<<c;

    return 0;    
}

Measured memory_bytes: 3636
import math

a, b = map(int, input().split())

ans = -2
for i in range(10000):
    if math.floor((i+1) * 8/100) == a and math.floor((i+1)/10 ) == b:
        ans += i+3
        break

no_ans = -1
print(max(ans, no_ans))

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;

  ll ans = 0;
  map<pair<char,char>,ll> mp;
  for(int i = 1;i <= n;i++){
    string sa = to_string(i);
    char a_head = sa[0];
    char a_tail = sa[sa.size()-1];
    mp[make_pair(a_head,a_tail)]++;
  }

  for(int i = 1;i <= n;i++){
    string sa = to_string(i);
    char a_head = sa[0];
    char a_tail = sa[sa.size()-1];
    ans += mp[make_pair(a_tail,a_head)];
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,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 (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;


template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;
ModInt mod_pow(ModInt x, ModInt n) {
	ModInt ret = 1;
	while (n.a > 0) {
		if (n.a & 1) (ret *= x);
		(x *= x);
		n.a >>= 1;
	}
	return ret;
}

lint N, K;
ModInt cnt[100001];

int main() {
	cin >> N >> K;
	IREP(x, K) {
		lint X = x + 1;
		cnt[X] = mod_pow(K / X, N);
		lint idx = 2;
		while (X * idx <= K) {
			cnt[X] -= cnt[X * idx];
			idx++;
		}
	}
	ModInt ans = 0;
	REP(i, K) {
		ans += cnt[i + 1] * (i + 1);
	}
	cout << ans.a << endl;
}


Measured memory_bytes: 4404
class UnionFind:
  def __init__(self):
    self.ht = {}

  def same(self, x, y):
    x = self.ht[x]
    y = self.ht[y]
    return x.root() == y.root()

  def unite(self, x, y):
    nx = self.ht[x]
    ny = self.ht[y]
    if self.same(x, y):
      return
    xr = nx.root()
    yr = ny.root()
    xr.set_parent(yr)

  def add(self, x):
    n = Node(x)
    n.set_parent(None)
    self.ht[x] = n

  def show(self):
    roots = {}
    for n in self.ht.values():
      nr = n.root()
      if nr in roots:
        roots[nr].append(n.val)
      else:
        roots[nr] = [n.val]
    for s in roots.values():
      print(s)

  def get_set(self):
    roots = {}
    for n in self.ht.values():
      nr = n.root()
      if nr in roots:
        roots[nr].append(n.val)
      else:
        roots[nr] = [n.val]
    return roots.values()

class Node:
  def __init__(self, val):
    self.val = val

  def root(self):
    n = self
    chain = []
    while n.parent != None:
      chain.append(n)
      n = n.parent
    root = n
    for n in chain:
      n.set_parent(root)
    return root

  def set_parent(self, x):
    self.parent = x


## main

n, m = map(int, input().split())
uf = UnionFind()

for i in range(1, n+1):
  uf.add(i)

for _ in range(m):
  x, y, z = map(int, input().split())
  uf.unite(x, y)

cnt = len(uf.get_set())

print(cnt)


Measured memory_bytes: 47520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	if(a==b){
		cout <<c;
	}
	else if(b==c){
		cout <<a;
	}
	else{
		cout << b;
	}
	cout <<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n;
	double sum = 0;
	int i = 0;
	
	scanf("%d",&n);
	
	double x[n];
	char s[n+1][4];
	
	while(i < n){
		scanf("%le %s",&x[i],&s[i]);
		i++;
	}	
	
	
	for(i = 0;i < n;i++){
		if(s[i][0] == 'J')
			sum += x[i];
		
		if(s[i][0] == 'B')
			sum += x[i]*380000;
	}

	printf("%f\n",sum);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;

ll f(pair<string,ll>&x ,pair<string,ll>&y) 
{
	if(x.first == y.first) 
	{
		return x.second>y.second;
	}
	else 
	{
		return x.first<y.first;
	}
}
 
void solve()
{
	ll n;
	cin>>n;
	vector<ll> a(n);
	ll sum=0,neg=0;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<0)
			neg++;
		sum+=abs(a[i]);
		a[i]=abs(a[i]);
	}
	// cout<<sum;
	sort(a.begin(),a.end());
	// cout<<neg;
	// cout<<a[0];
	if(neg%2==1)
		sum-=(2*a[0]);
	cout<<sum;
	return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


Measured memory_bytes: 3868
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
using namespace std;
using ll = long long;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll K, X, Y; cin >> K >> X >> Y;

    // Kが偶数だといける点が限られる(重要)
    if(K%2 == 0 && (abs(X)+abs(Y))&1) { cout << -1 << endl; }
    else {
        // 一回でいける
        if(abs(X) + abs(Y) == K) {
            cout << 1 << endl;
            cout << X << " " << Y << endl;
            return 0;
        }
        
        // 簡単のためX >= Y, X >= 0, Y >= 0にして後で復元
        bool xflg = false, yflg = false, swpflg = false;
        if(X < 0) X = -X, xflg = true;
        if(Y < 0) Y = -Y, yflg = true;
        if(X < Y) swap(X,Y), swpflg = true;

        int n = (X + Y + K - 1) / K;
        if(n <= 1) n = 2;
        if((X+Y) % 2 != n * K % 2) ++n;

        vector<pair<int,int>> ans;
        if(n==3 && X < K) {
            int over = (K + X - Y) / 2;

            ans.emplace_back(X, X - K);

            ans.emplace_back(X + over, Y - (K - over));

            ans.emplace_back(X , Y);
        } else {
            // X >= K,  y軸方向に余分な動きをして合わせる -> 余分な移動は (n*K - X - Y) / 2
            int over = (K * n - (X+Y)) / 2; // 余分な動き
            for(int i = 1; i <= n; ++i) {
                int dist = i * K;
                if(dist <= Y + over) {
                    ans.emplace_back(0, dist); // 縦方向のみ
                } else if(dist <= Y + over + X) {
                    ans.emplace_back(dist - Y - over, Y + over); // 角をまたいだ
                } else {
                    ans.emplace_back(X, Y + (n-i) * K); // gーる
                }
            }
        }

        // out
        cout << ans.size() << '\n';
        for(auto xy : ans) {
            int x = xy.first, y = xy.second;
            if(swpflg) swap(x, y);
            if(yflg) y = -y;
            if(xflg) x = -x;
            cout << x << " " << y << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 3952
import functools, fractions

N,M = map(int,input().split())
S = input()
T = input()

def lcm(a, b):
	return a * b // fractions.gcd(a, b)

def check(L, NM):
    res = []
    for i in range(NM):
        res.append(int(i*(L/NM)+1))
    return res

def check2(x, L, NM):
    return int((x-1)*NM/L)

L = lcm(N,M)
ans = L


a = list(set(check(L, N)) & set(check(L, M)))
for i in a:
    if S[check2(i, L, N)] != T[check2(i, L, M)]:
        ans = -1
        break
print(ans)

Measured memory_bytes: 20084
#include <cstdio>

int main() {
    double h[100] = { 0 };
    int co = 0;

    while (scanf("%lf", &h[co]) != EOF) {co++;}

    double mi = h[0];
    double mx = 0.0f;

    for (int i = 0; i < co; ++i) {
        if (h[i] < mi) {
            mi = h[i];
        }

        if (mx < h[i]) {
            mx = h[i];
        }
    }

    printf("%lf\n", mx - mi);

    return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException{
		final BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		int[][] x=new int[1001][1001];
		for(int i=0;i<n;i++){
			int line = 0;
			String str1=br.readLine();
			String str2=br.readLine();
			
			for(int j=1;j<=str1.length();j++){
				for(int k=1;k<=str2.length();k++){
					char a=str1.charAt(j-1);
					char b=str2.charAt(k-1);
					if(a==b) x[j][k]=x[j-1][k-1]+1;
					else x[j][k]=Math.max(x[j-1][k],x[j][k-1] );
					line=Math.max(line, x[j][k]);
				}
				
			}
			System.out.println(line);
		}
		br.close();
	}
}

Measured memory_bytes: 26360
#include <iostream>

using namespace std;

int main()
{
    int A, B, X;
    cin >> A;
    cin >> B;
    cin >> X;
    if((X>=A)&(A+B)>=X)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main (void) {
    char s[16];
    scanf("%s", s);
    if ( !strcmp(s, "Sunny") )
        printf("Cloudy\n");
    else if ( !strcmp(s, "Cloudy") )
        printf("Rainy\n");
    else
        printf("Sunny\n");
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256