akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

ll dp[100][100];
vector<pair<int,int>> matrix(100);


ll kukandp(int i, int j){
    if(dp[i][j]!=INF)return dp[i][j];
    if(j-i==0)dp[i][j]=0;
    if(j-i==1)dp[i][j]=matrix[i].first*matrix[i].second*matrix[j].second;

    if(j-i>1){
        for(int k=i; k<j; k++){
            dp[i][j]=min(dp[i][j], kukandp(i,k)+kukandp(k+1,j)+matrix[i].first*matrix[k].second*matrix[j].second);
        }
    }

    return dp[i][j];
}

int main(){
    int N; cin>>N;
    rep(i,N){
        cin>>matrix[i].first>>matrix[i].second;
    }
    rep(i,100)rep(j,100)dp[i][j]=INF;
    cout<<kukandp(0,N-1)<<endl;
    return 0;
}


Measured memory_bytes: 3180
N, M, C = map(int, input().split())
B = [int(i) for i in input().split()]

cnt = 0

for i in range(N):
    A = [int(i) for i in input().split()]
    sum = C
    for j in range(M):
        sum += A[j] * B[j]
        j += 1
    if sum > 0:
        cnt += 1
    i += 1

print(cnt)


Measured memory_bytes: 9080
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static int N = 3;
	static int N2 = 9;

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

	private void run() {
		Scanner scanner = new Scanner(System.in);
		Puzzle puzzle = new Puzzle();
		for (int i = 0; i < N2; i++) {
			int v = scanner.nextInt();
			puzzle.map[i] = v;
			if (v == 0) {
				puzzle.space = i;
			}
		}
		System.out.println(slove(puzzle));
	}

	int[][] dxy = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

	private int slove(Puzzle in) {
		Puzzle u = new Puzzle();
		Puzzle v = new Puzzle();
		Deque<Puzzle> deque = new ArrayDeque<Puzzle>();
		Set<Puzzle> set = new HashSet<Main.Puzzle>();
		set.add(in);
		deque.offer(in);
		while (!deque.isEmpty()) {
			u = deque.poll();
			if (isTrue(u)) {
				return u.count;
			}
			int y = u.space / N;
			int x = u.space % N;
			for (int[] a : dxy) {
				int dy = y + a[0];
				int dx = x + a[1];
				if (dy < 0 || dx < 0 || N <= dy || N <= dx)
					continue;
				v = u.clone();
				swap(v, u.space, dy * N + dx);
				v.space = dy * N + dx;
				if (!set.contains(v)) {
					set.add(v);
					v.count++;
					deque.offer(v);
				}
			}
		}
		return -1;
	}

	private boolean isTrue(Puzzle u) {
		for (int i = 0; i < N2 - 1; i++) {
			if (u.map[i] != i + 1) {
				return false;
			}
		}
		return true;
	}

	private void swap(Puzzle v, int space, int i) {
		int t = v.map[i];
		v.map[i] = v.map[space];
		v.map[space] = t;

	}
	class Puzzle implements Cloneable {
		int[] map = new int[N2];
		int space;
		int count = 0;

		@Override
		public Puzzle clone() {
			try {
				Puzzle clonePuzzle = (Puzzle) super.clone();
				clonePuzzle.map = Arrays.copyOf(map, N2);
				return clonePuzzle;
			} catch (CloneNotSupportedException e) {
				throw new InternalError();
			}
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + Arrays.hashCode(map);
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Puzzle other = (Puzzle) obj;
			if (!getOuterType().equals(other.getOuterType()))
				return false;
			if (!Arrays.equals(map, other.map))
				return false;
			return true;
		}

		private Main getOuterType() {
			return Main.this;
		}

	}
}

Measured memory_bytes: 74892
#include<iostream>
#include<algorithm>
int main(){
  int n;
  std::cin >> n;
  int i;
  int a[n];
  int ans[n];
  for(i=0;i<n;i++){
    std::cin >> a[i];
  }
  int tmp = a[0];  
  for(i=1;i<=n;i++){
    ans[a[i-1]-1]=i;
  }
  for(i=0;i<n-1;i++){
    std::cout << ans[i] << " ";
  }
  std::cout << ans[n-1];
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

int main(void) {

  int n;
  cin >> n;
  for(int i=n; i>=1; i--){
    if( i == 64 || i == 32 || i == 16 || i == 8 || i == 4 || i == 2 || i == 1 ){
      cout << i << endl;
      return 0;
    }
  }


  return 0;
}

// EOF


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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,flag;
    char c;
    while(cin >> n)
    {
        flag = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> c;
            if(c == 'Y')
                flag = 1;
        }
        cout << (flag? "Four" : "Three") << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        s: String,
    }
    let ans = if s
        .chars()
        .collect::<Vec<_>>()
        .windows(2)
        .any(|w| w[0] == w[1])
    {
        "Bad"
    } else {
        "Good"
    };
    println!("{}", ans);
}


Measured memory_bytes: 2120
//10のi乗pow(10, i);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  vector<int>n(s.size());
  rep(i,s.size()){
    if(s.at(i)=='A' ||s.at(i)=='C'||s.at(i)=='G'||s.at(i)=='T'){
      n.at(i)=1;
    }
  }
  int ma=0;
  int count=0;
  
  rep(i,s.size()){
//    cout << n.at(i);
    if(n.at(i)==1)count++;
    else count=0;
  ma = max(ma,count);
  }
  cout<< ma <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define pi acos(-1)
#define pii pair<int,int>
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int MAXN = 2e5 + 10;
const int MAXM = 2e6 + 10;
const ll mod = 1e9 + 7;

struct node {
    int type;
    ll attack;
}a[MAXN];

bool cmp(node x,node y) {
    if(x.attack != y.attack) return x.attack > y.attack;
    return x.type < y.type;
}

int main() {
#ifdef local
    freopen("data.txt","r",stdin);
//    freopen("data.txt","w",stdout);
#endif
    int n,m = 0;
    ll h;
    scanf("%d%lld",&n,&h);
    for(int i=0; i<n; i++) {
        ll x,y;
        scanf("%lld%lld",&x,&y);
        a[m++] = {1,x};
        a[m++] = {2,y};
    }
    sort(a,a+m,cmp);
    ll ans = 0;
    for(int i=0; i<m; i++) {
        if(a[i].type == 1) {
            ans += h / a[i].attack;
            if(h % a[i].attack != 0) ans++;
            break;
        }
        else if(a[i].type == 2) {
            h -= a[i].attack;
            ans++;
            if(h <= 0) break;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
//kalyanchirla
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
#define int long long
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define csl ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007

int freq[100000+1];

int32_t main()
{ 
    csl;

    int n,k;
    cin >> n >> k;

    while(n--)
    {
        int a,b;
        cin >> a >> b;
        freq[a]+=b;
    }
    int sum=0;
    int ans =-1;
    for(int i=1;i<=100000;i++)
    {
        sum+=freq[i];
        if(sum>=k)
        {
            ans = i;
            break;
        }
    }
    cout << ans << "\n";
}

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

int main(){
    string s;
    cin>>s;
    string ans="Yes";
    for(ll i=0;i<s.size();++i){
        if(i%2==0){
            if(s[i]=='L'){
                ans="No";
                break;
            }
        }else{
            if(s[i]=='R'){
                ans="No";
                break;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
S = input()
ans = 0

for i in range(1<<len(S)-1):
    func = S[0]
    a = 0
    for j in range(len(S)-1):
        if (i>>j)&1 == 1:
            func += "+"
        func += S[j+1]
    a = eval(func)
    ans += a
    
print(ans)

Measured memory_bytes: 9068
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<int>
#define pll pair<ll,ll>
#define un unsigned
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.0000000001
#define inf 10000000000001
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define debug(x) cerr<<"LINE: "<<__LINE__<<" || "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(auto i=s;i!=n;i++)
#define rloop(i,n,b) for(auto i=n-1;i>=b;i--)
#define min2(a,b) (a)<(b)?(a):(b)
using namespace std;


bool f(int k,vec &a,vec &dp)
{
	if(k<0) return 1;
	if(dp[k]!=-1) return dp[k];
	dp[k] = 0;
	loop(i,0,size(a))
	{
		if(f(k-a[i],a,dp)==0) 
		{
			dp[k] = 1;
			break;
		}
	}
	return dp[k];
}

bool solve(int k,vec &a)
{
	vec dp(k+1000,-1);
	dp[k] = f(k,a,dp);
	return dp[k];
}

int main()
{
	int n,k;
	cin>>n>>k;
	vec a(n);
	loop(i,0,n) cin>>a[i];
	if(solve(k,a)) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
stack<int>s;
int main()
{
    char ch;
    int ans=0;
    while(cin>>ch)
	{
        ans++;
        if(ch=='S') s.push(1);
        else 
		    if(!s.empty()) 
			    s.pop(),ans-=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
def solve():
    print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())-1])
    return 0

if __name__ == '__main__':
    solve()

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
 
int32_t main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    int dp[n+1];
    dp[0]=0;
    dp[1]=0;
 	int mn=INT_MAX;
    for(int i=2;i<=n;i++){
    	for(int j=1;j<=k;j++){
    		if(i-j>=1)
    		mn=min(mn,dp[i-j]+abs(a[i-1]-a[i-(j+1)]));
    	}
    	dp[i]=mn;
    	mn=INT_MAX;
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 5204
#include <stdio.h>
#include <math.h>

int main(void) {
	double a, b, x;
	double pi = 3.14159265358979;
	scanf("%lf%lf%lf", &a, &b, &x);
	double rad;
	if (x < a * a * b / 2)
		rad = pi / 2 - atan((2 * x) / (a * b * b));
	else
		rad = atan((2 * b) / a - (2 * x) / (a * a * a));
	printf("%lf\n", rad/pi*180);
	return 0;
}

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

struct Seg {
  int l;
  int r;
  double h;
  int a;
  int b;
  double add;
};

int D;
int L;
int N;
int M;
int num;
int A[114];
int B[114];
int H[114];
int F[114];
int P[114];
int T[114];
Seg seg[12];
double ans[50];

int main() {
  scanf("%d", &D);
  while (D--) {
    scanf("%d", &N);
    for (int i=0; i<N; i++) {
      scanf("%d%d", &B[i], &H[i]);
      seg[i].b = H[i];
      seg[i].r = B[i];
      seg[i].h = 0;
      seg[i].add = 0;
    }
    seg[N].b = 50;
    seg[N].r = 100;
    seg[N].h = 0;
    seg[N].add = 0;
    for (int i=0; i<N; i++) {
      seg[i+1].a = H[i];
      seg[i+1].l = B[i];
    }
    seg[0].a = 50;
    seg[0].l = 0;
    num = N+1;

    scanf("%d", &M);
    for (int i=0; i<M; i++) {
      scanf("%d%d", &F[i], &A[i]);
    }

    scanf("%d", &L);
    for (int i=0; i<L; i++) {
      scanf("%d%d", &P[i], &T[i]);
      ans[i] = 50;
    }

    int time = 0;
    while (1) {
      time++;
      for (int i=0; i<M; i++) {
        for (int j=0; j<num; j++) {
          if (seg[j].l <= F[i] && F[i] <= seg[j].r) {
            seg[j].add += A[i];
            break;
          }
        }
      }

      while (1) {
        for (int i=0; i<num; i++) {
          double req = 30 * (seg[i].r-seg[i].l) * (min(seg[i].a, seg[i].b)-seg[i].h);
          if (seg[i].add >= req) {
            double diff = seg[i].add-req;
            if (seg[i].a == seg[i].b) {
              seg[i-1].add += diff/2;
              seg[i+1].add += diff/2;
            } else if (seg[i].a > seg[i].b) {
              seg[i+1].add += diff;
            } else {
              seg[i-1].add += diff;
            }
            seg[i].add = req;
          }
        }

        bool should_break = true;
        for (int i=0; i<num; i++) {
          double req = 30 * (seg[i].r-seg[i].l) * (min(seg[i].a, seg[i].b)-seg[i].h);
          if (seg[i].add < req) {
            seg[i].h += seg[i].add/(30 * (seg[i].r-seg[i].l));
            seg[i].add = 0.0;
          } else {
            seg[i].h = min(seg[i].a, seg[i].b);
            seg[i].add -= req;
          }
          should_break &= seg[i].add <= 0.0;
        }
        should_break |= (num == 1 && seg[0].h >= 50);

        bool found;
        do {
          found = false;
          for (int i=0; i<num-1; i++) {
            if (seg[i].h >= seg[i].b && seg[i+1].h >= seg[i+1].a) {
              assert(seg[i].h == seg[i+1].h);
              seg[i].b = seg[i+1].b;
              seg[i].add += seg[i+1].add;
              seg[i].r = seg[i+1].r;
              for (int j=i+1; j<num-1; j++) {
                seg[j] = seg[j+1];
              }
              num--;
              found = true;
              break;
            }
          }
        } while (found);
        if (should_break) break;
      }

      for (int i=0; i<L; i++) {
        if (T[i] != time) continue;
        for (int j=0; j<num; j++) {
          if (seg[j].l <= P[i] && P[i] <= seg[j].r) {
            ans[i] = seg[j].h;
            break;
          }
        }
      }

      if (num == 1 && seg[0].h >= 50) break;
    }

    for (int i=0; i<L; i++) printf("%.10f\n", ans[i]);
  }
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std ;
const int MaxN = 50 + 5 ;
long long A[MaxN] , B[MaxN] ;
long long Dfs( int N , long long X ) {
	register long long Mid = ( A[N] + 1ll ) >> 1 ;
	if( X == 0 ) return 0ll ;
	if( X == Mid ) return B[N] / 2.0 + 1ll ;
	if( X == A[N] ) return B[N] ;
	if( X < Mid ) return Dfs( N - 1 , X - 1 ) ;
	if( X > Mid ) return Dfs( N - 1 , X - Mid ) + B[N] / 2.0 + 1ll ;
}
int main() {
	int N ;
	long long X ;
	scanf( "%d%lld" , &N , &X ) ;
	A[0] = 1 ;
	B[0] = 1 ;
	for(register int i = 1 ; i <= N ; ++i ) {
		A[i] = A[i-1] * 2ll + 3ll ;
		B[i] = B[i-1] * 2ll + 1ll ;
	}
	return not printf( "%lld\n" , Dfs( N , X ) ) ;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> inline T pow3_L(T a){
  return a*a*a;
}
int main(){
  int N, res;
  rd(N);
  res =pow3_L(N);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// {
//   int N, res;
//   rd(N);
//   res = N**3;
//   wt(res);
// }


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string S;
	cin >> S;
	map<char, int> mp;
	for (int i = 0; i < N; i++) {
		mp[S[i]]++;
	}
	int res = mp['R'] * mp['G'] * mp['B'];

	for (int i = 0; i < N; i++) {
		for (int j = 1; j < N; j++) {
			if (i + 2 * j >= N) break;
			if (S[i] != S[i + j] && S[i] != S[i + 2 * j] && S[i + j] != S[i + 2 * j]) {
				res--;
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <algorithm>

using namespace std;

int dp[3001];

int main()
{
	int N, T, S;
	int A[3000], B[3000];
	
	scanf("%d %d %d", &N, &T, &S);
	
	for (int i = 0; i < N; i++){
		scanf("%d %d", A + i, B + i);
	}
	
	int ans = 0;
	for (int i = 0; i < N; i++){
		for (int j = T; j - B[i] >= 0; j--){
			if (!(j - B[i] < S && S < j)) dp[j] = max(dp[j], dp[j - B[i]] + A[i]);
			ans = max(ans, dp[j]);
		}
	}
	
	printf("%d\n", ans);
	
	return (0);
}

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

int main(void){
  char buf[16] = { 0 };
  int N;
  int a,ans;
  
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d", &N);
  a = N % 1000;
  if(a != 0) a = 1000 -a; 
  printf("%d\n", a);
  return 0;
}

Measured memory_bytes: 1656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String arg[]) throws IOException{
        process();
    }
    public static void process() throws IOException{
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(in.readLine());
        int n=Integer.parseInt(st.nextToken());
        int m=Integer.parseInt(st.nextToken());
        char arr[][]=new char[n][m];
        for(int i=0;i<n;i++)
            arr[i]=in.readLine().toCharArray();
        long dp[][]=new long[n][m];
        long mod=1000000007;
        for(int i=0;i<n;i++)
            if(arr[i][0]=='.')
                dp[i][0]=1;
            else
                break;
        for(int j=0;j<m;j++)
            if(arr[0][j]=='.')
                dp[0][j]=1;
            else
                break;
        for(int i=1;i<n;i++){
            for(int j=1;j<m;j++){
                if(arr[i][j]=='.')
                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
        System.out.println(dp[n-1][m-1]);
    }
}


Measured memory_bytes: 37892
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cassert>
#define SIZE 600005
#define INF 1000000000

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

char str[SIZE];
int A[SIZE];
int n;

bool check(int X)
{
	for(int i=0;i<n;i++)
	{
		A[i]=str[n-i-1]-'0';
		A[i]*=9;
	}
	A[0]+=X;
	int sum=0;
	for(int i=0;i+1<SIZE;i++)
	{
		A[i+1]+=A[i]/10;
		sum+=A[i]%10;
		//if(i<20) printf("%d ",A[i]%10);
		A[i]=0;
	}
	//printf(": %d %d\n",X,sum);
	return sum<=X;
}
int main()
{
	scanf("%s",&str);
	n=strlen(str);
	int l=-1,r=INF;
	while(r-l>1)
	{
		int m=(l+r)/2;
		if(check(m)) r=m;
		else l=m;
	}
	printf("%d\n",(r+8)/9);
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll c[n];mem(c);
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    c[x-1]++;
    c[y-1]++;
  }
  rep(i,n) pr(c[i]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main()
{
	ios::sync_with_stdio(false);
	
	long a,b,x;
	cin>>a>>b>>x;
	long c,d;
	
	if(a==0)
	{
		d=long(b/x);
		cout<<d+1<<endl;
	}
	else
	{
		c=long((a-1)/x);
		d=long(b/x);
		cout<<d-c<<endl;
	}
	
	return 0;
}

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

void to_vec(vector<char>& v, string s){
    for(int i = 0; i < s.size(); ++i){
        v.emplace_back(s[i]);
    }
}

string to_str(vector<char>& v){
    string s = "";

    for(auto c : v)
        s += c;

    return s;
}

int main(){
    string s, t; cin >> s >> t;
    vector<char> a,b;

    to_vec(a,s);
    to_vec(b,t);

    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), greater<char>());

    string s_ = to_str(a);
    string t_ = to_str(b);

    if(a < b)
        cout << "Yes\n";
    else
        cout << "No\n";

    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int q,w,e;
	cin>>q>>w>>e;
	for(int i=1;i<=w;i++)
		if((q*i)%w==e)
		{
			cout<<"YES"<<endl;
			return 0;
		}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll N;
vl a;
vl b;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    a = vl(N-2-0+1);
    b = vl(N-2-0+1);
    for(int i = 0; i < N-2-0+1; ++i){
        cin >> a[i];
        cin >> b[i];
    }
    solve();
}

// 2 ≤ N ≤ 10^5
// 0 ≤ a_i, b_i < N
// 与えられるグラフは木である。

vvl g;
ll ans=0;

bool f(ll x,ll p){
    bool ret=g[x].size()>2;
    ll cnt=g[x].size()-1-(p!=-1);
    for(ll to:g[x]){
        if(to==p)continue;
        if(f(to,x)){
            --cnt;
            ret=true;
        }
    }
    ans+=max(cnt,0LL);
    return ret;
}

// ll N, vl a, vl b
// 条件を満たすようにアンテナを設置するとき、アンテナの個数 K の最小値を出力せよ。
void solve(){
    g.resize(N);
    rep(i,N-1){
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }

    ll idx=-1;
    rep(i,N){
        if(g[i].size()>=3)idx=i;
    }
    if(idx==-1){
        cout<<1<<endl;
        return;
    }

    f(idx,-1);
    cout<<ans<<endl;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (Int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (Int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
    Int X, A, B, B1;
    cin >> X;

    if (X == 0) {
        A = 0;
        B = 0;
    }

    else {

    set<Int> s;
    vector<Int> five(10000);

    set<Int>::iterator ite;;

    rep(i,10000) {
        five[i] = i * i * i * i * i;
        ite = s.find(five[i] - X);
        if (ite != s.end()) {
            A = i;
            B1 = *ite;
            break;
        }

        s.insert(five[i]);
        s.insert(-five[i]);
    }

    rep(i,10000) {
        if (five[i] == B1) {
            B = i;
            break;
        }
        else if (five[i] == (0 - 1) * B1) {
            B = (0 - 1) * i;
            break;
        }
    }

    }

    cout << A << " " << B << endl;
}


Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
int op_no(int N){
  if(N == 0){
    return 0;
  }
  int pop_count = 0;
  for(int i = 0; i < 32; i++){
    if(((N >> i) & 1) == 1){
      pop_count ++;
    }
  }
  return 1 + op_no(N % pop_count);
}

int ans[200000];
long long two_power[2][200000];
long long total[2];
int main(){
  int N;
  cin >> N;
  string X;
  cin >> X;
  reverse(X.begin(), X.end());

  int org_pop_count = 0;
  for(int i = 0; i < N; i++){
    if(X[i] == '1'){
      org_pop_count ++;
    }
  }

  if(org_pop_count > 1){
    two_power[0][0] = 1;
    two_power[1][0] = 1;
    for(int i = 1; i < N; i++){
      two_power[0][i] = (two_power[0][i - 1] * (long long) 2) % (org_pop_count + 1);
      two_power[1][i] = (two_power[1][i - 1] * (long long) 2) % (org_pop_count - 1);
    }

    for(int i = 0; i < N; i++){
      if(X[i] == '1'){
        total[0] = (total[0] + two_power[0][i]) % (org_pop_count + 1);
        total[1] = (total[1] + two_power[1][i]) % (org_pop_count - 1);
      }
    }

    for(int i = 0; i < N; i++){
      if(X[i] == '0'){
        int second_num = (total[0] + two_power[0][i]) % (org_pop_count + 1);
        ans[i] = 1 + op_no(second_num);
      } else {
        int second_num = (total[1] - two_power[1][i] + (org_pop_count - 1)) % (org_pop_count - 1);
        ans[i] = 1 + op_no(second_num);
      }
    }
  } else {
    two_power[0][0] = 1;
    for(int i = 1; i < N; i++){
      two_power[0][i] = (two_power[0][i - 1] * (long long) 2) % (org_pop_count + 1);
    }
    for(int i = 0; i < N; i++){
      if(X[i] == '1'){
        total[0] = (total[0] + two_power[0][i]) % (org_pop_count + 1);
      }
    }
    for(int i = 0; i < N; i++){
      if(X[i] == '0'){
        int second_num = (total[0] + two_power[0][i]) % (org_pop_count + 1);
        ans[i] = 1 + op_no(second_num);
      } else {
        ans[i] = 0;
      }
    }
  }

  reverse(ans, ans + N);
  for(int i = 0; i < N; i++){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 7652
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  string s[n],t[n];
  for(int i=0;i<n;i++) cin>>s[i];
  bool f=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      f|=s[i][j]=='#';
  if(!f){
    cout<<-1<<endl;
    return 0;
  }
  int ans=2*n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) t[j]=s[j];
    bool ff=0;
    for(int j=0;j<n;j++)
      if(t[j][i]=='#') ff=1;
    int tmp=!ff;
    for(int j=0;j<n;j++)
      if(t[i][j]=='.') tmp++;
    for(int j=0;j<n;j++){
      bool fff=0;
      for(int k=0;k<n;k++) fff|=t[k][j]=='.';
      tmp+=fff;
    }
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

void solve()
{
	long N, M;
	cin >> N >> M;
	vector<long> adj[N], color(N, -1), cnt(2);
	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	color[0] = 0;
	queue<int> q;
	q.push(0);
	while (!q.empty())
	{
		int v = q.front();
		q.pop();
		cnt[color[v]]++;
		for (int nv : adj[v])
		{
			if (color[nv] != -1)
			{
				if (color[v] == color[nv])
				{
					cout << N*(N-1)/2 - M << endl;
					return;
				}
			}
			else
			{
				color[nv] = 1-color[v];
				q.push(nv);
			}
		}
	}
	cout << cnt[0] * cnt[1] - M << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 7808
def judge(array, key):
    if key in array:
        return True
    else :
        return False

s_length = int(input())
array_s = [int(i) for i in input().split()]
t_length = int(input())
array_t = [int(i) for i in input().split()]

cnt = 0
for i in range(t_length):
    key = array_t[i]
    if judge(array_s, key):
        cnt += 1

print(cnt)


Measured memory_bytes: 6552
import java.io.*;
 
public class Main{
	public static void main(String[] args)throws IOException{
    	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      
      int n;
      n=Integer.parseInt(br.readLine());
      n=n%10;
      switch(n){
        case 2:
        case 4: 
        case 5:
        case 7:
        case 9:
          System.out.println("hon");
          break;
        case 0:
        case 1:
        case 6:
        case 8:
          System.out.println("pon");
          break;
        case 3:
          System.out.println("bon");
          break;
      }
    }	
}

Measured memory_bytes: 32616
chomp( my $s = <> );
chomp( my $t = <> );

$s =~ s/\?/./g;
my $len = length $t;
for my $i ( -length($s)+$len .. 0 ) {
    if ( $t =~ substr $s, -$i, $len ) {
	substr $s, -$i, $len, $t;
	$s =~ s/\./a/g;
	print $s;
	exit;
    }
}

print 'UNRESTORABLE';
exit;


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll d,w;
ll field[30][30];

ll solve(ll y,ll x,ll yy,ll xx){
    ll h = INF;
    FOR(i,y,yy+1){
        FOR(j,x,xx+1){
            if(i == y || i == yy || j == x || j == xx)h = min(h,field[i][j]);
        }
    }
    ll ans = 0;
    FOR(i,y+1,yy){
        FOR(j,x+1,xx){
            if(h <= field[i][j])return 0;
            ans += h - field[i][j];
        }
    }
    return ans;
}

int main(){
    while(cin >> d >> w && d){
        rep(i,d)rep(j,w)cin >> field[i][j];
        ll ans = 0;
        rep(i,d){
            rep(j,w){
                FOR(ii,i+1,d){
                    FOR(jj,j+1,w){
                        ans = max(ans,solve(i,j,ii,jj));
                    }
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3104
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		final int n = sc.nextInt();
		final String s = sc.next();

		int maxMachCount = 0;

		for (int i = 0; i < n; i++) {
			final String sLSubstr = s.substring(0, i + 1);
			final String sLeft[] = sLSubstr.split("");

			if (n < i + 1) {
				break;
			}

			final String sRSubstr = s.substring(i + 1);
			final String sRight[] = sRSubstr.split("");

			List<String> left = new ArrayList<String>();
			for (final String l : sLeft) {
				left.add(l);
			}
			List<String> right = new ArrayList<String>();
			for (final String r : sRight) {
				right.add(r);
			}

			final List<String> left2 = new ArrayList<String>(new LinkedHashSet<>(left));
			final List<String> right2 = new ArrayList<String>(new LinkedHashSet<>(right));

			int machCount = 0;
			for (final String l2 : left2) {
				if (right2.contains(l2)) {
					machCount++;
				}
			}
			if (maxMachCount < machCount) {
				maxMachCount = machCount;
			}

		}

		System.out.println(maxMachCount);

	}

}

Measured memory_bytes: 23892
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


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

    map<string,ll> count;
    ll max_count = 0;

    rep(i,n){
        string s;
        cin >> s;
        count[s]++;
        if(count[s] > max_count){
            max_count = count[s];
        }
    }

    vector<string> ans;
    for(auto &i : count){
        if(i.second == max_count){
            ans.push_back(i.first);
        }
    }

    sort(ALL(ans));

    rep(i,ans.size()){
        cout << ans[i] << endl;
    }

    
    return 0;
}

Measured memory_bytes: 24784
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

struct Point
{
	Point() : x(0.), y(0.){}
	Point(double _x, double _y) :x(_x), y(_y){}
	double x;
	double y;
};

void KochCurve(int n, Point& p1, Point& p2)
{
	if (0 == n){
		cout << fixed << std::setprecision(5) << p1.x << " " << p1.y << "\n";
		return;
	}

	Point q1, q2, q3;
	q1.x = p1.x + (p2.x - p1.x) / 3;
	q3.x = p1.x + 2 * (p2.x - p1.x) / 3;
	q1.y = p1.y + (p2.y - p1.y) / 3;
	q3.y = p1.y + 2 * (p2.y - p1.y) / 3;
	double r3 = sqrt(3);
	q2.x = ((q3.x - q1.x) - r3 * (q3.y - q1.y)) / 2 + q1.x;
	q2.y = (r3 * (q3.x - q1.x) + (q3.y - q1.y)) / 2 + q1.y;

	KochCurve(n - 1, p1, q1);
	KochCurve(n - 1, q1, q2);
	KochCurve(n - 1, q2, q3);
	KochCurve(n - 1, q3, p2);
}

int main()
{
	int n;
	cin >> n;
	Point p1 = Point(0., 0.);
	Point p2 = Point(100., 0.);
	KochCurve(n, p1, p2);
	cout << fixed << std::setprecision(5) << p2.x << " " << p2.y << "\n";
	return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    map<char,int> mp;
    for (int i=0; i<n; i++) mp[s[i]]++;

    int cnt = count(s.begin(), s.begin() + mp['R'], 'R');
    cout << mp['R'] - cnt << endl;
}

Measured memory_bytes: 3424
module mod_union_find
  implicit none
  type union_find
    integer :: n = 0
    integer, pointer :: par(:), rnk(:), siz(:) => null()
  contains
    procedure :: init => inituf
    procedure :: release => releaseuf
    procedure :: find => find
    procedure :: same => same
    procedure :: unite => unite
    procedure :: size => size_of
  end type
  interface union_find
    module procedure :: newuf
  end interface union_find
contains
  function newuf(n) result(ret)
    integer, intent(in) :: n
    type(union_find) :: ret
    integer :: i
    ret%n = n
    allocate(ret%par(n),ret%rnk(n),ret%siz(n))
    ret%rnk = 0
    ret%siz = 1
    ret%par = [(i,i=1,n)]
  end
  subroutine inituf(this,n)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: n
    integer :: i
    if (this%n /= n) then
      if (this%n /= 0) deallocate(this%par,this%rnk,this%siz)
      allocate(this%par(n),this%rnk(n),this%siz(n))
    end if
    this%n = n
    this%rnk = 0
    this%siz = 1
    this%par = [(i,i=1,n)]
  end
  subroutine releaseuf(this)
    class(union_find), intent(inout) :: this
    if (this%n /= 0) deallocate(this%par,this%rnk,this%siz)
    this%n = 0
  end
  recursive function find(this,i) result(ret)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: i
    integer :: ret
    if (this%par(i) /= i) this%par(i) = find(this,this%par(i))
    ret = this%par(i)
  end
  logical function same(this,i,j)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: i, j
    same = find(this,i) == find(this,j)
  end
  subroutine unite(this,i,j)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: i, j
    integer :: x, y
    x = find(this,i)
    y = find(this,j)
    if (x == y) return
    if (this%rnk(x) < this%rnk(y)) then
      this%par(x) = y
      this%siz(y) = this%siz(y)+this%siz(x)
    else
      this%par(y) = x
      this%siz(x) = this%siz(x)+this%siz(y)
      if (this%rnk(x) == this%rnk(y)) this%rnk(x) = this%rnk(x)+1
    end if
  end
  integer function size_of(this,i)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: i
    size_of = this%siz(find(this,i))
  end
end module mod_union_find
program decayed_bridges
  use mod_union_find
  implicit none
  integer :: n, m, a(100000) = 0, b(100000) = 0, i
  integer(8) :: x(0:100000) = 0
  type(union_find) :: uf
  read(*,*) n, m
  do i = 1, m
    read(*,*) a(i), b(i)
  end do
  uf = union_find(n)
  x(m) = int(n,8)*(n-1)/2
  do i = m, 1, -1
    x(i-1) = x(i)
    if (.not.uf%same(a(i),b(i))) then
      x(i-1) = x(i-1)-int(uf%size(a(i)),8)*uf%size(b(i))
      call uf%unite(a(i),b(i))
    end if
  end do
  do i = 1, m
    write(*,'(i0)') x(i)
  end do
end program decayed_bridges

Measured memory_bytes: 4088
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    final int N;
    int[] a;

    AtCoder(FastScanner sc) {
        N = sc.nextInt();
        a = IntStream.range(0, N).map(i -> sc.nextInt()).sorted().toArray();
    }

    void solve(PrintWriter out) {
        out.println(a[N - 1] - a[0]);
    }

}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 25428
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define mod 998244353

using namespace std;

string a, b;
llint n, m, t;

const int FACT_MAX = 200005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	make_fact();
	
	cin >> a >> b;
	for(int i = 0; i < a.size(); i++){
		if(a[i] == '1' && b[i] == '1') m++;
		else if(a[i] == '1' && b[i] == '0') t++;
	}
	n = m+t;
	if(t == 0){
		llint ans = fact[n] * fact[n] % mod;
		cout << ans << endl;
		return 0;
	}
	
	llint ans = 0;
	for(int i = 0; i <= m; i++){
		llint tmp = comb(m, i) * fact[m-i] % mod;
		tmp *= fact[i] * fact_inv[i+t] % mod, tmp %= mod;
		llint sum = 0;
		for(int j = 0; j <= t; j++){
			if(j % 2) sum += mod - comb(t, j) * modpow(t-j, i+t) % mod, sum %= mod;
			else sum += comb(t, j) * modpow(t-j, i+t) % mod, sum %= mod;
		}
		tmp *= sum, tmp %= mod;
		ans += tmp, ans %= mod;
	}
	ans *= fact[n] * fact[t] % mod, ans %= mod;
	cout << ans << endl;
	
	return 0;
}

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

n = int(input())
A = list(map(int, input().split()))
A_plus = []
for a in A:
    A_plus.append(a+1)
A_minus = []
for a in A:
    A_minus.append(a-1)

B = {}
for a in A:
    if a not in B:
        B[a] = 1
    else:
        B[a] += 1
for a_plus in A_plus:
    if a_plus not in B:
        B[a_plus] = 1
    else:
        B[a_plus] += 1
for a_minus in A_minus:
    if a_minus not in B:
        B[a_minus] = 1
    else:
        B[a_minus] += 1

count = 0
for b in B.keys():
    count = max(count, B[b])

print(count)


Measured memory_bytes: 25824
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const k = parseInt(spi[0]);
    const s = spi[1];

    const n = s.length;
    if (n <= k) console.log(s);
    else console.log(`${s.substr(0, k)}...`);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 30552
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

string s;

int main()
{
    cin >> s;
    int n = s.size();
    if(n == 1) puts("0");
    else{
        int ans = 0;
        rrep(i,n-1){
            if(s[i] != s[i-1]) ans++;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 512
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD

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

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long nCr(long n, long r){
    if(n==r || r==0){
        return 1;
    } else {
        return mod_add(nCr(n-1,r),nCr(n-1,r-1));
    }
}




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

   int upper[101]; 
   int lower[101];
   upper[0]=0;
   lower[0]=0;

int s=0;
   for(int i=1; i<n+1;i++){
       int a; cin >>a; s+=a; upper[i]=s;
   }
s=0;
for(int i=1; i<n+1;i++){
       int a; cin >>a; s+=a; lower[i]=s;
   }

int ans =0;
  for(int i=0;i<n;i++){
    if(ans < upper[i+1]+lower[n]-lower[i]){
       ans = upper[i+1]+lower[n]-lower[i];
   }
   }
   cout<<ans<<endl;

}

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

using namespace std ; 

const int N = 2e5 + 7 ;

int n; 
long long ans = 0 ; 


int main(){
        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ; 
        //freopen("in.in" , "r" , stdin) ; 
        cin >> n; 

        for(int i = 0 ;i < n -1 ;i++){
                long long u , v ; 
                cin >> u >> v; 
                if(u > v)
                        swap(u , v) ; 
                ans -= 1LL *  u * (n - v + 1LL) ; 
        }

        for(int i = 1; i<= n;i++){
                ans +=1LL * (i * (n - i + 1LL)) ; 
        }
        cout<< ans ; 

        return 0; 
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
  int T,H,S;
  int second;
  while(1){
    scanf("%d %d %d",&T,&H,&S);
    if(T==-1 && H==-1 && S==-1)break;
    second=T*3600+H*60+S;
    second=2*3600-second;
    printf("%02d:%02d:%02d\n",second/3600,(second%3600)/60,second%60);
    second=3*second;
    printf("%02d:%02d:%02d\n",second/3600,(second%3600)/60,second%60);
  }
  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int n;
string s;

bool exist(int i) {
    string str = to_string(i);
    if (i <= 9) str = "00" + str;
    else if (i <= 99) str = "0" + str;
    int tmp = 0;
    rep(i, 0, n) {
        if (s[i] == str[tmp]) tmp++;
        if(tmp == 3) break;
    }
    if (tmp == 3) return true;
    else return false;
}

int main() {
    cin >> n;
    cin >> s;
    int ans = 0;
    for (int i = 0; i <= 999; i++) {
        if (exist(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256