akhauriyash/Code-Regression huggingface dataset:
/*  ex3_3
    kosaq       */

#include <stdio.h>

int main(void){
    int number;    //the number of N
    int k_base;    //the number of K
    int count;    //count how many times it looped

    count = 0;
    scanf("%d" "%d", &number, &k_base);    //input N and K

    while(number > 0){
        number = number / k_base;    //devide N by K
        count++;    //add 1 to count
    }
    printf("%d\n", count);    //output count
    return 0;
}

Measured memory_bytes: 128
#include <deque>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, sy, sx, gy, gx;
  cin >> h >> w >> sy >> sx >> gy >> gx;
  sy--, sx--, gy--, gx--;
  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  deque<pair<int, int>> q;
  q.push_front({sy, sx});
  vector<vector<int>> cost(h, vector<int>(w, -1));
  cost[sy][sx] = 0;
  int dy[4] = {1, -1, 0, 0}, dx[4] = {0, 0, 1, -1};
  while (!q.empty()) {
    auto p = q.front();
    q.pop_front();
    int y = p.first, x = p.second;
    for (int i = 0; i < 4; i++) {
      int ny = y + dy[i];
      int nx = x + dx[i];
      if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
      if (cost[ny][nx] != cost[y][x] && a[ny][nx] == '.') {
        q.push_front({ny, nx});
        cost[ny][nx] = cost[y][x];
      }
    }
    for (int i = -2; i <= 2; i++) {
      for (int j = -2; j <= 2; j++) {
        int ny = y + i, nx = x + j;
        if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
        if (cost[ny][nx] == -1 && a[ny][nx] == '.') {
          q.push_back({ny, nx});
          cost[ny][nx] = cost[y][x] + 1;
        }
      }
    }
  }
  cout << cost[gy][gx] << '\n';
  return 0;
}

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

using namespace std;
int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("inputf.in", "r", stdin);
    //freopen("outputf.in", "w", stdout);int i;
    //#endif
    int n;
    int temp;
    int flag=0;
    cin>>n;
    while(n!=0)
    {
        temp=n%10;
        if(temp==7)
        {
            flag=1;
            break;
        }
        n=n/10;
    }
        if(flag==1)
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }

}

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

Measured memory_bytes: 2704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll 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; cin >> N;
  string ans ="";
  while(1){
    N--;
    ans += (char)('a'+N%26);
    N /= 26;
    if(N==0) break;
  }
  reverse(all(ans));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<55)
#define mod 1000000007
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 prime_div(vector<ll> &ret,ll n){
    ll x=n;
    for(ll i=2;i*i<=x;i++){
	    while(n%i==0){
  		    n/=i;
            ret.push_back(i);
	    }
    }
    if(n!=1){ 
	    ret.push_back(n);
    }

    return;
}

int main(){
    ll n;cin>>n;

    vector<ll> ret;
    for(ll i=1;i<=n;i++){
        prime_div(ret,i);
    }
    sort(ret.begin(),ret.end());
    ret.push_back(INF);

    vector<ll> pr(101,0);
    ll num=1;
    rep(i,ret.size()-1){
        if(ret[i]==ret[i+1]){
            num++;
        }else{
            if(num!=1){
                pr[ret[i]]=num;
            }
            num=1;
        }
    }

    ll n2=0,n4=0,n14=0,n24=0,n74=0;
    rep(i,pr.size()){
        if(pr[i]>=74){
            n74++;
        }
        if(pr[i]>=24){
            n24++;
        }
        if(pr[i]>=14){
            n14++;
        }
        if(pr[i]>=4){
            n4++;
        }
        if(pr[i]>=2){
            n2++;
        }
    }
    
    cout<<n74+n24*(n2-1)+n14*(n4-1)+n4*(n4-1)*(n2-2)/2<<endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        System.out.println(solve(A, B, C) ? "YES" : "NO");

        sc.close();
    }

    static boolean solve(int A, int B, int C) {
        boolean[] seen = new boolean[B];
        int index = 0;
        while (true) {
            index = (index + A) % B;
            if (index == C) {
                return true;
            }
            if (seen[index]) {
                return false;
            }

            seen[index] = true;
        }
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#define N 400001
using namespace std;
typedef long long ll;
string s[N];
ll n,maxl=-1;
priority_queue< ll , vector < ll > , greater < ll > > q;  
inline bool cmp(string sa,string sb){
	return sa<sb;
}
main(){
	register int i,j;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>s[i];
	sort(s+1,s+n+1,cmp);
	ll p=1,tot=1;
	while(p<=n){
		if(s[p]==s[p+1])tot++;
		else{
			if(maxl<tot){
				maxl=tot;
				while(!q.empty())q.pop();
				q.push(p);
			}
			else if(maxl==tot)q.push(p);
			tot=1;
		}
		p++;
	} 
	while(!q.empty()){
		ll k=q.top();
		cout<<s[k]<<endl;
		q.pop();
	}
	return 0;
} 

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

struct P{
  double x, y, z;
  P():x(0), y(0), z(0){}
  P(double x, double y, double z):x(x), y(y), z(z){}
  P operator+(const P& b)const{
    P res;
    res.x = x + b.x;
    res.y = y + b.y;
    res.z = z + b.z;
    return res;
  }
  P operator-(const P& b)const{
    P res;
    res.x = x - b.x;
    res.y = y - b.y;
    res.z = z - b.z;
    return res;
  }
  bool operator<(const P& b)const{
    if(x == b.x)
      if(y == b.y)
        return z < b.z;
      else
        return y < b.y;
    else
      return x < b.x;
  }
};

bool eq(double a, double b){
  return abs(a-b) < 0.01;
}

// Experimence
int main(void){
  int T; cin >> T;
  while(T--){
    double QR, RP, PQ; cin >> QR >> RP >> PQ;
    int N; cin >> N;
    vector<P> points(N);
    for(int i = 0; i < N; i++){
      cin >> points[i].x >> points[i].y >> points[i].z;
    }
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        for(int k = 0; k < N; k++){
          if(i == j || j == k || i == k) continue;
          vector<P> triangle(3);
          triangle[0] = points[i];
          triangle[1] = points[j];
          triangle[2] = points[k];

          vector<double> edge(3);
          for(int edge_idx = 0; edge_idx < 3; edge_idx++){
            P subtract = triangle[edge_idx%3] - triangle[(edge_idx+1)%3];
            edge[edge_idx] = sqrt(subtract.x*subtract.x + subtract.y*subtract.y + subtract.z*subtract.z);
          }
          if( eq(edge[0]/QR, edge[1]/RP) && eq(edge[0]/QR, edge[2]/PQ) ){
            cout << k+1 << " " << i+1 << " " << j+1 << endl;
            i = N; j = N; k = N;
          }
        }
      }
    }
  }
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 500005

using namespace std;

ll fact[max_n];

ll p(ll n, ll k)
{
	if (k == 0)return 1;
	ll x = p(n, k / 2) % M;
	if (k % 2 == 0) return ((x % M) * (x % M)) % M;
	else return ((((x % M) * (x % M)) % M) * n) % M;
}

ll ncr(ll n, ll r)
{
	ll ans = fact[n];
	ans = (ans * p(fact[n - r], M - 2)) % M;
	ans = (ans * p(fact[r], M - 2)) % M;
	return ans;
}

void solve()
{
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	for (int i = 0; i <= n; ++i)
	{
		ll c = 1;
		if (i & 1)c = - 1;
		c *= ncr(n, i);
		c = (c + M) % M;
		c *= ncr(m, i);
		c %= M;
		c *= fact[i];
		c %= M;
		c *= (ncr(m - i, n - i) * ncr(m - i, n - i)) % M;
		c %= M;
		c *= ((fact[n - i] * fact[n - i]) % M) % M;
		c %= M;
		ans = (ans + c) % M;
	}
	cout << ans << endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin>>T;
	fact[0] = 1;
	for (int i = 1; i < max_n; ++i)
	{
		fact[i] = (fact[i - 1] * i) % M;
	}
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 7544
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int a,b;
  cin>>a>>b;

  cout<< ( a<=b ? a : a-1 )<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
import Data.List

scan _ [] = []
scan n (s:sx) =
  let v = if s >= n
          then 0
          else (n-s)
  in
    v:scan n sx

ans n m i =
  let s = take (m-1) $ reverse $ sort i
      r = sum $ scan n s
  in
    r

main = do
  h <- getLine
  c <- getContents
  let (n:m:_) = map read $ words h :: [Int]
      i = map (\ (a:b:_) -> a ) $ map (map read) $ map words $ lines c :: [Int]
      o = ans n m i
  print o
  

Measured memory_bytes: 4692
#include <bits/stdc++.h>
#include <numeric>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
ll H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int gcd(int m, int n){
	return n == 0 ? m : gcd(n, m % n);
}
int main() {
	cin >> N >> X;
	vector<int>x(N);
	cin >> ans;
	ans = abs(ans - X);
	for (int i = 1; i < N; i++) {
		int tmp;
		cin >> tmp;
		x[i] = abs(tmp - X);
		ans = gcd(ans, x[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

#define ll long long

void solve()
{
	ll h;

	cin >> h;

	ll temp = 2;

	while (temp <= h)
	{
		temp *= 2;
	}

	temp -= 1;

	cout << temp;
}

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

	solve();

	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), t = in.nextInt();
            int[] arr = new int[n];
            long res = t;
            for (int i = 0; i < n; ++i) arr[i] = in.nextInt();
            for (int i = 1; i < n; ++i) res += Math.min(arr[i] - arr[i - 1], t);
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 47080
#include <stdio.h>



int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((x >= r && x <= W-r) && (y >= r && y <= H-r))
		printf("Yes\n");
	else{
		printf("No\n");
	}
}


Measured memory_bytes: 2688
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		String S = sc.get();
		char[] chars = S.toCharArray();
		int count = 0;
		for (int i = 1; i < chars.length; i++) {
			if (chars[i - 1] != chars[i]) count++;
		}
		System.out.println(count + 1);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

Measured memory_bytes: 23252
#B
O = list(str(input()))
E = list(str(input()))
o = len(O)
e = len(E)
if o == e:
    ans = ""
    for i in range(o):
        ans+=O[i]
        ans+=E[i]
else:
    ans = ""
    for i in range(o-1):
        ans+=O[i]
        ans+=E[i]
    ans+=O[o-1]
    
print(ans)
    



Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int k, s;
	cin >> k >> s;

	int ans = 0;
	rep(x, k + 1)rep(y, k + 1) {
		int z = s - x - y;
		if (0<=z&&z<=k) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,k=n1()
p=n1()

e=[(1+x)/2 for x in p]

ans=sum(e[0:k])
tmp=ans
for i in range(k,n):
    tmp=tmp+e[i]-e[i-k]
    ans=max(tmp,ans)
print(ans)

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

N,M,X = map(int, input().split())
A = list(map(int, input().split()))

cost_l = 0
for i in range(1,X):
    if i in A:
        cost_l = cost_l + 1
    else:
        pass

cost_r = 0
for i in range(X+1,N):
    if i in A:
        cost_r = cost_r + 1
    else:
        pass
    
if cost_l < cost_r:
    print(cost_l)
else:
    print(cost_r)

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

int main() {
    int N;
    std::cin >> N;
    std::vector<int> v(N);
    for (auto& e : v) std::cin >> e;

    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int k;
        std::cin >> k;
        std::cout << (std::lower_bound(v.begin(), v.end(), k) - v.begin()) << std::endl;
    }
}



Measured memory_bytes: 3100
N = int(input())
seat = ['?' for _ in range(N+1)]
left = 0
right = N
for i in range(20):
  if i == 0:
    output = 0
  else:
    output = (right + left)//2
  print(output)
    
  s = input()
  if s == 'Vacant':
    exit()
  seat[output] = s
  if i == 0:
    seat[N] = s
  #print(seat)
  if ((right + output) % 2 == 0 and seat[right] != seat[output]) or ((right + output) % 2 == 1 and seat[right] == seat[output]):
    left = output
  else:
    right = output


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

int main()
{   
    string s,w;
    cin>>s;
    int j=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0'){
            w[j]='0';
            j++;
        }
        else if(s[i]=='1'){
            w[j]='1';
            j++;
        }
        else{
            w[j]=' ';
            if(j!=0)  j--;
           
        }
    }
    
    for(int i=0;i<j;i++) cout<<w[i];
    

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  ll sum=0;
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    sum+=a[i];
  }
  if(sum%(n*(n+1)/2)) {
    cout << "NO" << endl;
    return 0;
  }
  ll cnt=sum/(n*(n+1)/2);
  vec d(n);
  for(ll i=0;i<n;i++) {
    d[i]=a[(i+1)%n]-a[i];
    d[i]-=cnt;
  }
  ll f=1;
  for(ll i=0;i<n;i++) {
    if(d[i]>0||d[i]%n) f=0;
  }
  if(f) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 1920
#include<iostream>
using namespace std;
int main(){
    int n,m,l,i,j,k;
    cin>>n>>m>>l;
    int a[n][m],b[m][l];                                       
    long long c[n][l];
    //行列aの入力
    for(i=0;i<n;i++){
        for(j=0;j<m;j++)
            cin>>a[i][j];
    }
    //行列bの入力
    for(j=0;j<m;j++){
        for(k=0;k<l;k++)
            cin>>b[j][k];
    }           
    //行列cの初期化
    for(i=0;i<n;i++){
        for(k=0;k<l;k++)
            c[i][k]=0;
    }
    //行列cの出力
    for(i=0;i<n;i++){
        for(k=0;k<l;k++){
            for(j=0;j<m;j++){
                c[i][k]+=a[i][j]*b[j][k];
            }   
            cout<<(k==0?"":" ")<<c[i][k];
        }   
        cout<<"\n";
    }   
    return 0;

}


Measured memory_bytes: 3236
import java.util.*;
public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	double W = sc.nextDouble();
	double H = sc.nextDouble();
	double x = sc.nextDouble();
	double y = sc.nextDouble();

	System.out.printf("%.6f ",W*H/2);

	if(x == W/2 && y == H/2) {
	    System.out.println(1);
	} else {
	    System.out.println(0);
	}
    }
}


Measured memory_bytes: 23252
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdint(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main(void) {
	int n, k;
	n = getint();
	k = getint();
	char s[n];
	scanf("%s", s);
	s[k-1] = s[k-1] + 32;
	showstring(s);
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdint(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


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

int main(){
  int n,a,b;
  bool c=true;
  cin>>n;
  a=n/7;
  while(a>=0){
    if((n-a*7)%4==0){
      cout<<"Yes"<<endl;
      c=false;
      break;
    }
    a--;
  }
  if(c) cout<<"No"<<endl;
  return 0;
}


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

int main() {
	int n;
	stack<int> s;
	while(cin >> n) {
		if(n == 0) {
			cout << s.top() << endl;
			s.pop();
		} else {
			s.push(n);
		}
	}
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

vec tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

int main() {
  ll n;
  cin >> n;
  fact(n);
  cout << tfact[n] << endl;
}

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

 
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int n, l, val, mn = 1e9, sum = 0, sum2, d, ans;
	
	cin >> n >> l;
	
	vector<int> v;
	
	for(int i = 1; i <= n; i++){
		val = l+i-1;
		sum += val;
		v.push_back(val);
	}
	
	
	for(int i = 0; i < n; i++){
		d = v[i];
		sum2 = sum - d;
		
		if(abs(sum-sum2) < mn) {ans = sum2; mn = abs(sum-sum2);}
	}
	
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
s_list = [input() for _ in range(int(N))]
import math
ok = {}
count = 0
for s in s_list:
    s = ''.join(sorted(s))
    if s in ok:
        ok[s] += 1 
    else:
        ok[s] = 1

for val in ok:
    prev = (ok[val] - 1)
    if prev != 0:
        count += math.floor(ok[val] * prev / 2)
print(count)

Measured memory_bytes: 72664
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int a, b; cin >> a >> b;
    a = (a+11) % 13; b = (b+11) % 13;
    if(a == b) cout << "Draw" << endl;
    else if(a < b) cout << "Bob" << endl;
    else cout << "Alice" << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
            using namespace std;
             
            int main(){
            	long long int a,b,n;
              cin>>n>>a>>b;
              if(abs(a-b)%2==0){
              	cout<<abs(a-b)/2<<endl;
              }
              else{
              	cout<<min(a-1,n-b)+1+(b-a-1)/2;
              }
            }

Measured memory_bytes: 256
H, W = map(int, input().split())
s = [input() for _ in range(H)]
dp = [[0]*W for _ in range(H)]
if s[0][0] == "#": dp[0][0] = 1
for w in range(1, W):
    dp[0][w] += dp[0][w-1]
    if s[0][w] == "#" and s[0][w-1] != "#": dp[0][w] += 1
for h in range(1, H):
    dp[h][0] += dp[h-1][0]
    if s[h][0] == "#" and s[h-1][0] != "#": dp[h][0] += 1
        
for h in range(1, H):
    for w in range(1, W):
        res0 = dp[h-1][w]
        res1 = dp[h][w-1]
        if s[h][w] == "#":
            if s[h-1][w] != "#": res0 += 1
            if s[h][w-1] != "#": res1 += 1
        dp[h][w] += min(res0, res1)
print(dp[H-1][W-1])

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] lucaNum = new long[N+1];
        lucaNum[0]=2;
        lucaNum[1]=1;
        for(int n=2;n<=N;n++){
        	lucaNum[n]=lucaNum[n-1]+lucaNum[n-2];
        }
        System.out.println(lucaNum[N]);
    }
}

Measured memory_bytes: 21716
void main()
{
    long n = readln.chomp.to!long;

    long result;
    foreach (i; 1 .. 500001)
    {
        int x = 108 * i / 100;
        if (x == n)
        {
            result = i;
            break;
        }
    }

    if (result > 0)
    {
        result.writeln;
    }
    else
    {
        ":(".writeln;
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n;
	cin >> n;
	for(int i=n; i<1000; i++){
		if(n<=i){
			int x=i;
			int s=x%10;
			x/=10;
			int t=x%10;
			x/=10;
			int u=x;
			if(s==t && t==u){
				cout << i << endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Graphi = vector<vi>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
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; }
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};

struct UnionFind
{
    // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
    vector<int> par;
    // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
    vector<int> sizes;
    
    UnionFind(int n) : par(n), sizes(n, 1) {
        // 最初は全てのデータiがグループiに存在するものとして初期化
        rep(i,n) par[i] = i;
    }
    
    // データxが属する木の根を得る
    int root(int x) {
        if (x == par[x]) return x;
        return par[x] = root(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
    }
    
    // 2つのデータx, yが属する木をマージする
    void unite(int x, int y) {
        // データの根ノードを得る
        x = root(x);
        y = root(y);
        
        // 既に同じ木に属しているならマージしない
        if (x == y) return;
        
        // xの木がyの木より大きくなるようにする
        if (sizes[x] < sizes[y]) swap(x, y);//mergeテク
        
        // xがyの親になるように連結する
        par[y] = x;
        sizes[x] += sizes[y];
        sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
    }
    
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool connected(int x, int y) {
        return root(x) == root(y);
    }
    
    // データxが含まれる木の大きさを返す
    long long size(int x) {
        return sizes[root(x)];
    }
};


int main(){

    int n,m,k; cin >> n >> m >> k;
    UnionFind tree(n);
    vector<int> friends(n,0);
    rep(i,m){
        int a,b; cin >> a >> b;
        a--;b--;
        tree.unite(a,b);
        friends.at(a)++;
        friends.at(b)++;
    }
    vector<vi> G(n);
    rep(i,k){
        int c,d; cin >> c >> d;
        c--;d--;
        G.at(c).push_back(d);
        G.at(d).push_back(c);
    }
    rep(i,n){
        if(i != 0) cout << " ";
        int ans;
        ans = tree.size(i) - 1;
        ans -= friends.at(i);
        for(auto dislike : G.at(i)){
            if(tree.connected(i,dislike)) ans--;
        }
        cout << ans;
    }
    cout << endl;
    return 0;

}

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

int main(){
  int N,K;
  int x;
  
  cin >> N >> K;
  
  int d=0;
  
  for(int i=0;i<N;i++){
    
    cin >> x;
    
    if(abs(x) <= abs(x-K)){
      d=d+x*2;
    }
    else{
      d=d+(abs(x-K))*2;
    }
  }
  
  cout << d << endl;
}

Measured memory_bytes: 3600
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
goukei=0
for i in range(n):
  for j in range(n):
    if i>j:
      goukei+=((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5
average=goukei/(n*(n-1)/2)
print(average*(n-1))

Measured memory_bytes: 38384
//********************************************************************//
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fi first 
#define se second 
#define RANGE(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define DFOR(i, a, b) for(int i = a; i > b; --i)
#define DEB(x) cout << #x << ": " << x << endl
#define ALL(v) v.begin(), v.end() 
#define SORT(v) sort(ALL(v))
#define DISPV(v) { for(auto x___: v) cout << x___ << " "; cout << endl; }
#define DISPM(m) { for(auto x____: m){ cout << x____.first << ": " << x____.second << endl; } };
#define DISPMV(m) { for(auto x_____: m){ cout << x_____.first << ": " ;DISPV(x_____.second);} };
using LL = long long;
using VI = vector <int>;
using VC = vector <char>;
using VS = vector <string>;
using VL = vector <long long>;
using VVI = vector<VI>;
using VVL = vector <VL>;
using MII = map<int, int>;
using MIVI = map<int, VI>;
using MSS = map<string, string>;
using MLL = map<LL, LL>;
int READ_INT(){int temp;cin>>temp;return temp;}      // read an int
LL READ_LONG(){LL temp;cin>>temp;return temp;}      // read a long long
void mcs(VI &series, int &max_sum){                    // maximum contigous sub sum(kadane)
    int s=0;
    for(auto x: series){
        s += x;
        max_sum = max(max_sum, s);
        if(s < 0)s = 0;
    }
}
template<typename T>
T MAX(T t){ return t;}
template <typename T, typename... Args>
T MAX(T t, Args... args){ return max(t, MAX(args...)); }
const int MOD = int(1e9) + 7;
const int INF = 1e9 + 5;
const double PI = acos(-1.0); //M_PI;
const double EPS = 1e-9;
//********************************************************************//

int n;
double dp[3000][3000];
double p[3000];

double probablity(int n, int t){
    if(n < t)
        return 0;
    if(n == 0){
        if(t == 0)return 1;
        else return 0;
    }
    if(!isnan(dp[n][t]))
        return dp[n][t];
    double a = 0, b = 0;
    // if head comes up on this coin
    if(t > 0)
        a = p[n] * probablity(n-1, t-1);

    // if tails comes up on this coin
    b = (1 - p[n]) * probablity(n-1, t);
    dp[n][t] = a + b;
    return dp[n][t];
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    memset(dp, -1, sizeof(dp));
    // cout << dp[0][0] << endl;
    cin >> n;
    int mn = n/2 + 1;
    double ans = 0;
    for(int i = 1; i <= n; ++i)cin >> p[i];
    for(int i = n; i >= 1; --i){
        if(i >= mn)
            ans += probablity(n, i);
    }
    // cout << mn << endl;
    cout << setprecision(10) << ans  << endl;
    return 0;
}



/* complie flags
-Wall -Wextra -pedantic -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector
*/

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

int main(){
    ll N,NN,last=1;cin>>N;
    NN=N;
    for(ll i=2;i*i<=N;i++)if(N%i==0)last=i;
    cout<<floor(log10(NN/(double)last)+1)<<endl;
}







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

using namespace std;

int main() {
    int n[3];
    int K;

    cin >> n[0] >> n[1] >> n[2];
    cin >> K;

    for (int i = 0; i < K; i++) {
        if (n[0] > n[1] && n[0] > n[2]) {
            n[0] = n[0] * 2;
        } else if (n[1] > n[0] && n[1] > n[2]) {
            n[1] = n[1] * 2;
        } else {
            n[2] = n[2] * 2;
        }
    }

    cout << n[0] + n[1] + n[2] << endl;

    return 0;
}

Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, A, B = getlist()
	ans = int(N // (A + B)) * A + min(N % (A + B), A)
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 38320
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

  if (s[s.size()-1] == 's') {
    cout << s << "es";
  } else {
    cout << s << 's';
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
//Available in Snips
#define fi(i, x, y)   for (__typeof(x) i = x; i < y; i ++)
#define fir(i, x, y)  for (__typeof(x) i = x; i > y; i --)
#define fv(x)   for (auto itr = x.begin(); itr != x.end(); itr ++)
#define fvr(x)  for (auto itr = x.end() - 1; itr != x.begin() - 1; itr --)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
	int n,m;
	vi a;
	cin >> n >> m;
	in(a,m);
	int s = 0;
	for(int x : a){
		s+=x;
	}
	s = (s>n) ? -1 : (n-s);
	cout << s;
}


Measured memory_bytes: 3732
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((t * a) < b) {
            System.out.println((t * a));
        } else {
            System.out.println(b);
        }
    }
}


Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
class Program{
  static void Main(){
    int N = int.Parse(Console.ReadLine());
    
    // 木の初期化
    var Dic = new Dictionary<int, List<Tree>>();
    for (int i = 0; i < N; i++){
      Dic.Add(i, new List<Tree>());
    }
    // 受け取り
    for (int i = 0; i < N-1; i++){
      string[] input = Console.ReadLine().Split(' ');
      int u = int.Parse(input[0]);
      int v = int.Parse(input[1]);
      long w = long.Parse(input[2]);
      Dic[u-1].Add(new Tree(v-1, w));
      Dic[v-1].Add(new Tree(u-1, w));
    }
    // 結果の初期化
    int[] result = new int[N];
    result[0] = 0;
    for (int i = 1; i < N; i++)
      result[i] = -1;
    // キュー
    var queue = new Queue<Tree>();
    var pque = new Queue<int>();
    foreach (Tree t_ in Dic[0]){
      queue.Enqueue(t_);
      pque.Enqueue(0);
    }
    
    while (queue.Count != 0){
      Tree t = queue.Dequeue();
      int parent = pque.Dequeue();
      
      // t と隣接する頂点をキューに追加
      foreach (Tree s in Dic[t.Node]){
        if (result[s.Node] == -1){
          queue.Enqueue(s);
          pque.Enqueue(t.Node);
        }
      }
      // t の色を設定
      result[t.Node] = t.Weight ^ result[parent];
    }
    
    Console.WriteLine(string.Join("\n", result));
  }
  
  public struct Tree{
    public int Node {get;}
    public int Weight {get;}
    public Tree(int node, long weight){
      this.Node = node;
      this.Weight = (int)(weight % 2);
    }
  }
}

Measured memory_bytes: 35220
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
using namespace std;

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;
    const F f;
    const Monoid M1;
    int sz;
    vector<Monoid> dat;
    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1), sz(1) {
        while (sz < n) sz <<= 1;
        dat.assign(sz * 2, M1);
    }
    void set(int k, const Monoid &x) { dat[k + sz] = x; }
    void build() {
        for (int k = sz - 1; k > 0; k--) {
            dat[k] = f(dat[2 * k], dat[2 * k + 1]);
        }
    }
    void update(int k, const Monoid &x) {
        dat[k += sz] = x;
        while (k >>= 1) dat[k] = f(dat[2 * k], dat[2 * k + 1]);
    }
    Monoid get(int a, int b) {  // [a, b)
        Monoid L = M1, R = M1;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = f(L, dat[a++]);
            if (b & 1) R = f(dat[--b], R);
        }
        return f(L, R);
    }
    Monoid operator[](const int &k) const { return dat[k + sz]; }
    friend ostream& operator<<(ostream& os, SegmentTree<Monoid> &seg) {
        for (int i = 0; i < seg.sz; i++) os << seg[i] << " ";
        return os;
    }
};

int main() {
    int n; cin >> n;
    int Q; cin >> Q;
    int a, b; cin >> a >> b; a--, b--;
    vector<int> x(Q + 1);
    x[0] = a;
    for (int q = 1; q <= Q; q++) cin >> x[q], x[q]--;
    const long long INF = 1LL << 60;    // 1.15x10^18
    using ll = long long;
    SegmentTree<ll> dpL(n, [](ll a, ll b) { return min(a, b); }, INF);
    SegmentTree<ll> dpR(n, [](ll a, ll b) { return min(a, b); }, INF);
    dpL.set(b, 0 - b); dpL.build();
    dpR.set(b, 0 + b); dpR.build();
    ll add = 0;
    for (int q = 1; q <= Q; q++) {
        int diff = abs(x[q] - x[q - 1]);
        add += diff;
        ll val = min(dpL.get(0, x[q]) + x[q], dpR.get(x[q], n) - x[q]);
        val -= diff;
        dpL.update(x[q - 1], val - x[q - 1]);
        dpR.update(x[q - 1], val + x[q - 1]);
    }
    ll mi = INF;
    for (int i = 0; i < n; i++) mi = min(mi, dpL[i] + i);
    cout << mi + add << endl;
    return 0;
}

Measured memory_bytes: 9216
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int solve (int a, int b, int c)
{
	int res = 0;
	int pairs = min (a, c);
	c -= pairs;
	a -= pairs;
	res += pairs;
	int goods = min (b, c);
	c -= goods;
	b -= goods;
	res += goods * 2;
	res += b;
	if (c > 0)
	{
		res += 1;
	}
	return res;
}

void main ()
{
	int a, b, c;
	while (readf (" %s %s %s", &a, &b, &c) > 0)
	{
		writeln (solve (a, b, c));
	}
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int size= sc.nextInt();
		int largest = 1;
		int second  = 0;
		int[] arr = new int[size];
		for(int i = 0;i<size;i++) {
			arr[i]=sc.nextInt();
			if(arr[i]>largest)largest=arr[i];
			else if(arr[i]>second)second = arr[i];
		}
		for(int i = 0;i<size;i++) {
			if(arr[i]==largest)System.out.println(second);
			else System.out.println(largest);
		}
		
	}
}


Measured memory_bytes: 79940
package main

import (
	"fmt"
)

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func countBuilding(nums []int) (count int) {
	count = 0
	for i := 0; i < len(nums); i++ {
		for j := i; j >= 0; j-- {
			if nums[j] > nums[i] {
				break
			}
			if j == 0 {
				count += 1
			}
		}
	}
	return
}

func main() {
	var N int
	fmt.Scan(&N)
	nums := scanNums(N)
	fmt.Println(countBuilding(nums))
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
bool same(Dice a,Dice b){
  for(int i=0;i<6;i++) if(a.s[i]!=b.s[i]) return false;
  return true;
}
int main(){
  Dice d[100];
  int n;cin >> n;
  for(int j=0;j<n;j++) 
    for(int i=0;i<6;i++)
      cin >> d[j].s[i];
  
  bool ff = true;
  for(int k=0;k<n-1;k++){
    for(int l=k+1;l<n;l++){
      bool f=false;
      for(int i=0;i<4;i++){
	d[l].roll('R');
	for(int j=0;j<4;j++){
	  d[l].roll('N');
	  if(same(d[k],d[l])) f=true;
	}
      }
      d[l].roll('E');
      for(int j=0;j<4;j++){
	d[l].roll('N');
	if(same(d[k],d[l])) f=true;
      }
      
      d[l].roll('W');
      d[l].roll('W');
      for(int j=0;j<4;j++){
	d[l].roll('N');
	if(same(d[k],d[l])) f=true;
      }
      if(f) ff=false;
    }
  }
  
  cout << (ff?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 3124
def main():
  n,k,q = [int(x) for x in raw_input().split()]
  memo = {}

  for _ in xrange(q):
      pid = int(raw_input()) - 1
      if pid not in memo:
          memo[pid] = 0
      memo[pid] += 1

  for pid in xrange(n):
      score = k - q + memo.get(pid, 0)
      print("Yes" if score > 0 else "No")

main()

Measured memory_bytes: 7612
N, K = map(int, input().split())
h_list = list(map(int, input().split()))

dp = [float("inf")] * N
dp[0] = 0

for i in range(N):
    for k in range(1, K + 1):
        if i + k <= N - 1:
            dp[i + k] = min(dp[i + k], dp[i] + abs(h_list[i + k] - h_list[i]))
print(dp[N-1])


Measured memory_bytes: 55264
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#define maxn 5010
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define IL inline
#define ss system
using namespace std;

int sz[maxn], n, root = 0;
ll f[maxn][maxn], fac[maxn], ifac[maxn], ans = 0;
const ll p = 1e9 + 7;
vector<int> nxt[maxn];
template <class T> void read (T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch))
    fl |= ch == '-', ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
void upd(ll &x, const ll &y) {
  x = (x + y) % p;
}
ll pw(ll a, ll b) {
  ll ret = 1;
  while (b) {
    if (b & 1)
      ret = ret * a % p;
    a = a * a % p, b >>= 1;
  }
  return ret;
}
ll A(int a, int b) {
  return a < b || b < 0 ? 0 : fac[a] * ifac[a - b] % p;
}
ll C(int a, int b) {
  return a < b || b < 0 ? 0 : fac[a] * ifac[b] % p * ifac[a - b] % p;
}
void dfs(int x, int fa) {
  int tmp = !(sz[x] = 1);
  for (auto &v : nxt[x]) {
    if (v != fa)
      dfs(v, x), sz[x] += sz[v], tmp = max(tmp, sz[v]);
  }
  tmp = max(tmp, n - sz[x]);
  if (tmp <= n / 2) {
    if (root && root != x)
      printf("%lld\n", fac[n / 2] * fac[n / 2] % p), exit(0);
    root = x;
  }
}
void init() {
  fac[0] = 1;
  for (int i = 1; i < maxn; i++) {
    fac[i] = fac[i - 1] * i % p;
  }
  ifac[maxn - 1] = pw(fac[maxn - 1], p - 2);
  for (int i = maxn - 2; ~i; i--) {
    ifac[i] = ifac[i + 1] * (i + 1) % p;
  }
}
int main() {
  read(n), init();
  for (int i = 1, u, v; i <= n - 1; i++) {
    read(u), read(v), nxt[u].pb(v), nxt[v].pb(u);
  }
  dfs(1, 0), dfs(root, 0);
  f[0][0] = 1;
  for (int i = 0, tot = 0; i < nxt[root].size(); i++) {
    int v = nxt[root][i];
    for (int j = 0; j <= tot; j++) {
      for (int k = 0; k <= sz[v]; k++) {
        upd(f[i + 1][j + k], f[i][j] * C(sz[v], k) % p * A(sz[v], k));
      }
    }
    tot += sz[v];
  }
  for (int i = 0; i < n; i++) {
    upd(ans, f[nxt[root].size()][i] * fac[n - i] % p * (i & 1 ? p - 1 : 1));
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 194688
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if (a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0{
		fmt.Println("Possible")
	} else {
		fmt.Println("Impossible")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
using namespace std;
 
int main(){
  //入力
  int H,N;
  cin>>H>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int power=0;
  for(int i=0;i<N;i++){
    power+=A[i];
  }
  //出力
  if(power>=H){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 640
word=[]
blue=[]
red=[]
n=int(input())
for i in range(n):
  s=input()
  blue.append(s)
  if not s in word:
    word.append(s)
    
m=int(input())
for i in range(m):
  s=input()
  red.append(s)
  if not s in word:
    word.append(s)
ans=0
for wd in word:
  x=blue.count(wd)-red.count(wd)
  if ans<x:
    ans=x
print(ans)
  

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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

signed main(){
	string s;
	string t[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
	
	cin >> s;
	rep(i,0,7){
		if(s == t[i]) cout << 7 - i << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

vector<long long> Dijkstra(long long start,vector<vector<pair<long long,long long>>> adj){
  long long V = adj.size();
  vector<long long> dmin(V,-1);
  priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> pque;
  pque.push(make_pair(0,start));
  pair<long long,long long> p;
  while(pque.size()){
    p = pque.top();
    pque.pop();
    if(dmin[p.second] == -1){
      dmin[p.second] = p.first;
      for(auto x:adj[p.second]){
        if(dmin[x.first] == -1)pque.push(make_pair(dmin[p.second]+x.second,x.first));
      }
    }
  }
  return dmin;
}

signed main(){
  long long V,E,r,s,t,d;
  scanf("%lld %lld %lld",&V,&E,&r);
  vector<vector<pair<ll,ll>>> adj(V);
  FOR(i,0,E){
    scanf("%lld %lld %lld",&s,&t,&d);
    adj[s].pb(make_pair(t,d));
  }
  vector<ll> dmin = Dijkstra(r,adj);
  FOR(i,0,V)
  if(dmin[i] != -1){
    printf("%lld\n",dmin[i]);
  }
  else{
    printf("INF\n");
  }
}


Measured memory_bytes: 32960