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

using namespace std;

#define ll long long
#ifdef __APPLE__
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif


int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll n;
    scanf("%lld", &n);
    vector<ll> a(n + 1, 1);
    for (ll i = 1; i <= n; ++i)
        scanf("%lld", &a[i]);
    if (a[n] != 2) return printf("-1\n"), 0;
    ll lo = 1, hi = 1;
    for (ll i = n; i > 0; --i) {
        ll plo = lo, phi = hi;
        ll le = plo * a[i], ri = (plo + 1) * a[i];
        le = (le + a[i - 1] - 1) / a[i - 1];
        ri = (ri + a[i - 1] - 1) / a[i - 1];
        lo = le;
        hi = ri - 1;
        le = phi * a[i], ri = (phi + 1) * a[i];
        le = (le + a[i - 1] - 1) / a[i - 1];
        ri = (ri + a[i - 1] - 1) / a[i - 1];
        lo = min(lo, le);
        hi = max(hi, ri - 1);
        if (lo > hi) return printf("-1\n"), 0;
    }
    printf("%lld %lld\n", lo, hi);

    
    return 0;
}      

Measured memory_bytes: 1024
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 B PIC 9(15).
        01 C PIC 9(15).
      	01 D PIC 9(15).
      	01 F PIC 9(15).
      	01 E PIC ZZZZZZZZZZZZ9.
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
        01 N PIC 9(15).
      
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT INP.
        	PERFORM VARYING temp1 FROM 1 BY 1
            UNTIL INP(temp1:1) = SPACE
        	END-PERFORM.
        	SUBTRACT 1 FROM temp1.
        	MOVE INP(1:temp1) TO A.
        	ADD 2 TO temp1.
        	PERFORM VARYING temp2 FROM temp1 BY 1
            UNTIL INP(temp2:1) = SPACE
        	END-PERFORM.
        	COMPUTE N = temp2 - temp1.
        	MOVE INP(temp1:N) TO B.
      		COMPUTE B = B + 3 * A.
      		COMPUTE B = B / 2.
      		MOVE B to E.
     		DISPLAY E.
		STOP RUN.

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

int n, a[2 * int(1e5)];
ll k;
vector <int> c;
bool mk[2 * int(1e5)];

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

    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i], --a[i];
        
    int v = 0;
    while (!mk[v] && k > 0) {
        mk[v] = 1;
        c.push_back(v);
        v = a[v];
        --k;
    }
    if (!k) {
        cout << v + 1 << "\n";
        return 0;
    }
    
    c.clear();
    for (int i = 0; i < n; ++i)
        mk[i] = 0;
        
    while (!mk[v] && k > 0) {
        mk[v] = 1;
        c.push_back(v);
        v = a[v];
        --k;
    }
    
    if (!k) {
        cout << v + 1 << "\n";
        return 0;
    }
    
    cerr << "k = " << k << "\n";
    cerr << "c = " << ll(c.size()) << "\n";
    
    k %= ll(c.size());
    cout << c[k] + 1 << "\n";
}


Measured memory_bytes: 5232
#include<bits/stdc++.h>
    using namespace std;
    typedef long long int lli;
    #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define PB push_back
    #define MP make_pair
    #define F first
    #define S second
    int dp[1000006];
    int b[1000006];
    int main()
    {      
        int n;
        cin>>n;
        int a[200005];
        int count=0;
        for(int i=0;i<n;i++)
        {
             cin>>a[i];
             b[a[i]]++;
        }
        for(int i=1;i<1000006;i++)
        {
            if(b[i]!=0)
            {
                for(int j=2*i;j<1000006;j+=i)
                {
                     dp[j]=1;
                }
            }
        }
        for(int i=0;i<n;i++)
        {    
            if(b[a[i]]>1)
            {
                continue;
            }
            if(dp[a[i]]==0)
            {
                count++;
            }
        }
        cout<<count;
        return 0;
    }

Measured memory_bytes: 12164
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		
		switch(S) {
		case "Sunny":
			System.out.println("Cloudy");
			break;
		case "Cloudy":
			System.out.println("Rainy");
			break;
		case "Rainy":
			System.out.println("Sunny");
			break;
		}
	}
}
		
	

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){

  int N;  cin >> N;

  string s;
  long long int mp[5] = {0};
  for(int i = 0;i < N;i++){
    cin >> s;
    if(s[0] == 'M')mp[0]++;
    if(s[0] == 'A')mp[1]++;
    if(s[0] == 'R')mp[2]++;
    if(s[0] == 'C')mp[3]++;
    if(s[0] == 'H')mp[4]++;
  }




  long long int ans = 0;

  for(int i = 0;i < 5;i++){
    for(int j = i + 1;j < 5;j++){
      for(int k = j + 1;k < 5;k++){
        ans += mp[i] * mp[j] * mp[k];
      }
    }
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
N = int(input())
L = []
for i in range(N):
  A = int(input())
  LA = []
  for j in range(A):
    LA.append(list(map(int,input().split())))
  L.append(LA)
from itertools import product
LL = list(product(range(2), repeat=N))
cnt = 0
for i in LL:
  flg = True
  for j in range(len(L)):
    #jの情報は、(hito=x, singi = y=1,0)
    #iの情報は、(singi = (1/0,...,1/0))
    for x,y in L[j]:
      #jさんの情報      
      #i[j] :sinngi　正解
      #y:sinngi　を変換
      if i[j]==1:
        if i[x-1]!=y:
          flg = False
          break
  if flg:
    cnt = max(cnt,sum(i))
print(cnt)

Measured memory_bytes: 8948
N=int(input())
S=input()
l=[0]*len(S)
for i in range(len(S)):
    if ord(S[i])+N<=90:
        l[i]=chr(ord(S[i])+N)
    else:
        l[i]=chr(ord(S[i])+N-26)
print(''.join(l))


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

int main() {
  int N;
  std::cin >> N;
  
  int i;
  int ans = 0;
  for (i = 0; i < N; i++){
    int a, b;
    std::cin >> a >> b;
    
    ans += (b - a) + 1;
  }
  std::cout << ans << std::endl;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    int ans = a*b;
    if(ans%2==0){
        cout<<"Even\n";
    }else{
        cout<<"Odd\n";
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class P
{
    static void Main(string[] args)
    {
        int[] HW = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int[][] energyTable = new int[10][];
        int[][] wall = new int[HW[0]][];
        for (int i = 0; i < 10; i++) energyTable[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        for (int i = 0; i < HW[0]; i++) wall[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        bool b = true;
        while (b)
        {
            b = false;
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        if (energyTable[i][j] > energyTable[i][k] + energyTable[k][j])
                        {
                            b = true;
                            energyTable[i][j] = energyTable[i][k] + energyTable[k][j];
                        }
                    }
                }
            }
        }

        int res = 0;
        for (int i = 0; i < HW[0]; i++)
        {
            for (int j = 0; j < HW[1]; j++)
            {
                res += wall[i][j] != -1 ? energyTable[wall[i][j]][1] : 0;
            }
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 15444
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf

const int MAXN = 105000;
const int BITS = 40;

int n;
long long mx;
long long a[MAXN];
int oneCount[45];
long long dp[45][2];

int getBit(long long x, int pos) {
  return (x & (1ll << pos)) > 0 ? 1 : 0;
}

int main() { 

  scanf("%d %lld", &n, &mx);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }

  for (int i = 0; i <= BITS; i++) {
    for (int j = 0; j < n; j++) {
      if (a[j] & (1ll << i)) {
        oneCount[i]++;
      }
    }
  }

  memset(dp, -1, sizeof(dp));
  dp[BITS + 1][0] = 0;

  for (int i = BITS + 1; i >= 1; i--) {
    int mxBit = getBit(mx, i - 1);
    for (int less = 0; less <= 1; less++) {
      if (dp[i][less] == -1) {
        continue;
      }
      // cerr << i << " " << less << " " << dp[i][less] << endl;
      for (int nextBit = 0; nextBit <= 1; nextBit++) {
        if (!less && nextBit > mxBit) {
          continue;
        }
        bool newLess = less | (nextBit < mxBit);
        long long match = (nextBit == 0) ? oneCount[i - 1] : n - oneCount[i - 1];
        // cerr << match << endl;
        dp[i - 1][newLess] = max(dp[i - 1][newLess], dp[i][less] + (1ll << (i - 1)) * match);
      }
    }
  }

  long long ans = max(dp[0][1], dp[0][0]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  //ツ素ツ青板青カツ青ャ
  const int NUM = 10001;
  bool prime[NUM];
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<NUM;i++)
    prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

  int maxtwin[10001],twin;
  for(int i=5;i<10001;i++){
    if(prime[i]&&prime[i-2])twin = i;
    maxtwin[i]=twin;
  }
  for(int n;cin>>n,n;){
    cout<<maxtwin[n]-2<<" "<<maxtwin[n]<<endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  float ans,A;
  int i;
  for(i=0;i<N;i++){
    cin >> A;
    ans+=1/A;
  }
  ans=1/ans;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define MAXN 1000010

int n,h;
int g[MAXN],nume;
int p[MAXN][2],nump;
int d[MAXN],size[MAXN],sd[MAXN][2];
bool tag[MAXN];
int f[MAXN];

int getf(int x){
	if(f[x]==x) return x;
	return f[x]=getf(f[x]);
}

int main(){
#ifdef DEBUG
	freopen("E.in","r",stdin);
#endif
	for(int i=1;i<MAXN;i++) f[i]=i;
	memset(g,-1,sizeof g);
	scanf("%d%d",&n,&h);
	for(int i=1;i<=h;i++) p[i][0]=++nump;
	for(int i=1;i<=h;i++) p[i][1]=++nump;
	for(int i=1;i<=n;i++){
		int t1,t2,t3,t4,u,v;
		scanf("%d%d%d%d",&t1,&t2,&t3,&t4);
		if(!t3) u=p[t1][1];
		else u=p[t3][0];
		if(!t4) v=p[t2][0];
		else v=p[t4][1];
		if(getf(u)^getf(v)) f[f[u]]=f[v];
		d[u]--;
		d[v]++;
		tag[u]=tag[v]=1;
	}
	for(int i=1;i<=n;i++) 
		if(d[p[i][0]]<0 || d[p[i][1]]>0){
			puts("NO");
			return 0;
		}
	for(int i=1;i<=nump;i++){
		size[getf(i)]++;
		if(d[i]<0) sd[getf(i)][0]+=-d[i];
		else sd[getf(i)][1]+=d[i];
		if(tag[i]) tag[getf(i)]=1;
	}
	int numc=0;
	int s0=0,s1=0;
	for(int i=1;i<=nump;i++)
		if(getf(i)==i && tag[i]){
			if(!sd[i][0] && !sd[i][1]){
				puts("NO");
				return 0;
			}
			s0+=sd[i][0];
			s1+=sd[i][1];
			numc++;
		}
	if(s0^s1){
		puts("NO");
		return 0;
	}
	if(s0<numc-1){
		puts("NO");
		return 0;
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 18048
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		if (a + b >= c)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 24276
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
 int a,b,c;
 cin >> a >> b >> c;
 if (c<=b) cout << "delicious" << endl;
 else if (c<=b+a) cout << "safe" << endl;
 else cout << "dangerous" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  	string str;
  	cin>>str;
  	int size = str.size();
  	if(size == 0) {
    	cout<<"No";
      	return 0;
    }
  	for(int i=0;i<size;i++) {
    	if(i%2==0 && (str[i]=='R' || str[i]=='U' || str[i]=='D'))
          continue;
      	else if(i%2!=0 && (str[i]=='L' || str[i]=='U' || str[i]=='D'))
          continue;
      	else {
        	cout<<"No";
          	return 0;
        }
    }
  	cout<<"Yes";
	return 0;
}


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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))

int main() {
    int n;
    int x = 0, y = 0, z = 0;
    int yen;
    bool success = false;
    
    cin >> n >> yen;
    
    for(x = 0; x <= n; x++) {
        for(y = 0; y <= n; y++) {
            z = n - (x + y);
            if((x * 10000 + y * 5000 + z * 1000) == yen && z >= 0 && (x + y + z) == n) {
                success = true;
                break;
            }
        }
        if(success) {
            break;
        }
    }
    if(x == n + 1 && y == n + 1) {
        x = y = z = -1;
    }
    cout << x << " " << y  << " " << z << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

#define N 50

static
int map[ N ][ N ];
static
int w, h;

int dfs (
  int x,
  int y
  )
{
  if ( x < 0 || x >= w
    || y < 0 || y >= h )    return ( 0 );
  if ( map[ x ][ y ] == 0 ) return ( 0 );

  map[ x ][ y ] = 0;
  dfs ( x - 1, y - 1 );
  dfs ( x - 1, y );
  dfs ( x - 1, y + 1 );
  dfs ( x, y - 1 );
  dfs ( x, y + 1 );
  dfs ( x + 1, y - 1 );
  dfs ( x + 1, y );
  dfs ( x + 1, y + 1 );

  return ( 1 );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    int x, y;
    int res = 0;

    scanf ( "%d%d", &w, &h );
    if ( !( w | h ) ) break ;

    for ( y = 0; y < h; ++y )
    for ( x = 0; x < w; ++x )
    {
      scanf ( "%d", &map[ x ][ y ] );
    }

    for ( y = 0; y < h; ++y )
    for ( x = 0; x < w; ++x )
    {
      res += dfs ( x, y );
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main() {
    long long int n, k;
    cin>>n>>k;
    long long int mind=n%k;
    long long int diff=n%k;
    while(!(diff>mind))
    {
        diff = abs(diff-k);
        if(diff<mind) mind = diff;
    }
    cout<<mind;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  int ans1=a<=b?a:b;
  int ans2=c<=d?c:d;
  cout<<ans1+ans2<<endl;
  return 0;
}


Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
P = []
for i in range(min(3000, X)):
    for j in range(min(3000//(i+1) + 1, Y)):
        for z in range(min(3000//(i+1)//(j+1) +1, Z) ):
            P.append(A[i]+B[j]+C[z])
P.sort(reverse=True)
for i in range(K):
    print(P[i])

Measured memory_bytes: 81348
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#include <limits.h>
#include <math.h>

int a, b, c, available;

int main() {
	scanf("%d %d %d %d", &a, &b, &c, &available);

	if(abs(a - b) <= available && abs(b - c) <= available) {
		printf("Yes\n");
	}
	else if(abs(a - c) <= available) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

    int a = 0,b = 0;
    
    scanf("%d %d",&a,&b);
    
    if(a > b){
        printf("a > b\n");
    }else if(a < b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}
// http://drken1215.hatenablog.com/entry/2018/09/09/015414
int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> A(H, vector<char>(W));
    //移動する過程で、駒が常に右または下に動いていた可能性があるか判定してください。
    ll cnt = 0LL;
    REP(i, H) {
        REP(j, W) {
            cin >> A[i][j];
            if(A[i][j] == '#') {
                cnt++;
            }
        }
    }
    if(cnt >= H + W) {
        cout << "Impossible" << endl;
    } else {
        cout << "Possible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
x = int(input())

def search(num, x):
    res = 0
    a_ = 0
    b = 0
    for a in range(num):
        a_ = a
        b = num-a
        if a**5 - b**5 == x:
            res = 1
            break
        elif a**5 + b**5 == x:
            b = -b 
            res = 1
            break
    return a_, b ,res 

for i in range(555555):
    a, b, res = search(i,x)
    if res == 1:
        break

print("{} {}".format(a, b))

Measured memory_bytes: 9208
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
h = [0]*n
p = []

for i in reversed(range(n)):
    k = i+1
    if k > n/2:
        h[i] = a[i]
        if a[i] == 1:
            p.append(k)
        continue
    s = 0
    for j in range(1,n//k):
        s += h[k*(j+1)-1]
    s %= 2
    if s != a[i]:
        h[i] = 1
        p.append(k)

t = len(p)

print(t)

if t != 0:
    print(' '.join([str(u) for u in p]))

Measured memory_bytes: 74744
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
struct node 
{
	int x,d,id;
}robot[200010];
priority_queue<node> q;
queue<node> q1;
int cnt,to[200010],nxt[200010],head[200010],n,ans,fa[200010];
long long tot[200010];
bool operator < (node a,node b)
{
	return a.x>b.x;
}
void adde(int x,int y)
{
	to[++cnt]=y;
	nxt[cnt]=head[x];
	head[x]=cnt;
}
void work(int u)
{
	tot[u]=1;
	long long sum=1;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(!v)
		{
			continue;
		}
		work(v);
		sum=(sum*tot[v])%mod;
	}
	tot[u]+=sum;
}
bool cmp(node a,node b)
{
	return a.x==b.x?a.d<b.d:a.x<b.x;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&robot[i].x,&robot[i].d);
		robot[i].id=i;
	}
	sort(robot+1,robot+n+1,cmp);
	for(int i=n;i>=1;i--)
	{
	    while(!q.empty())
		{
			node u=q.top();
			if(u.x<robot[i].x+robot[i].d)//看题目描述，这里不能取等 
			{
				adde(robot[i].id,u.id);
				fa[u.id]=robot[i].id;
				q.pop();
			}else{
				break;
			}
		} 
		q.push(robot[i]);
	}
	while(!q.empty())
	{
		node u=q.top();
		work(u.id);
		q.pop();
		q1.push(u);
	}
	ans=1;
	while(!q1.empty())
	{
		ans=(1ll*ans*tot[q1.front().id])%mod;
		q1.pop();
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <limits>
 
using namespace std;
 
typedef long long ll;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '

const int MAXN = 200;
//ll a[MAXN], ST[MAXN * 4], LZ[MAXN*4];

/*bool perfectSquare(ll x){
    ll s = sqrt(x);
    if(s *s == x) return true;
    else return false;
}*/

int main() { 
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    auto res = unique(s.begin(), s.end());
    int index = 0;
    for(char a = 'a'; a <= 'z'; ++a){
        if(s[index] != a){
            cout << a << endl;
            return 0;
        }
        ++index;
    }
    cout << "None" << endl;
  
    return 0; 
} 


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

int main()
{
    int n;
    cin >> n;
    set<string> ss;
    map<string, int> mp;
    string s;
    int mx = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        ss.insert(s);
        mp[s]++;
        mx = max(mx, mp[s]);
    }
    auto ptr = ss.begin();
    while (ptr != ss.end())
    {
        if (mp[*ptr] == mx) cout << *ptr << endl;
        ptr++;
    }
}

Measured memory_bytes: 34560
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,x=0;string A,B,C;
  cin>>N>>A>>B>>C;
  for(int i=0;i<N;i++){
    char a=A.at(i),b=B.at(i),c=C.at(i);
    if(a==b){if(a!=c)x++;}
    else{
      if(a==c||b==c)x++;
      else x+=2;
    }
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(2)]
    count = 0
    for i in range(N):
        count = max(sum(A[0][0:i+1]) + sum(A[1][i:N]), count)
    print(count)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
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();}
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;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,M;
  cin>>N>>M;
  ll X[N],Y[M];
  REP(i,N) cin>>X[i];
  REP(i,M) cin>>Y[i];
  
  ll SUMX=0,SUMY=0;
  REP(i,N) SUMX=(SUMX+i*X[i]-(N-i-1)*X[i])%MOD;
  REP(i,M) SUMY=(SUMY+i*Y[i]-(M-i-1)*Y[i])%MOD;
  
  ll ans=SUMX*SUMY;
  ans=(ans%MOD+MOD)%MOD;
  co(ans);
  return 0;
}

Measured memory_bytes: 5244
#include <stdio.h>

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

	int T[100];
	int i;
	int sum = 0;
	for(i = 0; i < N; i++) {
		scanf("%d", &T[i]);
		sum += T[i];
	}

	int M;
	scanf("%d", &M);

	int P[100], X[100];
	for(i = 0; i < M; i++)
		scanf("%d %d", &P[i], &X[i]);

	for(i = 0; i < M; i++)
		printf("%d\n", sum - T[P[i] - 1] + X[i]);

	return 0;
}

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


class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();

        var ret = "";
        if (s == "Sunny") ret = "Cloudy";
        if (s == "Cloudy") ret = "Rainy";
        if (s == "Rainy") ret = "Sunny";

        Console.Write(ret);
    }
}




Measured memory_bytes: 11092
#include <stdio.h>
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;
for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}

Measured memory_bytes: 2472
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i > 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

  int m[9][9] = {
    {0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0}
  };
  
  char a, b;
  int n, ai, bi;
  string ns;
  REP(i, N){
    n = i + 1;
    if (n < 10) {
      m[i][i]++;
      continue;
    }
    if (n % 10 == 0) continue;
    
    ns = to_string(n);
    a = ns[0];
    b = ns[ns.size()-1];
    ai = a - '0' - 1;
    bi = b - '0' - 1;
    
    m[ai][bi]++;
  }
  
  int r = 0;
  REP(i, 9){
    FOR(j, i, 9) {
      r += m[i][j] * m[j][i] * (i == j ? 1 : 2);
    }
  }
    
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mp make_pair
#define pb push_back

void solve(){
    // Solve here
    int a, b, c;
    cin>>a>>b>>c;

    int ans = c*b;

    if(ans >= a) cout<<"Yes\n";
    else cout<<"No\n";
}

int main() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main(){

  int N;
  cin >> N;
  int A[N];
  REP(i, 0, N)
    cin >> A[i];


  long double sum = 0;
  REP(i, 0, N)
    sum += ((long double)1 / (long double)A[i]);

  cout << setprecision(100) << (long double)1 / sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  double a,b,x;
  cin >> a >> b >> x;
  double PI = acos(-1);
  double ans;
  if(2.0*x > a*a*b){
    double h = x /(a*a);
    double c = atan2(2.0*b-2.0*h,a);
    ans = c * 180.0 / PI;
  }else{
    double c = atan2(b,2.0*x/(a*b));
    ans = c * 180.0 / PI;
  }
  fix10;
  cout << ans << endl;
}


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

using namespace std;

int main() {
	long long x;
	cin >> x;
	long long res = (x / 500) * 1000L;
	x = x - (x / 500 * 500);
	res += (x / 5) * 5L;
	cout << res << '\n';
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int q;
  cin >> q;
  string t;
  rep(i,q) {
    int x;
    cin >> x;
    if(x==1) swap(s,t);
    else {
      int f;
      char c;
      cin >> f >> c;
      if(f==1) t += c;
      else s += c;
    }
  }
  reverse(t.begin(),t.end());
   t += s;
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 1128
#include<stdio.h>
int main()
{
		int a[10000],i,x,max,min,n,b;
		long long sum;
		max=-1000000;
		min=1000000;
		sum=0;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
				if(max<a[i]){
				max=a[i];
				}
				if(min>a[i]){
				min=a[i];
				}
				sum+=a[i];
		}
		printf("%d %d %lld\n",min,max,sum);
		return 0;
}


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

int main(){
  int w, h, pat[1002][1002] = {{}};
  int x1, x2, y1, y2;

  pat[1][1] = 1;
  for(int i = 1; i < 1002; i++){
    for(int j = 1; j < 1002; j++){
      if(i != 1 || j != 1) (pat[i][j] = pat[i - 1][j] + pat[i][j  - 1]) %= 100000007;
    }
  }

  cin >> w >> h >> x1 >> y1 >> x2 >> y2;

  int diffx = abs(x2 - x1), diffy = abs(y2 - y1);
  diffx = min( diffx, w - diffx), diffy = min( diffy, h - diffy);

  int weight = (1 + (w % 2 == 0 && w / 2 == diffx)) * (1 + (h % 2 == 0 && h / 2 == diffy));
  cout << (weight * pat[++diffx][++diffy]) % 100000007 << endl;

  return(0);
}

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

int main() {
	int64_t a, b, c;
	cin >> a >> b >> c;
	if (c - b - a > 0 && 4 * a * b < (c - b - a) * (c - b - a)) {
		puts("Yes");
	}
	else {
		puts("No");
	}
	return 0;
}

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

int a[1000][1000], H, W, h, w;
int main(void) {
  scanf("%d%d%d%d", &H, &W, &h, &w);
  if ((H%h == 0) && (W%w == 0)) {printf("No\n"); return 0;}
  printf("Yes\n");
  a[0][0]= (H/h)*(W/w) + 1;
  a[h - 1][w - 1] = -a[0][0] - 1;
  for (int i =0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      printf("%d ",a[i%h][j%w]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2048
import fractions
N=int(input())

vt=va=0
for _ in range(N):
  T,A=map(int,input().split())
  kt=-(-vt//T)
  ka=-(-va//A)
  if kt==0 and ka==0:
    vt=T
    va=A
  else:
    k=max(kt,ka)
    vt=k*T
    va=k*A
  
  #print(vt,va)
  
print(vt+va)

Measured memory_bytes: 5052
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	long double a,b,h,m;
	cin>>a>>b>>h>>m;
	long double A=h*30.0+m/2.0;
	long double B=6.0*m;
	long double now=double(abs(A-B));
	if(now>=180.0){
		now=360.0-now;
	}
	now=now*2.0*M_PI/360.0;
	now= double(cos( now));
    long double ans=a*a+b*b-2.0*a*b*now;
	ans=sqrt(ans);
	cout <<printf("%.10Lf",ans);
	// your code goes here
	return 0;
}

Measured memory_bytes: 4176
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
	
	int satu;
	scanf ("%d",&satu);
	if (satu >= 0 && satu<= 111){
		printf ("111\n");
	}
	else if (satu > 111 && satu<=222){
		printf ("222\n");
	}
	else if (satu > 222 && satu<=333){
		printf ("333\n");
	}
	else if (satu > 333 && satu<=444){
		printf ("444\n");
	}
	else if (satu > 444 && satu<=555){
		printf ("555\n");
	}
	else if (satu > 555 && satu<=666){
		printf ("666\n");
	}
	else if (satu > 666 && satu<=777){
		printf ("777\n");
	}
	else if (satu > 777 && satu<=888){
		printf ("888\n");
	}
	else if (satu > 888 && satu<=999){
		printf ("999\n");
	}
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
            while(true){
                int n = sc.nextInt();
                if(n==0){break;}
                int[]scores=new int[n];
                for(int i = 0; i<scores.length;i++){
                    scores[i]=sc.nextInt();
                }
                double average = 0, variance = 0, sum = 0, SUM = 0;
                for(int j = 0; j<scores.length;j++){
                    sum += scores[j];
                }
                average = sum/scores.length;
                for(int k = 0; k<scores.length;k++){
                    SUM += (scores[k]-average)*(scores[k]-average);
                }
                variance = SUM/scores.length;
                System.out.println(Math.sqrt(variance));

            }
        }
    }
}


Measured memory_bytes: 31276
#include<iostream>
using namespace std;
int main(){
  int h,w;
  while(cin >> h >> w && h||w){
    for(int j=0;j<w;j++) cout << "#";
    cout << endl;
    for(int i=1;i<h-1;i++){
      cout << "#";
      for(int j=1;j<w-1;j++) cout << ".";
      cout << "#" << endl;
    }
    for(int j=0;j<w;j++) cout << "#";
    cout << endl << endl;
  }
}


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


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int               long long
#define endl              '\n'
#define ff                first
#define ss                second
#define pb                push_back
#define vii               vector<int> 
#define pii               pair<int,int>
#define loop(i,s,e)       for(int i=s;i<e;i++)
#define mset(a,f)         memset(a,f,sizeof(a))
#define fastio            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 107, inf = 1e18;
int n, W;
pii arr[N];
int  dp[N][100007];

int getval(int it, int v)
{            
      if( v == 0 ) return 0;
      if( v < 0 || it == 0 ) return inf;  
      if( dp[it][v] != -1 ) return dp[it][v];
      int a = inf , b = inf;
      a = arr[it].ff + getval(it - 1, v - arr[it].ss);
      b = getval(it - 1, v);
      return dp[it][v] = min(a,b);
}

int32_t main() {
    fastio;
    
      cin >> n >> W;
      loop(i,1,n+1)  cin >> arr[i].ff >> arr[i].ss;
      mset(dp,-1);
      int ans = 0;
      for(int v = 100001; v>=0 ; v--){
			 if( getval(n,v) <= W ) 
             {
               ans = v;
               break;
             }
      }
      cout << ans << endl; 

}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //















Measured memory_bytes: 83968
#include <cstdio>
#include <cstring>
#include <algorithm>
const int N = 100005;
const int R = 16;
const int _R = 1 << R;
int n, head[N], cnt[R], dp[_R], tot, x, y, z, ans;
struct edge { int to, nxt, cost; } e[N << 1];
void addedge(int x, int y, int z) {
	e[++tot] = (edge) { y, head[x], z }; head[x] = tot;
	e[++tot] = (edge) { x, head[y], z }; head[y] = tot;
}
void dfs(int x, int f = -1) {
	int v = 0; for (int i = head[x]; i; i = e[i].nxt) v ^= e[i].cost; cnt[v]++;
	for (int i = head[x]; i; i = e[i].nxt) if (e[i].to != f) dfs(e[i].to, x);
}
int main() {
	std::scanf("%d", &n);
	for (int i = 1; i < n; i++) std::scanf("%d%d%d", &x, &y, &z), addedge(x, y, z); 
	dfs(0);
	int v = 0;
	for (int i = 1; i < R; i++) ans += cnt[i] >> 1, cnt[i] &= 1, v |= cnt[i] << i;
	std::memset(dp, 0x3f, sizeof dp);
	dp[0] = 0;
	for (int i = 2; i < _R; i += 2) {
		int v = 0; for (int t = 0; t < 16; t++) if (i >> t & 1) v ^= t;
		if (v) continue;
		dp[i] = __builtin_popcount(i) - 1;
		for (int j = (i - 1) & i; j; j = (j - 1) & i)
			dp[i] = std::min(dp[i], dp[j] + dp[i - j]);
	}
	std::printf("%d\n", dp[v] + ans);
	return 0;
}

Measured memory_bytes: 6144
from collections import Counter
from functools import reduce
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


n = IS()
print('Yes') if int(n) % sum([int(x) for x in n]) == 0 else print('No')


Measured memory_bytes: 5640
object Main extends App {
  val sc = new FastScanner(System.in)
  val n, q = sc.nextInt()
  val c = Array.fill(n)(sc.nextInt()-1)
  val lr = List.fill(q)((sc.nextInt()-1, sc.nextInt()-1))
  val ans = Array.fill(q)(0)

  val pos = Array.fill(n)(-1)
  val bit = new BinaryIndexedTree(n)
  var lPrev = n

  for (((l, r), idx) <- lr.zipWithIndex.sortBy(-_._1._1)) {
    for (i <- lPrev-1 to l by -1) {
      val ci = c(i)
      val p = pos(ci)
      pos(ci) = i
      if (p != -1) {
        bit.add(p, -1)
      }
      bit.add(i, 1)
    }
    lPrev = l
    ans(idx) = bit.query(r+1)
  }

  val pw = new java.io.PrintWriter(Console.out)
  ans.foreach(pw.println)
  pw.flush()
}

class BinaryIndexedTree(n: Int) {
  private val tree = Array.fill(n+1)(0)

  def query(r: Int): Int = {
    var res = 0
    var i = r
    while (i > 0) {
      res += tree(i)
      i -= i & -i
    }
    res
  }

  def add(idx: Int, a: Int): Unit = {
    var i = idx+1
    while (i <= n) {
      tree(i) += a
      i += i & -i
    }
  }
}

class FastScanner(source: java.io.InputStream) {
  val buf = new Array[Byte](1024)
  var now, end = 0

  def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126
  def isNum(b: Byte): Boolean = 48 <= b && b <= 57

  def hasNextByte: Boolean = {
    if (now < end) {
      true
    } else {
      now = 0
      end = source.read(buf)
      end > 0
    }
  }

  def nextByte(): Byte = {
    if (hasNextByte) {
      val b = buf(now)
      now += 1
      b
    } else {
      -1
    }
  }

  def hasNext: Boolean = {
    while (hasNextByte && !isPrintable(buf(now))) {
      now += 1
    }
    hasNextByte
  }

  def next(): String = {
    if (hasNext) {
      val sb = new StringBuilder()
      var b = nextByte()
      while (isPrintable(b)) {
        sb += b.toChar
        b = nextByte()
      }
      sb.toString
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextInt(): Int = {
    nextLong().toInt
  }

  def nextLong(): Long = {
    if (hasNext) {
      var b = nextByte()
      var sign = 1
      var n = 0L
      if (b == '-') {
        sign = -1
        b = nextByte()
      }
      while (isNum(b)) {
        n = n * 10 + (b - 48)
        b = nextByte()
      }
      sign * n
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextDouble(): Double = next().toDouble
}


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

int f(int n){
 if(n % 2 == 0) return n / 2;
  else return 3 * n + 1;
}

int main(void){
  int N, A, B;
  cin >> N;
  if(N == 1) cout << "Hello World";
  else {
    cin >> A >> B;
    cout << A + B;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;
const int N=64,mod=1e9+7;

ll dp[N][N][N];
ll d[N][N][N];
ll a[N][N];
int32_t main(){
    ll n,k;
    cin >> n >> k;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++){
            cin >> a[i][j];
            if (a[i][j]){
                dp[i][j][0]=1;
            }
        }
    }
    vector <int> b;
    while(k>0){
        b.pb(k%2);
        k/=2;
    }
    for (int m=1;m<=b.size();m++){
        for (int i=1;i<=n;i++){
            d[i][i][b.size()]=1;
            for (int j=1;j<=n;j++){

                /// dp[i][j][m];
                for (int l=1;l<=n;l++){
                    dp[i][j][m]+=dp[i][l][m-1]*dp[l][j][m-1]%mod;
                    dp[i][j][m]%=mod;
                }
                //cout << i << " " << j << " " << m << " " << dp[i][j][m] << endl;
            }
        }
    }
    for (int m=b.size()-1;m>-1;m--){
        for (int i=1;i<=n;i++){
                for (int j=1;j<=n;j++){
                    if (b[m]==0){
                        d[i][j][m]=d[i][j][m+1];
                       // cout << 2 << endl;
                        continue;
                    }
                    for (int l=1;l<=n;l++){
                        d[i][j][m]+=dp[i][l][m]*d[l][j][m+1]%mod;
                        d[i][j][m]%=mod;
                    }
                    //cout << i << " " << j << " " << m << " " << d[i][j][m] << endl;

                }
        }
    }
    ll ans=0;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++){
            ans+=d[i][j][0];
            ans%=mod;
        }
    }
    cout << ans;
}




























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

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int num[] = new int [7];
		int cnt = in.nextInt();
		for(int i = 0;i < cnt;i++){
			double a = in.nextDouble();
			if(a < 165.0){
				num[1]++;
			}else if(a >= 165.0 && a < 170.0){
				num[2]++;
			}else if(a >= 170.0 && a < 175.0){
				num[3]++;
			}else if(a >= 175.0 && a < 180.0){
				num[4]++;
			}else if(a >= 180.0&& a < 185.0){
				num[5]++;
			}else if(a >= 185.0){
				num[6]++;
			}
		}
		for(int i = 1;i < 7;i++){
			System.out.print(i+":");
			for(int j = 0;j < num[i];j++){
				System.out.print("*");
			}
			System.out.println();
		}
	}
}

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

double ans[100010];

double dp[110];
double tmp[110];
double rate[110];


void solve(){
	
	rate[0]=1.0;
	for(int i=1;i<110;i++){
		rate[i]=rate[i-1]*0.5;
	}
	
	dp[0]=1.0;
	for(int i=1;i<=100000;i++){
		ans[i]+=ans[i-1];
		for(int j=0;j<100;j++){
			tmp[0]+=((1.0-rate[j])*dp[j]);
			tmp[j+1]=(rate[j]*dp[j]);
			ans[i]+=(rate[j]*dp[j]);
		}
		for(int j=0;j<110;j++){
			dp[j]=tmp[j];
			tmp[j]=0.0;
		}
	}
	
	
	
}

int main(){
	
	solve();
	
	for(int n;;){
		cin>>n;
		if(n==0)break;
		printf("%.8f\n",ans[n]);
	}
	
	return 0;
}


Measured memory_bytes: 1976
import sys
import fractions

dp = None
A = []

def lcm(a, b):
    return a * b // fractions.gcd(a, b)

def f(m):
    ans = 0
    for a in A:
        ans += m % a
    return ans

def main():
    global A

    N = int(input())
    A = [int(_) for _ in input().split()]

    lcmtemp = 1

    for a in A:
        lcmtemp = lcm(lcmtemp, a)

    print(f(lcmtemp-1))

main()


Measured memory_bytes: 5332
import math
N,D=map(int,input().split())
L=[list(map(int,input().split())) for i in range(N)]
ans=0
for n in range(N):
	for n2 in range(n+1,N):
		tmp=0
		for d in range(D):
			tmp+=abs(L[n][d]-L[n-n2][d])**2
		if math.sqrt(tmp) % 1 == 0:
			ans+=1
print(ans)

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

int main() {
  int a,b; cin>>a>>b;
  int res=-1;
  for (int i=1; i<1000000; i++) {
    int tmp1=8*i/100;
    int tmp2=i/10;
    if (tmp1==0&&tmp2==0) continue;
    if ((tmp1==a)&&(tmp2==b)) {
      res=i;
      break;
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
    ll n,k,q;cin>>n>>k>>q;
    vector<ll> v(n,0);
    rep(i,q){
        ll a;cin>>a;a--;
        v[a]++;
    }

    rep(i,n){
        if(v[i]>q-k){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 1408
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt(), k = scanner.nextInt() - 1;
			long[][] dp = new long[h + 1][w];
			dp[0][0] = 1L;
			long[] factorial = new long[w], revFactorial = new long[w];
			factorial[0] = 1L;
			IntStream.range(1, w).forEach(i -> factorial[i] = factorial[i - 1] * i % MOD);
			revFactorial[w - 1] = modPow(factorial[w - 1], MOD - 2);
			IntStream.range(0, w - 1).map(i -> w - 2 - i)
					.forEach(i -> revFactorial[i] = revFactorial[i + 1] * (i + 1) % MOD);
			IntStream.rangeClosed(1, h).forEach(i -> IntStream.range(0, w).forEach(j -> {
				dp[i][j] += dp[i - 1][j] * calc(j, factorial, revFactorial) % MOD
						* calc(w - 1 - j, factorial, revFactorial) % MOD;
				dp[i][j] %= MOD;
				if (j > 0) {
					dp[i][j] += dp[i - 1][j - 1] * calc(j - 1, factorial, revFactorial) % MOD
							* calc(w - 1 - j, factorial, revFactorial) % MOD;
					dp[i][j] %= MOD;
				}
				if (j < w - 1) {
					dp[i][j] += dp[i - 1][j + 1] * calc(j, factorial, revFactorial) % MOD
							* calc(w - 2 - j, factorial, revFactorial) % MOD;
					dp[i][j] %= MOD;
				}
			}));
			System.out.println(dp[h][k]);
		}
	}

	/**
	 * ( n_C_0 + (n-1)_C_1 + ... + (n/2)_C_(n/2) ) mod MODを計算する
	 * 
	 * @param n
	 * @param factorial    階乗の配列
	 * @param revFactorial 逆階乗の配列
	 * @return ( n_C_0 + (n-1)_C_1 + ... + (n/2)_C_(n/2) ) mod MOD
	 */
	private static long calc(int n, long[] factorial, long[] revFactorial) {
		long result = 0L;
		for (int i = 0; i <= n / 2; i++) {
			result += factorial[n - i] * revFactorial[i] % MOD * revFactorial[n - 2 * i] % MOD;
			result %= MOD;
		}
		return result;
	}

	/**
	 * n^m mod MODを計算する
	 * 
	 * @param n
	 * @param m
	 * @return n^m mod MOD
	 */
	private static long modPow(long n, long m) {
		long result = 1L;
		while (m > 0) {
			if (1 == (m & 1)) {
				result = result * n % MOD;
			}
			n = n * n % MOD;
			m >>= 1;
		}
		return result;
	}
}


Measured memory_bytes: 36528
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	map<string, int> s;
	rep(i, n){
		string in;
		cin >> in;
		s[in]++;
	}
	
	int m;
	map<string, int> t;
	cin >> m;
	rep(i, m){
		string in;
		cin >> in;
		t[in]++;
	}
	int ans = 0;
	for(auto p : s){
		int a_ = p.second;
		a_ -= t[p.first];
		ans = max(ans, a_);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]
ans = [[0] * (w) for _ in range(h)]

dx = [-1, 0, 1, -1, 1, -1, 0, 1]
dy = [-1, -1, -1, 0, 0, 1, 1, 1]


for i in range(h):
    for j in range(w):
        if S[i][j] == "#":
            for k in range(8):
                nx = j + dx[k]
                ny = i + dy[k]
                if nx < 0 or nx >= w:
                    continue
                if ny < 0 or ny >= h:
                    continue
                ans[ny][nx] += 1

for i in range(h):
    for j in range(w):
        if S[i][j] == "#":
            ans[i][j] = "#"

for i in range(h):
    print(*ans[i], sep="")


Measured memory_bytes: 3572