akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <fstream>

#include <cmath>
#include <string>

#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

const long long MOD = 1000000007;
long long dp[10005][105][2];

string s;
int d;

long long calc(int i, int m, int tight) {
	if (i < 0) {
		if (m == 0) return 1;
		else return 0;
	}
	if (dp[i][m][tight] != -1) return dp[i][m][tight];

	dp[i][m][tight] = 0;

	if (tight) {
		for (int j = 0; j < s[i]-48; j++) {
			dp[i][m][tight] += calc(i-1, (m+j)%d, 0);
		}
		dp[i][m][tight] += calc(i-1, (s[i]-48 + m+100*d)%d, tight);
	}
	else {
		for (int j = 0; j < 10; j++) {
			dp[i][m][tight] += calc(i-1, (m+j)%d, 0);
		}	
	}

	dp[i][m][tight] %= MOD;

	return dp[i][m][tight];
}

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

	for (int i = 0; i < 10005; i++) {
		for (int j = 0; j < 105; j++) {
			dp[i][j][0] = dp[i][j][1] = -1;
		}
	}

	cin >> s >> d;
	reverse(s.begin(), s.end());
	cout << (calc(s.size()-1, 0, 1) + MOD - 1) % MOD << endl;

	return 0;
}


Measured memory_bytes: 17408
#include<stdio.h>
int main(void)
{
    int n, Sn=0;

    scanf("%d", &n);
    int a = n;
    while(a>=1)
    {
          Sn = Sn + a % 10;

          a = a / 10;
    }

    if(n % Sn == 0)
       printf("Yes\n");
    else
       printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int i, n, p, d1, d2, max[2];
	
	while (scanf("%d", &n), n != 0){
		max[0] = 0;
		max[1] = 0;
		
		for (i = 0; i < n; i++){
			scanf("%d %d %d", &p, &d1, &d2);
			
			if (max[1] < d1 + d2){
				max[0] = p;
				max[1] = d1 + d2;
			}
		}
		
		printf("%d %d\n", max[0], max[1]);
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <vector>
#include <iostream>

using namespace std;

bool isprime(int val)
{
	if (val < 2) return false;
	if (val == 2) return true;
	if (val % 2 == 0) return false;
	for (int i = 3; i*i <= val; i+=2)
	{
		if (val % i == 0) return false;
	}
	return true;
}

int main()
{
	int vals = 0;

	cin >> vals;
	int count = 0;
	while (cin >> vals) count += isprime(vals);
	cout << count << endl;
	return 0;
}

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

#include <stdio.h>

#include <math.h>
/********
*	??????????????????????????¢
*
*	??¢?????´?????????
*	(1)????????? n ?¬???????????????????????????????????????§??°????????\???
*	(2)pp ??????????????? 1???2???3????????? ?????????????????????????????¢????±???????????????°??????.?¨???????????????????
*********/

int main(void)
{
	double n ;		//n?¬?????????????????????´??°???
	double p = 0;
	double sumx = 0, sumy= 0;
	double x[1000]={0}; //x???????´?
	double y[1000]={0}; //y???????´?
	double dxy = 0 ; //??????????´?
	double max = 0;	//?????§???
	
	cin >> n ;
	
	p = n;
	for (int i = 0 ;  i<n ;  i++){
		cin >> x[i] ;	
	}
	for (int i = 0 ;  i<n ;  i++){
		cin >> y[i] ;	
	}
	
//------------------------------------???????????????	

	for(p=1; p <= 3; p++){
		sumx = 0;
		sumy = 0;
		for (int i = 0 ;  i<n ;  i++){
			sumx += pow(fabs(x[i]-y[i]),p);
			sumy  = pow(sumx,1.0/p);

		}
		printf("%f\n", sumy);
	}	
	
//	????¬?????????¨???
	for(int i =0; i<n; i++){
		dxy=0;
			dxy = fabs(x[i]-y[i]);
		if( max < dxy){
			max = dxy;
		}else {
			//???????????????
		}
	}
	printf("%f\n", max);
	return 0;

}

Measured memory_bytes: 1308
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    s = input()
    word = ['eraser', 'erase', 'dreamer', 'dream']
    for x in word:
        s = s.replace(x, '')
    if s == '':
        print('YES')
    else:
        print('NO')
        
        
        
            
        
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9152
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define endl "\n"
#define tt ll tc;cin >> tc;while(tc--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
bool cm(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}
#define int long long

int par[100005],n,m;

int find(int a) {
    if(par[a] < 0) {
        return a;
    }
    else return par[a] = find((par[a]));
}

void xunion(int a, int b) {

    par[a] = min(par[a],par[b]);
    par[b] = a;
}
int32_t main() {
    int r;
    cin >> r;

    double x = 2 * r *  3.141592653589793238;
    cout << x << endl;
        return 0;
}




Measured memory_bytes: 3264
import java.io.*;

public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true){
                String line = reader.readLine();
                int sum = 0;
                if(line.charAt(0)=='0'){
                    break;
                }
                
                for(int i=0;i<line.length();i++){
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                }
                System.out.printf("%d\n",sum);
            }
        }catch(IOException e){
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 25316
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll ans;
  ans=(n-1)/(k-1);
  if((n-1)%(k-1)){
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;
typedef long long LL;
LL i,j,k,n,m;
LL mod=1000000007;
string s;

int main() {
  LL r,g,b;cin >>r>>g>>b>>n;
  int nr=n/r;
  int ng=n/g;
  int nb=n/b;
  int cnt = 0;
  for(i=0;i<nr+1;++i) {
    for(j=0;j<ng+1;++j) {
      int val = n -i*r - j*g;
      if (val < 0) continue;
      if(val%b==0) ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

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


ll n,m,k = 1;
bool flag = false;
string s;
int main() {
    INIT();

    cin >> n;
    vector<ll> a(n);
    REP(i,n) {
        cin >> a[i];
        if(a[i] == 0) {
            cout << 0;
            return 0;
        }
    }
    REP(i,n) {
        if(k * a[i] > 1000000000000000000 || (k > 1e9 && a[i] > 1e9)) {
            cout << -1;
            return 0;
        }
        k *= a[i];
    }
    cout << k;
}


Measured memory_bytes: 3964
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x1,y1,x2,y2,x3,y3,x4,y4;
    cin>>x1>>y1>>x2>>y2;
    int dx = x2 - x1;
    int dy = y2 - y1;
    x3 = x2 - dy;
    y3 = y2 + dx;
    x4 = x1 - dy;
    y4 = y1 + dx;
    printf("%d %d %d %d\n",x3,y3,x4,y4);
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int m,d,cnt=0,a,b;
	string s1,s2,s3;
	cin>>m>>d;
	for(int i=1;i<m+1;i++){
		for(int j=11;j<d+1;j++){
			s1=to_string(j);
			s2=s1.substr(0,1);
			s3=s1.substr(1,1);
			a=stoi(s2);
			b=stoi(s3);
			if(a*b==i && a>=2 && b>=2){
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}



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

int main(){
    int N, M;
    cin >> N >> M;
    if(N==1 && M==0){
        cout << 0 << endl;
        return 0;
    }

    int num[N];
    num[0] = 1;
    for(int i=1; i<N; i++){
        num[i] = 0;
    }

    int s[M], c[M];
    for(int i=0; i<M; i++){
        cin >> s[i] >> c[i];
        num[s[i]-1] = c[i];
    }

    if(N>1 && s[0]==1 && c[0]==0){
        cout << -1 << endl;
        return 0;
    }

    for(int i=0; i<M; i++){
        for(int j=0; j<M; j++){
            if(i != j && s[i]==s[j] && c[i] != c[j]){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    int ans=0;
    for(int i=0; i<N; i++){
        ans = ans*10 + num[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int v[3];
	for (int a = 0; a < 3; a++) {
		cin >> v[a];
	}
	sort(v, v + 3);
	cout << v[2] * 10 + v[1] + v[0] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int main()
{     int n;
      cin>>n;
	  while(n>=1){
	     if(n%10==9){
		 puts("Yes");
		 return 0;
	     }
	     n/=10;
	 }
	 puts("No");
	  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


s = list(map(int,input().split()))
r=s[0]
D=s[1]
x=s[2]

def x_next(x):
    return r*x-D

for i in range(10):
    x = x_next(x)
    print(x)


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <unordered_set>
using namespace std;

int main(void){
    int N, M;
    cin >> N >> M;
    int a[N];
    for(int i = 0; i < N; i++){
        a[i] = -1;
    }
    int s, c, ans;
    ans = 0;
    for(int i = 0; i < M; i++){
        cin >> s >> c;
        if(a[s-1] == -1 || a[s-1] == c){
            a[s-1] = c;
        }else{
            ans = -1;
            break;
        }
    }
    if(ans == 0){
        for(int i = 1; i < N; i++){
            ans += max(0, a[i])*pow(10, N-i-1);
        }
        if(a[0] == -1){
            if(N == 1){
                ans = 0;
            }else{
                ans += 1*pow(10, N-1);
            }
        }else if(a[0] == 0){
            if(N == 1){
                ans = 0;
            }else{
                ans = -1;
            }
        }else{
            ans += a[0]*pow(10, N-1);
        }
    }
    cout << ans << endl;
}

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

#define ll long long

ll n,mx,a,b[100005],sum[10005],sum2[100005];

int main(int argc, char *argv[])
{
	cin>>n;cin>>a;sum[0]=a;
	for(int i=1;i<n;i++){cin>>a;sum[i]+=a+sum[i-1];}
	for(int i=0;i<n;i++){cin>>b[i];}
	sum2[n-1]=b[n-1];
	for(int i=n-2;i>=0;i--){sum2[i]+=b[i]+sum2[i+1];}
	for(int i=0;i<n;i++)
	{
		mx=max(mx,sum[i]+sum2[i]);
	}
	cout<<mx<<"\n";
	
}

/*

7
3 3 4 5 4 5 3
5 3 4 4 2 3 2

1
2
3

4
1 1 1 1
1 1 1 1

5
3 2 2 4 1
1 2 2 2 1

*/

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define MAX_LEN 500000
#define BIG 2000000000

int L[MAX_LEN / 2 + 2], R[MAX_LEN / 2 + 2];

int cnt;

void merge_sort_helper(int *A, int n, int l, int m, int r)
{
	for (int i = l; i < m; ++i) L[i - l] = A[i];
	for (int i = m; i < r; ++i) R[i - m] = A[i];
	L[m - l] = R[r - m] = BIG;

	int idx1(0), idx2(0);
	for (int idx0 = l; idx0 < r; ++idx0)
	{
		A[idx0] = (L[idx1] <= R[idx2]) ? L[idx1++] : R[idx2++];
		cnt++;
	}
}

void merge_sort(int *A, int n, int l, int r)
{
	if (l < r - 1)
	{
		int m = l + (r - l) / 2;
		merge_sort(A, n, l, m);
		merge_sort(A, n, m, r);
		merge_sort_helper(A, n, l, m, r);
	}
}

int main()
{
	int A[MAX_LEN], n, i, val;
	cnt = 0;

	cin >> n;
	i = 0;
	while (cin >> A[i++]);

	merge_sort(A, n, 0, n);
	for (int i = 0; i < n; ++i)
	{
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << cnt << endl;
	return 0;
}

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

constexpr int64_t inf = 1e18;

int main() {
  int n;
  cin >> n;
  vector<int64_t> x(n), y(n), p(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> p[i];
  }
  vector dx(1 << n, vector(n, inf)), dy(1 << n, vector(n, inf));
  for (int i = 0; i < 1 << n; i++) {
    for (int j = 0; j < n; j++) {
      dx.at(i).at(j) = p.at(j) * abs(x.at(j));
      dy.at(i).at(j) = p.at(j) * abs(y.at(j));
    }
    for (int j = 0; j < n; j++) {
      if (i >> j & 1) {
        for (int k = 0; k < n; k++) {
          dx.at(i).at(k) = min(dx.at(i).at(k), p.at(k) * abs(x.at(j) - x.at(k)));
          dy.at(i).at(k) = min(dy.at(i).at(k), p.at(k) * abs(y.at(j) - y.at(k)));
        }
      }
    }
  }
  vector<int64_t> ans(n + 1, inf);
  vector<int> v(n + 1);
  while (v.at(n) == 0) {
    int k = 0, s1 = 0, s2 = 0;
    for (int i = 0; i < n; i++) {
      if (v.at(i) == 1) {
        s1 += 1 << i;
      } else if (v.at(i) == 2) {
        s2 += 1 << i;
      }
    }
    int64_t d_total = 0;
    for (int i = 0; i < n; i++) {
      if (v.at(i)) k++;
      d_total += min(dx.at(s1).at(i), dy.at(s2).at(i));
    }
    ans.at(k) = min(ans.at(k), d_total);
    v.at(0)++;
    int l = 0;
    while (v.at(l) == 3) {
      v.at(l) = 0;
      v.at(l + 1)++;
      l++;
    }
  }
  for (int i = 0; i <= n; i++) {
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 13048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = Long.parseLong(sc.nextLine());

		double sqrt = Math.sqrt(n);
		double nearNum = Math.floor(sqrt);

		long ans = (long) Math.pow(nearNum, 2);

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 23764
#include <stdio.h>

int main()
{    
    int a, b, c;
    int temp;

    scanf("%d %d %d", &a, &b, &c);
    
    if (a > b)
    {
       temp = b;
       b = a;
       a = temp;
    }
    if (a > c)
    {
        temp = c;
        c = a;
        a = temp;
    }
    if (b > c)
    {
        temp = c;
        c = b;
        b = temp;
    }

    printf("%d %d %d\n", a, b, c);

    return 0;
}

Measured memory_bytes: 596
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::min;

fn main() {
    let n = read::<usize>();
    let mut b = vec![1000000; n];
    let mut a = vec![0; n];

    for i in 0..n-1 {
        b[i] = read::<usize>();
    }

    let mut ans = b[0];
    for i in 1..n-1 {
        ans += min(b[i], b[i-1]);
    }
    println!("{}", ans + b[n-2])
}

Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
using namespace std ;


int n ;

void input ( ) {
    scanf ( "%d" , &n ) ;
}

void solve ( ) {
    printf ( "%d\n" , n * n * n ) ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

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

  vector<int> x(N), y(N), h(N);

  for(int i=0;i<N;++i){
    cin >> x[i] >> y[i] >> h[i];
  }

  for(int cy=0;cy<101;++cy){
    for(int cx=0;cx<101;++cx){
      int height = -1;
      for(int i=0;i<N;++i){
        if(h[i] > 0){
          int tmp = abs(cx - x[i]) + abs(cy-y[i]) + h[i];
          if(height == -1){
            if(tmp > 0) height = tmp;
          }else{
            if(tmp != height){
              height = -2;
              break;
            }
          }
        }
      }
      if(height == -2) continue;

      if(height > 0){
        for(int i=0;i<N;++i){
          if(h[i] == 0){
            int dist = abs(cx - x[i]) + abs(cy-y[i]);
            if(dist < height){
              height = -2;
              break;
            }
          }
        }
        if(height > 0){
          cout << cx << " " << cy << " " << height << endl;
          return 0;
        }
      }
    }
  }
}


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

typedef long long ll;
#define FOR(i, a, n) for (ll i=(ll)a;i<(ll)n;i++)
#define REP(i, n) FOR(i, 0, n)

int main(){
    int n; cin >> n;
    int cnt = 0;
    string s; cin >> s;

    REP(i, n){
        if (s.compare(i,1,"R")==0){
            cnt++;
        }
    }

    string ans;
    if (cnt>n/2){
        ans = "Yes";
    }
    else{
        ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b;
    if(a<=0&&b>=0)Cout("Zero");
    else if(a>0)Cout("Positive");
    else{
        tmp=abs(abs(a)-abs(b));
        if(tmp%2==0)Cout("Negative");
        else Cout("Positive");
    }
    return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll 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);

  int k, t;
  cin >> k >> t;

  int max_a = -1;
  rep(i, t){
    int a;
    cin >> a;
    chmax(max_a, a);
  }

  cout << max(max_a - (k-max_a)-1, 0) << endl;


  return 0;
}


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

typedef pair< int, int > Pi;
struct edge{
  int to, cost;
};
typedef vector< vector< edge > > Graph;

int Dijkstra(Graph& info, int s, int g,
             vector< int >& min_cost) {
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  min_cost.resize(info.size(), -1);
  que.push( Pi( 0, s));
  min_cost[s] = 0;
  while(!que.empty()){
    Pi p = que.top(); que.pop();
    if(p.second == g) return p.first;
    if(p.first > min_cost[p.second]) continue;
    for(int i = 0; i < info[p.second].size(); i++){
      edge& e = info[p.second][i];
      if(min_cost[e.to] == -1 ||
         p.first + e.cost < min_cost[e.to]){
        min_cost[e.to] = p.first + e.cost;
        que.push( Pi( min_cost[e.to], e.to));
      }
    }
  }
  return -1;
}
int main(){
  int n;
  cin >> n;
  Graph graph(n);
  vector< int > min_cost;
  for(int i = 0; i < n; i++){
    int u, k;
    cin >> u >> k;
    for(int i = 0; i < k; i++){
      int c, v;
      cin >> v >> c;
      graph[u].push_back( (edge){ v, c});
    }
  }
  Dijkstra( graph, 0, n, min_cost);
  for(int i = 0; i < n; i++){
    cout << i << " " << min_cost[i] << endl;
  }
}

Measured memory_bytes: 1284
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;

void solve(long long N, std::vector<long long> L){
    sort(L.begin(), L.end());
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            int lmax = L[i] + L[j] - 1;
            int lmin = abs(L[i] - L[j]) + 1;

            int imin = distance(L.begin(), lower_bound(L.begin(), L.end(), lmin));
            // 1 2 3 4 4 4 4
            //       | * 
            // lb( , 4)

            // 1 2 3 4 4 4 4 5
            //               |
            int imax = distance(L.begin(), upper_bound(L.begin(), L.end(), lmax));
            imin = max(j + 1, imin);
            imax = max(j, imax);
            ans += imax - imin;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        long double a,b,c; cin>>a>>b>>c;
        long double eps = 1e-14;
        if(sqrt(a)+sqrt(b)+eps<sqrt(c)) cout<<"Yes";
        else cout<<"No";
    }   
}


Measured memory_bytes: 3784
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include<cstring>
#include <iomanip>
#include <iostream>

using namespace std;


int main(void){
  int a1,a2,a3;
  cin >> a1 >> a2 >>a3;
  if(a1+a2+a3>=22){
    cout << "bust";
    return 0;
  }
  else{
    cout << "win";
  }


return 0;
}


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

int gcd(long long a, long long b){
  long long M = max(a, b), m = min(a, b);
  while(m != 0){
  	long long r = M%m;
    M = m; m = r;
  }
  return M;
}

int digit_sum(long long n){
  long long ans;
  while(n != 0){
  	ans += n%10;
  	n /= 10;
  }
  return ans;
}

int main(){
  int n ;
  cin >> n;
   
  cout << n*n*n << endl;
}

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

int main(){
    int num1, num2;
    char symbol;
    while(symbol != '?'){
        cin >> num1 >> symbol >> num2;
        switch (symbol){
            case '+':
            cout << num1 + num2 << endl;
            break;
            case '-':
            cout << num1 - num2 << endl;
            break;
            case '*':
            cout << num1 * num2 << endl;
            break;
            case '/':
            cout << num1 / num2 << endl;
        }
    }
}

Measured memory_bytes: 1164
K = int(input())

queue = [1, 2, 3, 4, 5, 6, 7, 8, 9]


def get_lunlun(K):
    for num in queue:
        if len(queue) >= K:
            return queue[K - 1]
        for i in range(-1, 2):
            last = num % 10 + i
            if last < 0 or last > 9:
                continue
            queue.append(num * 10 + last)


print(get_lunlun(K))

Measured memory_bytes: 7316
#include<iostream>
#include<vector>

using namespace std;

vector<int> num; // num[n]: nの倍数の個数
vector<int> a;
vector<int> memo;

int rec(int n){
	int tmp = 0;
	if(memo[n] != -1) return memo[n];

	if(num[n] == 0) {
		memo[n] = a[n];
		// cout << "return "<< n << " " << memo[n] << endl;
		return memo[n];
	}

	for(int i = 2*(n+1); i <= (num[n]+1)*(n+1); i += (n+1)){
		// cout << "n:" << n << " i:" << i-1  << "tmp:" << tmp << endl;
		//if(memo[i-1] == -1) tmp += rec(i-1);
		//else tmp += memo[i-1];
		tmp += rec(i-1);


		// cout << "n:" << n << " tmp:" << tmp << endl;
	}
	
	memo[n] = ((tmp+a[n]) % 2 == 0) ?  0 : 1;
	return memo[n];
}

int main(){
	int N; cin >> N;
	a.resize(N); for(int i = 0; i < N; ++i) cin >> a[i];

	num.resize(N);
	memo.resize(N);
	for(int i = 0; i < N; ++i){
		num[i] = (N / (i+1)) - 1;
		// cout << "num" << num[i] << endl;
		memo[i] = -1;
	}

	rec(0);

	int M = 0;
	for(int i = 0; i < N; ++i){
		if(memo[i] == 1) M++;
	}

	vector<int> b;

	for(int i = 0; i < N; ++i){
		// cout << "memo:" << memo[i] << endl;
	}

	if(M > 0){
	for(int i = 0; i < N; ++i){
		if(memo[i] == 1){ b.push_back(i); }
	}
	}

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

	return 0;
}


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

signed main() {
  int N;
  cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int k=0;
  for(int i=0;i<N;i++)k+=v[i];
  int ans=100000000000000000;
  int kk=0;
  int tt;
  for(int i=0;i<N-1;i++){
    kk+=v[i];
    tt=abs(2*kk-k);
    ans=min(ans,tt);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<cstdio>

using namespace std;

int main(void){
    string input;
    
    while(getline(cin, input)){
        if(*input.c_str() == EOF) break;
        
        int h, w;
        sscanf(input.c_str(), "%d %d\n", &h, &w);
        
        int sq = h * w;
        int l = (h * 2) + (w * 2);
        
        printf("%d %d\n", sq, l);
    }
    
    return(0);
}



Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string x,y,s;
    cin >>x>>s>>y;
    char q=s[0];
    cout <<'A'<<q<<'C'<<endl;



}


Measured memory_bytes: 256
N,d=gets.chomp.split(' ').map{|n| n.to_i}
A = Array.new(N)
0.upto(N-1){|d|
	A[d],dum=gets.chomp.split(' ').map{|n| n.to_i}
}
if(A[0]!=0)
	puts -1
	exit(0)
end
cur = 0
sum = 0
A.each{|a|
	case a - cur <=> 1
	when 0
		cur += 1
	when 1
		puts -1
		exit(0)
	when -1
		sum += cur
		cur = a
	end
}
sum += cur
puts sum


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

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    h, n = input_to_int_map()
    ab = [input_to_int_tuple() for i in range(n)]

    x = max(a for a, b in ab)

    dp = [0] * (h + x)
    for i in range(1, h + 1):

        dp[i] = min(dp[i - a] + b for a, b in ab)

    return dp[h]


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 3540
#include <stdio.h>

int main(void)
{
   int ball[10];
   int N;
   int B, C, tmp;
   int i, j;

   scanf("%d", &N);
   for(i=0; i<N; i++){
      scanf("%d %d %d %d %d %d %d %d %d %d",
         &ball[0], &ball[1], &ball[2], &ball[3], &ball[4],
         &ball[5], &ball[6], &ball[7], &ball[8], &ball[9]);
      B=11; C=11;
      for(j=9; j>=0; j--){
         //B is always smaller.
         if(B>ball[j]) B=ball[j];
	 else if(C>ball[j]) C=ball[j];
         else break;
	 if(B>C){ tmp=B; B=C; C=tmp;}
      }
      if(j==-1) printf("YES\n");
      else printf("NO\n");
   }
   return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int n, q;

int main() {
	cin >> n >> q;
	for (int i = 0; i < q; ++i) {
		int v, w; cin >> v >> w;
		if (n == 1) {
			cout << min(v, w) << endl;
			continue;
		}
		int dv = 0, dw = 0;
		int vv = v, ww = w;
		while (vv != 1) {
			++dv;
			vv = (vv + n - 2) / n;
		}
		while (ww != 1) {
			++dw;
			ww = (ww + n - 2) / n;
		}
		while (dw > dv) {
			w = (w + n - 2) / n;
			--dw;
		}
		while (v != w) {
			v = (v + n - 2) / n;
			w = (w + n - 2) / n;
		}
		cout << v << endl;
	}
	return 0;
}

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

int main() {
  string A;
  cin >> A;
  int a = A.size();
  
  int s = 0;
  for (int i = 0; i < a; i++) {
    if (A.at(i) == '0') s++;
  }
  
  cout << min(s, a - s) * 2 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;
#define INF 1000000000

int n, m, x;
Vec c;
vector<Vec>a; 

int		check(Vec skill)
{
	bool f = true;
	for (int j = 0; j < m; j++)
		if (skill[j] < x)
			f = false;
	if (!f)
		return (INF);
	return (0);
}



int		rec(int i, Vec skill)
{
	if (i == n)
		return (check(skill));
	int tmp = rec(i + 1, skill);
	for (int j = 0; j < m; j++)
		skill[j] += a[i][j];
	int tmp2 = rec(i + 1, skill);
	if (tmp == INF && tmp2 == INF )
		return (INF);
	if (tmp < tmp2 + c[i])
		return (tmp);
	return(tmp2 + c[i]);
}

int		main(void)
{
	cin >> n >> m >> x;
	c = Vec(n);
	a = vector<Vec>(n, Vec(m));
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
		for (int j = 0; j < m; j++)
			cin >> a[i][j];
	}
	Vec skill(m, 0);
	int ret = rec(0, skill);
	if (ret == INF)
		cout << -1 << endl;
	else
		cout << ret << endl;
}


Measured memory_bytes: 3640
def A():
    seq = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = int(input())
    print(seq[K-1])

import math
def B():
    H, W = map(int, input().split())
    if H==1 or W==1:
        print(1)
        return
    print(int(math.ceil(H*W/2.0)))

def C():
    a, b, c = map(int, input().split())
    d = c-a-b
    if d > 0 and d**2 > 4*a*b:
        print('Yes')
    else:
        print('No')
C()

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,int> pil;

long long MOD = 10000000000 + 7;

int main(){
  int H,W; cin >> H >> W;
  int sx,sy; cin >> sx >> sy; sx--; sy--;
  int gx,gy; cin >> gx >> gy; gx--; gy--;
  int INF = 1000000;

  vector<string> S(H);
  for(int i = 0; i < H; i++){
    cin >> S[i];
  }

  vector<vector<int>> dist(H, vector<int>(W, INF));

  dist[sx][sy] = 0;

  deque<pii> q;
  q.push_front(make_pair(sx, sy));


  auto check = [&S,&H,&W](int x, int y){
    if(x < 0 || x >= H) return false;
    if(y < 0 || y >= W) return false;
    if(S[x][y] == '#') return false;

    return true;
  };

  while(!q.empty()){
    int now_x = q.front().first;
    int now_y = q.front().second;
    q.pop_front();
    int now_dist = dist[now_x][now_y];

    for(int k = -2; k <=2; k++){
      for(int l = -2; l <= 2; l++){

        if(k == 0 && l == 0) continue;

        int next_x = now_x + k;
        int next_y = now_y + l;

        if(!check(next_x, next_y)) continue;

        int next_dist = dist[next_x][next_y];
        if(next_dist <= now_dist) continue;

        if(abs(k)+abs(l) == 1){
          dist[next_x][next_y] = now_dist;
          q.push_front(make_pair(next_x, next_y));
        } else {
          dist[next_x][next_y] = now_dist + 1;
          q.push_back(make_pair(next_x, next_y));
        }
      }
    }
  }

  cout << ( dist[gx][gy] == INF ? -1 : dist[gx][gy]) << endl;
}



Measured memory_bytes: 10092
#include<stdio.h>

int max(int a,int b){
  if(a>b) return b;
  return a;
}
 
int main(void){
  int n,i;
  int tmp,answer;
  scanf("%d",&n);
  
  char s[n];
  
  int a[n],b[n];
  
  for(i=0;i<n;i++){
    a[i]=0;
    b[i]=0;
  }
  
  scanf("%s",s);
  
  if(s[0]=='#') a[0]=1;
  if(s[n-1]=='.') b[n-1]=1;
  
  for(i=1;i<n;i++){
    if(s[i]=='#') 
      a[i]=a[i-1]+1;
    else a[i]=a[i-1];
    
    if(s[n-1-i]=='.')
      b[n-1-i]=b[n-i]+1;
    else b[n-1-i]=b[n-i];
  }
  
  for(i=0;i<n;i++) 
    answer=max(answer,a[i]+b[i]-1);
  
  printf("%d",answer);
  
  return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int a=sc.nextInt();
		int b=sc.nextInt();
		
		int c=a*a;
		int d=c-b;

		System.out.println(d);

	}
}

Measured memory_bytes: 23124
package main

import (
  "fmt"
)

func main() {
  var s, t string 
  fmt.Scan(&s, &t)
  rs := []rune(s)
  n := len(rs)
  ans := "No"
  for i := 0; i < n; i++ {
    if string(rs) == t {
      ans = "Yes"
      break
    }
    rs = append(rs[n-1:], rs[:n-1]...)
  }
  fmt.Println(ans)

}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, q;
string s;

int main() {
    cin >> q;
    n = 1e5;

    Vi primes;
    V<bool> isPrime(n+1, true);
    for (int i = 2; i <= n; i++) {
        if (!isPrime[i]) continue;
        primes.push_back(i);
        long long buf = i * 2;
        while (buf <= n) {
            isPrime[buf] = false;
            buf += i;
        }
    }

    Vi cnt(n+1, 0);
    FOR(i, primes) {
        if (*i == 2) continue;
        if (isPrime[(*i + 1)/2]) {
            cnt[*i] = 1;
        }
    }
    REP2(i, 1, n+1) {
        cnt[i] += cnt[i-1];
    }

    REP(i, q) {
        int l, r; cin >> l >> r;
        std::cout << cnt[r] - cnt[l-1] << '\n';
    }

    return 0;
}


Measured memory_bytes: 1152
//
// Created by ryo on 2019/11/23.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> cake(h);
    vector<vector<int>> ans(h, vector<int>(w));
    rep(i, h) {cin >> cake[i];}

    vector<int> unmaped;
    int num = 0;

    rep(y, h){
        bool flag = true;
        rep(x, w) {
            string str = "";
            if (cake[y][x] == '#') {
                flag = false;
                num ++;
            }

            if (!flag) {
                ans[y][x] = num;
            } else {
                ans[y][x] = -1;
            }
        }

        int pre = -1;
        for (int p = w - 1; p >= 0; --p) {

            if (ans[y][p] != -1) {
                pre = ans[y][p];
            }

            if (ans[y][p] == -1) {
                ans[y][p] = pre;
            }
        }

        if (flag) {
            unmaped.push_back(y);
        }
    }

    rep(x, w) {
        ll pre = -1;
        rep(y, h) {
            if (ans[y][x] != -1) {
                pre = ans[y][x];
            } else {
                if (pre != -1) {
                    ans[y][x] = pre;
                }
            }
        }
    }

    rep(x, w) {
        ll pre = -1;
        for (int y = h - 1; y >= 0; --y) {
            if (ans[y][x] != -1) {
                pre = ans[y][x];
            } else {
                if (pre != -1) {
                    ans[y][x] = pre;
                }
            }
        }
    }

    rep(i, h) {
        rep(j, w) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;

int main() {
    string S;
    cin >> S;
    if(S.size()==2){
      cout << S << endl;
    }else{
      cout << S[2] << S[1] << S[0] << endl;
    }

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

ll order(v1 a, vl cai, int n){
    ll ans = 0;
    v1 check(n+1, 0);
    for(int i = 1;i <= n; i++){
        check[i] = i;
    }
    for(int i = 1; i <= n; i++){
        int c = 0;
        for(int j = 1; j < a[i]; j++){
            if(check[j] != 0) c++;
        }
        ans += c*cai[(n-i)];
        check[a[i]] = 0;
    }
    return ans+1;
}



int main(){
    int n;
    cin >> n;
    v1 a(n+1);
    v1 b(n+1);
    for(int i = 1; i<= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> b[i];
    }
    vl cai(n+1);
    cai[0] = 1;
    for(int i = 1; i<= n; i++){
        cai[i] = cai[i-1]*i;
    }
    ll ans = abs(order(a, cai, n) - order(b, cai, n));
    cout << ans << endl;

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;int64_t p[1<<20],g,N,i,c,b,n[1<<20],d[1<<20];main(){for(cin>>N;i<N;)cin>>c>>b,c+=1e9,p[i++]=(c<<32)+c+b;for(sort(p,p+N);c=i--;g=d[i]=(g+d[n[i]=c]+1)%998244353)for(;c<N&p[c]<p[i]<<32;c=n[c]);cout<<g+1;}

Measured memory_bytes: 5888
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  string str;
  cin>>str;
  bool V = true;
  if(str[0] != 'A')
  {
    V = false;
  }
  int COUNT = 0;
  for (int i = 1; i < str.size(); i++)
  {
    if(str[i] == 'C' && i >= 2 && i<str.size()-1)COUNT++;
    else if(str[i] <= 'Z') V = false;
  }
  if(COUNT != 1) V = false;
  // DEBUG(COUNT);
  cout<<(V?"AC":"WA")<<endl;
  
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[0 for i in range(m)]
for i in range(n):
    k=list(map(int,input().split()))
    for g in range(k[0]):
        a[k[g+1]-1]+=1
s=0
for i in range(m):
    if a[i]==n:
        s+=1
print(s)


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;



int main(){
	int N;
	while(~scanf("%d",&N)){
		if(N==0) break;

		vector<int> row;
		vector<int> col;
		for(int i=0;i<N;i++){
			int num;
			cin >> num;
			row.push_back(num);
		}

		for(int i=0;i<N;i++){
			int num;
			cin >> num;
			col.push_back(num);
		}
		sort(col.begin(),col.end(),greater<int>());

		bool isok = true;
		for(int i=0;i<col.size();i++){			
			for(int j=0;j<row.size();j++){
				if(row[j] > 0){
					col[i]--;
					row[j]--;
				}
			}
		}

		if(count(col.begin(),col.end(),0) != col.size()
			|| count(row.begin(),row.end(),0) != row.size()){
				isok = false;
		}

		printf("%s\n",isok ? "Yes" : "No");
	}
}

Measured memory_bytes: 1360
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a; i<n; i++)
using namespace std;

const int S = 10010;
int uf[S];

int find(int a) {
    if(a == uf[a]) return a;
    return find(uf[a]);
}

void unite(int a, int b) {
    int fa = find(a), fb = find(b);
    if(fa == fb) return;
    uf[fa] = uf[fb];
}

int main() {
    rep(i,0,S) uf[i] = i;
    int n, q; cin >> n >> q;
    rep(i,0,q) {
        int c, x, y; cin >> c >> x >> y;
        if(c == 0) unite(x, y);
        else if(c == 1) cout << (find(x) == find(y)) << endl;
    }
    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

int main()
{    
    ll n,d;
    cin>>n>>d;
    ll ct = 0;
    REP(i,0,n){
        ll x,y;
        cin>>x>>y;
        if(x*x + y*y <= d*d) ct++;
    }
    cout<<ct<<endl;
    return 0;
}

Measured memory_bytes: 3648