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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main()
{
    int N;
    cin >> N;
    vector<int> P, Q;
    int count = 0;
    int ansp = 0, ansq = 0;
    rep(i, N)
    {
        int p;
        cin >> p;
        P.push_back(p);
    }
    rep(i, N)
    {
        int q;
        cin >> q;
        Q.push_back(q);
    }
    vector<int> nums1, nums2;
    for (int i = 1; i <= N; i++)
    {
        nums1.push_back(i);
        nums2.push_back(i);
    }
    do
    {
        count++;
        bool check = true;
        rep(i, nums1.size())
        {
            if (nums1[i] != P[i])
            {
                check = false;
                break;
            }
        }
        if (check)
        {
            ansp = count;
            break;
        }
    } while (next_permutation(nums1.begin(), nums1.end()));
    count = 0;
    do
    {
        count++;
        bool check = true;
        rep(i, nums2.size())
        {
            if (nums2[i] != Q[i])
            {
                check = false;
                break;
            }
        }
        if (check)
        {
            ansq = count;
            break;
        }
    } while (next_permutation(nums2.begin(), nums2.end()));
    cout << abs(ansq - ansp) << endl;
    
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] first = splitInt(sc.nextLine(), " ");
		int result = (3*first[0] + first[1])/2;
		System.out.println(result);
		
	}
	public static int[] splitInt(String str, String split) {
		String[] array = str.split(split);
		int[] array2 = new int[array.length];
	
		for(int i=0; i<array.length; i++) {
				array2[i] = Integer.parseInt(array[i]);
		}
		return array2;
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    constexpr int INF = 1e9;
    const vector<int> dx{0,1,0,-1};
    const vector<int> dy{1,0,-1,0};
    int H, W;
    cin >> H >> W;
    int SH, SW;
    cin >> SH >> SW;
    SH--; SW--;
    int GH, GW;
    cin >> GH >> GW;
    GH--; GW--;
    vector<string> SS(H);
    REP(i,H) cin >> SS[i];

    vector<vector<int>> hw(H,vector<int>(W,INF));
    hw[SH][SW] = 0;
    set<pii> t_next;
    t_next.emplace(SH,SW);
    int step = 0;

    auto ishw = [&](int y, int x) {
        if (x < 0 || x >= W) return false;
        if (y < 0 || y >= H) return false;
        return true;
    };

    while(!t_next.empty() && hw[GH][GW] == INF) {
        set<pii> next;
        swap(t_next,next);
        while(!next.empty()) {
            set<pii> cnt;
            swap(next,cnt);
            for(auto p:cnt) {
                REP(i,4) {
                    int nx = p.second + dx[i];
                    int ny = p.first + dy[i];
                    if (!ishw(ny,nx)) continue;
                    if (SS[ny][nx] == '.' && hw[ny][nx] > step) {
                        next.emplace(ny,nx);
                        hw[ny][nx] = step;
                    } else {
                        FOR(y,p.first-2,p.first+3) FOR(x,p.second-2,p.second+3) {
                            if (!ishw(y,x)) continue;
                            if (SS[y][x] == '.' && hw[y][x] > step) {
                                t_next.emplace(y,x);
                                hw[y][x] = step+1;
                            }
                        }
                    }
                }
            }
        }
        step++;
    }

    OUT((hw[GH][GW] != INF) ? hw[GH][GW] : -1)

    return 0;
}

Measured memory_bytes: 9172
#include<stdio.h>
#include<math.h>
int main(){
int a,i;
double b=100,d=0,c=0;
scanf("%d",&a);
for(i=0;i<a;i++){
b*=1.05;
b+=0.9999;
double c=floor(b);
b=c;
}
printf("%d\n",(int)b*1000);
}

Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv vector<vector<int> >
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



int main(){
int n,m,x;cin>>n>>m>>x;
vi a(n);
vv b(n,vi (m));
int ans=10000000;
rep(i,n){
  cin>>a.at(i);
  rep(j,m)cin>>b.at(i).at(j);
}
for(int bits=1;bits<(1<<n);bits++){
  int an=0;
  vi d(m);
  for(int i=0;i<n;i++){
    if(bits&(1<<i)){
      an+=a.at(i);
      rep(h,m){
        d.at(h)+=b.at(i).at(h);

      }
    }
  }
  rep(k,m){
    if(d.at(k)>=x){
      if(k==m-1){
        ans=min(ans,an);
        break;
      }
      continue;
    }
    break;
  }

}
  if(ans==10000000)ans=-1;
cout<<ans<<endl;
return 0;

}


Measured memory_bytes: 3628
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    B = [0] * N
    B[0] = sum(A) - sum(2*A[1::2])
    for i in range(N-1):
        B[i+1] = 2*A[i] - B[i]

    print(*B)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17
int memo[MAX];
int rec(int n){
    if(n==0)return 0;
    if(memo[n]!=-1)return memo[n];
    int res=INF;
    for(int pow6=1;pow6<=n;pow6*=6){
        if(n-pow6>=0)res=min(res,rec(n-pow6)+1);
    }
    for(int pow9=1;pow9<=n;pow9*=9){
        if(n-pow9>=0)res=min(res,rec(n-pow9)+1);
    }
    return memo[n]=res;
}
int main(){
    ll n;cin>>n;
    memset(memo,-1,sizeof(memo));
    cout<<rec(n)<<endl;
}

Measured memory_bytes: 7080
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();
    int y = sc.nextInt();
    int a1[] = {1,3,5,7,8,10,12};
    int a2[] = {4,6,9,11};
    int count1 = 0;
    int count2 = 0;
    int count3 = 0;
    for(int i = 0; i < 7; ++i){
      if(x == a1[i]){
        count1 +=1;
      }
    }
    for(int i = 0; i < 4; ++i){
      if(x == a2[i]){
        count2 +=1;
      }
    }
      
    for(int i = 0; i < 7; ++i){
      if(y == a1[i]){
        count1 +=1;
      }
    }
    for(int i = 0; i < 4; ++i){
      if(y == a2[i]){
        count2 +=1;
      }
    }
    
    if(x==2 && y==2){
      count3 = 2;
    }
    
    if(count1==2 || count2==2 || count3==2){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35492
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

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


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


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


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


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

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




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  double ans=0;
  Rep(i,n+1){
    ll tmp=i;
    ll cnt=0;
    while(tmp<k){
      tmp*=2;
      cnt++;
    }
    
    ans+=(double)1/(n*(ll)pow(2,cnt));
  }
  cout<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb(a) push_back(a)
#define vi vector<int>
#define loop(i, n) for(int i=1;i<=n;i++)
#define loop0(i, n) for(int i=0;i<n;i++)
#define in(i) scanf("%d", &i);
#define out(i) printf("%d", i)
using namespace std;
int n, k, h[100001], dp[100001];

int solve(int stone)
{
  if(stone>=n)
    return 0;
  if(dp[stone]!=-1)
    return dp[stone];
  if(stone==n-1)
    return dp[stone]=abs(h[stone]-h[stone+1]);
  return dp[stone]=min(
      solve(stone+1)+abs(h[stone]-h[stone+1]),
      solve(stone+2)+abs(h[stone]-h[stone+2])
      );
}
int main()
{
  memset(dp, -1, sizeof(dp));
  in(n);
  loop(i, n)
  {
    in(h[i]);
  }
  cout<<solve(1)<<"\n";
}


Measured memory_bytes: 6804
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, K, S;
	cin >> N >> K >> S;

	if (S > N) {
		rep(i, K) cosp(S);
		rep(i, N - K) cosp(1);
	}
	else {
		rep(i, K) cosp(S);
		rep(i, N - K) cosp(S + 1);
	}



	Would you please return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int main(void){
  int n,k,q,a[100005],score[100005];
  scanf("%d %d %d",&n,&k,&q);
   for(int i=1;i<=q;i++){
     scanf("%d",&a[i]);
  }
   for(int i=1;i<=n;i++){
     score[i]=k-q;
   }
   for(int i=1;i<=q;i++){
     score[a[i]]++;
   }
   for(int i=1;i<=n;i++){
     if(score[i]>0) printf("Yes\n");
     if(score[i]<=0) printf("No\n");

       }



  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string S;
    cin >> S;
    map<char, int> m;
    REP(i, S.size()) {
        m[S[i]]++;
    }
    bool ok = true;
    for (auto p : m) {
        if (p.second != 2) ok = false;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int h,w,n;
    scanf("%d %d\n%d",&h,&w,&n);
    
    int c[10001];
    for(int i=0;i<n;i++){
        scanf("%d",&c[i]);
    }
    
    int s[101][101]={};
    
    int now=0;
    for(int i=0;i<h;i++){
        if(i%2==0){
            for(int j=0;j<w;j++){
                if(c[now]<=0)now++;
                
                s[i][j]=now+1;
                c[now]--;
                
                if(c[now]<=0)now++;
            }
        }else{
            for(int j=w-1;j>=0;j--){
                if(c[now]<=0)now++;
                
                s[i][j]=now+1;
                c[now]--;
                
                if(c[now]<=0)now++;
            }
        }
    }
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            printf("%d",s[i][j]);
            if(j!=w-1)printf(" ");
        }
        printf("\n");
    }
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		int length = s.length();
		String res = "";
		for(int i = 0; i < length;i++) {
			res += "x";
		}
		System.out.println(res);
	}

}


Measured memory_bytes: 23124
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int a, b, x;
    cin >> a >> b >> x;
    if (a <= x && x <= a + b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int i=0;
    int j;
    int count[26];
    int oomoji[26];
    int komoji[26];
    char n[1200];

for(j=0;j<26;++j){
    count[j]=0;
        oomoji[j] ='A'+j;
        komoji[j] ='a'+j;
    }

    while(scanf("%c", &n[i]) != EOF){ 
        for(j=0;j<26;++j){    
          if(n[i]==oomoji[j] || n[i]==komoji[j])
           ++count[j];
        }
        ++i;   
    }

    for(j=0;j<26;++j){
        printf("%c : %d\n",komoji[j],count[j]);
    }
    return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

pair<int, pair<string, int> > R[100];

bool ord(pair<int, pair<string, int> > r1, pair<int, pair<string, int> > r2)
{
	return (r1.second.first < r2.second.first) ||
		((r1.second.first == r2.second.first) 
			&& r1.second.second > r2.second.second);
}

int main()
{
	int N, P;
	string S;

	cin >> N;
	rep(i, N) {
		cin >> S >> P;
		R[i] = make_pair(i + 1, make_pair(S, P));
	}

	sort(R, R + N, ord);
	rep(i, N) cout << R[i].first << endl;

	return 0;
}


Measured memory_bytes: 256
#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);
  int i = vec.at(0);
  int count =1;
  while(i != 2){
    i = vec.at(i - 1);
    count++;
    if(count > N)
      break;
  }
  if (count <= N)
    cout << count << endl;
  else
    cout << -1 << endl;
        
    
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
string S;
int Q;
int T[201010];
bool is_reverse;
string front, back;

int main()
{
    cin >> S;
    cin >> Q;
    front.reserve(2010101);
    back.reserve(2010101);
    rep(i, 0, Q)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            if (is_reverse)
            {
                is_reverse = false;
            }
            else
            {
                is_reverse = true;
            }
        }
        else
        {
            int f;
            string c;
            cin >> f;
            cin >> c;
            if (f == 1)
            {
                if (is_reverse == false)
                {
                    front += c;
                }
                else
                {
                    back += c;
                }
            }
            else
            {
                if (is_reverse == false)
                {
                    back += c;
                }
                else
                {
                    front += c;
                }
            }
        }
    }
    reverse(front.begin(), front.end());
    S = front + S + back;
    if (is_reverse == false)
    {
        cout << S << endl;
    }
    else
    {
        reverse(S.begin(), S.end());
        cout << S << endl;
    }
}

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

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

const ll MOD = 1000000007;

int main() {
    int a , b;
    cin >> a >> b;

    if ( a != 2 && b != 2 ) {
        cout << "Yes" << endl;
    } 
    else {
        cout << "No" << endl;
    }

    return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

ll gcd(ll a, ll b) {
    if (a < b) {
        return gcd(b, a);
    }
    ll c = a % b;
    while (c != 0) {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    cin >> n;
    vl a(n + 10);
    IPT(a, n)
    vl ans(n + 10);

    maxi = 0;
    NREP() {
        maxi = max(maxi, a[i]);
        ans[i] = 0;
    }
    ll digit = ceil(log2(maxi));

    REP(i_d, 0, 32) {
        ll mask = 1 << i_d;
        ll bit_count = 0;
        NREP() {
            ll bit = (a[i] & mask) >> i_d;
            bit_count += bit;
        }

        if (bit_count % 2 == 0) {
            NREP() {
                ans[i] += a[i] & mask;
            }
        } else {
            NREP() {
                ll bit = (a[i] & mask) >> i_d;
                if (bit == 0) {
                    ans[i] += 1 << i_d;
                }
            }
        }
    }

    NREP() {
        cout << ans[i];
        if (i < n){
            cout << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 6380
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll x;
            cin>>x;
            cout<<x+x*x+x*x*x<<endl;
        }
        return 0;
    }


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int N, K;
    cin >> N >> K;

    vector<ll> nums(K, 0);
    FOR(i, 1, N + 1)
    {
        nums.at(i % K)++;
    }

    ll ans = 0;
    REP(a, K)
    {
        int b = (K - a) % K;
        int c = (K - a) % K;
        if ((b + c) % K == 0)
        {
            ans += nums.at(a) * nums.at(b) * nums.at(c);
        }
    }
    cout << ans;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000


int gcd(int a, int b){
  if(a<b){
    int temp=a;
    a=b;
    b=temp;
  }
  int c;
  while(a%b!=0){
    c=a%b;
    a=b;
    b=c;
  }
  return b;
}


int main(){
  char buf[1024];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  int *A=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    scanf("%d",&A[i]);
  }

  int ans;
  ans=gcd(A[0], A[1]);
  srep(i,2,N){
    ans=gcd(ans, A[i]);
  }

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

  return 0;


}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    ll left, right;
    cin(left); cin(right);

    if (2019 - left % 2019 <= right - left) {
        print(0);
        return 0;

    } else {
        ll result = LLONG_MAX;
        rep3(i, left, right) {
            erep3(j, i + 1, right) {
                if (i * j % 2019 < result) result = i * j % 2019;
            }
        }
        print(result);
        return 0;
    }
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <ctype.h>
#include <cmath>
#include <iomanip>
#include <ios>

using namespace std;

int main(void){
    
    int n;
    int ans=0;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    bool t=true;
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=h[i];
        if(i==n-1&&sum==0){
            t=false;
        }
    }
    
    while(t){
        int l=1000,r=-1;
        for(int i=0;i<n;i++){
            //cout<<l<<' '<<r<<endl;
            if(h[i]>0&&i<l){
                l=i;
            }if(h[i]>0&&i>r){
                r=i;
            }if(l!=1000&&r!=-1&&h[i]==0){
                break;
            }if(i==n-1&&l==1000&&r==-1)t=false;
        }
        //cout<<endl;
        if(t){
            for(int i=l;i<=r;i++){
                h[i]-=1;
            }
            ans+=1;
        }
        
    }
    cout<<ans<<endl;
    
    return 0;
}




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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int> cnt(n+1,1);
    for(int i=2;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            cnt[j]++;
        }
    }
    ll ans=0;
    for1(i,n) ans+=(ll)i*cnt[i];
    cout<<ans;
    return 0;
}



Measured memory_bytes: 42300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

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

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> d;
  rep(i, n){
    auto it = lower_bound(d.rbegin(), d.rend(), a[i]);
    if (it == d.rbegin()){
      d.push_back(a[i]);
    }else{
      --it;
      *it = a[i];
    }
  }
  int ans = d.size();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4180
#include <bits/stdc++.h> 
using namespace std;
int main() {     
	int a,s,d=1;
	cin>>a>>s;
	int asd[a+1];
	for(int i=1;i<=a;i++)asd[i]=i+s-1;
	for(int i=2;i<=a;i++)if(fabs(asd[i]-0)<fabs(asd[d]-0))d=i;
	int ans=0;
	for(int i=1;i<=a;i++)ans+=asd[i];
	ans-=asd[d];
	cout<<ans;
 	return 0; 
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    REP(i,s.size()){
        if(i%2==0) cout<<s[i];
    }
    cout<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string> 
using namespace std;
int main(void){
    
    int a;
    cin>>a;
    string b[a];
    
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;
    for(int i=0;i<a;i++){
        if(b[i]=="AC"){
            ac++;
        }if(b[i]=="WA"){
            wa++;
        }if(b[i]=="TLE"){
            tle++;
        }if(b[i]=="RE"){
            re++;
        }
        
    }
     cout<<"AC"<<" "<<"x"<<" "<<ac<<"\n";
     cout<<"WA"<<" "<<"x"<<" "<<wa<<"\n";
     cout<<"TLE"<<" "<<"x"<<" "<<tle<<"\n";
     cout<<"RE"<<" "<<"x"<<" "<<re<<"\n";
    return 0;
}


Measured memory_bytes: 6684
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int n,a,b,c,d;cin >>n>>a>>b>>c>>d;
  string s;cin >> s;
  bool canplace_a = true;
  bool canplace_b = true;
  bool canplace_c = true;
  for(int i=a-1; i<c-2;++i){
    if(s.substr(i,2) == "##" ) canplace_a = false;
  }
  for(int i=b-1; i<d-2;++i){
    if(s.substr(i,2) == "##" ) canplace_b = false;
  }
  if(d<c){
    canplace_c = false;
    for(int i=b-2; i<d-1;++i){
      if(s.substr(i,3) == "..." ) canplace_c = true;
    }
  }
  if(canplace_a && canplace_b && canplace_c){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    int n = Integer.parseInt(r.readLine());
    String[] sl = r.readLine().split("[\\s]+");
    int[] p = new int[100009];
    int[] s = new int[100009];

    p[0] = 0;
    for (int i = 1; i <= n; i++)
    {
      p[i] = Integer.parseInt(sl[i - 1]);
    }
    p[n + 1] = 0;

    s[0] = 0;
    for (int i = 1; i <= n + 1; i++)
    {
      s[i] = s[i - 1] + Math.abs(p[i] - p[i - 1]);
    }

    for (int i = 1; i <= n; i++)
    {
      System.out.println(s[i - 1] + Math.abs(p[i + 1] - p[i - 1]) + s[n + 1] - s[i + 1]);
    }

  }

}


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

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

struct town {
		int num;
		int y;
		int ken;
		int id = 0;
};
bool cmp(town a,town b){
		if(a.ken != b.ken) return a.ken < b.ken;
		return a.y < b.y;
}
bool cmp_id(town a,town b){
		return a.num < b.num;
}

signed main() {
		int n,m;
		cin >> n >> m;
		vector<town> a;
		for(int i=0;i<m;i++){
				int x,y;
				cin >> x >> y;
				town t;
				t.ken = x;
				t.y = y;
				t.num = i;
				a.push_back(t);
		}
		sort(a.begin(),a.end(),cmp);
		int ken = a[0].ken;
		int id = 1;
		for(auto& A : a){
				if(A.ken == ken) {
						A.id = id;
						id++;
				}else{
						ken = A.ken;
						id = 1;
						A.id = id;
						id++;
				}
		}
		sort(a.begin(),a.end(),cmp_id);
		for(auto& A : a){
				int z = 6 - to_string(A.ken).length();
				for(int i=0;i<z;i++){
						cout << 0;
				}
				cout << A.ken;
				z = 6 - to_string(A.id).length();
				for(int i=0;i<z;i++){
						cout << 0;
				}
				cout << A.id << endl;
		}
}



Measured memory_bytes: 6512
//
// Created by Tzyark on 2018/9/19.
//
#include <iostream>
#include <cstring>
using namespace std;
int c[101][101];
int main() {
    int W, H, N, x, y, a;
    cin >> W >> H >> N;
    memset(c, 0, sizeof(c));
    for (int n = 0; n < N; n++) {
        cin >> x >> y >> a;
        if (a == 1) {
            for (int i = 0; i < x; i++) {
                for (int j = 0; j < H; j++) {
                    c[i][j] = 1;
                }
            }
        } else if (a == 2) {
            for (int i = x; i < W; i++) {
                for (int j = 0; j < H; j++) {
                    c[i][j] = 1;
                }
            }
        } else if (a == 3) {
            for (int i = 0; i < W; i++) {
                for (int j = 0; j < y; j++) {
                    c[i][j] = 1;
                }
            }
        } else if (a == 4) {
            for (int i = 0; i < W; i++) {
                for (int j = y; j < H; j++) {
                    c[i][j] = 1;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < W; i++) {
        for (int j = 0; j < H; j++) {
            if (!c[i][j]) ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
	string str;
	getline(cin, str);
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == 'a' && str.substr(i + 1, 4) == "pple")str.replace(i, 5, "peach");
		else if (str[i] == 'p'&&str.substr(i + 1, 4) == "each")str.replace(i, 5, "apple");
	}
	cout << str << endl;
}


Measured memory_bytes: 3008
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust"<<endl;
    }else{
        cout<<"win"<<endl;
    }


    
return 0;
}


Measured memory_bytes: 256
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<string>
#include <stdlib.h>
using namespace std;

#define         rep(i,n)       for ( i=0 ; i<n ; ++i )
#define         rep1(i,n)      for ( i=1 ; i<=n ; ++i )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rev(str)       reverse(str.begin(),str.end())
#define         usajo(str)     sort(str.rbegin(),str.rend())
#define         pi             2*acos(0.0)
#define         nel            printf("\n")
#define         longmx         92233720368547758
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         vcl            vector<ll>
#define         pb             push_back
#define         prl            pair< ll , ll >
#define         mkp(x,y)       make_pair(x,y)
#define         ff             first
#define         sc             second
#define         spc            ' '
#define         nn             '\n'
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef         long long int  lli;
typedef         long long      ll;

int main(){//Faysal

    lli ans,sum,tot,cnt,mx,mn,idx,chk,rem,ret,tmp,mid,lft,rgt,pos;

    ll tc,n,m,a,b,c,d,g,h,l,r,x,y,i,j,k;

    string s;
    cin>>s;
    string t=s;
    rev(t);
    if(t != s)
    {
        no;
        return 0;
    }
    n=s.size();
    l=(n-1)/2;
    string ss,tt;
    ss=s.substr(0,l);
    tt=ss;
    rev(tt);
    bool f=false;
    if(ss==tt) f=true;
    x=(n+3)/2-1;
    ss=s.substr(x,l);
    tt=ss;
    rev(tt);
    if(f && ss==tt) f=true;
    else f=false;
    if(f) yes;
    else
        no;
    return 0;
}


Measured memory_bytes: 256
n,m,q=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(q)]
ans=0
for i1 in range(1,m+1):
  for i2 in range(i1,m+1):
    for i3 in range(i2,m+1):
      for i4 in range(i3,m+1):
        for i5 in range(i4,m+1):
          for i6 in range(i5,m+1):
            for i7 in range(i6,m+1):
              for i8 in range(i7,m+1):
                for i9 in range(i8,m+1):
                  for i10 in range(i9,m+1):
                    tmp=0
                    arrs=[0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                    for a,b,c,d in arr:
                      if arrs[b]-arrs[a]==c:
                        tmp+=d
                    ans=max(ans,tmp)
print(ans)


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

char s[3000][3000];
int main(){
	int h,w;cin>>h>>w;
	int a,b;cin>>a>>b;
	rep(i,h)rep(j,w)s[i][j]='0';
	rep(i,b)rep(j,a)s[i][j]='1';
	rep(i,h-b)rep(j,w-a){
		s[i+b][j+a]='1';
	}
	rep(i,h)printf("%s\n",s[i]);
}

Measured memory_bytes: 5248
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(a: int, b: int, c: int):
    if c - a - b < 0:
        print(NO)
        exit()
    print(YES if 4 * a * b < (c - a - b) ** 2 else NO)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    solve(a, b, c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


def solve(N: int):
    print(N**3)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n = int(input())

num_li = []
for i in range(3):
    tmp = n % 10
    n = n // 10
    if tmp == 1:
        num_li.append(9)
    else:
        num_li.append(1)

multi = 1
n = 0
for i in range(len(num_li)):
    n = n + num_li[i] * multi
    multi *= 10

print(n)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <functional>
#define rep(i, a, b) for(int i=a;i<b;++i)
#define MOD 1000000007
#define RAND 1000
using namespace std;

int main(void)
{
	int n, m, a[100] = { 0 }, b, c;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> b >> c;
		++a[b];
		++a[c];
	}
	for (int i = 1; i <= n; ++i) {
		cout << a[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
  int n;

  while(true) {
    cin >> n;
    if(n == 0)
      break;

    int sum = 0;
    int min_val = 10000;
    int max_val = -1;
    for (int i = 0; i < n; i++) {
      int s;
      cin >> s;
      min_val = (min_val > s) ? s : min_val;
      max_val = (max_val < s) ? s : max_val;
      sum += s;
    }
    sum -= min_val + max_val;
    cout << (sum / (n - 2)) << endl;
  }
  return 0;
}

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

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

typedef long long int lli;

#define MOD ((lli)1000000007LL)
lli mop(lli p,lli q){
	lli res=1;
	while(q){
		if(q&1)res=(res*p); //%MOD;
		q/=2;
		p=(p*p); //%MOD;
	}
	return res;
}

char s[300005];
lli roh[300005];
void init(){
	int ls = strlen(s);
	roh[0]=0;
	rep(i,ls){
		roh[i+1]=(roh[i]*10007+s[i]); //%MOD;
		//printf("%lld %lld\n",roh[i],roh[i]*12345);
	}
}

lli getha(int p,int q){
	//printf("%d %d %lld %lld\n",p,q,roh[q],roh[p]*mop(12345,q-p));
	//return (roh[q]+MOD-(roh[p]*mop(10007,q-p)%MOD))%MOD;
	return (roh[q]-(roh[p]*mop(10007,q-p)));
}

int main(){
	int n,m;
	scanf("%d%d%s",&n,&m,s);
	init();
	vector<lli> has;
	int a=0,b=1;
	rep(i,m){
		char cs[10];
		scanf("%s",cs);
		int d=1;
		if(cs[1]=='-')d=-1;
		if(cs[0]=='L')a+=d;
		else b+=d;
		lli ha = getha(a,b);
		//printf("%d %d %lld\n",a,b,ha);
		has.push_back(ha);
	}
	sort(has.begin(),has.end());
	has.erase(unique(has.begin(),has.end()),has.end());
	printf("%lu\n",has.size());
}


Measured memory_bytes: 9712