akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = (1ll << 60);

int main(void)
{
    int n, k;
    cin >> n >> k;

    vector<ll> l(k), r(k), dp(n , 0), s(n +1, 0);

    for (int i = 0; i < k; i++)
    {
        cin >> l[i] >> r[i];
    }

    dp[0] = 1;
    s[1] = 1;

    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < k; j++)
        {
            ll x, y;

            if (i - l[j] < 0)
            {
                continue;
            }

            x = max(i - l[j], 0ll) + 1; //big
            y = max(i - r[j], 0ll);     //small

            dp[i] += s[x] - s[y] + MOD;
            dp[i] %= MOD;
        }

        s[i + 1] = s[i] + dp[i] + MOD;
        s[i + 1] %= MOD;
    }

    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 6376
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll h,w;
string s[10];
bool d[10][10];
ll dfs(ll x,ll y){
  d[x][y] = true;
  ll res=0;
  ll dx[]={1,0,-1,0},dy[]={0,1,0,-1},nx,ny;
  for(int i=0;i<4;i++){
    nx = dx[i]+x;
    ny = dy[i]+y;
    if(nx>=0 && ny>=0 && nx<h && ny<w && s[nx][ny]=='#'&&!d[nx][ny]){
      res+=dfs(nx,ny);
    }
  }
  return res+1;
}
signed main(){
  ll v;
  cin >> h >> w;
  fill(d[0],d[10],false);
  for(int i=0;i<h;i++){
    cin >> s[i];
  }
  v = dfs(0,0);
  if(v==h+w-1){
    cout <<"Possible\n";
  }else{
    cout <<"Impossible\n";
  }
}


Measured memory_bytes: 256
N,K=map(int,input().split())
B=[[0]*(2*K) for i in range(2*K)]
W=[[0]*(2*K) for i in range(2*K)]
sumb=[[0]*(2*K+1) for i in range(2*K+1)]
sumw=[[0]*(2*K+1) for i in range(2*K+1)]
for i in range(N):
    x,y,c=map(str,input().split())
    x=int(x)
    y=int(y)
    if c=="B":
        B[y%(2*K)][x%(2*K)]=+1
        sumb[y%(2*K)+1][x%(2*K)+1]+=1
    else:
        W[y%(2*K)][x%(2*K)]=+1
        sumw[y%(2*K)+1][x%(2*K)+1]+=1
for i in range(2*K):
    for j in range(2*K):
        sumb[i+1][j+1]=sumb[i][j+1]+sumb[i+1][j]-sumb[i][j]+sumb[i+1][j+1]
        sumw[i+1][j+1]=sumw[i][j+1]+sumw[i+1][j]-sumw[i][j]+sumw[i+1][j+1]

ans=0
for i in range(K):
    for j in range(K):
        for _ in range(2):
            s=0
            s+=sumb[i][j]-sumb[i][0]-sumb[0][j]+sumb[0][0]#
            s+=sumb[i+K][j+K]-sumb[i][j+K]-sumb[i+K][j]+sumb[i][j]
            s+=sumb[i][2*K]-sumb[0][2*K]-sumb[i][j+K]+sumb[0][j+K]#
            s+=sumb[2*K][j]-sumb[i+K][j]-sumb[2*K][0]+sumb[i+K][0]#
            s+=sumb[2*K][2*K]-sumb[i+K][2*K]-sumb[2*K][j+K]+sumb[i+K][j+K]#

            s+=sumw[i][j+K]-sumw[0][j+K]-sumw[i][j]+sumw[0][j]#
            s+=sumw[i+K][j]-sumw[i][j]-sumw[i+K][0]+sumw[i][0]#
            s+=sumw[2*K][j+K]-sumw[i+K][j+K]-sumw[2*K][j]+sumw[i+K][j]#
            s+=sumw[i+K][2*K]-sumw[i+K][j+K]-sumw[i][2*K]+sumw[i][j+K]#

            ans=max(ans,s)
            sumb,sumw=sumw,sumb

print(ans)


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

using namespace std;

int itoamy(int i,char *num)
{
    int xx=i;
    int yy=0;
    char *ccp=num;
    char ck[11]={0};
    while(xx > 0)
    {
        ck[yy++] = xx % 2 + '0';
        xx /= 2;
    }
    for(int j=yy-1;j>=0;j--)
    {
        *ccp++=ck[j];
    }
     *ccp='\0';
}
int main()
{
    char ch[11];
    char num[11]={0};
    scanf("%s",ch);
    int l = strlen(ch);
    int sum=1;
    long long  cnt=0;
    for(int i=0;i<l-1;i++)
        sum*=2;
    for(int i=0;i<sum;i++)
    {
        itoamy(i,num);
        int j;
        int ll =strlen(num);
        for(j=ll;j<l-1;j++)
            num[j-ll] = '0';
        if(ll!=l-1)
        {
            itoamy(i,num+j-ll);
        }
        long long ccnntt=0;
        for(j=0;j<l;j++)
        {
            ccnntt = ccnntt*10+(ch[j]-'0');
            int numm=0;
            if((num[j]-'0')==1)
            {
                cnt+=ccnntt;
                ccnntt = 0;
            }
        }
        cnt+=ccnntt;
    }
    printf("%lld\n",cnt);
}

Measured memory_bytes: 256
def main():
    n = input()
    result = ""
    for i in range(3):
        if n[i] == "1":
            result += "9"
        elif n[i] == "9":
            result += "1"
        else:
            result += n[i]
    print(result)


if __name__ == '__main__':
    main()

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

int main(){
	int series[12][12],num[12],k;
	string numm;
	while(cin>>numm){
		int series[12][12]={};
		for(int i=0;i<10;i++){
		num[i]=numm[i]-'0';
			series[0][i]=num[i];
	}
		//for(int i=0;i<10;i++)cout<<series[0][i];
		for(int i=1;i<10;i++){
			for(int j=i;j<10;j++){
				series[i][j]=(series[i-1][j-1]+series[i-1][j])%10;
			}
		}
		cout<<series[9][9]<<endl;
}
}

Measured memory_bytes: 1180
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>

using namespace std;

int main(){
    string s;
    cin>>s;
    int c=0;
    for (int i=0; i<s.size()/2; i++) {
        if (s.at(i)!=s.at(s.size()-1-i)) c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

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

int main(){
    int n,x,cnt=0;
    cin >> n;
    rep(i,n){
        cin>>x;
        if(IsPrime(x))cnt++;
    }
    out(cnt);
}



Measured memory_bytes: 3104
#include<set>
#include<cmath>
#include<cstdio>
#include<algorithm>

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

using namespace std;

const double INF=1e77;
const double PI=acos(-1);

template<class T>
struct point{ T x,y; };

template<class T>
double abs(const point<T> &a){ return sqrt(a.x*a.x+a.y*a.y); }

template<class T>
double arg(const point<T> &a,const point<T> &b){
	double ta=atan2(a.y,a.x);
	double tb=atan2(b.y,b.x);
	return tb-ta<0 ? tb-ta+2*PI : tb-ta;
}

point<double> rot(const point<double> &a,double theta){
	return (point<double>){a.x*cos(theta)-a.y*sin(theta),a.x*sin(theta)+a.y*cos(theta)};
}

struct robot{
	point<double> p; // 位置
	int dir; // 移動方向 (+1 or -1)
	bool operator<(const robot &Z)const{ return p.x<Z.p.x; }
};

// 速さ v で動くロボット A, B が衝突するときの時刻
double f(const robot &A,const robot &B,double r,double v){
	double w=abs(A.p.x-B.p.x);
	double h=sqrt(4*r*r-w*w);
	return (abs(A.p.y-B.p.y)-h)/(2*v);
}

int main(){
	for(int n;scanf("%d",&n),n;){
		point<double> v;
		double r; scanf("%lf%lf%lf",&v.x,&v.y,&r);
		double v_abs=abs(v);

		static robot Z[100000];
		rep(i,n) scanf("%lf%lf%d",&Z[i].p.x,&Z[i].p.y,&Z[i].dir);

		// y 軸の +/- 方向に移動するように座標を取り替える
		double theta=-arg((point<double>){0,1},v);
		v=rot(v,theta);
		rep(i,n) Z[i].p=rot(Z[i].p,theta);

		sort(Z,Z+n);

		double ans=INF;
		// S_u : 上方向に動くロボットの集合
		// S_d : 下方向に動くロボットの集合
		// double をそのまま比較しているけど、誤差が出るような演算はしていないので大丈夫
		set< pair<double,int> > S_u,S_d;
		for(int i=0,j=0;i<n;i++){
			// x 方向に離れすぎてロボット i とぶつかれなくなったロボットを削除
			while(j<i && Z[i].p.x-Z[j].p.x>2*r){
				if(Z[j].dir==1) S_u.erase(make_pair(Z[j].p.y,j));
				else            S_d.erase(make_pair(Z[j].p.y,j));
				j++;
			}

			set< pair<double,int> >::iterator it;
			// ロボット i は上方向に動く
			if(Z[i].dir==1){
				if(!S_d.empty()){
					it=S_d.lower_bound(make_pair(Z[i].p.y,-1));
					if(it!=S_d.end()){
						int k=it->second;
						ans=min(ans,f(Z[i],Z[k],r,v_abs));
					}
				}
			}
			// ロボット i は下方向に動く
			else{
				if(!S_u.empty()){
					it=S_u.lower_bound(make_pair(Z[i].p.y,-1));
					if(it!=S_u.begin()){
						--it;
						int k=it->second;
						ans=min(ans,f(Z[i],Z[k],r,v_abs));
					}
				}
			}

			if(Z[i].dir==1) S_u.insert(make_pair(Z[i].p.y,i));
			else            S_d.insert(make_pair(Z[i].p.y,i));
		}

		if(ans>INF/2) puts("SAFE");
		else          printf("%.9f\n",ans);
	}

	return 0;
}

Measured memory_bytes: 2848
use std::io::*;
use std::str::FromStr;
use std::num::*;
use std::vec::*;

fn main() {
    let mut a: i32 = read();
    let mut b: i32 = read();
    let mut c: i32 = read();
    let mut d: i32 = read();
    let mut e: i32 = read();
    let mut x:Vec<i32> = [a,b,c,d,e].to_vec();
    let mut y:Vec<i32> = [a,b,c,d,e].to_vec();
    let mut x2:Vec<i32> = x.into_iter().map(|x| x%10).filter(|&x| x!=0).collect::<Vec<i32>>();
    x2.sort();
    if x2.len()==0 {
        x2.push(0);
    }
    let mut ans: i32 = 0;
    let mut flag: i32 = 0;
    for i in 0..5 {
        if flag==0 && y[i as usize]%10==x2[0] {
            ans+=y[i as usize];
            flag=1;

        }else{
            ans+=((y[i as usize]+9) / 10)*10;
        }
    }
    println!("{}", ans);
}
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

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

typedef struct node{
  int key;
  struct node* next;
  struct node* prev;
}Node;

Node *nil;

void init(){
  nil = (Node*)malloc(sizeof(Node));
  nil -> next = nil;
  nil -> prev = nil;
}

void printList(){
  Node *cur = nil -> next;
  int isf = 0;
  while(1){
    if(cur == nil) break;
    if(isf++ > 0) printf(" ");
    printf("%d",cur -> key);
    cur = cur -> next;
  }
  printf("\n");
}

Node* listSearch(int key){
  Node *cur = nil -> next;
  while(cur != nil && cur -> key != key) cur = cur -> next;
  return cur;
}

void insert(int key){
  Node *x = (Node*)malloc(sizeof(Node));
  x -> key = key;
  x -> next = nil -> next;
  nil -> next -> prev = x;
  nil -> next = x;
  x -> prev = nil;
}

void deleteNode(Node *t){
  if(t == nil) return ;
  t -> prev -> next = t -> next;
  t -> next -> prev = t -> prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil -> next);
}

void deleteLast(){
  deleteNode(nil -> prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

int main(){
  int key,n,i,size=0,np=0,nd=0;
  char com[20];

  scanf("%d",&n);
  init();
  for(i = 0;i < n;i++){
    scanf("%s%d",com,&key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F') deleteFirst();
	else if(com[6] == 'L') deleteLast();
      }
      else{
	deleteKey(key);
	nd++;
      }
      size--;
    }
  }
  printList();

  return 0;
}

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

int main(){
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(M);
  for(int i=0; i<M; i++){
    cin >> A.at(i);
  }
  int L=0, R=0;
  for(int i=0; i<M; i++){
    if(A.at(i)<X){
      L++;
    }
    else{
      R++;
    }
  }
  cout << min(L, R) << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
s = gets.chomp
t = gets.chomp

ncommon = 0
n.downto(1) do |i|
  if s[(n - i)..(n - 1)] == t[0..(i - 1)] then
    ncommon = i
    break
  end
end
puts (n - ncommon) * 2 + ncommon

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

using namespace std;

struct node{
	double x,y;
}p[10];
double dis(node a,node b){
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int a[10];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i].x>>p[i].y;
		a[i]=i;
	}
	double ans=0;
	int num=0;
	do{
		num++;
		for(int i=2;i<=n;i++){
			ans+=dis(p[a[i]],p[a[i-1]]);
		}
	}while(next_permutation(a+1,a+n+1));
	printf("%.12lf\n",ans/num);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int W, H, x, y, r;
    std::cin >> W >> H >> x >> y >> r;
    if(r <= x && x <= W-r && r <= y && y <= H-r)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;

    return 0;
}


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

int n, m;
vector<pair<int, int>> v[10000];

int main()
{
	cin >> n >> m;
	
	int s, t, e;
	while (cin >> s >> t >> e, s){
		s--; t--;
		v[s].push_back(make_pair(t, e));
	}

	int l;
	cin >> l;
	for (int i = 0; i < l; i++){
		static int b[10000];
		for (int j = 0; j < m; j++){
			cin >> b[j];
		}
		
		for (int j = 0; j < n; j++){
			long long sum = 0;
			for (auto &p : v[j]){
				sum += b[p.first] * p.second;
			}
			cout << sum << "\n "[j < n - 1];
		}
	}
}

Measured memory_bytes: 2248
import sys
from collections import Counter
N = int(sys.stdin.readline().rstrip())
D = list(map(int, sys.stdin.readline().rstrip().split()))
mod = 998244353

if D[0] != 0 or 0 in D[1:]:
    print(0)
    exit()

d_cnt = sorted(Counter(D).items())

ans = 1
par = 1
prev = 0
for k, v in d_cnt:
    if k > 0:
        if prev + 1 == k:
            ans *= pow(par, v, mod)
            ans %= mod
            par = v
            prev = k
        else:
            print(0)
            exit()
print(ans)

Measured memory_bytes: 21460
#include <iostream>

using namespace std;

int
gcd2(int a, int b)
{
    if(a < b) return gcd2(b, a);

    int r;

    while((r=a%b)){
        a = b;
        b = r;
    }
    return b;
}


int
my_gcd(int i, int j, int k)
{
    return gcd2(gcd2(i,j),k);
}

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

    int ans = 0;
    for(int i=1;i<=x;i++){
        for(int j=1;j<=x;j++){
            for(int k=1;k<=x;k++){
                 ans += my_gcd(i,j,k);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

const int MAX = 510000;
 const int MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int 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;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
 
  long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll k,n;
    std::cin >> k>>n;
    
    ll mi = 0;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        
        std::cin >> a[i];
        if(i>0){
            mi = max(mi,a[i]-a[i-1]);
        }
        if(i==n-1){
            mi = max(mi,k-a[i]+a[0]);
        }
    }
    
    std::cout << k-mi << std::endl;
    
}



Measured memory_bytes: 1920
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

vector<int>G[1010];
int N,M;
int ans;
int s;
void BFS(int x) {
	vector<bool>used(N+1);
	used[x] = true;
	queue<int>que;
	int cnt = 1;
	que.push(x);
	vector<int>nex;
	//cout << "v:" << x << endl;
	while (!que.empty()) {
		int now = que.front(); que.pop();
		//pe(now);
		used[now] = true;
		for (auto v : G[now]) {
			if (v == x) {
				//pe(v); print(cnt);
				if (ans > cnt) {
					s = v;
					ans = cnt;
				}
				return;
			}
			if (used[v])continue;
			nex.pb(v);
			used[v] = true;
		}
		
		if (que.empty()) {
			REP(i, nex.size()) {
				que.push(nex[i]);
			}
			nex.clear();
			cnt++;
		}
	}
}
//bool done = false;
//bool used[1010];
//void DFS(int n,vector<int>vec) {
//	if (done)return;
//	used[n] = true;
//	for (auto nex : G[n]) {
//		if (nex == n) {
//			REP(i, vec.size()) {
//				print(vec[i]);
//			}
//			done = true;
//			return;
//		}
//		if (used[nex])continue;
//		vector<int>tmp = vec;
//		tmp.pb(nex);
//		DFS(nex, tmp);
//	}
//}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ans = 1e9;
	cin >> N >> M;
	REP(i, M) {
		int u, v; cin >> u >> v;
		//u--, v--;
		G[u].pb(v);
	}
	FOR(i,1, N+1) {
		BFS(i);
	}
	if (ans == 1e9) {
		print(-1);
	}
	else {
		print(ans);
		vector<int>pre(N + 1);
		queue<int>que;
		que.push(s);
		vector<int>used(N + 1);
		while (!que.empty()) {
			int now = que.front(); que.pop();
			used[now] = true;
			for (auto nex : G[now]) {
				if (pre[nex] == 0) {
					pre[nex] = now;
				}
				if (nex == s) {
					int pos = now;
					print(pos);
					while (true) {
						pos = pre[pos];
						print(pos);
						if (pos == s)return 0;
					}
				}
				if (used[nex])continue;
				que.push(nex);
			}
		}
	}
}


Measured memory_bytes: 384
#!/usr/bin/env python3


def main():
    H, W = [int(x) for x in input().split()]
    a = [input() for _ in range(H)]
    a = [ai for ai in a if "#" in ai]
    ar = zip(*[bi for bi in zip(*a) if "#" in bi])
    for ai in ar:
        print("".join(ai))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <ctime>
#include <random>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <list>

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map <ll, int> cnt;
    ll sum = 0;
    ++cnt[0];
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        sum += x;
        ++cnt[sum];
    }
    ll ans = 0;
    for (auto p : cnt) {
        ans += (ll)p.second * (p.second - 1) / 2;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;

    int ans=1;
    for(int i=1; i*i<=m; i++) {
      if(m%i==0) {
        if(m/i>=n) chmax(ans, i);
        if(i>=n) chmax(ans,m/i);
      } 
    }
    cout << ans << endl;
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

// const int maxn = 1e6 + 11;
const ll inf = 1e18;

int n;
ll w;
int maxn;

int main() {

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

    cin >> n >> w;
    maxn = n * 1000 + 10;

    vector<ll> dp(maxn, inf);
    dp[0] = 0LL;
    
    for (int i = 0; i < n; i++) {
        ll wei; 
        int val;
        cin >> wei >> val;
        for (int v = maxn-1; v >= 0; v--) {
            if (dp[v] == inf) continue;
            if (val+v < maxn) {
                dp[val+v] = min(dp[val+v], dp[v]+wei);
            }
        }
    }

    int ans = 0;
    for (int v = 0; v < maxn; v++) {
        if (dp[v] <= w) ans = max(ans,v);
    }
    
    out(ans);
    
    return 0;
}


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

int main(void){
  long a, b;
  char op[10];

  scanf("%ld", &a);
  scanf("%s", op);
  scanf("%ld", &b);

  if(strcmp(op, "+") == 0){
    printf("%ld\n", a+b);
  }else{
    printf("%ld\n", a-b);
  }

  return 0;
}


Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int k,n;
  cin>>k>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  int mx=0;
  repi(i,1,n){
    mx=max(mx,a[i]-a[i-1]);
  }
  mx=max(mx,k-a[n-1]+a[0]);
  cout<<k-mx<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int a[1001],n,i,j,tmp,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;++i){
		for(j=i+1;j<n;++j){
			if(a[i]>a[j]){
				tmp=a[i];
				a[i]=a[j];
				a[j]=tmp;
			}
		}
	}
	for(i=0;i<n-1;i++){
		sum+=a[i+1]-a[i];
	}
	printf("%d\n",sum);
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

int N,C;

int calc(vector<vint>st){
    bool flag[10][10]={};
    rep(i,N)rep(j,i+1)if(st[i][j]==0)flag[i][j]=1;
    rep(t,100)rep(i,N)rep(j,i+1){
        rep(d,6){
            int ny=i+dy[d],nx=j+dx[d];
            if(ny<0||ny>=N||nx<0||nx>ny)continue;
            if(st[ny][nx]==0||st[ny][nx]==st[i][j])flag[i][j]|=flag[ny][nx];
        }
    }

    int ret=0;
    rep(i,N)rep(j,i+1)if(!flag[i][j]){
        if(st[i][j]==C)ret--;
        else ret++;
    }
    return ret;
}

void solve(){
    vector<vint>st(N);
    rep(i,N){
        rep(j,i+1){
            int a;cin>>a;st[i].pb(a);
        }
    }

    int ans=INT_MIN;
    rep(i,N)rep(j,i+1)if(st[i][j]==0){
        st[i][j]=C;
        chmax(ans,calc(st));
        st[i][j]=0;
    }
    cout<<ans<<endl;
}

signed main(){
    while(cin>>N>>C,N||C)solve();
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;
int main(){
    int a[5],k;
    for(int i=0;i<5;i++)
    cin>>a[i];
    cin>>k;
    sort(a,a+5);
    if(a[4]-a[0]<=k)
    cout<<"Yay!"<<endl;
    else
    cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 256
#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;

// -------------------------------------------------------

int N;
int A[200];

int main()
{
    cin >> N;
    rep(i, 0, N)
    {
        cin >> A[i];
    }
    rep(i, 0, N)
    {
        if (A[i] % 2 == 0)
        {
            if (A[i] % 3 == 0 || A[i] % 5 == 0)
            {
                continue;
            }
            else
            {
                cout << "DENIED";
                return 0;
            }
        }
    }

    cout << "APPROVED";
}


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

using namespace std;
const long long maxn = 1e5 + 100;
char s[maxn];
int rock[maxn];

int main() {
    cin >> s;
    int p = 0, r = 0;
    int ans=0;
    int roc = 0, paper = 0;
    for (int i = 0; s[i] != '\0'; i++) {
        if (s[i] == 'g') {
            if (!roc) {
                roc++;
            } else {
                roc--;
                ans++;
            }
        } else {
            if(!roc) {
                roc++;
                ans--;
            }
            else{
                roc--;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;


void main() {
    auto s = readln.split.map!(to!long);
    auto H = s[0];
    auto W = s[1];

    if (H % 3 == 0 || W % 3 == 0) {
        writeln(0);
        return;
    }

    long ans = min(H, W);

    foreach (i; 1..W) {
        long area1 = H * i;
        long area2 = H / 2 * (W - i);
        long area3 = (H / 2 + H % 2) * (W - i);
        long tmp = max(max(abs(area1 - area2), abs(area2 - area3)), abs(area3 - area1));
        ans = min(ans, tmp);
    }
    foreach (i; 1..H) {
        long area1 = W * i;
        long area2 = W / 2 * (H - i);
        long area3 = (W / 2 + W % 2) * (H - i);
        long tmp = max(max(abs(area1 - area2), abs(area2 - area3)), abs(area3 - area1));
        ans = min(ans, tmp);
    }

    ans.writeln;
}


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

using namespace std;

int main(void)
{
  int t,ta,tb,d,da,db;
  scanf("%d%d%d%d%d%d",&t,&d,&ta,&tb,&da,&db);
  double res = LLONG_MAX;
  for( int i = 0; i <= 1000; i++ ) {
    for( int j = 0; j <= 1000; j++ ) {
      int v = da*i+db*j;
      if( 1 <= v && v <= d ) {
        double vt = double(ta*da*i+tb*db*j)/v;
        res = min(res,fabs(t-vt));
      }
    }
  }
  printf("%.10f\n",res);
  return 0;
}

Measured memory_bytes: 1068
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX=100005;
long long int a[MAX],prefix[MAX];
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i){
		prefix[i]=prefix[i-1]+a[i];
	}
	int init=n;
	for(int i=n-1;i>0;--i){
		if(prefix[i]*2>=a[i+1]) init=i;
		else break;
	}
	cout<<n-init+1<<endl;
	return 0;
}

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

using ll = long long;
#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 INF 1e9
// const ll INF = 1LL << 60;

int V, E;
vector<vector<int>> g;
int dp[1<<20][20];

void solve(){
  REP(bit, 1<<V){
    REP(i, V){
      if(bit != 0 && (bit>>i & 1)==0) continue;
      REP(j, V){
        if(bit >> j & 1) continue;
        dp[bit|1 << j][j] = min(dp[bit|1<<j][j], dp[bit][i] + g[i][j]);
      }
    }
  }
}

int rec(int bit, int v){
  if(dp[bit][v] != -1){
    return dp[bit][v];
  }
  if(bit == 1){
    return dp[bit][v] = g[v][0];
  }
  int ans = INF;
  FOR(nv, 1, V){
    if(!(bit & 1<<nv)) continue;
    int nbit = bit & ~(1<<nv);
    ans = min(ans, rec(nbit, nv)+g[v][nv]);
  }
  return dp[bit][v] = ans;
}
int main(){
  cin >> V >> E;
  g.resize(V, vector<int>(V, INF));
  REP(i, E){
    int s, t, d;
    cin >> s >> t >> d;
    g[s][t] = d;
  }
  REP(i, 1<<20){
    REP(j, 20){
      dp[i][j] = -1;
    }
  }
  rec((1<<V)-1, 0);
  if(dp[(1<<V)-1][0] >= INF){
    cout << -1 << endl;
  }
  else{
    cout << dp[(1<< V)-1][0] << endl;
  }
  return 0;
}




Measured memory_bytes: 85092
/*********************************
                                                        *****          All is Well          *********
                                                        ******       Mehedi Hasan       ******
                                                        *******    Dept of ICE,IU           ****
                                                        *****************************/
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,i,j,arr[100005],c=0,ans,ans1,co;
cin>>n;

for(i=0;i<=7;i++){
    ans=pow(2,i);
    if(ans>n){
        co=i-1;
        break;
    }
}
ans1=pow(2,co);
cout<<ans1<<endl;
  return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
int main(){

    int N, D; cin>>N>>D;
    int X[N], Y[N];
    int cnt=0;

    for(int i=0; i<N; i++){
        cin>>X[i]>>Y[i];
    }

    for(int i=0; i<N; i++){
        if( sqrt(pow(X[i], 2) + pow(Y[i], 2) ) <=D ) cnt++;
    }
    cout<<cnt<<endl;
}


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

int main(){
    int n;cin >>n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(),l.end());
    int cnt = 0;
    for(int i = 0;i<=n-3;i++){
        for(int j = i+1;j<=n-2;j++){
            for(int k=j+1;k<=n-1;k++){
                if(l[i]==l[j]||l[j]==l[k])continue;
                if(l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[k]+l[i]>l[j]) cnt++;
            }
        }
    }

    cout<< cnt<< endl;
}

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

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;

const ll M = LLONG_MAX;

int main() {
	int n, W;
	cin >> n >> W;
	
	vi v(n), w(n);
	ll sum = 0;
	
	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i], sum += v[i];
	
	vll dp(sum + 1, M);
	dp[0] = 0;
	
	for (int i = 0; i < n; i++)
		for (int j = sum; j >= v[i]; j--)
			if (dp[j - v[i]] != M)
				dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
	
	int ans;
	for (int i = sum; i >= 0; i--)
		if (dp[i] <= W) {
			ans = i;
			break;
		}
	
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  int n[3],m[2],ans = -1;
  for(int i=0; i<3; i++) cin >>n[i];
  for(int i=0; i<2; i++) cin >>m[i];
  for(int i=0; i<3; i++)
    for(int j=0; j<2; j++)
      if(ans == -1 || ans>n[i]+m[j]-50) ans = n[i]+m[j]-50;
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1160
input = gets
A = input.split(" ")[0].to_i
B = input.split(" ")[1].to_i

if A > 100 || A < 0
  exit
end

if B > 1000 || B < 2
  exit
end

if B % 2 != 0
  exit
end

if A >= 13
  print "#{B}"
elsif A >= 6 && A <= 12
  print "#{B/2}"
else
  print "0"
end

Measured memory_bytes: 1788
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#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 <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"YES\n":"NO\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a, b, c;
  bool f = true;
  cin >> a >> b >> c;
  if(a[a.size()-1] != b[0]) f = false;
  if(b[b.size()-1] != c[0]) f = false;
  YesorNo(f);
  return 0;
}
//templete by private_yusuke

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

int main() {
  ll N; cin >> N;
  using p = pair<ll, ll>;
  vector<p> a[2];

  for (ll i = 0; i < N; i++) {
    string s; cin >> s;
    ll mn = 0;
    ll cur = 0;

    for (char c : s) {
      cur += (c == '(' ? 1 : -1);
      mn = min(mn, cur);
    }

    if (cur >= 0) {
      a[0].push_back(make_pair(-mn, cur - mn));
    } else {
      a[1].push_back(make_pair(-mn, cur - mn));
    }
  }

  sort(a[0].begin(), a[0].end(), [](auto &x, auto &y) {
    return x.first < y.first;
  });
  sort(a[1].begin(), a[1].end(), [](auto &x, auto &y) {
    return x.second > y.second;
  });

  ll cur = 0;
  for (ll i = 0; i < 2; i++) {
    for (auto &pr : a[i]) {
      ll m = pr.first, c = pr.second;
//      cout << m << "," << c << endl;

      if (cur - m < 0) {
        cout << "No" << endl;
        return 0;
      }
      cur += c - m;
    }
  }

  if (cur == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 19096
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
const int mod=1e9+7;

int main(){
	int n;
	cin >> n;
	vector<int> x(n);
	for(int i=0; i<n; i++)
		cin >> x[i];
	vector<int> sortx = x;
	sort(sortx.begin(), sortx.end());
	for(int i=0; i<n; i++){
		if(x[i]>=sortx[n/2])
			cout << sortx[n/2-1] << endl;
		else
			cout << sortx[n/2] << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int n,y;
	cin>>n>>y;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			if((10000*i)+(5000*j)+(1000*(n-i-j))==y&&n-i-j>=0){
				cout<<i<<" "<<j<<" "<<n-i-j<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
 * atcoder/abc112_3rd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

ll N, M;
void solve() {
  cin >> N >> M;
  vector<ll> D;
  for (int i=1; i*i<=M; i++) {
    if (M % i == 0) {
      D.push_back(i);
      if (i*i!=M) {
        D.push_back(M/i);
      }
    }
  }

  ll max_ = 0;
  for (auto&& d: D) {
    if (d * N > M) continue;
    chmax(max_, d);
  }
  cout << max_ << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <limits>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
#define ll long long
#define rep(i_, start, end) for(ll i_=(ll)start; i_<(ll)end; i_++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");

int main(){
  ll n, w, weight[101], value[101];
  cin >> n >> w;
  ll dp[101][100001] = {};
  
  rep(i, 0, n) cin >> weight[i] >> value[i];
  
  rep(i, 0, n){
    rep(sum_w, 0, w+1){
      if (sum_w - weight[i] >= 0){
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
      }
      dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
    }
  }
  print(dp[n][w]);
  
  return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
        int n;
        long long k;
        std::cin >> n >> k;

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

        std::vector<int> point(n+1,-1);
        std::vector<int> log;
        int v = 1;

        while(point[v] == -1)
        {
                point[v] = log.size();
                log.push_back(v);
                v = a[v-1];
        }
        int T = log.size() - point[v];
        int l = point[v];

        if(k < l)
                std::cout << log[k] << std::endl;
        else
        {
                k -= l;
                k %= T;
                std::cout << log[l+k] << std::endl;
        }
}

Measured memory_bytes: 5788
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
    
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i <= S.length() -3; i++){
            int sum = 0;
            for(int j = 0; j < 3; j++){
                int x = S.charAt( i+j ) - '0';
                x *= Math.pow(10, 2-j);
                sum += x;
            }
            
            ans = Math.min( ans, Math.abs(753 - sum) );
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	Info(int arg_x,int arg_y){
		x = arg_x;
		y = arg_y;
	}
	bool operator<(const struct Info &arg) const{
		if(x != arg.x){
			return x < arg.x;
		}else{
			return y < arg.y;
		}
	}
	int x,y;
};

int N;
vector<Info> V;

int main(){

	scanf("%d",&N);

	int tmp_x,tmp_y;

	for(int loop = 0; loop < N; loop++){
		scanf("%d %d",&tmp_x,&tmp_y);
		V.push_back(Info(tmp_x,tmp_y));
	}
	sort(V.begin(),V.end());

	for(int i = 0; i < N; i++){
		printf("%d %d\n",V[i].x,V[i].y);
	}

	return 0;
}




Measured memory_bytes: 3868
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, M; cin >> N >> M;
  vector<ll> s(M), c(M);
  for (ll i = 0; i < M; i++) {
    cin >> s.at(i) >> c.at(i);
  }
  ll p, q;
  if (N == 1) {
    p = 0; q = 10;
  }else if (N == 2) {
    p = 10; q = 100;
  }else if (N == 3) {
    p = 100; q = 1000;
  }else assert(0);
  for (ll x = p; x < q; x++) {
    vector v(10, -1);
    ll y = x;
    for (ll i = 0; i < N; i++) {
      v.at(N - i) = y % 10;
      y /= 10;
    }
    bool succ = true;
    for (ll i = 0; i < M; i++) {
      if (v.at(s.at(i)) != c.at(i)) {
	succ = false;
	break;
      }
    }
    if (succ) {
      cout << x << endl;
      return 0;
    }
  }
  cout << "-1\n";

  return 0;
}



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

using namespace std;
typedef long long ll;

const int N=100005;

int n,m,Q;
int a[N],na,b[N],nb;
int w[N],pnext[N],pnow[N];

int chk1(int p){
	int l=0,r=Q*2,mid=l+(r-l+1)/2;
	int x=pnow[p],y=pnext[p];
	if((b[y%nb]-a[x%na]+m)%m>=Q*2)
		return (a[x%na]+Q)%m;
	while(l<r){
		int cx=x-(mid+1)/2,cy=y+mid/2;
		ll dis=0;
		dis+=(ll)m*(cy/nb+(-cx)/na);
		cx%=na,cy%=nb;
		if(cx<0)cx+=na,dis+=m;
		dis+=b[cy]-a[cx];
		if(dis>=Q*2)
			r=mid-1;
		else
			l=mid;
		mid=l+(r-l+1)/2;
	}
	if(mid&1)return (a[((x-(mid+1)/2)%na+na)%na]+Q)%m;
	return ((b[(y+mid/2)%nb]-Q)%m+m)%m;
}

int chk2(int p){
	int l=0,r=Q*2,mid=l+(r-l+1)/2;
	int x=pnext[p]-1,y=pnow[p];
	if((b[y%nb]-a[(x%na+na)%na]+m)%m>=Q*2)
		return ((b[y%nb]-Q)%m+m)%m;
	while(l<r){
		int cx=x-mid/2,cy=y+(mid+1)/2;
		ll dis=0;
		dis+=(ll)m*(cy/nb+(-cx)/na);
		cx%=na,cy%=nb;
		if(cx<0)cx+=na,dis+=m;
		dis+=b[cy]-a[cx];
		if(dis>=Q*2)
			r=mid-1;
		else
			l=mid;
		mid=l+(r-l+1)/2;
	}
	if(mid&1)return ((b[(y+(mid+1)/2)%nb]-Q)%m+m)%m;
	return (a[((x-mid/2)%na+na)%na]+Q)%m;
}

int main(){
	scanf("%d%d%d",&n,&m,&Q);
	for(int i=1,x;i<=n;i++){
		scanf("%d%d",&x,&w[i]);
		if(w[i]==1)
			a[pnow[i]=na++]=x,pnext[i]=nb;
		else
			b[pnow[i]=nb++]=x,pnext[i]=na;
	}
	if(!na||!nb){
		for(int i=1;i<=n;i++)
			if(w[i]==1)
				printf("%d\n",(a[pnow[i]]+Q)%m);
			else
				printf("%d\n",((b[pnow[i]]-Q)%m+m)%m);
	}else{
		for(int i=1;i<=n;i++)
			if(w[i]==1)
				printf("%d\n",chk1(i));
			else
				printf("%d\n",chk2(i));
	}
	return 0;
}

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

int main() {

  int a, b, c;
  cin >> a >> b >> c;
  
  string str = "NO";
  if(a+b+c==17 && a*b*c==175)
    str = "YES";

  cout << str << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int sz=1e5+9;
long long a[sz];
long long n,k;
int cnt[64];
long long x,ans;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%lld %lld",&n,&k);
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    for(int i=0;i<n;i++){
        for(int j=0;j<62;j++) cnt[j]+=((a[i]>>j)&1);
    }
    for(int i=62;i>=0;i--){
        long long have=cnt[i];
        long long rem=n-cnt[i];
        if(rem>have&&(x|(1ll<<i))<=k){
            x|=(1ll<<i);
            ans+=rem*(1ll<<i);
        }else ans+=have*(1ll<<i);
    }
    /*long long tmp;
    for(int i=0;i<=k;i++){
        tmp=0;
        for(int j=0;j<n;j++) tmp+=(i^a[j]);
        cout<<i<< " "<<tmp<<'\n';
    }*/
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,k;
    cin >> n >> k;
    ll l, r, ary[n];
    cin >> l >> r;
    rep(i,n) cin >> ary[i];

    int m = n/2;
    vector<ll> zenhan[m+1];
    vector<ll> kohan[n-m+1];
    rep(bit, (1<<m))
    {
        ll tmpn=0;
        int cnt = 0;
        rep(i,m)
        {
            if((bit>>i) & 1)
            {
                // cout << "here" << endl;
                tmpn += ary[i];
                cnt++;
                // cout << tmpn << " " << cnt << endl;
            }
        }
        zenhan[cnt].push_back(tmpn);
    }
    // for (auto itr=zenhan[1].begin();itr!=zenhan[1].end();++itr)
    // {
    //     cout << *itr << endl;
    // }

    rep(bit, (1<<(n-m)))
    {
        ll tmpn = 0;
        int cnt = 0;
        rep(i,n-m)
        {
            if ((bit>>i)&1)
            {
                cnt++;
                tmpn += ary[m+i];
            }
        }
        kohan[cnt].push_back(tmpn);
    }


    ll ans = 0;
    rep(i,m+1)
    {
        if (0<=k-i && k-i<=n-m)
        {
            sort(zenhan[i].begin(), zenhan[i].end());
            sort(kohan[k-i].begin(), kohan[k-i].end());
            for(vector<ll>::iterator itr=zenhan[i].begin(); itr!=zenhan[i].end();itr++)
            {
                ll d = upper_bound(kohan[k-i].begin(), kohan[k-i].end(), r-(*itr)) - lower_bound(kohan[k-i].begin(), kohan[k-i].end(), l-(*itr));
                ans += d;
            }
            // cout << i << " " << *itr << " " << d << endl;
            // cout <<  upper_bound(kohan[k-i].begin(), kohan[k-i].end(), r-(*itr)) - kohan[k-i].begin() << endl;
            // cout <<  lower_bound(kohan[k-i].begin(), kohan[k-i].end(), l-(*itr)) - kohan[k-i].begin() << endl;
        }
    }
    cout  << ans << endl;
}





Measured memory_bytes: 23432
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

l = []

for h in range(H):
    for w in range(W):
        l.append((A[h][w], w, h))

l.sort()

S = [0] * (H * W + D + 10)

for i, x, y in l:
    if i + D <= H * W:
        _, xx, yy = l[i + D - 1]
        S[i + D] = abs(xx - x) + abs(yy - y) + S[i]

Q = int(input())

for i in range(Q):
    L, R = map(int, input().split())
    print(S[R] - S[L])


Measured memory_bytes: 23392
n = int(input())
mx = 10**18
a = list(map(int, input().split()))
for x in a:
    if x == 0:
        print(0)
        exit(0)
ans = 1
for x in a:
    ans *= x
    if ans > mx:
        print(-1)
        exit(0)
print(ans)

Measured memory_bytes: 21780
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
template<class T> inline bool chkmax(T& a,T b){return a<b?a=b,1:0;}
template<class T> inline bool chkmin(T& a,T b){return a>b?a=b,1:0;}
template<typename T> inline T& read(T& x){
    static char c; bool flag=0;
    while(!isdigit(c=getchar())) if(c=='-') flag=1;
    for(x=c-'0';isdigit(c=getchar());(x*=10)+=c-'0');
    if(flag) x=-x;
    return x;
}
const int maxn=100010;
int n,m,cnt[2];
vector<int> G[maxn];
int col[maxn];
bool dfs(int u){
    for(auto v:G[u])
        if(!~col[v]){
            ++cnt[col[v]=col[u]^1];
            if(!dfs(v)) return 0;
        }
        else if(col[v]==col[u]) return 0;
    return 1;
}
int main(){
#ifdef xffyjq
    freopen("exec.in","r",stdin);
    freopen("exec.out","w",stdout);
#endif
    read(n); read(m);
    memset(col,-1,sizeof col);
    for(int i=1;i<=m;i++){
        int u,v;
        read(u); read(v);
        G[u].pb(v); G[v].pb(u);
    }
    ++cnt[col[1]=0];
    if(dfs(1)) printf("%lld\n",1ll*cnt[0]*cnt[1]-m);
    else printf("%lld\n",1ll*n*(n-1)/2-m);
    return 0;
}


Measured memory_bytes: 6400