akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
//#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[5]={-1,0,1,0,0};
int dy[5]={0,-1,0,1,0};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------

    int a,b,c,d;cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }

        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------

















































Measured memory_bytes: 3640
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

void recur(std::vector<i64>& candidates, const i64 prev, const i64 left_digit) {
  if (left_digit == 0) {
    std::array<bool, 3> appeared = {false, false, false};
    for (const char& c : std::to_string(prev)) {
      switch (c) {
      case '3':
        appeared[0] = true;
        break;
      case '5':
        appeared[1] = true;
        break;
      case '7':
        appeared[2] = true;
        break;
      }
    }
    if (appeared[0] && appeared[1] && appeared[2]) {
      candidates.push_back(prev);
    }
  } else {
    recur(candidates, 10 * prev + 3, left_digit - 1);
    recur(candidates, 10 * prev + 5, left_digit - 1);
    recur(candidates, 10 * prev + 7, left_digit - 1);
  }
}

int main() {
  std::vector<i64> candidates;
  for (i64 digit = 3; digit <= 9; ++digit) {
    recur(candidates, 0, digit);
  }

  i64 N;
  std::cin >> N;
  std::cout << std::count_if(candidates.begin(), candidates.end(), [&N](const i64& candidate) { return candidate <= N; }) << std::endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
  
int main () {
  string S;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MOD2=998244353;
const double PI=acos(-1);
const ll INF=1e18;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

vl memo(100001,-1);

ll dfs(ll x){
  if(memo[x]!=-1){
    return memo[x];
  }
  if(x==0){
    return 0;
  }
  if(x==1||x==6||x==9){
    memo[x]=1;
    return 1;
  }
  ll a=6,b=9;
  ll t=x;
  while(x>=a){
    t=min(dfs(x-a)+1,t);
    a*=6;
  }
  while(x>=b){
    t=min(dfs(x-b)+1,t);
    b*=9;
  }
  memo[x]=t;
  return t;
}

int main() {
  ll n;
  cin >> n;
  ll x=dfs(n);
  cout << x << endl;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	string str;
	cin >> str;
	ll i,cnt=0;
	for(i=0;2*i<str.size();i++){
		if(str[i]!=str[str.size()-i-1])cnt++;
	}
	cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
 
int main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    int fa=0;
    int fb=0;
 
    if(c<d){
        for(int i=a-1;i<c-1;i++){
            if(s[i]=='#'&&s[i+1]=='#')fa=1;
        }
        for(int i=b-1;i<d-1;i++){
            if(s[i]=='#'&&s[i+1]=='#')fb=1;
        }
        if(fa==0&&fb==0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
 
    else if(c>d){
        int tmp=0;
        int tmp2=0;
 
        for(int i=a-1;i<c-1;i++){
            if(s[i]=='#'&&s[i+1]=='#')fa=1;
        }
        for(int i=b-1;i<d-1;i++){
            if(s[i]=='#'&&s[i+1]=='#')fb=1;
        }
        for(int i=b-2;i<d-1;i++){
            if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.')tmp=1;
        }
        if(fa==0&&fb==0&&tmp==1)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t l, r;
  cin >> l >> r;
  r = min(r, l+2019);
  int ans = 2018;
  for(int64_t i=l; i<r; i++){
    for(int64_t j=i+1; j<=r; j++){
      int x = (int64_t)i*j%2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <map>
using namespace std;
#define ll long long

int main() {
	string s;
	cin >> s;
	bool a = false, b = false, c = false;
	int num = 0, p, wn = 0;
	for (int i = 2; i < s.size() - 1; i++) {
		if (s[i] == 'C') {
			num++;
			p = i;
		}
	}
	if (num == 1) {
		a = true;
		for (int i = 1; i < s.size(); i++) {
			if (i == p)continue;
			if (s[i] >= 'a' && s[i] <= 'z') {

			}
			else {
				wn++;
			}
		}
		if (wn == 0)b = true;
	}
	if (s[0] == 'A')c = true;
	if (a = true && b == true && c == true)cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
 
 
public class Main {
	public static int[] C ;
	public static int[] ans ;
	public static PriorityQueue<Integer> D;
	public static List<List<Integer>> dim;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		
		
		int N = Integer.parseInt(sc.next());
		//int[][] dim = new int[N][3];
		dim = new ArrayList<>();
		for(int i=0; i<N; i++){
			List<Integer> dot = new ArrayList<>();
			dim.add(dot);
		}
		for(int i=0; i<N-1; i++){
			int e_1 = Integer.parseInt(sc.next())-1;
			int e_2 = Integer.parseInt(sc.next())-1;
			dim.get(e_1).add(e_2);
			dim.get(e_2).add(e_1);

		}
		C = new int[N];
		D = new PriorityQueue<>(Collections.reverseOrder());
		for(int i=0; i<N; i++){
			C[i] = Integer.parseInt(sc.next());
			D.offer(C[i]);
		}
		Arrays.sort(C);
		int sum=0;
		for(int i=0; i<N-1; i++){
			sum+=C[i];
		}
		
		ans = new int[N];
		
		walk(0);
		

		System.out.println(sum);
		for(int a : ans){
			System.out.print(a+" ");
		}
		//int Q = Integer.parseInt(sc.next());
		//long L = Long.parseLong(sc.next());
		//char[] c = sc.next().toCharArray();

	}
	
	public static void walk(int v){
		if(ans[v] != 0)return;
		if(D.size()==0)return;
		ans[v] = D.poll();
		for(int a : dim.get(v)){
			walk(a);
		}
	}
	
}



Measured memory_bytes: 42016
n = int(input())#输入几行呢
i = 1
string = []
while i <= n:
    string.append(input().split(" "))
    i = i + 1
i = 0
state = 1
while i < n:
    if int(string[i][0])%2 == 0 and (int(string[i][1]) + int(string[i][2]))%2 == 0 and int(string[i][1]) + int(string[i][2]) <= int(string[i][0]):
        pass
    elif int(string[i][0])%2 != 0 and (int(string[i][1]) + int(string[i][2]))%2 != 0 and int(string[i][1]) + int(string[i][2]) <= int(string[i][0]):
        pass
    else:
        state = 0
        break
    i = i + 1
if state == 1:
    print("Yes")
else:
    print("No")    

Measured memory_bytes: 32144
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;


int main(){
  ll N,M;
  cin >> N >> M;
  if(N==1 && M==1){
    cout << 1 << endl;
    return 0;
  }
  ll ans;
  if(N>=3 && M>=3){
    ans = (N-2)*(M-2);
  }else{
    if(N==1 && M>=3){
      ans = M-2;
      cout << ans << endl;
      return 0;
    }
    if(M==1 && N>=3){
      ans = N-2;
      cout << ans << endl;
      return 0;
    }
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}


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

 int n[5];
int main(){
    int a[10],b[10];
   
    for(int i=0;i<3;i++){
        cin>>a[i]>>b[i];
        n[a[i]]++;
        n[b[i]]++;
    }
    for(int i=1;i<=4;i++){
        if(n[i]>2) {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    LL S;
    cin >> S;
    cout << "0 0 ";
    LL lh = 0;
    LL hh = 2e9;
    while(lh < hh){
        LL mid = (lh + hh) / 2;
        if(mid*mid<S){
            lh = mid+1;
        }else{
            hh = mid;
        }
    }
    printf("%ld %ld %ld %ld\n", lh, lh*lh-S, 1, lh);
    return 0;
}


Measured memory_bytes: 764
//2020 1.22 バブルソート

#include <stdio.h>
#define N 100 

int main()
{
    int i;
    int a,cnt1=0,cnt2=0;
    int array[N];

    scanf("%d",&a);

    for(i=0;i<a;i++)
    {
        scanf("%d",&array[i]);
    }
    
    if(a>1)
    {
    while(1)
    {
        i = a;
      while(1)
        {
         if(array[i-2] > array[i-1])
            {
                int temp = array[i-2];
                array[i-2] = array[i-1];
                array[i-1] = temp;
                cnt1++;
            }
            i = i-1;
            if(i == 1) break;
        }
        cnt2++;
        if(cnt2 > a) break;
    }
    }
    
    for(i=0;i<a;i++)
    {
        printf("%d",array[i]);
        if(i != a-1)
        {
        printf(" ");
        }
    }
    printf("\n");
    printf("%d\n",cnt1);
    return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <math.h>
using namespace std;

long long a(int n) {
    return pow(2, n + 2) - 3;
}
long long p(int n) {
    return pow(2, n + 1) - 1;
}

int main(void){
    long long n, x;
    cin >> n >> x;
    
    long long k, ans = 0;
    while (x > 0) {
        k = 0;
        while (a(k + 1) + n - k - 1 <= x) k++;
        if (k == 0) {
            if (x > n) ans += x - n;
            break;
        }
        
        ans += p(k);
        x -= a(k) + n - k;
        
        if (x > 0) {
            ans++;
            x--;
        }
        
        n = k;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
// Problem : E - NEQ
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 500005

//Solution

int binpow(int x,int y){
    x %= mod;
    int res = 1;
    while(y){
        if(y&1) res = (res*x)%mod;
        x = (x*x)%mod;
        y = y/2;
    }
    return res;
}
 
int inv(int a){
    return binpow(a,mod-2);
}
 
int fact[N], invfact[N];
 
void precompute(){
    fact[0] = 1;
    for(int i=1;i<N;i++) fact[i] = (fact[i-1]*i)%mod;
    invfact[N-1] = inv(fact[N-1])%mod;
    for(int i=N-2;i>=0;i--) invfact[i] = (invfact[i+1]*(i+1))%mod;
}
 
int ncr(int n, int r){
    if(n<r) return 0;
    return (((fact[n]*invfact[r])%mod)*invfact[n-r])%mod;
}

void solve(){
    precompute();
    int n,m;
    cin>>n>>m;
    int p = 1;
    int ans = 0;
    for(int i=0;i<=n;i++){
        int cur = (((ncr(n,i)*ncr(m-i,n-i))%mod)*fact[n-i])%mod;
        ans = (ans+p*cur+mod)%mod;
        p = -p;
    }
    ans = (((ans*ncr(m,n))%mod)*fact[n])%mod;
    cout<<ans<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 11428
n = int(input())
start = [0,0,0]
next_d = []
for i in range(n):
    next_d = list(map(int, input().split()))
    t = start[0]-next_d[0]
    x = start[1]-next_d[1]
    y = start[2]-next_d[2]
    if abs(t)<abs(x)+abs(y) or abs(t)%2 != (abs(x)+abs(y))%2:
        print("No")
        exit()
    start = next_d
print("Yes")

Measured memory_bytes: 3064
#pragma GCC optimize "trapv"
#include<bits/stdc++.h>

#define ll long long int
#define pb push_back
#define ppb pop_back
#define ff first
#define ss second
#define sz(s) (ll)(s.size())
#define vvi vector<vector<ll>>
#define vi vector<ll>
#define all(a) (a).begin(),(a).end()
#define pii pair<ll,ll>
#define dbg(x,y) cout<<x<<" "<<y<<endl
#define endl '\n'
#define M 1000000007
const ll INF = 1ll<<60;

using namespace std;
//-----------------------------------------//


void solve(){
	string s;
	cin>>s;
	int ans=0,c=0;
	for(int i=0;i<sz(s);++i){
		if(s[i]=='R'){
			c++;
		}
		else{
			ans=max(ans,c);
			c=0;
		}
	}
	if(c!=0) ans=max(c,ans);
	cout<<ans<<endl;
}



int main(){

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	
	int t=1;
	// cin>>t;
	while(t--){
        solve();
	}
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int H, W, K; cin >> H >> W >> K;
  vector<vector<int>> v(H, vector<int>(W));
  for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
    int r, c, x; cin >> r >> c >> x; r--, c--;
    v[r][c] = x;
  }
  vector<vector<vector<ll>>> dp(H+1, vector<vector<ll>>(W+1, vector<ll>(4, 0)));
  for (int i = H - 1; i >= 0; i--) {
    for (int j = W - 1; j >= 0; j--) {
      for (int k = 0; k < 4; k++) {
        auto& res = dp[i][j][k];
        res = max(res, dp[i][j+1][k]);
        res = max(res, dp[i+1][j][0]);
        if (k != 3) {
          res = max(res, dp[i][j+1][k+1] + v[i][j]);
          res = max(res, dp[i+1][j][0] + v[i][j]);
        }
      }
    }
  }
  cout << dp[0][0][0] << endl;
}

Measured memory_bytes: 671608
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val k = readLine()?.toInt() ?: return
    val xList = readLine()?.split(" ")?.map { it.toInt() } ?: return

    // 0 or K との距離が近い方のロボットを起動すればよい
    // その距離合計の2倍が答え

    val result = xList.map {
        Math.min(it, Math.abs(k - it)) * 2
    }.sum()

    println(result)
}

Measured memory_bytes: 37900
#include<cstdio>
using namespace std;
const int maxn=5e5+5;
char ch,s[maxn];
int n,bit[maxn][30],opt,l,r,t;
int lowbit(int x){
    return x&(-x);
}
void update(int pos,int kind,int cnt){
    while(pos<=n){
        bit[pos][kind]+=cnt;
        pos=pos+lowbit(pos);
    }
}
int query(int x,int i){
    int ans=0;
    while(x>0){
        ans+=bit[x][i];
        x=x-lowbit(x);
    }
    return ans;
}
int main(){
    scanf("%d %s %d",&n,s+1,&t);
    for(int i=1;i<=n;i++){
        update(i,s[i]-'a',1);//加1
    }
    while(t--){
        scanf("%d",&opt);
        if(opt==1){
            scanf("%d %c",&l,&ch);
            if(s[l]!=ch){
                update(l,s[l]-'a',-1);//减1
                update(l,ch-'a',1);//加1
                s[l]=ch;//修改不要忘了
            }
        }else{
            scanf("%d %d",&l,&r);
            int ans=0;
            for(int i=0;i<=25;i++){//查询26个树状数组
                if(query(r,i)-query(l-1,i)){
                    ans++;
                }
            }
            printf("%d\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 59264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define rep(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define For(i, a, n) for (ll (i) = (a); (i) < (n); (i)++)
#define prl(x) cout << (x) << endl
#define pr(x) cout << (x)
#define all(v) (v).begin(), (v).end()

int main(void){
    ll n,k,ans=0;map<ll,ll> cnt;cin>>n>>k;
    vl a(n),cum(n+1,0),g(n+1,0);rep(i,n)cin>>a[i];
    rep(i,n)cum[i+1]=cum[i]+a[i],g[i+1]=(k+(cum[i + 1]-i-1)%k)%k;
    rep(r,n+1){
        if(r>=k)cnt[g[r-k]]--;
        ans+=cnt[g[r]]++;
    }
    prl(ans);
    return 0;
}

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

#define o cout<<"Hm"<<'\n';
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double

using namespace std;

const int N = 2e5 + 100;
const int mod = 1e9 + 7;

int main ()
{
	#define int ll
	int n, a[3];
	cin >> n >> a[0] >> a[1] >> a[2];
	string ss[n + 1];
	string ans = "Yes\n";
	for (int i = 1; i <= n; i++)
	{
		cin >> ss[i];
	}
	for (int i = 1; i <= n; i++)
	{
		int x = ss[i][0] - 'A';
		int y = ss[i][1] - 'A';
		if (!a[x] && !a[y])
		{
			ans = "No";
			break;
		}
		if (!a[x])
		{
			a[x]++;
			a[y]--;
			ans += x + 'A';
		}
		else if (!a[y])
		{
			a[x]--;
			a[y]++;
			ans += y + 'A';
		}
		else if (a[x] == 1 && a[y] == 1 && i + 1 <= n)
		{
			if (ss[i + 1][0] - 'A' == x || ss[i + 1][1] - 'A' == x)
			{
				a[x]++;
				a[y]--;
				ans += x + 'A';
			}
			else {
				a[x]--;
				a[y]++;
				ans += y + 'A';
			}
		}
		else {
			if (a[x] > a[y])
			{
				a[x]--;
				a[y]++;
				ans += y + 'A';
			}
			else {
				a[x]++;
				a[y]--;
				ans += x + 'A';
			}
		}
		ans += '\n';
	}
	if (a[0] < 0 || a[1] < 0 || a[2] < 0)
	{
		ans = "No";
	}  
	cout << ans << '\n';
}




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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;


int main() {

    ll A, B;
    cin >> A >> B;

    //すべて白で初期化
    vector<vector<char > > grid(100, vector<char >(100, '.'));

    //初期化
    //半分黒，半分白の連結成分が1つずつの状態にする
    //100*100の中で最大500と500しか連結成分が現れないので適当に穴抜きにする
    for(ll row = 0; row < 100; row++){
        for(ll col = 50; col < 100; col++){
            grid[row][col] = '#';
        }
    }    
    
    //白は黒の領域を穴抜きにする
    ll cn = 1;
    for(ll row = 1; row < 99; row+=2){
        /*
        ll col;
        if(row % 2 == 0){
            col = 52;
        }else{
            col = 51;
        }
        */

        for(ll col = 51; col < 99; col+=2){
            //cout << col << endl;
            if(cn >= A){
                break;
            }
            grid[row][col] = '.';
            cn++;
        }
        if(cn >= A){
            break;
        }
    }

    //黒は白の領域を穴抜きにする
    cn = 1;
    for(ll row = 1; row < 99; row+=2){
        /*
        ll col;
        if(row % 2 == 0){
            col = 2;
        }else{
            col = 1;
        }
        */

        for(ll col = 1; col < 49; col+=2){
            if(cn >= B){
                break;
            }
            grid[row][col] = '#';
            cn++;
        }
        if(cn >= B){
            break;
        }
    }

    //表示
    cout << 100 << " " << 100 << endl;
    for(ll row = 0; row < 100; row++){
        for(ll col = 0; col < 100; col++){
            cout << grid[row][col];
        }
        cout << endl;
    }        


}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

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

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

    int M = 0;
    vector<int> b(n, 0);
    for(int i = n; i >= 1; i--){
        int j = 2;
        int cnt = 0;
        while(j*i <= n){
            if(b[j*i-1] == 1) cnt++;
            j++;
        }
        if(a[i-1] != (cnt%2)){
            b[i-1] = 1;
            M++;
        }
    }

    cout << M << endl;
    for(int i = 0; i < n; i++){
        if(b[i] == 1) cout << i+1 << " ";
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 2432
n=int(input())
l=[0,0,0,0]
for i in range(n):
  s=input()
  if(s=="AC"):
    l[0]+=1
  elif(s=="WA"):
    l[1]+=1
  elif(s=="TLE"):
    l[2]+=1
  else:
    l[3]+=1

print("AC x",l[0])
print("WA x",l[1])
print("TLE x",l[2])
print("RE x",l[3])
    





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

int main(){
  int n,i,j;
  scanf("%d",&n);
  int h[n];
  for(i=0;i<n;i++) {
    scanf("%d",&h[i]);
  }
  int ans = 0;
  int check = 1;
  int prev = 0;
  while(check > 0) {
    check = 0;
    for(i=0;i<n-1;i++) {
      if(h[i]>0) {
        check++;
        h[i]--;
        prev = 1;
      } else {
        if(0 < i) {
          if(prev == 1) {
            ans++;
          }
        }
        prev = 0;
      }
    }
    i = n-1;
    if(h[i]>0) {
      check++;
      h[i]--;
      ans++;
    } else {
      if(prev == 1) {
        ans++;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
long long a,b,c,two,one,n;
int main()
{
    scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&two,&n);
    b = b * 2;a = a * 4;
    one = min(min(a,b),c);
    if(one * 2 > two)
        printf("%lld\n",n / 2ll * two + n % 2 * one);
    else
        printf("%lld\n",n * one);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>

using namespace std;
typedef pair<int, int> coord;
vector<vector<int>> bd(50, vector<int>(50,0));
vector<vector<long>> score(50, vector<long>(50,50*50));
vector<vector<bool>> label(50, vector<bool>(50, false));
long h,w;

int main(){
    long count=0;
    char c;
    cin >> h >> w;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> c;
            if( c == '.'){
                bd[i][j] = 1;
                count++;
            }
        }
    }
    
    queue<coord> points;
    score[0][0] = 1;
    points.push(make_pair(0,0));
    while(!points.empty()){
        coord crd = points.front();
        points.pop();
        int x=crd.first, y=crd.second;
        long s = score[y][x];
        if( (y-1) >= 0 ){
            if( (score[y-1][x] > s+1)&&(bd[y-1][x]==1) ){
                score[y-1][x] = s+1;
                points.push(make_pair(x,y-1));
            }
        }
        if( (x+1) < w ){
            if( (score[y][x+1] > s+1)&&(bd[y][x+1]==1) ){
                score[y][x+1] = s+1;
                points.push(make_pair(x+1,y));
            }
        }
        if( (y+1) < h ){
            if( (score[y+1][x] > s+1)&&(bd[y+1][x]==1) ){
                score[y+1][x] = s+1;
                points.push(make_pair(x,y+1));
            }
        }
        if( (x-1) >= 0 ){
            if( (score[y][x-1] > s+1)&&(bd[y][x-1]) ){
                score[y][x-1] = s+1;
                points.push(make_pair(x-1,y));
            }
        }
    
    }
    /*
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++){
            cout << score[i][j] << " " ;
        }
        cout << endl;
    }
    */
    long rt = score[h-1][w-1];
    if( rt >= 50*50 ) cout << -1 << endl;
    else cout << (count - rt) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	static int n;
	static int[][] f;
	static int[][] p;
	static int[] a;
	static int ans;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		f = new int[n][10];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 10; j++) {
				f[i][j] = sc.nextInt();
			}
		}
		p = new int[n][11];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 11; j++) {
				p[i][j] = sc.nextInt();
			}
		}
		sc.close();
 
		a = new int[10];
		ans = Integer.MIN_VALUE;
		dfs(0);
		System.out.println(ans);
	}
 
	static void dfs(int index) {
		if (index == 10) {
//			System.out.println(Arrays.toString(a));
			if (Arrays.toString(a).equals("[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]")) return;
			memo();
			return;
		} else {
			a[index] = 0;
			dfs(index + 1);
			a[index] = 1;
			dfs(index + 1);
		}
	}
 
	static void memo() {
		int partAns = 0;
		for (int i = 0; i < n; i++) {
			int count = 0;
			for (int j = 0; j < 10; j++) {
				if (a[j] == 1 && f[i][j] == 1) {
					count++;
				}
			}
			partAns += p[i][count];
		}
		ans = Math.max(partAns, ans);
	}
}

Measured memory_bytes: 26348
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

pair<string, string> firstHalf[1 << 18];//(赤,青)
pair<string, string> secondHalf[1 << 18];//(逆青,逆赤)
int N;
string S;

signed main() {
    cin >> N >> S;
    for (int mask = 0; mask < (1 << N); ++mask) {
        string red = "";
        string blue = "";
        for (int i = 0; i < N; ++i) {
            if ((mask >> i) & 1) {
                red += S[i];
            } else {
                blue += S[i];
            }
        }
        firstHalf[mask] = make_pair(red, blue);
    }
    for (int mask = 0; mask < (1 << N); ++mask) {
        string red = "";
        string blue = "";
        //逆順
        for (int i = N - 1; i >= 0; --i) {
            if ((mask >> i) & 1) {
                red += S[i + N];
            } else {
                blue += S[i + N];
            }
        }
        secondHalf[mask] = make_pair(blue, red);
    }
    const int size = 1 << N;
    sort(firstHalf, firstHalf + size);
    sort(secondHalf, secondHalf + size);
    int ans = 0;
    rep(i, size) {
        ans += u_b(secondHalf, secondHalf + size, firstHalf[i])
               - l_b(secondHalf, secondHalf + size, firstHalf[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 67328
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,k;
    cin >> n >> k;
    vi p(n);
    rep(i,n)cin >> p[i];
    vector<double> a(n+1,0);
    rep(i,n){
        double sum = (1+p[i])*p[i]/2.0;
        a[i+1] = sum/p[i];
    }
    rep(i,n)a[i+1] += a[i];
    double ans = 0;
    loop(i,k,n+1){
        double sum = a[i]-a[i-k];
        ans = max(ans, sum);
    }
    cout << shosu(10) << ans << endl;
}


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

typedef long long ll;

int main(){
  ll N, T;
  cin >> N >> T;
  vector<ll> t(N);
  for(int i=0; i<N; i++) cin >> t[i];

  ll sum=0;
  for(int i=0; i<N-1; i++){
    if(t[i]+T > t[i+1]){
      sum += t[i+1]-t[i];
    }
    else
      sum += T;
  }

  cout << sum+T << endl;
}


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

int main() {
    int K;
    ll ans = 0;
    cin >> K;
    
    for(int i=1; i<=K; i++){
        for (int j=1; j<=K; j++){
            for(int k=1; k<=K; k++){
                ans += gcd(gcd(i,j),k);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
import java.io.*;
import java.util.*;

public class Main {
	static final Reader in = new Reader();
	static final PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) {
		char[] s=in.next().toCharArray();
		int n=s.length;
		if(s[0]=='0'||s[n-1]=='1')
			fk();
		for(int i=0; i<n-2-i; ++i)
			if(s[i]!=s[n-2-i])
				fk();
		for(int i=1, l=0; i<n; ++i) {
			if(s[i]=='0')
				continue;
			for(int j=i; j>l; --j)
				out.println(j+" "+(i+1));
			l=i;
		}
		out.println(n+" "+(n-1));
		out.close();
	}
	
	static void fk() {
		System.out.println(-1);
		System.exit(0);
	}
	
	static class Reader {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		String next() {
			while(st==null||!st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

Measured memory_bytes: 40240
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b&&b == c) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
    for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
    FASTIO
    /*
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //scanf("%d", &T);
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n;
        string s;
        cin >> n >> s;
        if (n & 1) {
            cout << "No\n";
            return 0;
        }
        string str = s.substr(0, n / 2);
        string nxt = s.substr(n / 2, n);
        //dbg(str, nxt);
        if (str == nxt) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define REP(i,n) for (int i = 0; i < n; ++ i)
#define FOR(i,a,b) for (int i = a; i <= b; ++ i)
#define FORD(i,b,a) for (int i = b; i >= a; -- i)
#define debug(x) cerr << #x << ": " << x << "\n"
#define task ""
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> li;
typedef vector<int> vi;

const int N = 2e5 + 5;

int n, a[N], cnt[N][25];
ll res;

bool ok(int l, int r) {
	REP(i, 20) if (cnt[r][i] - cnt[l-1][i] > 1) return false;
	return true;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	//freopen(task".inp", "r", stdin);
	//freopen(task".out", "w", stdout);
	cin >> n;
	FOR(i, 1, n) {
		cin >> a[i];
		REP(j, 20) cnt[i][j] = cnt[i-1][j] + ((a[i] & (1 << j)) > 0);
		int l = 1, r = i, bs = r;
		while (l <= r) {
			int mid = (l + r) / 2;
			if (ok(mid, i)) bs = mid, r = mid - 1;
			else l = mid + 1;
		}
		res += i - bs + 1;
	}	
	cout << res;
}


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

//////////////////////////////////////////////



int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll t[3],v[3][3];
	FOR(i,2) cin >> t[i];
	FOR(i,2) cin >> v[0][i];
	FOR(i,2) cin >> v[1][i];
	ll dist[3][3];
	FOR(i,2) FOR(j,2) dist[i][j] = t[j] * v[i][j];
	ll dt[3];
	FOR(i,2) dt[i] = dist[i][0] + dist[i][1];
	if(dt[0] == dt[1]) cout << "infinity" << endl;
	else{
		int a = 0, b = 1;
		if(dt[0] > dt[1]) swap(a,b);
		ll dif = dt[b] - dt[a];
		ll tmp[3];
		FOR(i,2) tmp[i] = dist[b][i] - dist[a][i];
		bool never = true;
		ll difv = v[a][1] - v[b][1];
		ll difdist = dist[b][0] - dist[a][0];
		if(difdist > 0 && difv > 0 && difdist <= t[1] * difv) never = false;
		if(dist[b][0] < dist[a][0]) never = false;
		if(never) cout << 0 << endl;
		else{
			ll ans = (abs(tmp[0]) / dif * 2 + 1);
			if(ans / 2 * dt[a] + dist[a][0] == ans / 2 * dt[b] + dist[b][0]) ans--;
			printf("%lld\n",ans);
		}
	} 
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <utility>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

ll solve(void);

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

ll solve(void)
{
	ll N;
	string S;
	bool ans = true;

	cin >> N >> S;

	if (N % 2 > 0) { ans = false; }

	for (ll i = 0; i < N / 2; i++)
	{
		if (!ans) { break; }
		if (S[i] != S[i + N / 2])
		{
			ans = false;
			break;
		}
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:
#define error(args...) { vector<string> _debug = split(#args, ',');err(begin(_debug), args);}

vector<string> split(const string& s, char c){
	vector<string> v;stringstream ss(s);string x;
	while (getline(ss, x, c)) v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {cerr << endl;}
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...);
}

int h,w;
string s[15];

deque<int> order;

char tmp[15][15];

bool check(){
	rep(i,h)rep(j,w) tmp[i][j] = s[order[i]][j];

	vector<string> collect;

	rep(j,w){
		string in = "";
		rep(i,h) in += tmp[i][j];
		collect.push_back(in);
	}

	bool rest[15];
	rep(j,w) rest[j] = true;

	int total = w;
	
	while(total >= 2){
		bool found = false;

		const int n = w;

		rep(j,n)rep(i,j){
			if(rest[i] == false  or rest[j] == false) continue;
			
			bool same = true;
			rep(k,h) if(collect[i][k] != collect[j][h-1-k]) same = false; 

			if(same){
				rest[i] = false;
				rest[j] = false;
				total -=2;
				found = true;
			}
		}

		if(found == false) return false;
	}
	

	if(total == 0) return true;

	string str = "";
	rep(j,w) if(rest[j]) str = collect[j];
	rep(i,h) if(str[i] != str[h-1-i]) return false;
	
	return true;
}

bool ok = false;
bool used[15];

void dfs(int rest){
	if(rest == 0){
		ok |= check();
		return;
	}

	if(rest % 2 == 1){
		rep(i,h){
			if(used[i]) continue;
			used[i] = true;
			order.push_front(i);
			dfs(rest - 1);
			order.pop_front();
			used[i] = false;
		}
	}else{
		int pos = -1;
		rep(i,h){
			if(used[i]) continue;
			pos = i;
		}
			
		used[pos] = true;
		order.push_back(pos);
		dfs(rest - 1);	
		order.pop_back();
		used[pos] = false;
	}
}

int main(void){
	cin >> h >> w;

	rep(i,h) cin >> s[i];

	dfs(h);
	
	if(ok)
		puts("YES");
	else
		puts("NO");

	return 0;
}


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


void solve(){
    float d,t,s;cin>>d>>t>>s;

    if(t==0){cout<<"No";return;}

    if(d/t <= s)cout<<"Yes";
    else cout<<"No";
}


int main(){
    //ll tt;cin>>tt;
    //while(tt--){
        solve();
    //}
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main()
{   
    long int n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<int> ac(n);

    int cnt = 0;

    REP(i, n) {
        if (s[i] == 'A' && s[i+1] == 'C')
            cnt++;
        ac[i+1] = cnt;
    }

    vector<int> ans(q);

    REP(i, q) {
        long int l, r;
        cin >> l >> r;
        ans[i] = ac[r-1] - ac[l-1];
    }

    REP(i, q)   cout << ans[i] << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
	int n;
	long a[200100];
	long xor[200100];
	long sum=0;
	int i;
	int ok,ng,mid;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		xor[i]=a[i];
	}
	for(i=1;i<n;i++){
		a[i]+=a[i-1];
		xor[i]^=xor[i-1];
	}
	for(i=n;i;i--){
		a[i]=a[i-1];
		xor[i]=xor[i-1];
	}
	a[0]=0;xor[0]=0;
	for(i=0;i<n;i++){
		ok=i+1;ng=n+1;
		while(ng-ok>1){
			mid=(ok+ng)>>1;
			if((xor[mid]^xor[i])==a[mid]-a[i]){
				ok=mid;
			}else{
				ng=mid;
			}
		}
		sum+=(ok-i);
	}
	printf("%lld\n",sum);
	return 0;
}


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

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

struct Node *root,*NIL;

void insert(int k){
  struct Node *x=root;
  struct Node *y=NIL;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(struct Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  int a=0,b=0;
  char com[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    
    a = strcmp(com,"insert");
      if(a==0){
	scanf("%d",&x);
	insert(x);
      }

      b = strcmp(com,"print");
      if(b==0){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }
  }

  return 0;
}

Measured memory_bytes: 24040
#include <iostream>
#include <string>

using namespace std;

int main(){
    string S;
    cin >> S;
    int i=0;
    while(S.size()!=0){
        char a = S.back();
        S = S.substr(0,S.size()-1);
        while(S.size()!=0 && S.back()==a){
            S = S.substr(0,S.size()-1);
        }
        if(S.size()==0) cout << i << endl;
        else i++;
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int>vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin() , vec.end());
  reverse(vec.begin() , vec.end());
  int sum1 = 0;
  int sum2 = 0;
  for(int j = 0; j < N; j++){
    if(j % 2 == 0){
      sum1 += vec.at(j);
    }
    else{
      sum2 += vec.at(j);
    }
  }
 cout << sum1 - sum2 << endl;

}

Measured memory_bytes: 256
def main():
    s = input().rstrip()
    s = "0" + s
    dp = [0, float("inf")]
    for c in s:
        x = int(c)
        dp = [min(dp[0] + x, dp[1] + (10-x)), min(dp[0] + x+1, dp[1] + (10-x) - 1)]
    print(dp[0])

if __name__ == "__main__":
    main()


Measured memory_bytes: 5492