akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

char S[202020];

int main()
{
	scanf("%s", S);
	int ret = 1;
	int N = strlen(S);
	bool flg = false;
	for (int i = 1; i < N; ++i) {
		if (S[i] == S[i - 1]) {
			if (flg) {
				++ret;
				flg = false;
			} else {
				if (i == N - 1) break;
				++i; ++ret;
				flg = true;
			}
		} else {
			++ret;
			flg = false;
		}
	}
	printf("%d\n", ret);
	return 0;
}


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

int main(void){
    long N,M;
    scanf("%ld%ld",&N,&M);

    long ans;
    if((M-2*N)<0) ans=M/2;
    else ans=N+(M-2*N)/4;
    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/**
*   author: j o s e m a g o
*   user: m a m i s a k i
**/
using namespace std;

/***PLANTILLA***/

using namespace __gnu_pbds; //*st.find_by_order(1);  st.order_of_key(p);
#pragma GCC optimize ("Ofast")
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef double dbl;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;

string tostring(auto a){
    stringstream ss;ss<<a;string s = ss.str();
    return s;
}

/**Mi Debug**/
#define var(x) cout<<#x<<" = ";
#define db(x) cout<<#x<<" = "<<x<<"\n";
void dbvector(vector<auto>&v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}
void dbmapa(map<auto,auto>mp){
   for(auto x : mp) cout<<"{"<<x.first<<":"<<x.second<<"} ";cout<<"\n";
}
void dbstring(string v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}

/***********Code***************/

const int JJJ = 100100;










int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

    ios_base::sync_with_stdio(0); cin.tie(0);


    string s;
    string t;
    string c;
    cin >> s;
    cin >> t;
    for(int i = 0;i < s.size();i++){
        c+=t[i];
    }
    if(t.size()-1 == s.size() && c == s){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }







    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define boost ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define M 1000000007
#define eb emplace_back
#define watch(x) cout << (#x) <<" is "<< x <<"\n";


using namespace std;
//const int N = 1e6;

int32_t main(){
  boost;
  int tc = 1; //cin >> tc;
  while(tc--)
  {
    string s; cin >> s;
    bool f = 0;
    for(auto i : s)
      if(i == '7')
        f = 1;
    f == 1 ? cout <<"Yes\n" : cout <<"No";  
  }
}



Measured memory_bytes: 3656
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint h[200100];
int main()
{
	int n,k;lint out=0;cin>>n>>k;
	rep(i,n) cin>>h[i];sort(h,h+n);
	rep(i,n-k) out+=h[i];
	cout<<out<<endl;
}


Measured memory_bytes: 1792
n, W = map(int, input().split())
w = [0]*(n+1)
v = [0]*(n+1)

#dp = [[None for i in range(W+1)] for j in range(n+1)]
dp = [[0 for i in range(W+1)] for j in range(n+1)]

for i in range(n):
    w[i], v[i] = map(int, input().split())

def knap(i, j):
    if dp[i][j] is not None:
        return dp[i][j]

    res = 0

    if i == n:
       	res = 0
    elif j < w[i]:
        res = knap(i+1, j)
    else:
        res = max(knap(i+1, j), knap(i+1, j-w[i]) + v[i])

    dp[i][j] = res
    return dp[i][j]

for i in reversed(range(n)):
    for j in range(W+1):
#        res = 0
        # if i == n-1:
        #     res = 0
        if j < w[i]:
            dp[i][j] = dp[i+1][j]
        else:
            dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]] + v[i])

#print(knap(0, W))
print(dp[0][W])



Measured memory_bytes: 171436
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 5e5 + 5, mod = 1e9 + 7;

int block_size, freq[N], col[N], cnt, ans[N];
pair< pair<int, int>, int> queries[N];

inline bool mo_cmp(const pair< pair<int, int>, int> &x,
        const pair< pair<int, int>, int> &y)
{
    int block_x = x.first.first / block_size;
    int block_y = y.first.first / block_size;
    if(block_x != block_y)
        return block_x < block_y;
    return x.first.second < y.first.second;
}

void add(int x){
    if(freq[x] == 0) cnt++;
    freq[x]++;
}

void del(int x){
    if(freq[x] == 1) cnt--;
    freq[x]--;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, q;
    cin >> n >> q;
    block_size = sqrt(n);
    for(int i = 0; i < n; i++) cin >> col[i];
    for(int i = 0; i < q; i++){
        cin >> queries[i].first.first >> queries[i].first.second;
        queries[i].first.first--;
        queries[i].first.second--;
        queries[i].second = i;
    }
    sort(queries, queries + q, mo_cmp);
    int m_left = 0, m_right = -1;
    for(int i = 0; i < q; i++) {
        int l = queries[i].first.first;
        int r = queries[i].first.second;

        while(m_right < r) {
            m_right++;
            add(col[m_right]);
        }
        while(m_right > r) {
            del(col[m_right]);
            m_right--;
        }

        while(m_left < l) {
            del(col[m_left]);
            m_left++;
        }
        while(m_left > l) {
            m_left--;
            add(col[m_left]);
        }

        ans[queries[i].second] = cnt;
    }
    for(int i = 0; i < q; i++) cout << ans[i] << '\n';



   return 0;
}


Measured memory_bytes: 15464
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    
    string next;
    next.push_back( A[ 0 ] );
    
    int a{}, b{}, c{};
    while( true )
    {
        if( next == "a" )
        {
            if( A.empty() )
            {
                cout << "A" << endl;
                break;
            }
            next = *A.begin();
            A.erase( A.begin() );
            a++;
        }
        if( next == "b" )
        {
            if( B.empty() )
            {
                cout << "B" << endl;
                break;
            }
            next = *B.begin();
            B.erase( B.begin() );
            b++;
        }
        if( next == "c" )
        {
            if( C.empty() )
            {
                cout << "C" << endl;
                break;
            }
            next = *C.begin();
            C.erase( C.begin() );
            c++;
        }
    }
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
  int n;
  cin>>n;
    int ans=(n-1)/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()

{
	int a, b;
	scanf("%d %d", &a, &b);

	if (a<b)
	{
		printf("a < b\n");

	}
	else if (a>b)
	{
		printf("a > b\n");

	}
	else if (a == b)
	{
		printf("a == b\n");
	}

	return 0;
}

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

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

const ll INF64 = 1LL << 60;
const int INF = 1 << 29;
const ll MOD = 998244353;

const int CASES = 3;

long double calc(P a, P b){
    long double tmp = (a.first - b.first) * (a.first - b.first);
    tmp += (a.second - b.second) * (a.second - b.second);
    return sqrt(tmp);
}

void solve() {
    int n; cin >> n;
    vector<P> a(n);
    for(int i =0; i < n; ++i){
        long double x, y; cin >> x >> y;
        a[i] = {x, y};
    }

    vector<int> v(n);
    iota(v.begin(), v.end(), 0);

    long double count = 0.0;
    long double ans = 0.0;
    do {
        for(int i =0; i < n-1; ++i){
            ans += calc(a[v[i+1]], a[v[i]]);
        }
        ++count;
    } while( next_permutation(v.begin(), v.end()) );
    ans /= count;
    cout  << setprecision(10) << ans << endl;
    return;
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll N,K;
	cin>>N>>K;
	ll ans = 0LL;
	REP(i,N){
		ans += (N+1)/i * max(0LL, i-K);
		ans += max((N+1)%i-K, 0LL);
	}
	if(K==0) ans -= N;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
a, b, m = map(int, input().split())
list_a = list(map(int, input().split()))
list_b = list(map(int, input().split()))
total = min(list_a) + min(list_b)
for i in range(m):
    x, y, c = map(int, input().split())
    price = list_a[x - 1] + list_b[y - 1] - c
    total = min(price, total)
print(total)


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      if(s[i] == 'p') res--;
    } else {
      if(s[i] == 'g') res++;
    }
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        Set<Integer> doubles = new HashSet<>();
        Set<Integer> nocnt = new HashSet<>();
        Set<Integer> avails = new HashSet<>();
        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
            if(doubles.contains(A[i])){nocnt.add(A[i]);}
            doubles.add(A[i]);
        }
        //gen(A);
        Arrays.sort(A);
        int sum=0;
        for(int i=0;i<N;i++){
            if(avails.contains(A[i])){continue;}
            else{
                int now = A[i];
                while(now <= 1000000){
                    avails.add(now);
                    now += A[i];
                }
                if(!nocnt.contains(A[i]))
                    sum++;
            }
        }
        System.out.println(sum);
    }
    private static void showArr(int[] a){
        for(int p:a){
            System.out.print(p + " ");
        }
        System.out.println();
    }
    private static void gen(int[] A){
        for(int i=0;i<A.length;i++){
            A[i] = new Random().nextInt(500000)+500000;
        }
    }

}


Measured memory_bytes: 129652
#include<bits/stdc++.h>
using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        200005
#define mod         1000000007
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,m,c,x,y,z,i,mi=10000000000000;
    cin>>a>>b>>m;
    ll pa[a],pb[b];
    for(i=0;i<a;i++){
        cin>>pa[i];
    }
    for(i=0;i<b;i++){
        cin>>pb[i];
    }
    for(i=0;i<m;i++){
        cin>>x>>y>>c;
        mi=min(mi,pa[x-1]+pb[y-1]-c);
    }
    sort(pa,pa+a);
    sort(pb,pb+b);
    mi=min(mi,pa[0]+pb[0]);
    cout<<mi;
}

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

int main() {
	int N;
	cin >> N;
	int M;
	cin >> M;
	vector<int> r(N);
	for (int m = 0; m < M; m++) {
		int a;
		cin >> a;
		int b;
		cin >> b;
		r.at(a - 1)++;
		r.at(b - 1)++;
	}
	for (int n = 0; n < N; n++) {
		cout << r.at(n) << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int h, w, a, b;
char s[1010][1010];
int x[1010], y[1010];

int main(){
	cin >> h >> w >> a >> b;
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			s[i][j] = '0';
		}
	}
	bool ok = 1;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if((x[i] < a || w-x[i] > a) && (y[j] < b || (h-y[j]) > b)){
				s[i][j] = '1';
				x[i]++;
				y[j]++;
			}
		}
		if(x[i] != a && w-x[i] != a) ok = 0;
	}
	for(int j = 0; j < w; j++) if(y[j] != b && (h-y[j]) != b) ok = 0;
	if(ok){
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cout << s[i][j];
			}
			cout << endl;
		}
	}
	else cout << "No" << endl;
	
	return 0;
}

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

//#pragma GCC optimize "trapv"
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define drep(i,a,b) for(int i=a; i>b; i--)
#define inf 1e+18L
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define pii pair<int, int>
#define ll long long 
#define fi first
#define se second
const auto pi = 3.14159265359;
const auto e = 2.718281828459;

int numdigits(int x)
{
    return floor(log10(x)) + 1;
}

template<typename T>
T modpower(T x, T y)
{
    T res = 1;
    x %= mod;
    if(x == 0) return 0;
    while(y > 0)
    {
        if(y&1) res = (res*x)%mod;
        y >>= 1;
        x = (x*x)%mod;
    }
    return res;
}

void solve()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> dp(k+1, 0); //dp[i] is the number of sequences with gcd i
    drep(i,k,0)
    {
        ll val = k/i;
        val = modpower(val, n);
        val %= mod;
        for(int j=2*i; j<=k; j+=i)
        {
            val -= dp[j];
        }
        dp[i] = val;
    }
    // for(auto k : dp) cout << k << " ";
    // cout << "\n";
    ll ans = 0;
    rep(i,1,k+1)
    {
        ll var = ((dp[i]%mod)*(i%mod))%mod;
        ans = ((ans%mod) + (var%mod))%mod;
        ans %= mod;
    }
    cout << ans << "\n";
}

int main()
{
    FASTIO
    // int t;
    // cin >> t;
    // while(t--)
        solve();
    return 0;
}

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

const int INF = 1 << 20;
const int MAX_N = 110;

int main() {
  int cost[MAX_N][MAX_N];
  int mincost[MAX_N];
  bool used[MAX_N];
  int n, a, res;

  cin >> n;

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> a;
      cost[i][j] = a == -1 ? INF : a;
    }
  }

  for (int i = 0; i < n; ++i) {
    mincost[i] = INF;
    used[i] = false;
  }

  mincost[0] = 0;
  res = 0;

  while (true) {
    int v = -1;
    for (int u = 0; u < n; ++u) {
      if (!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
    }

    if (v == -1) break;

    used[v] = true;
    res += mincost[v];

    for (int u = 0; u < n; ++u) {
      mincost[u] = min(mincost[u], cost[v][u]);
    }
  }

  cout << res << endl;
  
  return 0;
}



Measured memory_bytes: 3140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(((0 <= a-b) && ((a-b) <= w)) || ((0 <= b-a) && ((b-a) <= w))){
            System.out.println(0);
        } else {
            System.out.println(Math.min(Math.abs(a-b+w), Math.abs(b-a+w)));
        }
    }

    double manhattan(Ten point1, Ten point2){
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }
}

class Ten{
    private int x;
    private int y;

    Ten(int x, int y){
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<string>
#include<functional>
#include<unordered_set>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
#define endl "\n";

const int maxn = 5e5+7;

LL a[maxn][26];

void add(int pos, int ch, int val) {
    for(;pos<maxn;pos+=lowbit(pos))
        a[pos][ch] += val;
}

LL getsum(int pos, int ch) {
    LL ret = 0;
    for(;pos; pos -= lowbit(pos))
        ret += a[pos][ch];
    return ret;
}

void run_case() {
    int n, q; string s;
    cin >> n >> s >> q;
    for(int i = 0; i < n; ++i) {
        add(i+1, s[i]-'a', 1);
    }
    while(q--) {
        static int type;
        cin >> type;
        if(type == 1) {
            static int pos;
            static char ch;
            cin >> pos >> ch;
            add(pos, s[pos-1]-'a', -1);
            s[pos-1] = ch;
            add(pos, ch-'a', 1);
        } else {
            static int l, r;
            cin >> l >> r;
            int ans = 0;
            for(int i = 0; i < 26; ++i) 
                ans += ((getsum(r, i)-getsum(l-1,i))>0?1:0);
            cout << ans << endl;
        }
    }
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 102520
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;

int main(){
    int n,mm;cin>>n>>mm;
   vector<vector<ll>  >m(n);
    vector<pair<int,ll> >v(mm);
    for(int i=0;i<mm;i++){
        cin>>v[i].first>>v[i].second;
        m[v[i].first-1].push_back(v[i].second);
        
    }
    for(int i=0;i<n;i++)sort(m[i].begin(),m[i].end());
    for(int i=0;i<mm;i++){
        int a=v[i].first; ll b=v[i].second;
        int x=lower_bound(m[a-1].begin(),m[a-1].end(),b)-m[a-1].begin()+1;
        printf("%06d",a);
        printf("%06d",x);
        cout<<endl;
    }
}

Measured memory_bytes: 8576
def getInput():
    separator = ' '
    ret_array = []
    while True:
        try:
            row = input().split(sep=separator)
            ret_array.append(row)
        except EOFError:
            break
    return ret_array


inp = getInput()
i = inp[0][0]

if i[0] == i[2]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
const int N=100005;
int vis[N];
vector<int> vp;
int lowbit(int x){return x&-x;}
int main(){
  //  freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    int n;cin>>n;
    if (lowbit(n)==n) {puts("No");return 0;}
    puts("Yes");
    int m=n-(n+1)%4,s=m+1;
    if (m==n||n==m+2||lowbit(n-2)==n-2){
        printf("2 1\n%d %d\n",2+n,1+n);
        printf("1 3\n%d %d\n",1+n,3+n);
        for (int i=3;i<m;i++) printf("%d %d\n%d %d\n",i,i+1,i+n,i+n+1);
        printf("%d %d\n",m,2+n);

        if (n==m+2){
            printf("%d %d\n%d %d\n",s,s+1,s+n,s+1+n);
            printf("%d 1\n%d 1\n",s+1,s+n);
        } else if (n>=5&&lowbit(n-2)==n-2){
            printf("%d %d\n%d %d\n",s,s+1,s+n,s+1+n);
            printf("%d 1\n%d 1\n",s,s+1+n);
            printf("%d %d\n%d 3\n",s,s+2,s+2+n);
        }
        return 0;
    }

    while (s) {int x=lowbit(s);vis[x]=1;vp.pb(x);s-=x;}
    vp.pb(1),vp.pb(3);vis[1]=vis[3]=1;
    for (int i=1;i<vp.size();i++){
        int x=vp[i],y=vp[i-1];
        printf("%d %d\n%d %d\n",x,y,x+n,y+n);
    }

    for (int i=m+1;i<=n;i++){
        printf("%d %d\n",i,vp[0]);
        if (i==m+1) printf("%d %d\n",i+n,vp[vp.size()-3]);
        if (i==m+2) printf("%d 1\n",i+n);
        if (i==m+3) printf("%d 3\n",i+n);
    }

    int last=3;
    for (int i=1;i<=m;i++) if (!vis[i]){
        printf("%d %d\n%d %d\n",i,last,i+n,last+n);
        last=i;
    }
    printf("%d %d\n",last,vp[0]+n);

    return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<set>
using namespace std;
typedef set<int>S;
S s['U'+1];
S::iterator q;
char e[9999];
int p;
S PT();
S OU(S a,S b){
	for(q=b.begin();q!=b.end();++q)
		a.insert(*q);
	return a;
}
S OD(S a,S b){
	for(q=b.begin();q!=b.end();++q)
		a.erase(*q);
	return a;
}
S OS(S a,S b){
	for(q=b.begin();q!=b.end();++q)
		if(a.erase(*q)==0)
			a.insert(*q);
	return a;
}
S OC(S a){
	return OD(s['U'],a);
}
S OI(S a,S b){
	return OD(a,OC(b));
}
S PB(){
	S a=PT();
	for(;;){
		if(e[p]=='u'){
			p++;
			a=OU(a,PT());
		}else if(e[p]=='i'){
			p++;
			a=OI(a,PT());
		}else if(e[p]=='d'){
			p++;
			a=OD(a,PT());
		}else if(e[p]=='s'){
			p++;
			a=OS(a,PT());
		}else 
			return a;
	}
}
S PT(){
	S a;
	int c=0;
	if(e[p]=='('){
		p++;
		a=PB();
		p++;
	}else if(e[p]=='c'){
		p++;
		a=OC(PT());
	}else{
		a=s[e[p]];
		p++;
	}
	return a;
}
int main(){
	char n;
	int m,v;
	for(;cin>>n>>m;){
		if(n!='R'){
			s[n].clear();
			for(;m--;){
				cin>>v;
				s[n].insert(v);
				s['U'].insert(v);
			}
		}else{
			cin>>e;
			p=0;
			S r=PB();
			for(q=r.begin();q!=r.end();){
				cout<<*q;
				cout<<(++q!=r.end()?' ':'\n');
			}
			if(r.empty())
				cout<<"NULL\n";
			s['U'].clear();
		}
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   int cnt = 1;
   while(1){
      if(n <= (2*d + 1)*cnt) break;
      else cnt++;
   }

   cout << cnt << endl;




   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int a[300][300] = { 0 };
int cnt[300][300] = { 0 };

int main(void) {
	int N;
	int i, j, k;
	long long int ans = 0;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			scanf("%d", &a[i][j]);
		}
	}

	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			for (k = 0; k < N; k++) {
				if (a[i][k] > a[i][j] + a[j][k]) {
					printf("-1\n");
					return 0;
				}
				else if ((i != j) && (j != k) && (a[i][k] == a[i][j] + a[j][k])) {
					cnt[i][k]++;
				}
			}
		}
	}

	for (i = 0; i < N; i++) {
		for (j = 0; j < i; j++) {
			if (cnt[i][j] == 0) ans += (long long int)a[i][j];
		}
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[1] == s[2] && (s[0] == s[1] || s[2] == s[3])){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}
    
     

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

 using namespace std;

 int main() {
   string S, ans;

   cin >> S;

   ans = "AC";
   if (S.front() == 'A') {
     int Ccount = 0;
     for (int i = 2; i < S.length() - 1; i++) {
       if (S.at(i) == 'C') Ccount++;
       else if (!islower(S.at(i))) {
         ans = "WA";
         break;
       }
     }

     if (!islower(S.at(1)) || !islower(S.back()) || Ccount != 1) ans = "WA";
   }
   else ans = "WA";

   cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
AC = 0
TLE = 0
WA = 0
RE = 0
for i in range(n) :
    s = input()
    if s == 'AC' :
        AC += 1
    elif s == 'TLE' :
        TLE += 1
    elif s == 'WA' :
        WA += 1
    else :
        RE += 1
print('AC x', AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)

Measured memory_bytes: 9004
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    //すべての商品について2で割っていったときの値引き額をリストかなんかに詰め込んでいき、
    //高い順にソートしてM個目まで足していき、総額から引いたら答えになる。
    int N = sc.nextInt();
    int M = sc.nextInt();
    long A[] = new long[N];
    //各商品最大でも31枚しか使えないはず・・・
    long priceDown[] = new long[N*31]; 
    long answer =0;
    int index =0;
    long priceOff =0;
    long totalPrice=0;
    for(int i=0;i<N;i++){
      A[i] = sc.nextInt();
      totalPrice=totalPrice+A[i];
    }
    //2で割って行って値引き額を格納したら次の添字
    //値引き額が0になったら次の商品に移る
    for(int i=0;i<N;i++){
      while((A[i]-(A[i]/2))>0){
        priceDown[index]=A[i]-(A[i]/2);
        A[i]=A[i]/2;
        index++;
      }      
    }
    //値引き額をソート
    Arrays.sort(priceDown);
    int cnt=0;
    for(int i=N*31-1;i>=0;i--){
      priceOff=priceOff+priceDown[i];
      cnt++;
      if(cnt>=M){
        break;
      }
    }
   System.out.println(totalPrice-priceOff);
  
    
    
  }
  
  //最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}


//素数判定
static boolean isPrime (int n) {
	if (n==2) return true;
	if (n<2 || n%2==0) return false;
	double d = Math.sqrt(n);
	for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
	return true;
}


//倍数判定（10進数以外のときに有用）
static boolean isMultiple (String s, int base, int m) {
	int temp = 0;
	for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	}
	if (temp==0) {return true;}
	return false;
}


//階乗
static long factorial (int i) {
	if (i==1) {return 1;}
	else {return i*factorial(i-1);}
}


//進数変換
static String toNbase (String sm, int m, int n) {
	return Long.toString(Long.parseLong(sm,m),n);
}
  
}

Measured memory_bytes: 73208
#include<iostream>
#include<vector>
#include<tuple>
#include<algorithm>
#include<iomanip>
using namespace std;
int N,M;

int main(){
  cin >> N >> M;
  tuple<int,int,int> data[M];
  for(int i = 0; i < M ; i++ ){
    int p,y;
    cin >> p >> y;
    data[i] = make_tuple(y,p,i);
  }

  sort(data,data+M);
  int cnt[N+1];
  fill(cnt,cnt+N+1,0);
  pair<int,int> id[M];
  for(int i = 0; i < M; i++){
    int y,p,idx;
    tie(y,p,idx) = data[i];
    cnt[p]++;
    id[idx] = make_pair(p,cnt[p]);
  }
  for(int i = 0; i < M;i++){
    cout << setw(6) << setfill('0') << id[i].first;
    cout << setw(6) << setfill('0') << id[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 3840
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.SplittableRandom;

public class Main {
	static boolean LOCAL = false;
	static Scanner sc = new Scanner(System.in);
	static int M = 20;
	static int[][] g = new int[M][M];

	public static void main(String[] args) {
		int N, S, T;
		if (LOCAL) {
			SplittableRandom rnd = new SplittableRandom();
			for (int i = 0; i < M; i++) {
				for (int j = 0; j < i; j++) {
					g[i][j] = g[j][i] = rnd.nextInt(10) + 1;
				}
			}
			for (int i = 0; i < M; i++) {
				for (int j = 0; j < M; j++) {
					for (int k = 0; k < M; k++) {
						g[j][k] = Math.min(g[j][k], g[j][i] + g[i][k]);
					}
				}
			}
			for (int i = 0; i < M; i++) {
				for (int j = 0; j < M; j++) {
					System.out.printf("%2d ", g[i][j]);
				}
				System.out.println();
			}
			N = g.length;
			S = 0;
			T = N - 1;
		} else {
			N = sc.nextInt();
			S = sc.nextInt() - 1;
			T = sc.nextInt() - 1;
		}
		ArrayList<Node> nodes = new ArrayList<>();
		int all = query(S, T);
		for (int i = 0; i < N; i++) {
			if (i == S || i == T) continue;
			int d1 = query(S, i);
			int d2 = query(i, T);
			if (d1 + d2 == all) {
				nodes.add(new Node(d1, i));
			}
		}
		Collections.sort(nodes, (n1, n2) -> Integer.compare(n1.d, n2.d));
		ArrayList<Integer> ans = new ArrayList<>();
		ans.add(S);
		int pi = S;
		int pd = 0;
		for (int i = 0; i < nodes.size(); i++) {
			Node n = nodes.get(i);
			if (query(pi, n.i) == n.d - pd) {
				ans.add(n.i);
				pi = n.i;
				pd = n.d;
			}
		}
		ans.add(T);
		System.out.print("!");
		for (int n : ans) {
			System.out.print(" " + (n + 1));
		}
		System.out.println();
	}

	static class Node {
		int d, i;

		public Node(int d, int i) {
			this.d = d;
			this.i = i;
		}
	}

	static int query(int s, int t) {
		if (LOCAL) {
			System.err.println(s + " " + t + " " + g[s][t]);
			return g[s][t];
		}
		System.out.println("? " + (s + 1) + " " + (t + 1));
		System.out.flush();
		int ret = sc.nextInt();
		if (ret == -1) System.exit(0);
		return ret;
	}
}



Measured memory_bytes: 35340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	string s;
	int k;
	cin>>k>>s;
	if(s.size()<=k)cout<<s;
	else
	{
		string p;
		for(int i=0;i<k;i++)
		p.pb(s[i]);
		for(int i=k;i<k+3;i++)
		p.pb('.');
		cout<<p;
	}
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,m,k,a,i,j,ans=0;
  cin>>n>>m;
  vector<int> c(m);
  for(i=0;i<n;i++){
    cin>>k;
    for(j=0;j<k;j++){
      cin>>a;
      c.at(a-1)++;
    }
  }
  for(i=0;i<m;i++) if(c.at(i)==n) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define inf 1000000000000000000
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(x) (x).begin(),(x).end()
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; }

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  
  ll h, w; cin >> h >> w;
  vector<vector<ll>> a(h, vector<ll>(w));
  vector<vector<ll>> b(h, vector<ll>(w));
  vector<vector<ll>> c(h, vector<ll>(w));
  rep(i, h) {
    rep(j, w) {
      cin >> a[i][j];
    }
  }
  rep(i, h) {
    rep(j, w) {
      cin >> b[i][j];
    }
  }
  rep(i, h) {
    rep(j, w) {
      c[i][j] = abs(a[i][j] - b[i][j]);
    }
  }
  ll max_value = 80 * (h + w);
  vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w,vector<bool>(max_value + 1, false)));
  dp[0][0][c[0][0]] = true;
  rep(i, h) {
    rep(j, w) {
      rep(k, max_value + 1) {
        if (0 <= i + 1 && i + 1 < h && dp[i][j][k]) {
          if (0 <= k + c[i + 1][j] && k + c[i + 1][j] <= max_value) dp[i + 1][j][k + c[i + 1][j]] = true;
          if (0 <= abs(k - c[i + 1][j]) && abs(k - c[i + 1][j]) <= max_value) dp[i + 1][j][abs(k - c[i + 1][j])] = true;
        }
        if (0 <= j + 1 && j + 1 < w && dp[i][j][k]) {
          if (0 <= k + c[i][j + 1] && k + c[i][j + 1] <= max_value) dp[i][j + 1][k + c[i][j + 1]] = true;
          if (0 <= abs(k - c[i][j + 1]) && abs(k - c[i][j + 1]) <= max_value) dp[i][j + 1][abs(k - c[i][j + 1])] = true;
        }
      }
    }
  }
  rep(k, max_value + 1) {
    if (dp[h - 1][w - 1][k]) {
      cout << k << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 14308
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long Int;
#define MOD 1000000007
Int dp[50][1 << 18];
#define mask ((1 << 18) - 1)
Int pt[60];
Int res;
int main(){
  int n, x, y, z;
  cin >> n >> x >> y >> z;
  Int pattern = 1;
  pattern <<= x;pattern++;
  pattern <<= y;pattern++;
  pattern <<= z;pattern++;
  
  dp[0][1] = 1;
  for(int i = 0;i <= n;i++){
    if(i == 0)pt[i] = 1;
    else pt[i] = pt[i-1]*10 % MOD;
  }
  for(int i = 0;i <= n;i++){
    for(int j = 0;j <= (1 << 18);j++){
      dp[i][j] %= MOD;
      if((j & pattern) == pattern){
	res += dp[i][j] * pt[n - i];
	res %= MOD;
	continue;
      }
      if(i == n)continue;
      for(int a = 1;a <= 10;a++){
	int nxt = ((j << a) + 1) & mask;
	dp[i+1][nxt] += dp[i][j];
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 84224
import Control.Monad
import Control.Arrow
import Data.Tree
import Data.Array
import Data.Graph
import Data.Maybe
import Data.Tuple
import qualified Data.ByteString.Char8 as BS

type CounterTree = Tree (Int, Int)

scanTree :: (b -> a -> b) -> b -> Tree a -> Tree b
scanTree f z (Node x ts) = Node xx (map (scanTree f xx) ts)
    where xx = f z x

accumCount :: Array Int Int -> (Int, Int) -> Int -> (Int, Int)
accumCount counts acc vertex = (vertex, snd acc + counts!vertex)

solve :: Int -> [(Int, Int)] -> Int -> [(Int, Int)] -> [Int]
solve n e q px = elems countArray
    where
        counts = accumArray (+) 0 (1, n) px
        graph = buildG (1, n) (e ++ map swap e)
        tree = (head . dfs graph) [1]
        accumulatedTree = scanTree (accumCount counts) (0, 0) tree
        countArray = array (1, n) (flatten accumulatedTree)

tuplify2 :: [a] -> (a, a)
tuplify2 (x:y:_) = (x,y)

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getIntTuple2 :: IO (Int, Int)
getIntTuple2 = do
    [x, y] <- map readInt . BS.words <$> BS.getLine
    return (x, y)

main :: IO ()
main = do
    [n, q] <- map readInt . BS.words <$> BS.getLine
    e <- replicateM (n - 1) (tuplify2 . map readInt . BS.words <$> BS.getLine)
    px <- replicateM q (tuplify2 . map readInt . BS.words <$> BS.getLine)
    putStrLn $ unwords $ map show $ solve n e q px


Measured memory_bytes: 190336
#include<bits/stdc++.h>
#define N 100005
#define Y second
#define X first
using namespace std;
typedef pair<int,int> P;

int n,q,a,b,c,d[N];
string s;
P par[N];

P Find(int x){
  if(par[x].X==x)return P(x,0);
  P r=Find(par[x].X);
  return par[x]=P(r.X,r.Y+par[x].Y);
}

void Union(int x,int y,int v){
  P rx=Find(x),ry=Find(y);
  if(rx.X==ry.X)return;
  par[rx.X]=P(ry.X,v-rx.Y+ry.Y);
}

void IN(){
  scanf("%d%d%d",&a,&b,&c);
  Union(a,b,-c-d[a]+d[b]);
  d[a]+=c;
  d[b]+=c;
}

void COMPARE(){
  scanf("%d%d",&a,&b);
  P r1=Find(b),r2=Find(a);
  if(r1.X!=r2.X)printf("WARNING\n");
  else printf("%d\n",r1.Y-r2.Y+d[b]-d[a]);
}

int main(){
  cin>>n>>q;
  for(int i=1;i<=n;i++)par[i]=P(i,0);
  while(q--){
    cin>>s;
    if(s[0]=='I')IN();
    else COMPARE();
  }
  
  return 0;
}

Measured memory_bytes: 2424
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

calc :: [Int] -> Int
calc xs = let unused = [i | i <- [1..9], notElem i xs] in sub unused xs []
  where
    sub _ [] [i,h,g,f,e,d,c,b,a] = if (a+c+f) + 10*(b+e) + 100*d == 100*g + 10*h + i then 1 else 0
    sub u ((-1):ys) s = sum [sub (delete t u) ys (t:s) | t <- u]
    sub u (t:ys) s = sub u ys (t:s)

main = getInts >>= print . calc



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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

const int column = 50;

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


    ll size = a.size();
    vector<ll> counts(26, 0);
    for (char c : a) counts[c - 'a']++;

    ll pair_all = size * (size - 1) / 2;

    vector<ll> pair_counts(26);
    rep(i, 26) pair_counts[i] = counts[i] * (counts[i] - 1) / 2;


    ll ans = pair_all + 1;
    for (ll l : pair_counts) ans -= l;

    cout << ans << endl;

}



Measured memory_bytes: 640
n,m,x=map(int,input().split())
a=[int(i) for i in input().split()]
cost=0
for i in range(x,n):
    if i in a:
        cost+=1
cost2=0
for i in range(0,x+1)[::-1]:
    if i in a:
        cost2+=1
print(min(cost,cost2))

Measured memory_bytes: 9192
# -*- coding: utf-8 -*-

N = input()

sum = 0
for i in range(1, len(N) + 1, 2):

    if int(N) >= 10 ** i:
        sum += (10**i - 1) - (10**(i - 1) - 1)
    else:
        sum += int(N) - (10**(i - 1) - 1)

print(sum)



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

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

typedef long long LL;
typedef unsigned long UL;

using namespace std;


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

	int n;
	cin >> n;

	vector<int> a(n);


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

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

	int count0;
	for (int i = a[1]; i > 0; --i)
	{
		count0 = 0;

		REP(j, n)
		{
			if (a[j] % i != 0)
			{
				++count0;

				if (count0 > 1)
				{
					break;
				}
			}
		}
		if (count0 <= 1)
		{
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <cctype>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
int n, m, k, a[N], b[N], is_cov[N<<2], cov[N<<2], val[N<<2], _[N<<1];
void pushc(int x, int d) { is_cov[x] = 1, val[x] = cov[x] = d; }
void pushdown(int x) { if(is_cov[x]) pushc(x<<1, cov[x]), pushc(x<<1|1, cov[x]), is_cov[x] = 0; }
void cover(int x, int l, int r, int ql, int qr, int d)
{
    if(ql > qr) return; if(ql <= l&&r <= qr) return pushc(x, d);
    int mid = (l+r)>>1; pushdown(x);
    if(ql <= mid) cover(x<<1, l, mid, ql, qr, d);
    if(qr > mid) cover(x<<1|1, mid+1, r, ql, qr, d);
}
int query(int x, int l, int r, int p)
{
    if(l == r) return val[x];
    int mid = (l+r)>>1; pushdown(x);
    if(p <= mid) return query(x<<1, l, mid, p);
    else return query(x<<1|1, mid+1, r, p);
}
int sl[N], sr[N];
int64 f[N], s[N];
int64 query(int p) { int q = query(1, 1, m, p); return q?f[q]+(_[sl[q]]-_[p]+k)%k:0; }
int main()
{
    n = read(), k = read();
    for(int i = 1; i <= n; ++i)
    {
        a[i] = read(), b[i] = read(), s[i] = s[i-1]+a[i], sl[i] = 0, sr[i] = k-1; 
        if(b[i] != 2&&2*a[i] > k) return puts("-1"), 0;
    }
    for(int i = 1; i <= n; ++i)
    {
        if(b[i] == 1) sl[i] = (-2*s[i-1]%k+k)%k, sr[i] = (-2*s[i]%k+k)%k;
        _[++m] = sl[i], _[++m] = sr[i];
    }
    sort(_+1, _+1+m), m = unique(_+1, _+1+m)-_-1;
    for(int i = n; i; --i)
    {
        sl[i] = lower_bound(_+1, _+1+m, sl[i])-_;
        sr[i] = lower_bound(_+1, _+1+m, sr[i])-_;
        f[i] = query(sl[i]);
        if(sl[i] > sr[i]) cover(1, 1, m, sr[i]+1, sl[i]-1, i);
        else cover(1, 1, m, 1, sl[i]-1, i), cover(1, 1, m, sr[i]+1, m, i);
    }
    int64 ans = f[1]; 
    for(int i = 1; i <= m; ++i) ans = min(ans, query(i));
    printf("%lld\n", ans+2*s[n]);
    return 0;
}

Measured memory_bytes: 8704
l = input()

for i in range(1<<3):
    s = ""
    for k in range(3):
        if (i & (1<<k)):
            s += '+'
        else:
            s += '-'
    e = ""
    for i in range (3):
        e += l[i]
        e += s[i]

    e += l[3]

    if ( eval(e) == 7 ):
        e += "=7"
        print(e)
        break;


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

const int MOD = 1e9+7;

signed main(){

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

  static int dp[22][1 << 21];
  //男性i人目まで見て{j}の女性とマッチングする組み合わせ
  dp[0][0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 1 << n; j++){
      if(__builtin_popcount(j) != i) continue;
      for(int k = 0; k < n; k++){
        if(!(j >> k & 1) && a[i][k]){
          int &res = dp[i+1][j | 1 << k];
          res = (res + dp[i][j]) % MOD;
        }
      }
    }
  }
  cout << dp[n][(1 << n) - 1] << endl;

  return 0;
}


Measured memory_bytes: 258432
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		Scanner scan = new Scanner(System.in);
		String textString = scan.next();
		char[] text=textString.toCharArray();
		int decreeNum =scan.nextInt();
		int A = 0;
		int B = 0;
		String replaceText= "";
		String answer ="";
		
		for (int i=0; i<decreeNum; i++){
			String decree =scan.next();
			A = scan.nextInt();
			B = scan.nextInt();
			if(decree.equals("replace")){
				replaceText = scan.next();
				for(int j=0; j<(B-A+1); j++){
					text[A+j] = replaceText.charAt(j);
				}
			}
			if(decree.equals("reverse")){
				char[] hozon = (char[])text.clone();
				for(int j=0; j<B-A+1; j++){
					text[B-j] = hozon[j+A];
				}
			}
			if(decree.equals("print")){
				answer = "";
				for(int j=A; j<B+1; j++){
					answer = answer + text[j];
				}
				System.out.println(answer);
			}
		}
	}
}

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

int main(){
	int N, K, x ,sum = 0;
	cin >> N >> K;
	for (; N > 0; N--) {
		cin >> x;
		if (x * x > (x - K) * (x - K)) {
			if (x - K > 0) {
				sum = sum + (x - K) * 2;
			} else {
				sum = sum - (x - K) * 2;
			}
		} else {
			sum = sum + x * 2;
		}
	}
	cout << sum << endl;
 }

Measured memory_bytes: 256
package main

import(
    "fmt"
)



func main() {
    var a,b int
    fmt.Scan(&a,&b)
    fmt.Println((a-1)*(b-1))
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 1e18+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int n;
vector<int> a;

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

bool check(int mid){
  
  return false;
}

ll serch(ll ok,ll ng){
	while (abs(ok-ng) > 1) {
		ll mid = (ok + ng) / 2;
		if (check(mid))ok = mid;
		else ng = mid;
	}
	return ok;
}

int main(){
  cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
  string t;
  cin>>t;
  rep(i,t.size()){
    if(t[i]!='?'){
      cout<<t[i];
    }else{
      cout<<'D';
    }
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3788