akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N;
	long long T, t[200001];
	scanf("%d %lld", &N, &T);
	for (i = 1; i <= N; i++) scanf("%lld", &(t[i]));
	
	long long sum = T;
	for (i = 2; i <= N; i++) sum += (t[i] - t[i-1] > T)? T: t[i] - t[i-1];
	
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>

 

using namespace std;

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if(x-r >= 0 && y-r >= 0 && w-r-x >= 0 && h-r-y >= 0 )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3116
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string b=Console.ReadLine();
      switch(b){
        case "A":
          Console.WriteLine("T");
          break;
        case "T":
          Console.WriteLine("A");
          break;
        case "C":
          Console.WriteLine("G");
          break;
        default:
          Console.WriteLine("C");
          break;
      }
          
    }
    
  }

}


Measured memory_bytes: 25728
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,x;
    cin>>x>>a>>b;
    if((x+1+a)-b>=1)
    {
        if(b>x)
        {
            cout<<"safe"<<endl;

        }
        else
            cout<<"delicious"<<endl;
    }

    else
    {
        cout<<"dangerous"<<endl;
    }



}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int n;
int k;

vector<int> card;
set< string > cd;
set< vector<int> > ccd;

/*
string IteratorToString(vector<int>::iterator begin, vector<int>::iterator end){
	string str = "";
	char ch[256];
	for(;begin < end;begin++){
		sprintf(ch,"%d",*begin);
		str += ch;
	}
	return str;
}
*/
string VectorToString(const vector<int> &vec){
	string str = "";
	for(int i=0;i<vec.size();i++){
		char ch[256];
		sprintf(ch,"%d",vec[i]);
		str += ch;
	}
	return str;
}

string VectorToDebugText(const vector<int> &vec){
	string str = "";
	for(int i=0;i<vec.size();i++){
		char ch[256];
		sprintf(ch,"%d",vec[i]);
		str += ch;
		str += ":";
	}
	return str;
}

void solve(int a,vector<int> v){
	if(v.size() == k){
		sort(v.begin(),v.end());
		ccd.insert(v);
		return;
	}
	if(a == n){return;}
	solve(a + 1,v);
	v.push_back(card[a]);
	solve(a + 1,v);
}


int main(){
	while(1){
		int self;
		scanf("%d %d",&n,&k);
		if(n == 0 && k == 0){
			break;
		}
		card.clear();
		cd.clear();
		ccd.clear();
		for(int i=0;i<n;i++){
			scanf("%d",&self);
			card.push_back(self);
		}
		vector<int> cc(k);
	
		sort(card.begin(),card.end());
		/*
		while(next_permutation(card.begin(),card.end())){
			 cd.insert(VectorToString(card.begin(),card.begin()+k));
		}
		*/
		solve(0,vector<int>());
		for(set<vector<int> >::iterator it = ccd.begin();it != ccd.end();it++){
			vector<int> vec = *it;
			sort(vec.begin(),vec.end());
			cd.insert(VectorToString(vec));
			//printf("[%s]\n",VectorToDebugText(vec).c_str());
			while(next_permutation(vec.begin(),vec.end())){
				//printf("%s\n",VectorToDebugText(vec).c_str());
				//printf("%s\n",VectorToString(vec).c_str());
				cd.insert(VectorToString(vec));
			}
		}
		printf("%d\n",cd.size());
	}
}

Measured memory_bytes: 0
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer arr[]=new Integer[n];
        Integer arrToSort[]=new Integer[n];
        for (int i=0;i<n;i++){
            arr[i]=sc.nextInt();
            arrToSort[i]=arr[i];
        }
        Arrays.sort(arr);
        int cnt=0;
        for (int i=0;i<n;i++){
            if (!arr[i].equals(arrToSort[i])){
                cnt++;
            }
        }
        if (cnt!=2 && cnt!=0) {
            System.out.println("NO");
        }else System.out.println("YES");

    }

}



Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

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

ll yak(ll a, ll b, ll n){
	a = ceil(a/(ld)n);
	b = b/n;
        //cout << (b - a) + 1  << endl;
		return (b - a) + 1;
}

int main(void) {
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << b-a+1-yak(a,b,c)-yak(a,b,d)+yak(a,b,lcm(c,d)) << endl;
}


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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

void dfs(int i,vector<vector<int>>& edges,vector<bool>& used,vector<int>& ret) {
    for (int j : edges[i]) if (!used[j]) {
        used[j] = true;
        ret.push_back(j);
        dfs(j,edges,used,ret);
        break;
    }
}

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> ans;
    vector<bool> used(n,false);
    vector<vector<int>> edges(n);
    for (int i = 0;i < m;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    ans.push_back(0);
    used[0] = true;
    dfs(0,edges,used,ans);
    reverse(ans.begin(),ans.end());
    dfs(0,edges,used,ans);
    cout << ans.size() << endl;
    for (int i = 0;i < ans.size();++i)  cout << ans[i]+1 << " \n"[i == ans.size()-1];
    return 0;
}

Measured memory_bytes: 12536
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[105];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    scanf("%s",a);
    int n=strlen(a);
    n-=8;
    a[n]='\0';
    printf("%s\n",a);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

//long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
//long long dp[100010][3];
ll a[100010][3];
ll dp[100010][3];
int main() {
    //入力
    //ll a[100010][3];
    //ll dp[100010][3];
    ll N; 
    cin >> N;
    //long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう
    //ll a[100010][3];    //あまり、a[n]のnを大きくするとエラーなので注意
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];
    //dpテーブル
    //long long dp[100010][3];

    //ll dp[100010][3];
    //初期条件、初期化は既に終わっている

    //遷移
    for (ll i = 0;i<N;i++) {
        for (ll j = 0;j<3;j++) {
            for (ll k = 0;k<3;k++) {
                if (j==k) continue;
                chmax(dp[i+1][k],dp[i][j] + a[i][k]);
            }
        }
    }
    ll ans = max(dp[N][0],dp[N][1]); //dp[i] はi日目なので注意,
    ans = max(ans,dp[N][2]);         //N日目はN-1でなく、dp[N]なので注意
    cout << ans << endl;
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  ll dp[c+1][d+1];
  rep(i,0,c+1){
    rep(j,0,d+1){
      dp[i][j]=0;
    }
  }
  dp[a][b]=1;
  rep(i,b,d){
    dp[a][i+1]=dp[a][i]*a;
    dp[a][i+1]%=mod;
  }
  rep(i,a,c){
    dp[i+1][b]=dp[i][b]*b;
    dp[i+1][b]%=mod;
  }
  rep(i,a,c){
    rep(j,b,d){
      dp[i+1][j+1]=dp[i][j+1]*(j+1)%mod+dp[i+1][j]*(i+1)%mod-dp[i][j]*i%mod*j%mod;
      if(dp[i+1][j+1]<0) dp[i+1][j+1]+=mod;
      else dp[i+1][j+1]%=mod;
    }
  }
  cout<<dp[c][d]<<endl;
}

Measured memory_bytes: 73952
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=3007;
const ll mod=1000*1000*1000+7;
const ll inf=1e18;

int n;

ll tab[nax][nax];
ll war[1<<20];
ll dp[1<<20];

int main()
{
	scanf("%d", &n);
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<n; j++)
		{
			scanf("%lld", &tab[i][j]);
		}
	}
	for (int i=0; i<(1<<n); i++)
	{
		for (int j=0; j<n; j++)
			for (int l=0; l<j; l++)
				if ((i&(1<<j)) && (i&(1<<l)))
					war[i]+=tab[j][l];
	}
	for (int i=1; i<(1<<n); i++)
	{
		dp[i]=-inf;
		for (int j=i; j; j=(j-1)&i)
		{
			dp[i]=max(dp[i], dp[i^j]+war[j]);
		}
	}
	printf("%lld\n", dp[(1<<n)-1]);
	return 0;
}


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

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

    string s;
    getline(cin, s);

    int len = s.length();
    if(len%2 == 0){
        cout<<"No\n";
        return 0;
    }

    string a,b,c;

    // a and s
    b = s; a = s;
    reverse(begin(a), end(a));
    if(s != a){
        cout<<"No\n";
        return 0;
    }

    // intial 
    int newlen = (len - 1)/2;
    b = s.substr(0, newlen);
    a = b;
    reverse(begin(a), end(a));
    if(a != b){
        cout<<"No\n";
        return 0;
    }

    // ending
    newlen = (len+3)/2;
    --newlen;
    b = s.substr(newlen, (len - newlen));
    a = b;
    reverse(begin(b), end(b));
    if(a != b){
        cout<<"No\n";
        return 0;
    }

    cout<<"Yes\n";

    return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
priority_queue <int , vector <int >,greater <int > > Q;
const int N=500005;
#define mid ((l+r)>>1)
int a[N],val[N<<2];
inline int query(int root,int l,int r,int L,int R){
	if (r<L||l>R) return 0;
	if (L<=l&&r<=R) return val[root];
	return max(query(root<<1,l,mid,L,R),query((root<<1)|1,mid+1,r,L,R));
}
inline void update(int root,int l,int r,int x,int y){
	if (l==r) {val[root]=y;return;}
	if (x<=mid) update(root<<1,l,mid,x,y);
	else update((root<<1)|1,mid+1,r,x,y);
	val[root]=max(val[root<<1],val[(root<<1)|1]);
}
int Head[N],Next[N<<1],Adj[N<<1],tot=0,d[N],ans[N];
inline void addedge(int u,int v){Next[++tot]=Head[u],Head[u]=tot,Adj[tot]=v,d[v]++;}
int main (){
	int n,k;scanf ("%d%d",&n,&k);
	for (int i=1,x;i<=n;i++) scanf ("%d",&x),a[x]=i;
	for (int i=1;i<=n;i++){
		int t=query(1,1,n,max(1,a[i]-k+1),a[i]);
		if (t) addedge(a[t],a[i]);
		t=query(1,1,n,a[i],min(n,a[i]+k-1));
		if (t) addedge(a[t],a[i]);
		update(1,1,n,a[i],i);
	}
	for (int i=1;i<=n;i++) if (!d[i]) Q.push(i);
	int Time=0;
	while (!Q.empty()){
		int x=Q.top();ans[x]=++Time;Q.pop();
		for (int e=Head[x];e;e=Next[e]){
			d[Adj[e]]--;
			if (!d[Adj[e]]) Q.push(Adj[e]);
		}
	}
	for (int i=1;i<=n;i++) printf ("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 25716
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    while(cin >> S) {
        int ans = 0;
        rep(i, sz(S) - 1) {
            if(S[i] != S[i + 1])ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int n,i,j,a[1000],w,b,k,c[1001],d[1001],e[1001];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&c[i],&d[i],&e[i]);
		a[i]=0;
	}
		for(i=0;i<n;i++){
			w=0;
			b=0;
			k=0;
			for(j=0;j<n;j++){
			if(i!=j){
				if(c[i]==c[j]){
					w=1;
				}
				if(d[i]==d[j]){
					b=1;
				}
				if(e[i]==e[j]){
					k=1;
				}
			}
			}
			if(w==0){
				a[i]+=c[i];
			}
			if(b==0){
				a[i]+=d[i];
			}
			if(k==0){
				a[i]+=e[i];
			}		
		}
	for(i=0;i<n;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}

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

const int mxn = 1e5 + 5;
vector<int> adj[mxn];
int distu[mxn], distv[mxn];

void dfsu(int node, int parent){
    for(int x : adj[node]){
        if(x!=parent){
            distu[x] = distu[node] + 1;
            dfsu(x, node);
        }
    }
}

void dfsv(int node, int parent){
    for(int x : adj[node]){
        if(x!=parent){
            distv[x] = distv[node] + 1;
            dfsv(x, node);
        }
    }
}

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

    //good luck kittu!
    int n, u, v, x, y; cin>>n>>u>>v;
    for(int i = 0; i<n-1; i++){
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    dfsu(u, 0);
    dfsv(v, 0);

    int ans = -1;
    for(int i = 1; i<=n; i++){
        if(distv[i]>=distu[i]) ans = max(ans, distv[i]);
    }
    cout<<ans-1<<"\n";
    return 0;
}

Measured memory_bytes: 10368
function Main(input) {
  input = input.split("\n");
  string = input[0];
  var space = " ";
  var position = 4;
  var output = [string.slice(0, position), space, string.slice(position)].join('');
  console.log(output);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 10616
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int X = 0;
  for (int i = 2; i < S.size(); i++){
    int x = (S[i - 2] - '0') * 100 + (S[i - 1] - '0') * 10 + S[i] - '0';
    if (abs(x - 753) < abs(X - 753)) X = x;
  }
  cout << abs(X - 753);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int main()
{	
	int a,b,c,m;
	scanf("%d %d %d",&a,&b,&c);
	m=max(max(a,b),c);
	if(m == a&&a==b+c)
	printf("Yes");
	else if(m == b&&b==a+c)
	printf("Yes");
	else if(m == c&&c==a+b)
	printf("Yes");
     else 
     printf("No");
	return 0;
}

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

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

  cout << s.substr(0, 4) << " " << s.substr(4) << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N ;
  int ans=N;
  int sum=0;
  int divide=10000000;
  for(int i=0 ; i<8;i++){
    if(N/divide != 0){
      sum = sum + N / divide;
      N %= divide;    
    if(i==7) sum = sum + N / divide + N % divide;   
  //  cout << sum << endl;
    }
    divide /= 10;    
  }
  
  if(ans % sum ==0){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, b int
	fmt.Scan(&n, &b)
	items := 1
	cnt := n
	if b == 1 {
		fmt.Println(0)
		return
	}
	for {
		if cnt >= b{
			fmt.Println(items)
			return
		}
		cnt += n -1
		items++
	}
}

Measured memory_bytes: 512
while True:
    try:
        joi, ioi = 0, 0
        s = raw_input()
        for i in range(0, len(s)-2):
            if s[i:i+3] == 'JOI':
                joi += 1
            elif s[i:i+3] == 'IOI':
                ioi += 1
        print joi
        print ioi
    except EOFError:
        break

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for (int i = 0; i <= a; i++)
  for (int j = 0; j <= b; j++)
  for (int k = 0; k <= c; k++) {
    if (500 * i + 100 * j + 50 * k == x) ans++;
  }
  cout << ans << '\n';
}


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


int main(){
   int n,m,X,Y;
   cin >> n >> m >> X >> Y;
   int maxx = -100, miny = 100;
   rep(i,0,n){
      int x; cin >> x;
      maxx = max(maxx, x);
   }
   rep(i,0,m){
      int y; cin >> y;
      miny = min(miny, y);
   }
   if(maxx < miny && X <= maxx && Y >= miny) cout << "No War" << endl;
   else cout << "War" << endl;
}

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

#define DB if(0)

int p10[] = {1, 10, 100, 1000, 10000, 100000, 1000000};

int main(){
	int n;
	cin >> n;
	int digits = int(floor(log10(n))) + 1;
	DB cout << "digits " << digits << endl;
	//--
	int ans = 0;
	if(digits & 1){
		ans += (n - p10[digits-1] + 1 );
		digits--;
	}
	digits--;
	DB cout << "@" << ans << endl;
	//--
	while(digits > 0){
		DB cout << ( p10[digits] - 1 - p10[digits-1] + 1) << endl;

		ans += ( p10[digits] - 1 - p10[digits-1] + 1);
		digits -= 2;
	}
	//
	cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S, T;
  int sizeS;
  
  cin >> S >> T;
  
  sizeS = (int) S.size();
  
  T.erase(sizeS, 1);
  
  if(S == T) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48,ch=getchar();}
	return x*f;
}

int main()
{
	int a=read(),b=read();
	if(a<b) swap(a,b);
	long long ans = a;
	a--;
	if(a<b) swap(a,b);
	ans += a;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	vector <ll> B(N - 1);
	rep(i, N - 1) {
		cin >> B.at(i);
	}
	ll an = B.at(0) + B.at(N - 2);
	rep(u, N - 2) {
		an += min(B.at(u) , B.at(u + 1));
	}
	cout << an << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main { 
    public static void main(String[] args) {
      Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();
      String o="No";
      for(int i=1;i<10;i++){
      	if(n%i==0 && n/i<10){
        	o="Yes";
        }
      }
      
      System.out.println(o);
    }
}

Measured memory_bytes: 23380
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,m,v,p = readline() |> split |> parseMap
	a = readline() |> split |> parseMap |> sort
	l = 0
	r = n-p+1
	while r-l>1
		c = (l+r)>>1
		if c+p-1>=v&&a[c]+m>=a[n-p+1]
			r = c
		else
			s = 0
			f = 0
			for i in c+1:n-p+1
				if a[c]+m<a[i]
					f = 1
				else
					s += m-a[i]+a[c]
				end
			end
			if s<m*(v-c-p+1)||f==1
				l = c
			else
				r = c
			end
		end
	end
	println(n-l)
end

main()

Measured memory_bytes: 123940
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
yoko = [True if "#" in a[i] else False for i in range(H)]
b = [list(x) for x in zip(*a)]
tate = [True if "#" in b[i] else False for i in range(W)]
for j in range(H):
    for i in range(W):
        if yoko[j] and tate[i]:
            print(a[j][i], end="")
    if yoko[j]:
        print()


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

int main() {
	int n, a, b, F = 0; cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		string S = to_string(i);
		int ret = 0;
		for (int j = 0; j < S.size(); j++) {
			ret += (S[j] - '0');
		}
		if (a <= ret && ret <= b)F += i;
	}
	cout << F << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int D, N;
	cin >> D >> N;

	Int ans = 1;
	while (D) {
		ans *= 100;
		D--;
	}

	if (N==100) {
		ans *= N + 1;
	}
	else {
		ans *= N;
	}
	cout << ans << "\n";

}


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

int main(){
    int n,a,ans=0,h;
    cin >> n >> a;
    
    for(int i=0;i<a;i++){
        cin >> h;
        ans+=h;
    }

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


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	ll l, r;
	cin >> l >> r;
	if (r - l > 2019) {
		put(0);
		return 0;
	}
	int res = 2019;
	for (ll i = l; i <= r; ++i) {
		for (ll j = i + 1; j <= r; ++j) {
			chmin(res, (i * j) % 2019);
		}
	}
	put(res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;
    ll target_xor = accumulate(a.begin() + 2, a.end(), 0ll, bit_xor<ll>());
    ll target_and = (a[0] + a[1] - target_xor) >> 1;
    bool can = ((a[0] + a[1] - target_xor) & 1) == 0;
    ll a0 = 0, a1 = 0;
    for(int i = 0; i < 64 and can; i++) {
        if(target_and & (1ll << i)) {
            can &= not (target_xor & (1ll << i));
            a0 |= 1ll << i;
            a1 |= 1ll << i;
        }
    }
    for(int i = 63; i >= 0 and can; i--) {
        if(not (target_and & (1ll << i))) {
            if(target_xor & (1ll << i)) {
                target_xor &= ~(1ll << i);
                if((a0 | (1ll << i)) <= a[0] and (a1 | target_xor) >= a[1]) {
                    a0 |= (1ll << i);
                } else {
                    a1 |= (1ll << i);
                }
            }
        }
    }
    cout << (can and 0 < a0 and a0 <= a[0] and a1 >= a[1] ? a[0] - a0 : -1) << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;
const int numcon = 26;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int D; cin>>D;
    vector<ll> C(numcon),last(numcon,0);
    vector<vector<ll> > S(D, vector<ll>(numcon));
    REP(i,numcon){
        cin>>C[i];
    }
    REP(i,D){
        REP(k,numcon){
            cin >> S[i][k];
        }
    }
    vector<ll> T(D);

    ll ans = 0;
    vector<ll> ansans(D);
    vector<ll> anscontest(D);

    REP(i,D){
        ll maxi = -inf;
        ll max_contest = -1;
        REP(k,numcon){ //どれが最大になるタイプか求める
            ll now = S[i][k];
            REP(j,numcon){  //タイプjのコンテスト分引く
                if(k != j){
                    now -= C[j] * (i+1 - last[k]);
                }
            }
            if(maxi < now){
                maxi = now;
                max_contest = k;  //k + 1番目のコンテストがその時点での最大値
            }
        }
        ans += S[i][max_contest];
        last[max_contest] = i+1;

        REP(k,numcon){
            ans -= C[k] * (i+1 - last[k]);
        }
        ansans[i] = ans;
        anscontest[i] = max_contest + 1;
    }

    REP(i,D){
        cout << anscontest[i] << endl;
    }
    
}

Measured memory_bytes: 3756
package main

import (
	"fmt"
)

func main() {

	var n int
	var max int
	var sum int

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var l int
		fmt.Scan(&l)
		sum += l
		if max < l {
			max = l
		}
	}

	sum -= max

	if max < sum {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int N;
ll ans;
ll a_m, t_m;

int main(){
  cin >> N;
  int t, a;
  cin >> t >> a;
  ans = t + a;
  a_m = a;
  t_m = t;
  rep(i, N - 1){
    cin >> t >> a;
    ll j = max(ans/(a+t), max(a_m / a, t_m/t));
    while(true){
      if(j *(a+t) >= ans && j*a >= a_m && j*t >= t_m){
        ans = j*(a+t);
        a_m = j * a;
        t_m = j * t;
        break;
      }
      j++;
    }
  }
  cout <<ans <<endl;
}
    

Measured memory_bytes: 256
a, b = map(str, input().split(' '))
a = int(a)
x = ""
for i in b:
    if i == '.':
        continue
    x += i
b = int(x)

# print(a, b)
ans = a * b
ans = str(ans)
# print(ans)
if (len(ans) <= 2):
    print ('0')
else:
    print(ans[:-2])

# ans = str(ans)
# out = ""
# for i in ans:
#     if i == '.':
#         break
#     out += i

# # if (len(out) == 0):
# #     out = "0"
# print(out)


Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();

        int[] A = new int[n];
        for(int i=0; i < n; ++i) {
            A[i] = scan.nextInt();
        }

        MergeSort m = new MergeSort(A);

        for(int i=0; i < A.length; ++i) {
            if(i != 0) {
                System.out.print(" ");
            }
            System.out.print(A[i]);
        }
        System.out.println();
        System.out.println(m.getComp());
        scan.close();
    }
}

class MergeSort {
    private int[] A;
    private int comp = 0;

    public MergeSort(int[] A) {
        this.A = A;
        mergesort(0, A.length);
    }

    private void merge(int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;

        int[] L = new int[n1 + 1];
        int[] R = new int[n2 + 1];

        for(int i=0; i < n1; ++i) {
            L[i] = A[left+i];
        }

        for(int i=0; i<n2; ++i) {
            R[i] = A[mid+i];
        }

        L[n1] = Integer.MAX_VALUE;
        R[n2] = Integer.MAX_VALUE;

        int i = 0;
        int j = 0;

        for(int k=left; k < right; ++k) {
            comp += 1;
            if(L[i] <= R[j]) {
                A[k] = L[i];
                i += 1;
            } else {
                A[k] = R[j];
                j += 1;
            }
        }
    }
    public void mergesort(int left, int right) {
        if(left+1 < right) {
            int mid = (left + right) / 2;
            mergesort(left, mid);
            mergesort(mid, right);
            merge(left, mid, right);
        }
    }

    public int getComp() {return comp;}
}


Measured memory_bytes: 168380
n=1<<18;N,m;L[1<<18],p;first[1<<18],next[1<<18];i;
long dat[1<<20],lazy[1<<20],A[1<<18],x;
eval(i,l,r){
	dat[i]+=lazy[i];
	lazy[2*i+1]+=lazy[i];
	lazy[2*i+2]+=lazy[i];
	lazy[i]=0;
}
long f(a,b,k,l,r){
	eval(k,l,r);
	return a<=l&r<=b?lazy[k]+=x,eval(k,l,r),dat[k]:l<b&a<r?dat[k]=fmax(
		f(a,b,2*k+1,l,(l+r)/2),
		f(a,b,2*k+2,(l+r)/2,r)
	):dat[k];
}
main(j){
	for(scanf("%d%d",&N,&m);~scanf("%d%d%ld",L+j,&p,A+j);first[p]=j++)next[j]=first[p];
	for(;i++<N;){
		x=f(x=0,i,0,0,n);
		f(i,i+1,0,0,n);
		for(p=first[i];p!=0;p=next[p])x=A[p],f(L[p],i+1,0,0,n);
	}
	printf("%ld",f(x=0,i,0,0,n));
}

/*
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
*/

Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
struct query { int i, L, R; };
template <typename T, typename Add, typename Remove, typename Answer>
vector<T> mo(int n, vector<query>& queries, const Add& add, const Remove& remove, const Answer& answer) {
    static_assert(is_convertible<decltype(add), function<void(int)>>::value, "add must be void(int)");
    static_assert(is_convertible<decltype(remove), function<void(int)>>::value, "remove must be void(int)");
    static_assert(is_convertible<decltype(answer), function<T(int, int)>>::value, "answer must be T(int, int)");
    vector<T> ans(queries.size());
    int sqrt_n = int(sqrt(n) + 1);
    sort(queries.begin(), queries.end(), [&](auto& a, auto& b) {
        return pair(a.L / sqrt_n, a.R) < pair(b.L / sqrt_n, b.R);
    });
    int L = 1, R = 0;
    for(const query& q : queries) {
        while(R < q.R) add(++R);
        while(R > q.R) remove(R--);
        while(L < q.L) remove(L++);
        while(L > q.L) add(--L);
        ans[q.i] = answer(q.L, q.R);
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> c(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> c[i];
    }
    vector<query> queries(q);
    for(int i = 0; i < q; i++) {
        int L, R;
        cin >> L >> R;
        queries[i] = {i, L, R};
    }
    vector<int> counter(n + 1);
    int ans = 0;
    for(int ans : mo<int>(n, queries, [&](int i) {
        ans += counter[c[i]] == 0;
        counter[c[i]]++;
    }, [&](int i) {
        counter[c[i]]--;
        ans -= counter[c[i]] == 0;
    }, [&](int, int) {
        return ans;
    })) {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 15484
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	int n,m,c=0,t=1,i,j,k,sum=0,ans,f=0,x,y;
	//cin>>t;
	while(t--){
		//vector<int> v;map<int,int> mp;set<int> st;
		cin>>n;
		s=to_string(n);	
		string ans="No\n";
		for(char i:s) if(i=='7') ans="Yes\n";
		cout<<ans;
		//int a[n];rep(i,n) cin>>a[i];

	}
	return 0;
}




Measured memory_bytes: 3716
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
#define debug(a) cout<<#a<<" --> "<<(a)<<endl;
#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)
#define INPUT freopen("input.txt","r",stdin)
#define OUTPUT freopen("output.txt","w",stdout)
#define Error  1e-9
#define pi (2*acos(0))
const ll mod =1e9 +7;
const int N = 2e5 +5;
ll bigmod(ll a, ll b, ll m)
{
    if(b==0)
        return 1%m;
    ll x=bigmod(a,b/2,m);
    x=(x*x)%m;
    if(b%2==1)
        x=(x*a)%m;
    return x;
}
ll fact[N+5];
void init()
{
    fact[0]=1;
    for(ll i=1; i<N; i++)
    {
        fact[i]= fact[i-1]*i;
        fact[i]%=mod;
    }
}
ll get_ncr(ll n, ll r)
{
    ll down = fact[r]*fact[n-r];
    down%=mod;
    ll up= fact[n];
//    for(ll i=n;i>=n-r+1;i--)
//    {
//        up*=i;
//        up%=mod;
//    }
    up*= bigmod(down,mod-2,mod);
    return up%mod;
}
void Solve(int cas)
{
    init();
    ll n,k;
    cin>>n>>k;
    k= min(k,n-1);
    ll ans =0;
    for(ll i=0;i<=k;i++)
    {
        ll koto = n-i;
        ans+= (get_ncr(n-1,koto-1)*get_ncr(n,i))%mod;
        ans%=mod;
    }
    printf("%lld\n",ans);




}



int main()
{
    //fastInput;
    //cout.tie(0);
    //INPUT;
    //OUTPUT;
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        Solve(++cas);
    }
    return 0;
}
/*

*/


//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


Measured memory_bytes: 1792
// template {{{
#include <bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define sz(c) (static_cast<int>(c.size()))
#define endl "\n"

using ld = long double;
using ll = long long;

inline ll addm(ll __a, ll __b, ll __m);
inline ll subm(ll __a, ll __b, ll __m);
inline ll mulm(ll __a, ll __b, ll __m);
ll powm(ll __a, ll __b, ll __m);
ll inv(ll __x, ll __m);
// }}}

const ll INFL = numeric_limits<ll>::max() / 2;
const ll INF = numeric_limits<int>::max() / 2;
const ll MOD = 1e9+7;

const int N = 405;
ll a[N];
ll mem[N][N];
ll dp(int l, int r)
{
    if (l == r) return 0;
    ll &ret = mem[l][r];
    if (ret != -1) return ret;
    ret = INFL;
    for (int i = l; i+1 <= r; i++) {
        ll cost = a[r]-a[l-1];
        ret = min(ret, dp(l, i) + dp(i+1, r) + cost);
    }
    return ret;
}
void solve()
{
    memset(mem, -1, sizeof(mem));
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i) a[i] += a[i-1];
    }
    cout << dp(0, n-1) << endl;
}

// main {{{
int main()
{
    cin.sync_with_stdio(0); cin.tie(NULL);
    solve();
    return 0;
}

inline ll addm(ll __a, ll __b, ll __m = MOD) {
    return ((__a+__b)%__m);
}
inline ll subm(ll __a, ll __b, ll __m = MOD) {
    return (((__a-__b)%__m+__m)%__m);
}
inline ll mulm(ll __a, ll __b, ll __m = MOD) {
    return ((__a*__b)%__m);
}
ll powm(ll __a, ll __b, ll __m = MOD) {
    ll ret = (!__b) ? 1 : powm(__a, __b/2, __m);
    return (!__b) ? 1 : mulm(mulm(ret, ret, __m), (__b%2) ? __a : 1, __m);
}
ll inv(ll __x, ll __m = MOD) {
    return powm(__x, __m-2, __m);
}
// }}}


Measured memory_bytes: 1536
N = int(input())
A = list(map(int,input().split()))
for i in range(N-1):
    A[i+1] = A[i] + A[i+1]
ans = float('inf')
for i in range(N-1):
    ans = min(ans, abs(A[-1] - 2 * A[i]))
print(ans)

Measured memory_bytes: 23800
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	x, _ := sc.NextInt()
	ans := solve(x)
	fmt.Println(ans)
}

func solve(x int) int {
	a, b := 360, x
	return a / gcd(a, b)
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

// Scanner is a wrapper of bufio.Scanner which is customized for competitive programing.
type Scanner struct {
	bufio.Scanner
}

// NewScanner is a constructor for Scanner.
func NewScanner(r io.Reader) *Scanner {
	sc := Scanner{*bufio.NewScanner(r)}
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
	return &sc
}

// NextInt reads a integer from io stream.
func (sc *Scanner) NextInt() (int, error) {
	if !sc.Scan() {
		return -1, errors.New("failed to scan")
	}
	return strconv.Atoi(sc.Text())
}


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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
//using namespace __gnu_pbds;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair

bool compare(pair<ll,pii> a, pair<ll,pii> b)
{return a.second.second*b.second.first < b.second.second*a.second.first;
}

const int mod = 1e9 + 7;
const ll inf = ll(1e18);

vvl floyd(200,vl(200,inf)),g(200,vl(200,0));

bool containsOdd(int src,int V)
{
    int colorArr[V];
    for (int i = 0; i < V; ++i)colorArr[i] = -1;
    colorArr[src] = 1;
    queue <int> q;
    q.push(src);
    while (!q.empty()){
        int u = q.front();
        q.pop();
        if (g[u][u] == 1)return true;
        for (int v = 0; v < V; ++v){
            if (g[u][v] && colorArr[v] == -1){
                colorArr[v] = 1 - colorArr[u];
                q.push(v);
            }
            else if (g[u][v] && colorArr[v] == colorArr[u])return true;
        }
    }
    return false;
}

int main() {
    //clock_t tm = clock();
    fastio;
    int n;
    cin>>n;string s;
    vi ed(n,0);
    f(i,0,n){
        floyd[i][i]=0;
        cin>>s;
        f(j,0,n){
            if(s[j]=='1'){g[i][j]=1;floyd[i][j]=1;
            }
        }
    }
    if(containsOdd(0,n))cout<<-1<<endl;
    else {
        ll ans = 0;
        f(x, 0, n) {
            f(y, 0, n) {
                f(z, 0, n) {
                    if (floyd[y][x] + floyd[x][z] < floyd[y][z])
                        floyd[y][z] = floyd[y][x] + floyd[x][z];
                }
            }
        }
        f(i, 0, n)f(j, 0, n)ans = max(ans, ll(floyd[i][j]));
        ans++;
        cout << ans << endl;
    }
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int count;
        int max = 0;
        int ans = 1;
        int a;
        
        for (int i = 2; i <= n; i++) {
            a = i;
            count = 0;
            while (a % 2 == 0) {
                count++;
                a /= 2;
            }
            if (count > max) {
                max = count;
                ans = i;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21204
import java.io.InputStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().execute(System.in);
	}

	public void execute(InputStream in) {
		Scanner sc = new Scanner(in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double rh = (h + (m / 60.0)) * 360 / 12.0;
		double rm = (m * 360 / 60.0);
		double r = Math.abs(rh - rm);
		r = Math.toRadians(r);

		double c = a * a + b * b - 2 * a * b * Math.cos(r);
		c = Math.sqrt(c);
		
		System.out.println(c);
		sc.close();
	}
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin>>n;
  vll a(n);
  REP(i,n)cin>>a[i];

  REP(i,n){
    if(a[i]==0){
      cout<<0<<endl;
      return 0;
    }
  }

  ll ans=1;
  const ll lim=1e18;
  REP(i,n){
    if(lim/a[i]<ans){
      cout<<-1<<endl;
      return 0;
    }

    ans*=a[i];
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 3992
#include <stdio.h>

int main(){
	int S, h, m, s;
	scanf("%d", &S);
	h = (int)(S/3600);
	m = (int)((S - 3600*h)/60);
	s = S - 3600*h - 60*m;
	printf("%d:%d:%d\n", h, m, s);
	return 0;

}


Measured memory_bytes: 2044
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;

namespace IO {
  static const int SZ = 1 << 20;
  static FILE *fin = stdin, *fout = stdout;
  static char ibuf[SZ], *is = ibuf, *it = ibuf;
  static char obuf[SZ], *os = obuf, *ot = obuf + SZ;
  
  inline char nextChar() {
    if (is == it) {
      it = (is = ibuf) + fread(ibuf, sizeof(char), SZ, fin);
      if (is == it)
        return EOF;
    }
    return *is++;
  }
  template <typename T>
  inline void readInt(T &x) {
    x = 0;
    T flag(1);
    char ch;
    for (ch = nextChar(); isspace(ch); ch = nextChar())
      ;
    if (ch == '-')
      ch = nextChar(), flag = -flag;
    for (; isdigit(ch); ch = nextChar())
      x = x * 10 + ch - '0';  
    x *= flag;
  }
  inline void readCh(char &now) {
    for (now = nextChar(); isspace(now); now = nextChar())
      ;  
  }
  
  inline void flushBuffer() {
    fwrite(obuf, sizeof(char), os - obuf, fout);
    os = obuf;
  }
  inline void printChar(char ch) {
    if (os == ot)
      flushBuffer();
    *os++ = ch;
  }
  template <typename T>
  inline void printInt(T x) {
    static int dig[20], cnt;
    if (os + 20 > ot)
      flushBuffer();
    if (x < 0)
      *os++ = '-', x = -x;
    cnt = 0;
    do {
      dig[++cnt] = x % 10;
      x /= 10;
    } while (x);
    for (int i = cnt; i > 0; --i)
      *os++ = dig[i] + '0';
  }
}

using namespace IO;

const int N = 1e5 + 5;

int n, a[N], b[N], c[N];
ll total;

int main() {
#ifdef LOCAL_DEBUG
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#endif
  readInt(n);
	for (int i = 1; i <= n; ++i) readInt(a[i]);
	for (int i = 1; i <= n; ++i) readInt(b[i]);
	for (int i = 1; i <= n; ++i) readInt(c[i]);
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	sort(c + 1, c + n + 1);
	total = 0;
	for (int i = 1; i <= n; ++i) {
		int len1 = lower_bound(a + 1, a + n + 1, b[i]) - a - 1;	
		int len3 = upper_bound(c + 1, c + n + 1, b[i]) - c;
		len3 = n - len3 + 1;
//		cerr << len1 << ' ' << len3 << endl;
		total = total + 1LL * len1 * len3;
	}
	printInt(total);
	printChar('\n');
  flushBuffer();
  return 0;
}

Measured memory_bytes: 2432