akhauriyash/Code-Regression huggingface dataset:
import java.util.List;
import java.util.Scanner;

public class Main {

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

	void run() {
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();

		String[][] board=new String[h][w];

		for (int i = 0; i < h; i++) {
			board[i]=sc.next().split("");
		}

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



		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {

				if(board[i][j].equals("#")) {

					boolean connectWall=false;
					for (int k = 0; k < 4; k++) {

						int ny=i+dy[k];
						int nx=j+dx[k];


						if(isIn(ny,nx,h,w)) {
							if(board[ny][nx].equals("#")){
								connectWall=true;
							}
						}
					}

					if(!connectWall) {
						System.out.println("No");
						return;
					}
				}

			}
		}

		System.out.println("Yes");



	}

	public static boolean isIn(int y,int x,int h,int w) {

		return y>=0 && y<h && x>=0 && x<w;

	}



	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

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

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll a;cin>>a;
    ll mini=1e13;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0&&i+(a/i)<mini)mini=i+a/i;
    }
    cout<<mini-2<<endl;   
    return 0;
}


Measured memory_bytes: 256
from math import gcd
def main():
    ans = 0
    k = int(input())
    for i in range(1,1+k):
        for j in range(1,1+k):
            for l in range(1,1+k):
                ans += gcd(i,gcd(j,l))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9104
r, c, k = map(int, input().split())
rcv = [list(map(int, input().split())) for i in range(k)]

area = [[0] * (c+1) for i in range(r+1)]
for a, b, v in rcv:
    area[a-1][b-1] = v

# dp[i][j][k]: その行でiまで拾っており、
# j行k列目に到達時点の最大スコア
dp = [[[-1] * (c+1) for i in range(r+1)] for j in range(4)]
dp[0][0][0] = 0

for rr in range(r+1):
    for cc in range(c+1):
        for i in range(4):
            # 取って右
            if i+1<4 and cc<c and area[rr][cc]>0:
                dp[i+1][rr][cc+1] = max(dp[i+1][rr][cc+1],
                                        dp[i][rr][cc]+area[rr][cc])
            # 取って下
            if i+1<4 and rr<r and area[rr][cc]>0:
                dp[0][rr+1][cc] = max(dp[0][rr+1][cc],
                                      dp[i][rr][cc]+area[rr][cc])
            # 取らずに右
            if cc<c:
                dp[i][rr][cc+1] = max(dp[i][rr][cc+1],
                                      dp[i][rr][cc])
            # 取らずに下
            if rr<r:
                dp[0][rr+1][cc] = max(dp[0][rr+1][cc],
                                      dp[i][rr][cc])
# ans: r行c列目の最大値（iは問わず）
ans = max([dp[i][r][c] for i in range(4)])
print(ans)





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

int main () {
    int H,W;
    string w;
    for (int a=0;a<a+1;a++) {
        cin >> H >> W;
        if (H!=0 && W!=0) {
            for (int j=1;j<=H;j++) {
                if ( j%2==1 ) {
                    for (int i=1;i<=W;i++) {
                        if ( i%2==1 ) {
                            w = w + "#";
                        } else if ( i%2==0) {
                            w = w +".";
                        }
                    }
                    cout << w << endl;
                    w = "";
                } else if ( j%2==0 ) {
                    for (int i=1;i<=W;i++) {
                        if ( i%2==1 ) {
                            w = w + ".";
                        } else if ( i%2==0) {
                            w = w +"#";
                        }
                    }
                    cout << w << endl;
                    w = "";
                }
            }
            cout << endl;
        } else {
            break;
        }
    }
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <set>
#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 llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
//setprecision(10);
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

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

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
        return b != 0 ? gcd(b, a % b) : a;
    }

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string ans="No";
    int n; cin>>n;
    pair<llong, llong> W[n];
    REP(i,n)
    {
        llong a,b;
        cin>>a>>b;
        W[i].first=b;
        W[i].second=a;
    }
    sort(W,W+n);
    llong cnt=0;
    llong t=0;
    for(int i=0; i<n; i++)
    {
        if(t+W[i].second<=W[i].first)
        {
            cnt++;
            t+=W[i].second;
        }
    }

    if(cnt==n) ans="Yes";
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n,m;
    cin >> n >> m;
    int ans = 1;
    bool red[n] = {};
    red[0] = true;
    int cnt[n];
    REP(i,n){
        cnt[i] = 1;
    }
    int x,y;
    REP(i,m){
        cin >> x >> y;
        x--;
        y--;
        if(red[x] == true && red[y] == false){
            red[y] = true;
            ans++;
        }
        cnt[x]--;
        cnt[y]++;
        if(cnt[x] == 0 && red[x] == true){
            red[x] = false;
            ans--;
        }
    }
    cout << ans << endl;
}

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

int main() {
    int n; cin >> n;
    vector<double> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    double sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += 1./a[i];
    }
    cout << 1./sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int Cal_prime_number(int);

int main(void) 
{
  int n, number;

  while (scanf("%d", &n) != EOF) {
    number = Cal_prime_number(n);
    
    if (number == -1) 
      printf("Allocation error\n");
    else 
      printf("%d\n", number);
  }

  return 0;
}

/* エラトステネスの篩 */
int 
Cal_prime_number(int n) {

  int i, j, number = 0, found;
  int *prime;

  if ((prime = (int *) malloc(sizeof(int) * (n + 1))) == NULL) {
      printf("Cannot allocate %d byte\n", sizeof(int) * (n + 1));

      return -1;
    }

  for (i = 0; i <= n; i++) {
    if (i <= 1) 
      prime[i] = 0;
    else 
      prime[i] = 1;
  }

  for (i = 2; i <= n; i++) {

    found = 0;

    for (j = i; j <= n; j += i) {
      if (found == 0) {
	found++;
      } else 
	prime[j] = 0;
    }
  }

  for (i = 2; i <= n; i++) 
    if (prime[i] == 1) 
      number++;

  free(prime);

  return number;
}

Measured memory_bytes: 4760
N = int(input())
S = input()
ans = 0
snumber = [str(i) for i in range(10)]
for i in snumber:
    for j in snumber:
        for k in snumber:
            a = S.find(i)
            if a == -1:
                break
            b = S.find(j,a+1)
            if b == -1:
                break
            c = S.find(k,b+1)
            if c != -1:
                ans += 1
print(ans)


Measured memory_bytes: 38384
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    if(n%1000==0) {
        cout << 0;
        return 0;
    }
    cout << 1000-(n%1000);

    return 0;
}


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

using namespace std;
bool judge[10000000];
int main()
{
    int k,s;
    int x,y,z;
    int temp;
    int ans = 0;
    scanf("%d%d",&k,&s);
    for( x = 0; x <= k; x ++)
    {
        for( y = 0; y <= k; y ++)
        {
            z = s - x - y;
            if(z >= 0 && z <= k)
            {
                temp = x * 3000 + y;
                if(judge[temp] == false)
                {
                    ans ++;
                    judge[temp] = true;
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 8448
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin>>H>>W;
        if(H==0&&W==0){
            break;
        }
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(j==0||j==W-1){
                    cout<<"#";
                }else
                if(i==0||i==H-1){
                    cout<<"#";
                }else{
                    cout<<".";
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


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

int main() {
  int x, y;
  while (cin >> x >> y, (x | y) != 0) {
    if (x < y) {
      cout << x << " " << y << "\n";
    } else {
      cout << y << " " << x << "\n";
    }
  }
  return 0;
}


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

typedef long long LL;
//const int maxn = 1e5+3;
int main()
{
    LL n, a, b;
    scanf("%lld%lld%lld",&n,&a,&b);
    if((n==1&&a!=b) || a>b)
        return 0*puts("0");
    LL l, r;
    r = (n-1)*b+a;
    l = (n-1)*a+b;
    printf("%lld\n",r-l+1);
    return 0;
}


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

int main()
{
   int t,a,b;
  cin>>a>>b;
  if(a>=13)cout<<b;
  else{
       if(a>=6&&a<=12)cout<<b/2;
    else{
         if(a<=5)cout<<"0";
    }
  }

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c,i,j;
	scanf("%d %d %d",&a,&b,&c);
	for(i=0;i<=2;i++){
		if(a<b){
			}
		else{
			j=a;
			a=b;
			b=j;
			}
		if(b<c){}
		else{
			j=b;
			b=c;
			c=j;}
		}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 2672
N=int(raw_input())
d=0
for x in xrange(105,N+1):
    if(x%2==0): continue
    div=2
    i=2
    while i<=(x//2+x%2) and div<9:
        div=div+(0,1)[x%i==0]
        i=i+1
    #print(div,x)    
    if(div==8): d=d+1    
print("%d"%d)    


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


int N, M;
vector<ll> A;
vector<P> Card;
ll a, b, c;
ll res = 0;

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

    for(int i = 0; i < N; i++){ cin >> a; A.push_back(a); }
    for(int i = 0; i < M; i++){
        cin >> b >> c;
        Card.push_back({c,b});
    }

    sort(A.begin(), A.end());
    sort(Card.begin(), Card.end());
    reverse(Card.begin(), Card.end());

    int i = 0, j = 0;
    while(i < N && A[i] < Card[j].first){
        int k = 0;
        while(i+k < N && k < Card[j].second && A[i+k] < Card[j].first){
            A[i+k] = Card[j].first;
            ++k;
        }
        i += k;
       ++j;
    }

    for(int i = 0; i < N; i++) res += A[i];
    cout << res << endl;

    return 0;

}

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

using namespace std;

long long inv(long long a, long long b){
 return 1 < a ? b - inv(b % a, a) * b / a : 1;
}

const int N = 3030;
const int mod = 1e9 + 7;

int n, q;
int a[N];
int f[N][N];
int test[N][N];
pair < int, int > queries[N];

int main(){
  
  cin >> n >> q;
  for(int i = 1; i <= n; ++i) cin >> a[i];
  for(int i = 1; i <= q; ++i) cin >> queries[i].first >> queries[i].second;
  
  int mul = 1, halve = inv(2, mod);
  for(int i = 1; i <= q; ++i) mul = (mul + mul) % mod;
  
  for(int i = 1; i <= n; ++i) {
    for(int j = i + 1; j <= n; ++j) f[i][j] = mul;
  }
  
  
  vector < int > tempX(n + 1, 0), tempY(n + 1, 0), tempX1(n + 1, 0), tempY1(n + 1, 0);

  for(int i = q; i >= 1; --i) {
    int x = queries[i].first, y = queries[i].second;
    
    fill(tempX.begin(), tempX.end(), 0);
    fill(tempY.begin(), tempY.end(), 0);
    fill(tempY1.begin(), tempY1.end(), 0);
    fill(tempX1.begin(), tempX1.end(), 0);
    
    for(int j = 1; j <= n; ++j) {
      if(j == y || j == x) continue;
      tempX[j] = f[x][j] + f[y][j];
      tempX1[j] = f[j][x] + f[j][y];
    }
    
    for(int j = 1; j <= n; ++j) {
      if(j == x || j == y) continue;
      tempY[j] = f[y][j] + f[x][j];
      tempY1[j] = f[j][y] + f[j][x];
    }
    
    
    tempY[x] = tempX[y] = f[x][y] + f[y][x]; 
    
    for(int j = 1; j <= n; ++j) {
      f[x][j] = (1LL * tempX[j] * halve) % mod;
      f[y][j] = (1LL * tempY[j] * halve) % mod;
      
      if(j != x && j != y) f[j][x] = 1LL * tempX1[j] * halve % mod, f[j][y] = 1LL * tempY1[j] * halve % mod;
    }
    
    
  /*  for(int i = 1; i <= n; ++i) {
      for(int j = 1; j <= n; ++j) cout << f[i][j] << " \n"[j == n];
    }*/
  }
  

  int ans = 0;
  
  for(int i = 1; i <= n; ++i) {
    for(int j = i + 1; j <= n; ++j) {
      if(a[i] == a[j]) continue;
      if(a[i] < a[j]) ans += f[j][i];
      else ans += f[i][j];
      ans %= mod;
    }
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 37248
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


//階乗,二項係数
//*
ll fact[100010];
ll invfact[100010];
void makefact(int n,ll m){
	n=min(n,m-1);
	fact[0]=1;
	rep(i,0,n)fact[i+1]=fact[i]*(i+1)%m;
	invfact[n]=invp(fact[n],m);
	for(int i=n;i>0;i--)invfact[i-1]=invfact[i]*i%m;
}
ll choose(int n,int r,int m){return n<0||r<0||n-r<0?0:fact[n]*invfact[r]%m*invfact[n-r]%m;}
//*/

ll dp[30][1010];
int a[1010];
int main(){
	makefact(3000,MOD);
	int n,k;
	scanf("%d%d",&n,&k);
	rep(i,0,k)scanf("%d",a+i);
	dp[0][0]=1;
	rep(i,1,n+1)dp[0][0]=dp[0][0]*i%MOD;

	rep(i,0,k)rep(j,0,n+1){
		rep(k,0,n-j+1)dp[i+1][j+k]=(dp[i+1][j+k]+dp[i][j]*choose(n-k,a[i]-k,MOD)%MOD*invfact[k])%MOD;
	}
//	rep(i,0,k+1){rep(j,0,n+1)printf("%d ",dp[i][j]);puts("");}
	
	printf("%lld",dp[k][n]);
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  bool A = false;
  if(abs(a-c)<=d){
    A=true;
  }
  else if(abs(b-c)<=d && abs(a-b)<=d){
    A=true;
  }
  if(A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var ab = CRL().ArrayLongs();
        var a = ab[0];
        var b = ab[1];
        long val = 0;
        for (int i = 0; i < 2; i++)
        {
            if (a > b)
            {
                val += a;
                a--;
            }
            else
            {
                val += b;
                b--;
            }
        }

        CWL(val);
    }
}

public static partial class Program
{
    //テンプレここから
    private static long ToInt(this string str) => long.Parse(str);
    private static long[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] { 0, -1, 0, 1 };
    public static long[] dy = new long[] { -1, 0, 1, 0 };
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array)
    {
        var list = array.ToList();
        list.Sort();
        return list.ToArray();
    }
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    //テンプレここまで
}


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

int main()
{
	int n, x; cin >> n >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a.at(i);
	sort(a.begin(), a.end());

	int count = 0;
	for (int i = 0; i < n - 1; i++) {
		if (x >= a.at(i)) {
			x -= a.at(i);
			count++;
		}
	}
	if (x == a.at(n - 1)) {
		count++;
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 2e5 + 5;
const int oo = 1e9 + 5;
const LL ooll = 1e18 + 5;
 
// clock_t start = clock();
int go[44][19];
void solve() {
    int n;
    cin >> n;
    long long mul = 1e9;
    LL ans = 0;
    memset(go, 0, sizeof(go));
    for (int i=0;i<n;++i) {
        long long y = 0;
        string s;
        cin >> s;
        int cnt = 0;
        bool ok = false;
        for (auto it : s) {
            if (it == '.') {
                ok = true;
                continue;
            }
            y = (y << 1) + (y << 3) + it - '0';
            if (ok) ++cnt;
        }
        cnt = 9 - cnt;
        while(cnt--) y = (y << 1) + (y << 3);
        // cout << y << '\n';
        int two = 0, five = 0;
        while(y % 2 == 0) {
            y /= 2;
            ++two;
        }
        while(y % 5 == 0) {
            y /= 5;
            ++five;
        }
        for (int t=max(0,18-two);t<44;++t) for (int f=max(0,18-five);f<19;++f) {
            ans += go[t][f];
        }
        go[two][five]++;
    }
    cout << ans << '\n';
}
 
int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    while(T--) {
        solve();
    }
    // cout << fixed << setprecision(10);
    // cout << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
    return 0;
} 

Measured memory_bytes: 3676
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int[] array = new int[] {stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt()};
		
		Arrays.parallelSort(array);    // 5 5 7 になっていれば正解
		
		System.out.println(Arrays.equals(array,new int[] {5,5,7}) ? "YES":"NO");
		
		
	}

}


Measured memory_bytes: 22484
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1 {
    class Program {
        static void Main(string[] args)
        {
            int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(Math.Max(ab[0] - ab[1] * 2, 0));
            //Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13268
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    A, B, K = in_nn()

    count = 0
    num = min(A, B) + 1
    while count < K:
        num -= 1
        if A % num == 0 and B % num == 0:
            count += 1

    print(num)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9092
using System;
class Program
{
	static void Main(string[] args)
	{
      string S = Console.ReadLine();
      char[] s = {S[0], S[1], S[2], S[3]};
      Array.Sort(s);
      if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3])
      {
        Console.WriteLine("Yes");
      }
      else
      {
        Console.WriteLine("No");       
      }
	}
}

Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;
 
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;
}
using namespace std;

//ワーシャルフロイド法、全点対最短路
const int INFTY=numeric_limits<int>::max()/2;
vector<vector<int>>d;//d[u][v]は辺uvのコスト、ただし存在しないときINFTY,d[i][i]=0

void warshall_floyd(int V){//Vは頂点数
	for(int k=0;k<V;++k){//経由する頂点
		for(int i=0;i<V;++i){//始点となる頂点
			for(int j=0;j<V;++j)//目的地の頂点
      d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		}
	}
}



void solve(){
 int n,m,r;
 cin>>n>>m>>r;
 d.resize(n,vector<int>(n,INFTY));
 vector<int>rr(r);
 rep(i,r){
   cin>>rr[i];
   rr[i]--;
 }
 sort(rr.begin(),rr.end());//next_permutationを使うときは必ずソートする
 rep(i,m){
   int a,b,c;
   cin>>a>>b>>c;
   a--;b--;
   d[a][b]=c;
   d[b][a]=c;
 }
 warshall_floyd(n);
 int minv=numeric_limits<int>::max();
 do{
   int cmp=0;
   rep(i,r-1){
     cmp+=d[rr[i]][rr[i+1]];
   }
   minv=min(minv,cmp);
 }while(next_permutation(rr.begin(),rr.end()));
 cout<<minv<<"\n";
 return;
}
 
signed main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<fixed<<setprecision(20);
	solve();
	return 0;
}


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

#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin >> tt; rep1(qq,1,tt)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

#define lnode (2 * node + 1)
#define rnode (2 * node + 2)

using namespace std;

typedef pair<int, int> pii;

const int N = 1e5 + 5;

int n, m;

int32_t main()
{

	FIO
	//cout << fixed << setprecision(10);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
  cin >> n >> m;
  int res = (n * (n - 1)) / 2 + (m * (m - 1)) / 2;
  cout << res << '\n';
	
	
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef set <int> S;
 
int skip(string &str,int i){
  if(str[i]!='(')return i;
  string res;
  int cnt=1;i++;
  while(1) {
    if(str[i]=='(')cnt++;
    if(str[i]==')')cnt--;
    if(!cnt)break;
    res+=str[i++];
  }
  return i;
}
 
 
int num[1<<8];
vector <S> mem;
map <string,int> M;
void calc(char ch,S a,S b, S &res){
  S::iterator i,j;
  for(i=a.begin();i!=a.end();i++)
    for(j=b.begin();j!=b.end();j++){
      int I=*i,J=*j,c=0;
      if(ch=='+') c=I+J;
      else if(ch=='-') c=I-J;
      else if(ch=='*') c=I*J;
      else if(ch=='/'){
    if(!J)continue;
    c=I/J;
      }
      res.insert(c);
    }
}
 
S solve(string str){
  S res;
  if(str.size()==1){res.insert(num[str[0]]);return res;}
  if(M.count(str))return mem[M[str]];
  if(skip(str,0)==str.size()-1)return solve(str.substr(1,str.size()-2));
 
  string A,B;
  for(int i=0;(i=skip(str,i))<str.size()-1;i+=2){
    string A=str.substr(0,i+1),B=str.substr(i+2,str.size()-i-2);
    calc(str[i+1],solve(A),solve(B),res);
  }
  M[str]=mem.size();
  mem.push_back(res); 
  return mem[M[str]];
}
 
int main(){
  while(1){
    string str;
    cin>>str;
    if(str=="#")break;
    mem.clear(),M.clear();
    string siki;
    char ch='A';
    for(int i=0;i<(int)str.size();){
      int b=0;
      while('0'<=str[i]&&str[i]<='9') b=b*10+str[i++]-'0';
      if(b) num[ch]=b,siki+=ch++;
      else siki+=str[i++];
    }
    cout <<solve(siki).size()<<endl;
  }
  return 0;
}

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

int main(){
    int n;
    int m;
    int a[10000];
    int i;

    cin >> n >> m;
    for(i=0; i<m; i++){
        cin >> a[i];
    }

    for(i=0; i<m; i++){
        n -= a[i];
        if(n < 0){
            n = -1;
            break;
        }
    }
    cout << n << endl;

}

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

int N;
vector<ll> l(87);

ll getLucas(int k){
  if(l.at(k) != 0) return l.at(k);
  ll ret = getLucas(k-1) + getLucas(k-2);
  l.at(k) = ret;
  return ret;
}

int main(){
  cin >> N;
  l.at(0) = 2;
  l.at(1) = 1;
  ll ans = getLucas(N);
  cout << ans << endl;
}


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

#pragma GCC optimize("O3")

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

int main() {
    int n;
    cin >> n;
    map<string, int> data;
    int bigger = 1;
    for(int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		if(data.find(s) == data.end()) {
			data.insert(pair<string, int>(s, 1));
		} else {
			data.at(s) += 1;
			if(data.at(s) > bigger) bigger = data.at(s);
		}
	}
	vector<string> strs;
	for(auto it = data.begin(); it != data.end(); ++it) {
		if(it->second == bigger) {
			strs.emplace_back(it->first);
		}
	}
	sort(all(strs));
	
	for(auto x : strs) {
		cout << x << "\n";
	}
	
    return 0;
}


Measured memory_bytes: 27204
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>

using namespace std;



struct Section
{
	long long a, b;
	long long diff;
};
int n;
Section sections[100010];

bool compare(const Section &a, const Section &b)
{
	if (a.diff == b.diff)
		return a.a > b.a;
	else
		return a.diff > b.diff;
}

int main()
{
	scanf("%d", &n);
	
	for (int i = 0 ; i < n ; i++)
	{
		scanf("%lld%lld", &(sections[i].a), &(sections[i].b));
		sections[i].diff = sections[i].a + sections[i].b;
	}
	
	sort(sections, sections + n, compare);
	
	long long sumA = 0;
	long long sumB = 0;
	for (int i = 0 ; i < n ; i++)
	{
		if (i % 2 == 0)	//从1开始计数的话就是单数双数火 
			sumA = sumA + sections[i].a;
		else
			sumB = sumB + sections[i].b;
	}
	
	long long curDiff = sumA - sumB;
	printf("%lld\n", curDiff);

	return 0;
}


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

int main()
{
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  
  int ans = 0;
  for(int i = 0; i <= a; ++i)
  {
    for(int j = 0; j <= b; ++j)
    {
      for(int k = 0; k <= c; ++k)
      {
        if(i * 500 + j * 100 + k * 50 == x)
        {
          ans++;
        }
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  int n;
  int c[505],s[505],f[505];
  cin>>n;
  rep(i,n-1)cin>>c[i]>>s[i]>>f[i];
  rep(i,n-1){
    int time=0;
    REP(j,i,n-1){
      REP(k,0,INF){
	//cout<<"debug: "<<k<<": "<<time<<" "<<c[j]+s[j]+k*f[j]<<endl;
	if(time<=s[j]+k*f[j]){time=c[j]+s[j]+k*f[j];break;}
      }
    }
    cout<<time<<endl;
  }
  cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#define MX 1005
#define INF 1000000005
#define EPS 1e-10

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int cnt[MX][MX];
int dpx[MX],dpy[MX];
int tx[MX],ty[MX];
bool use[MX];
int n,D,mx;

bool check(int X)
{
	for(int i=0;i<D;i++) ty[i]=-1;
	for(int i=0;i<D;i++)
	{
		for(int j=0;j<D;j++)
		{
			if(cnt[i][j]>mx*mx)
			{
				ty[j]=i;
			}
		}
	}
	for(int i=0;i<D;i++)
	{
		int x=-1;
		for(int j=0;j<D;j++)
		{
			if(ty[j]<=i+X) use[j]=false;
			else
			{
				use[j]=true;
				x=max(x,j);
			}
		}
		for(int j=0;j<D;j++)
		{
			if(dpx[i]<=X&&dpy[j]<=X&&x-j<=X) return true;
			if(use[j]) x=j+D;
		}
		for(int j=0;j<D;j++)
		{
			if(cnt[i][j]>mx*mx)
			{
				ty[j]=i+D;
			}
		}
	}
	return false;
}
int main()
{
	scanf("%d %d",&n,&D);
	for(int i=0;i<n;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		cnt[x%D][y%D]++;
	}
	mx=0;
	for(int i=0;i<D;i++)
	{
		for(int j=0;j<D;j++)
		{
			if(cnt[i][j]>0)
			{
				int t=(int) ceil(sqrt(cnt[i][j])-EPS);
				t--;
				mx=max(mx,t);
			}
			else cnt[i][j]=-1;
		}
	}
	for(int i=0;i<D;i++)
	{
		int to=-1;
		for(int j=0;j<D;j++)
		{
			if(cnt[i][j]>mx*(mx+1))
			{
				to=j;
			}
		}
		if(to>=0)
		{
			for(int j=0;j<D;j++)
			{
				dpy[j]=max(dpy[j],to-j);
				if(cnt[i][j]>mx*(mx+1)) to=j+D;
			}
		}
	}
	for(int i=0;i<D;i++)
	{
		int to=-1;
		for(int j=0;j<D;j++)
		{
			if(cnt[j][i]>mx*(mx+1))
			{
				to=j;
			}
		}
		if(to>=0)
		{
			for(int j=0;j<D;j++)
			{
				dpx[j]=max(dpx[j],to-j);
				if(cnt[j][i]>mx*(mx+1)) to=j+D;
			}
		}
	}
	int l=-1,r=D;
	while(r-l>1)
	{
		int d=(l+r)/2;
		if(check(d)) r=d;
		else l=d;
	}
	printf("%lld\n",(ll) mx*(ll) D+r);
	return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
vector<int> a;
vector<int> b;
int main()
{
	int n;
	cin>>n;
	a.resize(n+2);
	b.resize(n+2);
	a[0]=0;
	b[0]=0;
	a[n+1]=0;
	int total=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=fabs(a[i]-a[i-1]);
		total+=b[i];
	}
	b[n+1]=fabs(a[n]-a[0]);
	total+=b[n+1];
	//cout<<total<<endl;
	for(int i=1;i<=n;i++)
	{
		int s=total-b[i]-b[i+1]+fabs(a[i-1]-a[i+1]);
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 2048
str=list(input())

count1=0
count2=0
if str[0]=="A":
  for i in range(len(str)-3):
    if str[i+2]=="C":
      count1 += 1
  for i in range(len(str)):
    if str[i]==str[i].capitalize():
      count2 += 1
  if count1 == 1 and count2 ==2 :
    print("AC")
  else:
    print("WA")
else:
  print("WA")

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<ll> sum(n + 1);
	for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i - 1];
	vector<ll_i> p(n + 1);
	for (int i = 0; i <= n; i++) p[i] = ll_i(sum[i], i);
	sort(p.begin(), p.end());
	vector<int> v(n + 1);
	for (int i = 0; i <= n; i++) v[i] = p[i].second;
	vector< vector<int> > dp(n + 1, vector<int>(n + 1));
	vector< vector<int> > prev(n + 1, vector<int>(n + 1, -1));
	for (int i = 1; i <= n; i++) dp[0][i] = 1;
	for (int i = 0; i <= n; i++) {
		int k = n, x = 0, p;
		for (int _k = 0; _k <= n; _k++) {
			int _j = v[_k];
			if (_j <= i) continue;
			while (k >= 0) {
				int j = v[k];
				if (j < i) {
					if (sum[i] - sum[j] >= sum[_j] - sum[i]) break;
					if (dp[j][i] > x) {
						p = j;
						x = dp[j][i];
					}
				}
				k--;
			}
			if (x > 0) {
				dp[i][_j] = x + 1;
				prev[i][_j] = p;
			}
		}
	}
	int i, m = 0;
	for (int j = 0; j < n; j++)
		if (dp[j][n] > m) {
			i = j;
			m = dp[j][n];
		}
	vector<int> c;
	int j = n;
	while (i > 0) {
		c.push_back(i);
		int _i = i;
		i = prev[i][j];
		j = _i;
	}
	reverse(c.begin(), c.end());
	cout << m << endl;
	for (int k = 0; k < m - 1; k++) {
		cout << c[k];
		if (k < m - 2) cout << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 126668
import java.util.Scanner;
	public class Main {
	public static void main(String[] args) {
	Scanner sc= new Scanner(System.in);
	while(true) {
		int n = sc.nextInt();
		if (n == 0) { break; }
		int[] s = new int[n];
		for(int i= 0; i< s.length; i++) {
				s[i] = sc.nextInt();
			}
		int average = 0;
		int y = 0;
		for(int j=0;j<n;j++){
			y = y + s[j];
			}
		int max = s[0];	//??¨?????????????????§??????n[0]????¨???????????????°max?????£??\
		int min = s[0];	//??¨????????????????°???????n[0]????¨???????????????°min?????£??\
		for (int i=0; i<s.length; i++) {
			if (max < s[i]) {	//?????¨????????§??????????????§?????????????????????
				max = s[i];	//?????°max???????????\????????????
			}
			if (min > s[i]) {	//?????¨???????°??????????????°??????????????????????
				min = s[i];	//?????°min???????????\????????????
			}
		}
		y = y - max - min;
		average = y/(n-2);
		
			System.out.println(average);
	}
	}
	}

Measured memory_bytes: 20936
use std::cmp;

const INF: u32 = 1 << 30 as u32;

fn main() {
    let sc = std::io::stdin();
    let mut sc = Scanner { reader: sc.lock() };
    let s: Vec<u32> = sc
        .read::<String>()
        .chars()
        .map(|c| c as u32 - 'a' as u32)
        .collect();
    let n = s.len();
    let mut hash: Vec<u32> = vec![0; n + 1];
    for i in 0..n {
        hash[i + 1] = hash[i] ^ (1 << s[i]);
    }

    let mut opt = vec![INF; n + 1];
    let mut min = vec![INF; 1 << 26];
    opt[0] = 0;
    min[0] = 0;

    for i in 0..n {
        let hash = hash[i + 1] as usize;
        for x in 0..27 {
            let prefix = if x == 0 { 0 } else { 1 << (x - 1) };
            let suffix = hash ^ prefix;
            opt[i + 1] = cmp::min(opt[i + 1], min[suffix] + 1);
        }
        min[hash] = cmp::min(min[hash], opt[i + 1]);
    }

    println!("{}", opt[n]);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

const string YES = "Yes";

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    unordered_map<long long, vector<long long>> paths;
    vector<bool> used(N+1);
    for (int i = 0; i < M; i++) {
        paths[A[i]].push_back(B[i]);
        paths[B[i]].push_back(A[i]);
    }

    vector<long long> result(N+1);
    used[1] = true;
    queue<long long> q1;
    queue<long long> q2;
    q1.push(1);
    while(!q1.empty()) {
        while (!q1.empty()) {
            long long current = q1.front();
            q1.pop();
            for (auto e : paths[current]) {
                if (used[e]) continue;
                used[e] = true;
                q2.push(e);
                result[e] = current;
            }
        }
        q1.swap(q2);
    }

    bool flag = true;
    for (int i = 2; i <= N; i++) {
        flag &= used[i];
    }
    cout << (flag ? "Yes" : "No") << endl;
    if (flag) {
        for (int i = 2; i <= N; i++) {
            cout << result[i] << endl;
        }
    }
}

// Generated by 1.1.7.1 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);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 20096
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <ostream>
#include <queue>
#include <random>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

inline void init() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
}

int main() {
  init();
  int n, sn = 0;
  cin >> n;
  std::string s = std::to_string(n);
  
  for (int i = 0; i < s.size(); ++i) {
    sn += s[i] - '0';
  }
  
  if (n % sn == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll k;
    cin>>k;
    
    vector<ll> ans(50);
    rep(i,50) {
        ans[i]=(ll)i+k/50;
    }
    
    rep(i,k%50) {
        rep(j,50) {
            if(j==i) ans[j]+=50;
            else ans[j]--;
        }
    }
    
    cout<<50<<endl;
    rep(i,50) cout<<ans[i]<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d,n,x,sum=0,i;
	for(i=0;i<50;i++){
		cin>>x;
	for(a=0;a<=9;a++){
		for(b=0;b<=9;b++){
			for(c=0;c<=9;c++){
				for(d=0;d<=9;d++){
					n=a+b+c+d;
					if(x==n){
						sum++;
					}
				}
			}
		}
	}
	cout<<sum<<endl;
	sum=0;
	}
	return 0;
}

Measured memory_bytes: 3100
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    long[] as;
    foreach (i, a; readln.split.to!(long[])) as ~= a - i.to!long - 1;
    sort(as);
    long b;
    if (N%2 == 1) {
        b = as[N/2];
    } else {
        b = (as[N/2-1] + as[N/2]) / 2;
    }
    long s;
    foreach (a; as) s += abs(a - b);
    writeln(s);
}

Measured memory_bytes: 11608
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int op(int a,int b){return max(a,b);}
int e(){return 0;}
segtree<int,op,e> G(300001);
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vec A(n);
    rep(i,n) cin>>A[i];
    ll dp[n+1][2];
    dp[0][0]=0,dp[0][1]=0;
    rep(i,n){
        dp[i+1][0]=max(dp[i][0],dp[i][1]);
        dp[i+1][1]=G.prod(max((ll)0,A[i]-k),min((ll)300001,A[i]+k+1))+1;
        G.set(A[i],dp[i+1][1]);
    }
    cout<<max(dp[n][0],dp[n][1]);
}

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

int main(){
  int n;
  while(1){
    cin>>n;
    if(!n)break;
    int a,b;
    int apoint=0,bpoint=0;
    rep(i,n){
      cin>>a>>b;
      if(a==b){
	apoint+=a;
	bpoint+=b;
      }else if(a>b){
	apoint+=(a+b);
      }else{
	bpoint+=(a+b);
      }
    }
    cout<<apoint<<" "<<bpoint<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
n, m = map(int, input().split())
L1 = []
L2 = []
for _ in range(n):
    L1.append(list(map(int, input().split())))
for _ in range(m):
    L2.append(int(input()))
for i in range(n):
    temp = 0
    for j in range(m):
        temp += L1[i][j] * L2[j]
    print(temp)


Measured memory_bytes: 6008
/**
*    author:  Dooloper
*    created: 05.05.2020 20:40:04
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>


using namespace std;
typedef unsigned long long ll;
#define N 100010

int main() {
    cin.tie(0);
    int n,m,h[N],ma[N];
    cin>>n>>m;
    // cout<<n<<" "<<m;
    // vector<int> h(N);
    // vector<int> ma(N);
    int a,b;
    for(int i = 1; i <= n; i++){
        cin>>h[i];
        ma[i]=0;
    }
    for(int i = 0;i < m; i++){
        cin>>a>>b;
        ma[a] = max(ma[a],h[b]);
        ma[b] = max(ma[b],h[a]);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
            ans+=h[i]>ma[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

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

typedef complex<double> P;
struct Line : public vector<P>
{
  Line(P a=P(), P b=P()) {
    push_back(a); push_back(b);
  }
};
typedef Line Segment;

#define EPS (1e-7)

bool operator < (P const& a, P const& b) {
  return (a.real() != a.real()) ? a.real() < b.real() : a.imag() < b.imag();
}

double dot(P const& a, P const& b) {
  return real(conj(a)*b);
}

double cross(P const& a, P const& b) {
  return imag(conj(a)*b);
}

P projection_point(P const& a, P const& b, P const& c) {
  double k = dot(b-a, c-a) / norm(b-a);
  return a+k*(b-a);
}

P reflection_point(P const& a, P const& b, P const& c) {
  return c + 2.*(projection_point(a, b, c) - c);
}

bool is_parallel(Segment const& s, Segment const& t) {
  return abs(cross(s[1]-s[0], t[1]-t[0])) < EPS;
}

bool is_orthogonal(Segment const& s, Segment const& t) {
  return abs(dot(s[1]-s[0], t[1]-t[0])) < EPS;
}

int ccw(P a, P b, P c) {
  b -= a, c -= a;
  if(cross(b, c) > 0) return +1; // counter clockwise
  if(cross(b, c) < 0) return -1;  // clockwise
  if(dot(b, c) < 0) return +2;    // c-a-b
  if(norm(b) < norm(c)) return -2;  // a-b-c
  return 0; // on segment
}

bool is_intersect_ss(Segment s, Segment t) {
  return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0
         && ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

P crosspoint_ss(Segment s, Segment t) {
  P bline = t[1]-t[0];
  double d1 = abs(cross(bline, s[0]-t[0])), d2 = abs(cross(bline, s[1]-t[0]));
  return s[0] + d1/(d1+d2) * (s[1]-s[0]);
}

int main () {
  
  int q; cin >> q;
  for(;q--;) {
    Segment s, t;
    cin >> s[0].real() >> s[0].imag();
    cin >> s[1].real() >> s[1].imag();
    cin >> t[0].real() >> t[0].imag();
    cin >> t[1].real() >> t[1].imag();
    
    P p(crosspoint_ss(s, t));
    printf("%.10f %.10f\n", p.real(), p.imag());
  }
  
  return 0;
}

Measured memory_bytes: 1256