akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string
#include <vector> // vector
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <cstdint> // int64_t, int_fast64_t

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

typedef std::int_fast64_t ll; // at least int64 > 9*10^18
typedef std::uint_fast64_t ull; // at least uint64

struct City
{
  int y,i,n;
  City() {}
  City(int y, int i) : y(y),i(i),n(1) {}
  bool operator< (const City& c) const {
    return y<c.y;
  }
};

struct Prefecture
{
  std::vector<City> cities;
  void sort() {
    std::sort(cities.begin(),cities.end());
    int i = 1;
    for(auto &c:cities) {
      c.n = i;
      i++;
    }
  }
  Prefecture() {}
};

int main() {
  int n,m;
  std::cin >> n >> m;
  std::vector<Prefecture> prefectures(n);
  rep(i,m) {
    int p,y;
    std::cin >> p >> y;
    p--;
    prefectures[p].cities.emplace_back(y,i);
  }
  rep(i,n) prefectures[i].sort();
  std::vector<std::string> id(m);
  rep(i,n) for(auto c:prefectures[i].cities) {
    id[c.i] = std::to_string(1e12+1e6*(i+1)+c.n).substr(1,12);
  }
  rep(i,m) std::cout << id[i] << ENDL;
  return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    int num = N;
    
    int diag, sum=0;
    while(N){
        diag = N % 10;
        sum = sum + diag;
        N = N / 10;
    }
    if(num%sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

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

using namespace std;

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

int main(){
	for(int W,H,n;scanf("%d%d%d",&W,&H,&n),W;){
		bool wallH[101][101]={},wallV[101][101]={};
		rep(x,W)	wallH[0][x]=wallH[H][x]=true;
		rep(y,H)	wallV[y][0]=wallV[y][W]=true;
		rep(i,n){
			int xa,ya,xb,yb;	scanf("%d%d%d%d",&xa,&ya,&xb,&yb);
			if(xb<xa)	swap(xa,xb);
			if(yb<ya)	swap(ya,yb);
			if(ya==yb)	for(int x=xa;x<xb;x++)	wallH[ya][x]=true;
			else		for(int y=ya;y<yb;y++)	wallV[y][xa]=true;
		}
		int xs,ys,dir;
		{
			int xa,ya,xb,yb;	scanf("%d%d%d%d",&xa,&ya,&xb,&yb);
			xs=min(xa,xb);
			ys=min(ya,yb);
			if(ya==yb){
				xs=min(xa,xb);
				if(ya==0)	ys=0,dir=1;
				else		ys=H-1,dir=3;
			}
			else{
				ys=min(ya,yb);
				if(xa==0)	xs=0,dir=0;
				else		xs=W-1,dir=2;
			}
		}
		int xg,yg;	scanf("%d%d",&xg,&yg);

		bool ok=false;
		int x=xs,y=ys,cnt=1;
		bool visited[100][100][4]={};
		while(1){
			if(x==xg && y==yg){ ok=true; break; }
			if(visited[y][x][dir])	break;
			visited[y][x][dir]=true;

			dir=(dir+1)%4;
			rep(i,4){
				int xx=x+dx[dir],yy=y+dy[dir];
				if((dir==0 && !wallV[y][xx]) || (dir==1 && !wallH[yy][x])
				|| (dir==2 && !wallV[y][ x]) || (dir==3 && !wallH[ y][x])){
					x=xx,y=yy;
					break;
				}
				dir=(dir+3)%4;
			}
			cnt++;
		}

		if(ok)	printf("%d\n",cnt);
		else	puts("Impossible");
	}

	return 0;
}

Measured memory_bytes: 836
//Copyright(c)2017 Mstdream
#include<bits/stdc++.h>
using namespace std;

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
set<int>s;
int now=1,fir;
int main(){
	int n;splay(n);
	for(int i=1;i<=n;i++){
		int x;splay(x);
		if(fir){
			puts("No");
			continue;
		}
		else if(x==now-1&&s.size()==now-1){
			fir=1;
			puts("Yes");
			continue;
		}
		else if(x<now)puts("No");
		else{
			while(s.find(x)!=s.end()){
				s.erase(x);
				x--;
			}
			s.insert(x);
			while(s.find(now)!=s.end())now++;
			puts("Yes");
		}
	}
}

Measured memory_bytes: 14804
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, x;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> x;
  int sum = 0, ans = 1;
  REP(i, n) {
    int a;
    cin >> a;
    sum += a;
    if(sum <= x) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)
def ggcd(a,b):
    if(b==0):
        return a
    return ggcd(b,a%b)
import math
import fractions
import collections
import itertools
import pprint
N=int(input())
l1=[]
adivb=[]
bis0=0
bdiva=[]
ais0=0
both0=0
p=10**9+7
fish=[list(map(int,input().split())) for _ in range(N)]
fishcomp=[]
d={}
for i in range(N):
    a=fish[i][0]
    b=fish[i][1]
    g=ggcd(a,b)
    if g!=0:
        a=a//g
        b=b//g
    if b<0:
        a=-a
        b=-b
    if (a!=0)or(b!=0):
        if d.get(a)==None:
            d[a]={}
            d[a][b]=1
        else:
            if d[a].get(b)==None:
                d[a][b]=1
            else:
                val=d[a].get(b)
                d[a][b]=val+1
        fishcomp.append([a, b])
    else:
        both0=both0+1
#print(d)
#print(fishcomp)
fishcomp=list(map(list,set(map(tuple,fishcomp))))
#print(fishcomp)
length=N-both0
sets=[]
for i in fishcomp:
    a=i[0]
    b=i[1]
    val1=d[a][b]
    #print(a,b,val1)
    if d.get(-b)!=None:
        if d[-b].get(a)!=None:
            val2=d[-b][a]
            sets.append([val1,val2])
            length=length-(val2+val1)
#print(sets,length)
pro=1
for i in sets:
    pro=(pro*(pow(2,i[0],p)+pow(2,i[1],p)-1))%p
#print(pro)
print((pow(2,length,p)*pro-1+both0)%p)


Measured memory_bytes: 236244
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

ll N, M;
vector<int> edge[200000];
ll dp[200000];
ll dp2[200000];
map<ll, map<ll,ll>> dp3;

void dfs(int cur, int par) {
  ll x = 1;
  for (auto c : edge[cur]) {
    if (c == par) continue;
    dfs(c, cur);
    x *= dp[c] + 1;
    x %= M;
  }
  dp[cur] = x;
}

void dfs2(int cur, int par) {
  ll x = 1;
  if (par != -1) {
    x *= (dp3[par][cur] + 1);
    x %= M;
  }
  for (auto c : edge[cur]) {
    if (c == par) continue;
    dfs2(c, cur);
    x *= dp[c] + 1;
    x %= M;
  }
  dp2[cur] = x;
}

ll prefix[200000];
ll suffix[200000];

void dfs3(int par, int ppar) {
  ll N = edge[par].size();
  if (N > 0) {
    prefix[0] = 1;
    if (edge[par][0] != ppar) prefix[0] = dp[edge[par][0]] + 1;
    for (int i=1; i<N; i++) {
      ll cur = edge[par][i];
      prefix[i] = prefix[i-1];
      if (cur != ppar) prefix[i] *= dp[cur] + 1;
      prefix[i] %= M;
    }

    suffix[N-1] = 1;
    if (edge[par][N-1] != ppar) suffix[N-1] = dp[edge[par][N-1]] + 1;
    for (int i=N-2; i>=0; i--) {
      ll cur = edge[par][i];
      suffix[i] = suffix[i+1];
      if (cur != ppar) suffix[i] *= dp[cur] + 1;
      suffix[i] %= M;
    }
  }
  // for (int i=0; i<N; i++) {
  //   printf("par=%ld i=%ld prefix=%ld suffix=%ld dp[edge[par][i]]=%ld\n", par, i, prefix[i], suffix[i], dp[edge[par][i]]);
  // }
  for (int i=0; i<edge[par].size(); i++) {
    ll cur = edge[par][i];
    if (cur == ppar) continue;
    ll x = 1;
    if (ppar != -1) {
      x *= (dp3[ppar][par] + 1) % M;
    }
    if (i-1 >= 0) { x *= prefix[i-1]; x %= M;}
    if (i+1 < N)  { x *= suffix[i+1]; x %= M;}
    dp3[par][cur] = x;
   //  printf("N=%d i=%d par=%ld cur=%ld dp3[par][cur]=%ld\n", N, i, par, cur, dp3[par][cur]);
  //  dfs3(cur, par);
  }
  for (auto cur: edge[par]) {
    if (cur == ppar) continue;
    dfs3(cur, par);
  }
}

int main() {
  cin >> N >> M;
  for (int i=0; i<N-1; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  dfs(0, -1);
  dfs3(0, -1);
  dfs2(0, -1);
  for (int i=0; i<N; i++) {
    cout << dp2[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 40064
import sys

n = input()
n= int(n)
ls = input().split()
lsnum = list(map(int,ls))
ma = max(lsnum)

minvalue = 10000000000
ans = -1
for num in lsnum:
    if num == ma:
        continue
    value = abs(ma-num*2)
    if minvalue >= value:
        minvalue = value
        ans = [ma, num]
print (ans[0], ans[1])


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

public class Main {

    public void solve() {
        int n = in.nextInt(), a = in.nextInt(), b = in.nextInt();
        char[] c = in.nextToken().toCharArray();

        int curA = 0, curB = 0;
        int passed = 0;
        for (int i = 0; i < n; i++) {
            if (c[i] == 'c') {
                out.println("No");
                continue;
            }
            if (c[i] == 'a') {
                if (passed < a + b) {
                    passed++;
                    out.println("Yes");
                } else {
                    out.println("No");
                }
            } else {
                curB++;
                if (passed < a + b && curB <= b) {
                    passed++;
                    out.println("Yes");
                } else {
                    out.println("No");
                }
            }
        }
    }

    public void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    FastScanner in;
    PrintWriter out;

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

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


Measured memory_bytes: 12336
//file_name:ABC57_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n,m;
    scanf("%d%d",&n,&m);


    ll ans = (n+m)%24;;

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#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, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int a, b, c;
  cin >> a >> b >> c;
  cout << a*b/2 << endl;

  return 0;
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_time = [0]
time = 0
for i in range(N):
    time += A[i]
    A_time.append(time)
B_time = [0]
time = 0
for i in range(M):
    time += B[i]
    B_time.append(time)

def binarySearch(key):
    left = -1
    right = len(B_time)
    
    while right - left > 1:
        mid = left + (right - left)//2
        if B_time[mid] > key:
            right = mid
        else:
            left = mid
    return left

Max = 0
for i in range(len(A_time)):
    j = binarySearch(K - A_time[i])
    Max = max(Max, i+j)
    if j < 0:
        break

print(Max)
    

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

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

    bool flag = true;
    for(int i=0; i<s.length(); i+=2){
        if(s[i] == 'L' || s[i+1] == 'R'){
            flag  = false;
        }
    }
    if(flag == true) cout << "Yes" << endl;
    if(flag == false) cout << "No" << endl;
    return 0;
}

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

map<Int, int> prime_factor(Int n) {
    map<Int, int> res;
    for(Int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}


int main(){
    Int N;

    cin >> N;

    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    else {

        map<Int, int> p = prime_factor(N);

        Int ans = 0;

        for (auto ite = p.begin(); ite!=p.end(); ++ite) {
            int now = ite->second;
            for (int j = 1; j * (j+1) <= 2 * now; j++) {
                ans++;
            }
        }

        cout << ans << endl;
    }

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<long long> c[26];
int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    s=s+s;
    for(int i=0;i<s.size();i++){
        c[s[i]-'a'].push_back(i);
    }
    for(int i=0;i<t.size();i++){
        if(c[t[i]-'a'].empty()){
            cout<<-1<<endl;
            return 0;
        }
    }
    long long sum=c[t[0]-'a'][0]+1;
    long long now=c[t[0]-'a'][0];
    for(int i=1;i<t.size();i++){
        long long hoge=*upper_bound(c[t[i]-'a'].begin(),c[t[i]-'a'].end(),now);
        sum+=hoge-now;
        (now=hoge)%=n;
    }
    cout<<sum<<endl;
	return 0;
}

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

public class Main {

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

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

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ori = new int[n];
        int[] after = new int[n];

        for(int i=0; i<n; i++){
            ori[i] = sc.nextInt();
        }

        int m = sc.nextInt();

        for(int i=0; i<m; i++){
            int sum = 0;
            int p = sc.nextInt()-1;
            int x = sc.nextInt();

            for(int j=0; j<n; j++){
                if(p==j){
                    sum+=x;
                } else {
                    sum+=ori[j];
                }
            }

            System.out.println(sum);
        }
    }

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

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

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

class Ten{
    private int x;
    private int y;

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

    public int getX() {
        return x;
    }

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

    public int getY() {
        return y;
    }

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

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
const int maxn=2e5+7;
const ll modn=1e9+7;
const int inf=2e9+7;
const ll INF=1000000000000000000ll;
const double PI = acos(-1.0);
const double eps=1e-8;
inline int lowbit(int x){return x&-x;}
inline ll lowbit(ll x) {return x&-x;}
inline int CountOneBinary(ll num){int ans=0;while(num){if(num&1) ans+=1;num>>=1;}return ans;}
inline void read(int &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline void read(ll &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline ll qpow(ll x,ll y){ll ans=1;while(y){if(y&1) ans=ans*x%modn;x=x*x%modn;y>>=1;}return ans;}
inline double qpow(double x,ll y){double ans=1;while(y){if(y&1) ans=ans*x;x=x*x;y>>=1;}return ans;}
int h,w,vh[111],vw[111];
char s[111][111];
int main()
{
    while(scanf("%d%d",&h,&w)==2)
    {
        memset(vh,0,sizeof(vh));
        memset(vw,0,sizeof(vw));
        for(int i=1;i<=h;i++) scanf("%s",s[i]+1);
        for(int i=1;i<=h;i++)
        {
            for(int j=1;j<=w;j++)
            {
                if(s[i][j]=='#') vh[i]++,vw[j]++;
            }
        }
        for(int i=1;i<=h;i++)
        {
            if(!vh[i]) continue;
            for(int j=1;j<=w;j++)
            {
                if(vw[j]) putchar(s[i][j]);
            }
            putchar('\n');
        }
    }
}


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

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

    int n, k, x, y;
    cin >> n >> k >> x >> y;
    long long total;
    if (n > k) {
        total = (k * x) + ((n - k) * y);
    } else if (n <= k) {
        total = (n * x);
    }
    cout << total;
}

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




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

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

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	ll n;
	cin >> n;
	vector<string> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	ll ans = 1;
	rep(i, n-1) {
		if (a[i] != a[i + 1])ans++;
	}
	cout << ans;
	return 0;
}










Measured memory_bytes: 9604
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(void) {
    long long int N, ans=0;
    cin >> N;

    long long int tmp,tmp2;
    tmp = N/500;
    tmp2 = (N-tmp*500)/5;
    ans = tmp*1000 + tmp2*5;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>

int main(){
    int n;
    std::string s;
    std::cin >> n >> s;

    int count = 0;
    for(int i = 0; i < 10; ++i){
        auto pos1 = s.find(std::to_string(i));
        if(std::string::npos != pos1){
            auto init1 = pos1 + 1, m = n - init1;
            auto sub1 = s.substr(init1, m);
            for(int j = 0; j < 10; ++j){
                auto pos2 = sub1.find(std::to_string(j));
                if(std::string::npos != pos2){
                    auto init2 = pos2 + 1, l = n - init2;
                    auto sub2 = sub1.substr(init2, l);
                    for(int k = 0; k < 10; ++k){
                        if(std::string::npos != sub2.find(std::to_string(k))){
                            ++count;
                        }
                    }
                }
            } 
        }
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 384
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

// code
// ------------------------------------------------
int main() {

  int k,s;
  cin >> k >> s;

  int n = 0;
  for(int x = 0;x <= k;x++)
  {
    for(int y = 0;y <= k;y++)
    {
      int z = s - x - y;
      if ((0 <= z) && (z <= k))
      {
        n++;
      }
    }
  }

  cout << n;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    int n, m; cin >> n >> m;

    if(m % n == 0){
        cout << m / n << endl;
        return 0;
    }

    int i = 1;
    int ans = -1;
    while(true){
        if(m % i == 0){
            if(i * n <= m) ans = i;
        } 
        if(i * n > m) break;
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;


void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



int main() {
	int a, b;
	cin >> a >> b;
	if(0<a && a<10 && 0<b&&b<10)
		cout << a * b << endl;
	else
		cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def f(x):
    if dp[x]!=-1:
        return dp[x]
    ans=0
    for e in d[x]:
        ans=max(ans,1+f(e))
    dp[x]=ans
    return ans

n,m = list(map(int, input().split()))
d={}
dp=[-1]
for i in range(1,n+1):
    d[i]=[]
    dp.append(-1)
for _ in range(m):
    a,b = list(map(int, input().split()))
    d[a].append(b)
ans=0
for i in range(1,n+1):
    ans=max(ans,f(i))
print(ans)

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

int main(){
  int A,B,T,i=1,time=0;
  cin >> A >> B >> T;
  while(1){
    time = i*A;
    if(time > T){
      cout << B*(i-1) << endl;
      break;
    }
    i++;
  }
  return 0;
}
    


Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<string.h>
typedef long long int llint;
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b < c) swap(b, c);
	if (a < b)swap(a, b);
	if (b < c)swap(b, c);
	cout << b*c / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
			
		int sum = 0;

		if(n <= k){
			sum = n * x;
		}

		else{
			sum = k * x;
			sum = sum + ((n - k) * y);
		}

		System.out.println(sum);
	}
}


Measured memory_bytes: 21588
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<list>
#include<iomanip>
#include<vector>
using ll = long long;
using namespace std;
const ll MM = 1000000000;
const ll mod = MM + 7;

int main(){
    ll a[4];
    for(int i = 0; i < 3; i++){
        cin >> a[i];
    }
    ll ans = -1;
    sort(a, a + 3);
    if(a[0]%2 == 0 || a[1]%2==0 || a[2]%2==0){
        ans = 0;
    } else {
        ans = a[0]*a[1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    vector<vector<int>> a(3,vector<int>(3));
    rep(i,3)rep(j,3) {
        cin >> a[i][j];
    }
    int n; cin >> n;
    vector<int> b(n);
    rep(i,n) cin >> b[i];
    rep(i,n) {
        rep(j,3)rep(k,3) {
            if (b[i]==a[j][k]) {
                a[j][k] = 0;
                break;
            }
        }
    }
    bool check = false;
    rep(i,3) {
        if (a[i][0]+a[i][1]+a[i][2]==0) {
            check = true;
            break;
        }
        if (a[0][i]+a[1][i]+a[2][i]==0) {
            check = true;
            break;
        }
    }
    if (a[0][0]+a[1][1]+a[2][2]==0) check = true;
    if (a[0][2]+a[1][1]+a[2][0]==0) check = true;
    if (check) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
main(){
  int n,i,x=1,s=0,k=1,c=0,g=0; 

  while(1)
    {     
      scanf("%d",&n);
      if(n==0){break;}
      
      for(i=n;i>0;i--)
	{	 
	  k=i; 
	  while(1){ 
	    
	    if(k%5==0)
	      {
		k/=5;
		g++;
	      }
	    else if(k%2==0){
	      k/=2;
	      c++;
	    }  
	    else
	      {
		break;	
	      } 
	  } 
	}
      
      if(g<=c){
	printf("%d\n",g);
      }
      else {printf("%d\n",c);
      }
      
      c=0;
      s=0;
      x=1;
      g=0;
      k=1;
    }
  return 0;
}

Measured memory_bytes: 0
N, M = map(int, input().split())
a = [0 for _ in range(M)]
b = [0 for _ in range(M)]
for i in range(M):
    a[i], b[i] = map(int, input().split())
for j in range(1, N+1):
    print(a.count(j)+b.count(j))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#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 itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64
#define n_MAX int(1e5)

int main(){
    int n;
    cin >>n;
    int A[n_MAX+5];
    set<int> judge;
    REP(i,n){
        scanf("%d",&A[i+1]);
    }
    int ans=0;
    int tmp=1;
    judge.insert(1);
    while(1){
        ans+=1;
        tmp=A[tmp];
        if(tmp==2) break;
        if(judge.erase(tmp)==1){
            cout << -1 << endl;
            return 0;
        }

        judge.insert(tmp);
    }
    cout << ans << endl;


}


Measured memory_bytes: 5376
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n,k,s=0;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    if(k>=n)
    cout<<0;
    else
    {
        for(int i=0;i<n-k;i++)
        s=s+a[i];
        cout<<s;
    }}

Measured memory_bytes: 5220
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;

const ll mod=1e9+7;
const ll N=4e5+5;

/*


*/

void solve(){
    string s; cin>>s;
    ll sum=0;
    for(auto i:s){
    	sum+=(i-'0');
    }

    if(sum%9==0){
    	ce("Yes");
    	re;
    }

    ce("No");
}

int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
}

/*


*/

  

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <iomanip>
#define M 100000
#define MAX 1000000001
#define MIN -10000000000000000
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;


int main(){
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll pre[n+1] = {0},ans = 0;
    for(int i=n-1;i>=0;i--){
        pre[i] = (pre[i] + pre[i+1]+a[i])%mod;
    }
    for(int i=0;i<n;i++){
        ans = (ans + (a[i]*pre[i+1])%mod)%mod;
    }
    cout<<ans<<"\n";
    return 0;
        
}


Measured memory_bytes: 6664
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<min(a*n,b)<<endl;

}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll h,w,a,b; cin >> h >> w >> a >>b;

    rep(i,h){
        if(i<b){
            rep(j,w){
                if(j<a){
                    cout << 0;
                }else{
                    cout << 1;
                }
            }
        }else{
            rep(j,w){
                if(j<a){
                    cout << 1;
                }else{
                    cout << 0;
                }
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
int main()
{
    ll h, w;
    cin >> h >> w;
    if (h != 1 && w != 1)
        cout << ll((h + 1) / 2) * ll((w + 1) / 2) + ll(h / 2) * ll(w / 2) << endl;
    else
        cout << 1 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	string s1,s2="";
	cin >> s1;

	for (int i =s1.size()-1; i >=0; i--) {
		if (s1[i] == 'b') s2 += 'd';
		else if (s1[i] == 'd')s2 += 'b';
		else if (s1[i] == 'p')s2 += 'q';
		else if (s1[i] == 'q') s2 += 'p';
		else s2[i] += s1[i];
	}
	
	if (s1 == s2)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=1e5+50;
const LL INF=1e18;
int n,X,Y,Z; 
LL ans=-INF,sum,pre[N],suf[N];
struct atom {LL x,y;}a[N];
priority_queue <LL> q;
int main() {
	X=rd(), Y=rd(), Z=rd(), n=X+Y+Z;
	for(int i=1;i<=n;i++) {
		a[i].x=rd(), a[i].y=rd();
		int c=rd(); sum+=c;
		a[i].x-=c; a[i].y-=c;
		a[i].x-=a[i].y;
	}
	sort(a+1,a+n+1,[](atom c,atom d) {return c.x>d.x;});
	for(int i=1;i<=n;i++) {
		pre[i]=pre[i-1]+a[i].x+a[i].y;
		q.push(-(a[i].x+a[i].y));
		if(q.size()>X) pre[i]+=q.top(), q.pop();
	}
	while(!q.empty()) q.pop();
	for(int i=n;i>=1;i--) {
		suf[i]=suf[i+1]+a[i].y;
		q.push(-a[i].y);
		if(q.size()>Y) suf[i]+=q.top(), q.pop();
	}
	for(int i=X;i+Y<=n;++i) ans=max(ans,pre[i]+suf[i+1]);
	cout<<(ans+sum)<<'\n';
}

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

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    s == u ? cout << a - 1 << " " << b : cout << a << " " << b - 1;
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream> 
#include<queue>
#include<vector> 
#include<algorithm>
#include<utility>
#include<cmath>
#define inf 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
ll gcd(ll a,ll b){
	ll t;
	while(b!=0){
		t=a;
		a=b;
		b=t%b;
	}
	return a;
}
int main()
{
	ll a,b;
	while(scanf("%lld%lld",&a,&b)!=EOF){
		ll Gcd=gcd(a,b);
		ll Lcm=a*b/Gcd;
		printf("%lld %lld\n",Gcd,Lcm);
	} 
    return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <iomanip>

using namespace std;

int HMS(const int count,int &h,int &m,int &s){
    int buf=count;
    h=buf/3600;
    buf-=h*3600;
    m=buf/60;
    buf-=m*60;
    s=buf;
}
int main(){
  int h,m,s;
  while(cin>>h>>m>>s&&h!=-1&&m!=-1&&s!=-1){
    int count=h*3600+60*m+s;
    int rest_h,rest_m,rest_s;
    HMS(120*60-count,rest_h,rest_m,rest_s);
    cout<<setfill('0');
   cout<<setw(2)<<rest_h<<":"<<setw(2)<<rest_m<<":"<<setw(2)<<rest_s<<endl; 
   HMS(3*(120*60-count),rest_h,rest_m,rest_s);
   cout<<setw(2)<<rest_h<<":"<<setw(2)<<rest_m<<":"<<setw(2)<<rest_s<<endl;
 
  }
}

Measured memory_bytes: 1168
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        lr: [(u64, u64); n],
    }

    let mut ans = 0;
    for (l, r) in lr {
        ans += r - l + 1;
    }
    println!("{}", ans);
}


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

import sys
from math import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

K = INT()

ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        ij = gcd(i, j)
        for k in range(1, K+1):
            ans += gcd(ij, k)
print(ans)


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

int main(){
    long long N;
    cin >> N;
    vector<long long> a(N),b(N);
    for (int i=0; i<N; ++i) {
        cin >> a[i];
    }
    int j=0,k=0;
    for (int i=1; i<=N; ++i) {
        if (N%2==0) {
            if (i%2==1) {
                b[N/2+j]=a[i-1];
                k++;
            }
            else {
                b[N/2-k]=a[i-1];
                j++;
            }
        }
        else {
            if (i%2==1) {
                b[N/2-j]=a[i-1];
                k++;
            }
            else {
                b[N/2+k]=a[i-1];
                j++;
            }
        }
    }
    for (int i=0; i<N; ++i) cout << b[i] << " ";
    cout << endl;
    
} 

Measured memory_bytes: 5624