akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
#ABC131 D
import sys
import math

N = int(input())

AB = [list(map(int,input().split())) for _ in range(N)]
AB = sorted(AB, key = lambda x:x[1])
#print(AB)

time = 0
for i in range(N):
    time += AB[i][0]
    if time > AB[i][1]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 55232
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Set<String> dic = new HashSet<String>();
		
		int n = in.nextInt();
		for (int i = 0; i < n; i++) {
			String oppe = in.next();
			String str = in.next();
			if (oppe.equals("insert")) {
				dic.add(str);
			} else {
				if (dic.contains(str)) {
					System.out.println("yes");
				} else {
					System.out.println("no");
				}
			}
		}
	}
}



Measured memory_bytes: 250976
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, d;
string in[200];

int main(){
	while(cin >> n, n){
		cin >> d;
		rep(i, n) cin >> in[i];
		vector<pair<string, string> > ans;
		map<string, vi> m;
		
		rep(i, n){
			vector<string> ss;
			rep(j, in[i].size() + 1){
				string s = in[i];
				if(j < s.size() - 1){
					swap(s[j], s[j + 1]);
					ss.pb(s);
				}
				s = in[i];
				if(j < s.size()){
					s.erase(s.begin() + j);
					ss.pb(s);
					
					rep(k, 26){
						s = in[i];
						s[j] = 'a' + k;
						ss.pb(s);
					}
				}
				rep(k, 26){
					s = in[i];
					s.insert(s.begin() + j, 'a' + k);
					ss.pb(s);
				}
			}
			ss.pb(in[i]);
			bool ok[200] = {};
			rep(j, ss.size()) if(m.count(ss[j])){
				each(k, m[ss[j]]){
					if(ok[*k]) continue;
					ok[*k] = 1;
					string a = in[*k], b = in[i];
					if(a > b) swap(a, b);
					ans.pb(mp(a, b));
				}
			}
			
			m[in[i]].pb(i);
			if(d > 1) rep(j, ss.size()){
				if(!m.count(ss[j]) || m[ss[j]].back() != i)
				m[ss[j]].pb(i);
			}
		}
		sort(all(ans));
		rep(i, ans.size()) cout << ans[i].first << "," << ans[i].second << endl;
		cout << ans.size() << endl;
	}
	return 0;
}

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

import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		if (m == 0) {
			System.out.println(n+1);
			return;
		}
		P[] ps = new P[m];
		for (int i=0;i<m;i++) {
			ps[i] = new P(sc.nextInt(), sc.nextInt());
		}
		sort(ps);
//		for (P p : ps) debug(p.f, p.t);
		int s = ps[0].f, e = ps[0].t;
		ArrayList<P> l = new ArrayList<P>();
		for (int i=1;;i++) {
//			debug(s, e, ps[i].f, ps[i].t);
			while (i < m && e >= ps[i].f) {
				e = max(e, ps[i].t);
//				debug(s, e, ps[i].f, ps[i].t);
				i++;
			}
			l.add(new P(s, e));
			if (i == m) break;
			s = ps[i].f; e = ps[i].t;
		}
		int len = 0, c = 0;
		for (P p: l) {
			len += p.f - c;
			len += 3 * (p.t - p.f);
			c = p.t;
//			debug(p.f, p.t);
		}
		len += n+1 - c;
		System.out.println(len);
	}

	class P implements Comparable<P>{
		int f, t;
		P(int f, int t) {
			this.f = f;
			this.t = t;
		}
		public int compareTo(P o) {
			// TODO 自動生成されたメソッド・スタブ
			if (f == o.f) {
				return o.t - t;
			}
			return f - o.f;
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

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

int main() {
    int S;
    cin >> S;
    
    int hour = S / 3600;
    int minute = (S - (hour * 3600 )) / 60;
    int sec = S - (hour * 3600) - (minute * 60) ;
    
    cout << hour << ":" << minute << ":" << sec << endl;
    
}



Measured memory_bytes: 3092
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;
#define NIL -1
#define fi first
#define sec second
#define MAX INT_MAX
#define INF 99999999
#define ll long long
#define PI acos(-1.0)
#define MOD 1000000007
#define PLL pair<ll,ll>
#define PII pair<int,int>
#define ull unsigned long long
#define triplell pair<pair<ll,ll> , ll>
#define triple pair<pair<int,int> , int>
#define For(i,n) for(int i=0;i<(int)n;i++)
#define Forn(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define forba(i,a,b) for(int i=(int)b;i>=(int)a;i--)

bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

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

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n;

    vector<ll>vec(n) , L(n) , R(n);

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

    L[0] = vec[0];
    R[n-1] = vec[i-1];

    for(i=1;i<n;i++)
    {
        L[i] = __gcd(L[i-1],vec[i]);
    }

    for(i=n-2;i>=0;i--)
    {
        R[i] = __gcd(R[i+1],vec[i]);
    }

    ll ans = 0;

    for(i=0;i<n;i++)
    {
        if(i==0)
            ans = max(ans,R[1]);
        else if(i==n-1)
            ans = max(ans,L[i-1]);
        else
        {
            ll gc = __gcd(L[i-1],R[i+1]);
           // cout<<gc<<endl;
            ans = max(ans,gc);
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 2560
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

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

  vvll dp(n + 1, vll(w + 1, -1));

  vll vs(n);
  vll ws(n);
  rep(i, n) cin >> vs[i] >> ws[i];

  ll ans = 0;
  dp[0][w] = 0;
  rep(i, n) rep(j, w+1) {
    bool cond = j + ws[i] > w || dp[i][j + ws[i]] == -1;
    if (cond) {
      dp[i + 1][j] = dp[i][j];
    } else {
      ll canda = dp[i][j];
      ll candb = dp[i][j + ws[i]] + vs[i];
      dp[i + 1][j] = max(canda, candb);
    }
    chmax(ans, dp[i + 1][j]);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 10812
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int sx,sy;
int n;
int kx[10],ky[10];
const int dx[12] = {2,2,2,1,0,-1,-2,-2,-2,-1,0,1};
const int dy[12] = {1,0,-1,-2,-2,-2,-1,0,1,2,2,2};
bool in(int x,int y){
  if(x<0||x>9) return false;
  if(y<0||y>9) return false;
  return true;
}
bool skr(int i,int x, int y){
  if(abs(x-kx[i])>1) return false;
  if(abs(y-ky[i])>1) return false;
  return true;
}
bool dfs(int i,int x,int y){
  if(i==n) return true;
  REP(j,12){
    int nx = x + dx[j];
    int ny = y + dy[j];
    if(!in(nx,ny)) continue;
    if(!skr(i,nx,ny)) continue;
    if(dfs(i+1,nx,ny)) return true;
  }
  return false;
}
int main(void){
  while(cin>>sx>>sy){
    if(sx==0&&sy==0) break;
    cin>>n;
    REP(i,n){
      cin>>kx[i]>>ky[i];
    }
    if(dfs(0,sx,sy))cout<<"OK"<<endl;
    else cout<<"NA"<<endl; 
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if(v<=w)
    {
        cout<<"NO";
        return 0;
    }
    ll num=abs(b-a);
    ll speed=v-w;
    if(speed*t>=num)
    cout<<"YES";
    else
    cout<<"NO";


    
    return 0;
}

Measured memory_bytes: 3652
import math as m
n = int(input())
max1 = 0
sqr = m.ceil(m.sqrt(n) + 1)
if n == 1:
	print(0)
	exit()
for i in range(1,sqr):
	if n%i == 0:
		max1 = max(max1, i)
print(max1 + n//max1 - 2)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
typedef long long llint;
llint n;
llint t[102];

llint gcd(llint a,llint b){
  if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void){
  cin >> n;
  for(llint i=0;i<n;i++) cin >> t[i];
  llint ans=1;
  for(llint i=0;i<n;i++){
    ans=ans/gcd(ans,t[i])*t[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = gets.to_i
p = gets.split.map(&:to_i)

s = Array.new(N)
N.times do |i|
  
  s[i] = p[i]-1 != i ? true : false
  
end

# p s

ans = 0
N.times do |i|
  
  if s[i] == false
    
    s[i] == true
    ans += 1
    
    if i-1 >= 0 && s[i-1] == false
      
      s[i-1] = true
      
    elsif i+1 <= N - 1 && s[i+1] == false
      
      s[i+1] = true
      
    elsif i+1 <= N - 1 
      
      s[i+1] = true
      
    else
      
      s[i-1] = true
      
    end
  end
      
end

puts ans

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    vector<ll> X(N), Y(N), Z(N);
    rep(i, N) cin >> X[i] >> Y[i] >> Z[i];

    ll ans = -INFLL;
    rep(a, 2) rep(b, 2) rep(c, 2) {
        vector<ll> tmp;
        rep(i, N) {
            tmp.push_back(
                    (a == 0 ? X[i] : -X[i]) +
                    (b == 0 ? Y[i] : -Y[i]) +
                    (c == 0 ? Z[i] : -Z[i])
            );
        }
        sort(tmp.begin(), tmp.end(), greater<ll>());
        
        ll sum = 0;
        rep(i, M) sum += tmp[i];
        ans = max(ans, sum);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
from collections import Counter

cnt = Counter()
num = int(input())
for ans in [input() for i in range(num)]:
    cnt[ans] += 1

print('AC x ' + str(cnt['AC']))
print('WA x ' + str(cnt['WA']))
print('TLE x ' + str(cnt['TLE']))
print('RE x ' + str(cnt['RE']))


Measured memory_bytes: 16584
#include <stdio.h>
#include <stdlib.h>
int BS(int, int *, int);
int main(){
  int n, q, S[100000], T;
  int i, num, count = 0;
  scanf("%d",&n);
  for(i = 0; i < n; i++)scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&T);
    num = BS(T, S, n);
    if(num == 1)count++;
  }
  printf("%d\n",count);
  return 0;
}
int BS(int T, int S[], int n){
  int L, R, M;
  L = 0;
  R = n;
  while(L < R){
    M = (L + R) / 2;
    if(S[M] == T)return 1;
    else if(T < S[M])R = M;
    else L = M +1;
  }
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(A > 0 && B > 0){
    C -= B;
    A -= D;
  }
  if(A <= 0 && C <= 0)cout << "Yes";
  if(A > 0 && C <= 0)cout << "Yes";
  if(A <= 0 && C > 0)cout << "No";
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
	int n,m,a[100],i,j,box;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=2;i<=m;i++){
		for(j=0;j<n-1;j++){
			if(a[j]%i>a[j+1]%i){
				box=a[j];
				a[j]=a[j+1];
				a[j+1]=box;
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}


Measured memory_bytes: 2084
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))

H, W, K = mi()
S = [list(sys.stdin.readline().rstrip()) for _ in range(H)]
l = [0] * H
for i in range(H):
    l[i] = sum([S[i][j] == '#' for j in range(W)])

l = list(accumulate(l))
#print(l)

ans = dp2(0, W, H)
num = 1
for i in range(H):
    if (i==l[i]==0):
        continue
    elif (i>0 and l[i]==l[i-1]):
        for j in range(W):
            ans[i][j] = ans[i-1][j]
    else:
        for j in range(W):
            ans[i][j] = min(num, l[i])
            if S[i][j] == '#':
                num += 1

for i in reversed(range(H)):
    if ans[i][0] == 0:
        for j in range(W):
            ans[i][j] = ans[i+1][j]

#print(ans)
for i in range(H):
    for j in range(W):
        print(ans[i][j], end='')
        if j != W-1:
            print(' ', end='')
    print('')

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

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

template<typename T>
string toString(const T& x) {
  ostringstream os; os << x; return os.str();
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int t, n;
  while (cin >> t >> n, t) {
    string s = toString(n);
    int sz = s.size();
    map<int, vector<int>> mp;
    for (int i = 0; i < 1 << (sz - 1); i++) {
      int l = 0, r = 0, sub = 0;
      while (l < sz - 1) {
        while (r < sz - 1 && (i >> r & 1) == 0) r++;
        sub += atoi(s.substr(l, r - l + 1).c_str());
        l = ++r;
      }
      if (l < sz) sub += atoi(s.substr(l, r - l + 1).c_str());
      mp[sub].emplace_back(i);
    }
    
    int ans = -1;
    for (auto& i : mp) {
      if (i.first > t) continue;
      ans = max(ans, i.first);
    }

    if (ans < 0) {
      cout << "error" << endl;
    } else if (mp[ans].size() > 1) {
      cout << "rejected" << endl;
    } else {
      cout << ans;
      int l = 0, r = 0;
      while (l < sz - 1) {
        while (r < sz - 1 && (mp[ans][0] >> r & 1) == 0) r++;
        cout << " " << s.substr(l, r - l + 1);
        l = ++r;
      }
      if (l < sz) cout << " " << s.substr(l, r - l + 1);
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include <cmath>

using namespace std;
using ll = long long;

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

  if(n%2) {
    int h = n/2;
    for (auto i = 0; i!=m;++i) {
      cout << h-i << " " << h+i+1 << endl;
    }
    return 0;
  } else {
    int g1 = min(n/4,m);
    int g2 = m - g1;

    for(auto i=0; i!=g2;++i) {
      cout << i+1 << " " << n-i-1 << endl;
    }
    int h = n/2;
    for(auto i=0; i!=g1;++i) {
      cout << h-i << " " << h+i+1 << endl;
    }
    return 0;
  }

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
cin >> N;
 if(N%2==0){
     cout << "0.5"<<endl;
 }
 else{
     int c;
     c=(N/2+1)*1000000/N;
     cout << 0.000001*c << endl;
 }
 
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;

template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO  

  char c;
  for(int row = 0; row < 3; ++row){
    for(int col = 0; col < 3; ++col){
      cin >> c;
      if(row == col) cout << c;
    }
  }

  return 0;
}

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

signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  sort(begin(A),end(A));
  int ans=0;
  rep(i,N-1)ans+=A[i];
  ans+=A[N-1]/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    ll d; cin >> d;
    int cnt = 0;
    for (int i = 1 ; i <= n ; i++){
        ll x , y; cin >> x >> y;
        if (x * x + y * y <= d * d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define for1(i, a, b) for (int i = (int)a; i < (int)(b); ++i)
#define rfor1(i, a, b) for (int i=(int)b-1;i>=(int)a;i--)
#define for2(i, a, b) for (int i = (int)a; i <= (int)(b); ++i)
#define for3(i, a, b) for (int i = (int)a; i < (int)(b); i=i+2)
#define for4(i, a, b) for (int i = (int)a; i <= (int)(b); i=i+2)
#define tc(t) int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b <= a + c && a + b <= b + c) {
        cout << a + b << endl;
    } else if (a + b >= a + c && c + b >= a + c) {
        cout << a + c << "\n";
    } else {
        cout << b + c << "\n";
    }
}









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

int main (){
    int a,b;
    int sum=1;
    int count=0;
    cin >>a>>b;
    int c=a-1;
    if(b==1){
        cout << 0 << endl;
        return 0;
    }
    while(1){
        sum+=c;
        count++;
        if(sum>=b) break;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;
const long double pi=atan(1)*4;
const long double eps=1e-10;

int main(){
	int X;
	cin >> X;
	long double x=0, y=1;
	LL K=1;
	long double deg=90;
	while(abs(x)>eps || abs(y)>eps){
		deg+=X;
		if(deg>360) deg-=360;
		x+=cos(deg/180*pi), y+=sin(deg/180*pi);
    	K++;
	}
  	cout << K << endl;

	return 0;
}

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

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define abs(a) (a)>0 ?(a):-(a)
#define llong long long

struct list{
	char s[20];
	struct list *left;
	struct list *right;
};

int insert(struct list**,char*);

int main(){
	int N; scanf("%d",&N);
	struct list *top = NULL;
	int cnt=0;
	rep(i,0,N){
		char s[20]; scanf("%s",s);
		cnt += insert(&top,s);
	}
	printf("%d",cnt);
	return 0;
}

int insert(struct list **top,char *s){
	if( *top == NULL ){
		*top = (struct list*)malloc(sizeof(struct list));
		strcpy((*top)->s,s);
		(*top)->left=NULL; (*top)->right=NULL;
		return 1;
	}
	struct list *t = *top;
	while(1){
		if( strcmp(t->s,s) < 0 ){
			if( t->left == NULL ){
				t->left = (struct list*)malloc(sizeof(struct list));
				t = t->left;
				strcpy(t->s,s); t->left=NULL; t->right=NULL;
				return 1;
			}else{
				t = t->left;
			}
		}else if( strcmp(t->s,s) > 0 ){
			if( t->right == NULL ){
				t->right = (struct list*)malloc(sizeof(struct list));
				t = t->right;
				strcpy(t->s,s); t->left=NULL; t->right=NULL;
				return 1;
			}else{
				t = t->right;
			}
		}else if( strcmp(t->s,s)==0 ){
			return 0;
		}
	}
}


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

int main() {
  int s,i;
  cin >> s;
  
  i = 0;
  i += s%10;
  
  s = s/10;
  i += s%10;
  s = s/10;
  i += s;

  cout << i << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

int main()
{
	int X,Y,Z;
	int N;
	scanf("%d %d %d",&X,&Y,&Z);
	N=(X-Z)/(Y+Z);
	printf("%d",N);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e8;
const ll infl = 1LL << 60;
///////
const ll MOD = 1e9+7;
int main(){
  int a,b,k;
  cin >> k >> a >> b;
  for(int i=a;i<=b;i++){
    if(i%k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3636
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))

AB = []
for i in range(M):
    a, b = list(map(int, input().split()))
    AB.append([a-1, b-1])

# nh = [0] * N
ans = [True] * N

for a, b in AB:
    if H[a] == H[b]:
        ans[a] = False
        ans[b] = False
    elif H[a] > H[b]:
        ans[b] = False
    else:
        ans[a] = False

r = ans.count(True)
print(r)



Measured memory_bytes: 28872
a = int(input()) #500
b = int(input()) #100
c = int(input()) #50
x = int(input()) #x==100(仮)
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            A = i*500 + j*100 + k*50
            if x == A:
                ans += 1

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
int n;
void solve(){
	cin>>n;
	int arr[n][3];
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < 3; j++) cin>>arr[i][j];
	}
	int dp[n][3];
	dp[0][0] = arr[0][0], dp[0][1] = arr[0][1], dp[0][2] = arr[0][2];
	for(int i = 1; i < n; i++){
		dp[i][0] = arr[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = arr[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = arr[i][2] + max(dp[i - 1][1], dp[i - 1][0]);
	}
	cout<<max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}
int main(){
	io;
	solve();
	return 0;
}


Measured memory_bytes: 5956
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;

int main() {
	string s;
	char c='A';
	ll n,ans=0;
	cin >> n;
	cin >> s;
	for (int i=0; i <n ; i++) {
		if (c != s[i]) {
			ans++;
			c = s[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
n,m = gets.chomp.split.map(&:to_i).sort
MOD = 10**9+7
ans = 0
if m - n <= 1
  ans = (1..n).inject{|sum,x| sum * x % MOD} * (1..m).inject{|sum,x| sum * x % MOD} % MOD
  ans *= 2 if m == n
end

puts ans % MOD

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    set<string> st;
    cin >> n;
    rep(i, 0, n){
        string s;
        cin >> s;
        st.insert(s);
    }
    int cnt = 0;
    cin >> m;
    rep(i, 0, m){
        string s;
        cin >> s;
        if(st.count(s)){
            if(cnt % 2 == 0){
                cout << "Opened by " << s << endl;
            }else{
                cout << "Closed by " << s << endl;
            }
            cnt++;
        }else{
            cout << "Unknown " << s << endl;
        }
    }

}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    set<int> se;
    se.insert(a);
    se.insert(b);
    se.insert(c);
    if(se.size()==2){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int result = (x - a) % b;
        System.out.println(result);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>

int base;

int hit(){
	if(base==3) return 1;
	else base++;
	return 0;
}

int homerun(){
	base++;
	return base;
}

int main(){
	int inning;
	std::cin >> inning;

	for(int i=0;i<inning;i++){
		int outCount=0;
		int point=0;
		std::string result;
		base=0;
		while(outCount<3){
			std::cin >> result;

			if(result == "HIT"){
				point += hit();
			} else if(result == "HOMERUN"){
				point += homerun();
				base=0;
			} else if(result == "OUT"){
				outCount++;
			}
		}
		std::cout << point << std::endl;
	}

    return 0;
}


Measured memory_bytes: 3032
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
static const int N=105;
int M[N+1][N+1];
void graph(int n){
    for(int i=1;i<=n;i++)M[0][i]=1;
    for(int i=1;i<=n;i++){
        int garbage;cin>>garbage;
        int k;cin>>k;
        for(int j=1;j<=k;j++){
            int l;cin>>l;
            M[i][l]=1;
        }
    }
}
int d[N],f[N],t=0,n;
stack <int>S;
void dfs(){
    S.push(0);
    while(S.empty()!=true){
        int flag=0,i=1;
        while(flag==0 && i<=n){
            if(M[S.top()][i]==0){
                i++;
            }else{
                    flag++;
                for(int z=0;z<=n;z++) M[z][i]=0;
            }
        }
        t++;
        if(i>=n+1){
            f[S.top()]=t;
            S.pop();
        }else{
            S.push(i);
            d[i]=t;
        }
    }
}

int main(){
    cin>>n;
    graph(n);
    dfs();
    for(int i=1;i<=n;i++){
        cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
    }
    
    return 0;
}

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

int main() {
    int N, K, sum = 0;
    cin >> N >> K;
    
    for(int i = 0; i < N; i++){
        int x, dist = 0;
        cin >> x;

        if(std::abs(K - x) < x){
            dist = std::abs(K - x);
        }else{
            dist = x;
        }
        sum += 2 * dist;
    }

    cout << sum << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mp(v1, v2)       make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------

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

  int tmp=1;
  while(1){
    if((tmp<<1)>n){
      prt(tmp);
      return 0;
    }
    tmp<<=1;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    ll N, D;
    cin >> N >> D;
    if(D == 1) {
        cout << N * (N - 1) / 2 << endl;
    }
    else if(D == 2){
        cout << N * (N - 1) / 2 - 1 << endl;
    }
    else{
        ll A = N - (D - 2);
        cout << A * (A - 1) / 2 - 1 + D - 2 << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 3212
N = int(input())
w_li = [input() for i in range(N)]
past_words = []
for i in range(N) :
    if i != 0 and (w_li[i] in past_words or past_words[i - 1][-1] != w_li[i][0]) :
        print("No")
        exit()
    past_words.append(w_li[i])
print("Yes")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int Solve(int p,int t,int n,int*a){
	
	if(p<=n){
		if(t==0)return 1;
		return Solve(p+1,t-*(a+p),n,a) | Solve(p+1,t,n,a);
	}
	return 0;
}

int main() {
	int n,q,a[2000],i,j,m;
	
	cin>>n;
	for(i=0;i<n;++i)cin>>a[i];
	
	cin>>q;
	
	for(i=0;i<q;++i){
		cin>>m;
		if(Solve(0,m,n,a))cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let m: usize = read();

    let mut rui: Vec<i64> = vec![0; n+1];
    
    for i in 0..m {
        let l: usize = read();
        let r: usize = read();
        rui[l-1] += 1;
        rui[r] -= 1;
    }

    for i in 0..n {
        rui[i+1] += rui[i];
    }

    let mut ans = 0;
    for i in 0..n {
        if rui[i] as usize == m {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
N = int(input())
A = list(map(int, input().split()))

d = {}
for a in A:
    d.setdefault(a, 0)
    d[a] += 1

A = sorted(set(A))
t = [True] * (10 ** 6 + 1)

for a in A:
    for i in range(a + a, 10 ** 6 + 1, a):
        t[i] = False

for a in d:
    if d[a] > 1:
        t[a] = False

result = 0
for a in A:
    if t[a]:
        result += 1
print(result)


Measured memory_bytes: 44340
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N + 1];
int B[MAX_N + 1];

void solve() {
	int a,b;
  	cin>>a>>b;
  	int sum=a-b*2;
  	if(sum<0){
    	ce(0);
    }else{
    	ce(sum);
    }
}

int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	vector<int> X(N);
	vector<int> P(N);
	rep(i, 0, N)cin >> X[i];
	int cnt = 0;
	rep(i, 0, N)
	{
		P[cnt]++;
		if (X[i] < (i - cnt) * 2 + 1)
		{
			cnt++;
		}
	}

	int ans = 1;
	int t = 0;
	rep(i, 0, N)
	{
		t = (P[i] + t) % MOD;
		ans *= t;
		ans %= MOD;
		t = (t - 1 + MOD) % MOD;
	}

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4728
from itertools import product


def main():
    n = input()
    numbers = ['3', '5', '7']
    length = len(n)
    answer = 0
    for i in range(3, length + 1):
        for new_num in product(numbers, repeat=i):
            if not all(x in new_num for x in numbers):
                continue
            elif int("".join(new_num)) <= int(n):
                answer += 1
    print(answer)


if __name__ == '__main__':
    main()



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

int main() {
    int min_residual = 10, min_idx;
    int sum_time = 0;
    int times[5];
    for (int i = 0; i < 5; i++) {
        cin >> times[i];
    }

    // search min residual idx
    for (int i = 0; i < 5; ++i) {
        if (times[i] % 10 != 0) {
            if (times[i] % 10 < min_residual) {
                min_residual = times[i] % 10;
                min_idx = i;
            }
        }
    }

    for (int i = 0; i < 5; i++) {
        if (i != min_idx) {
            sum_time += times[i];
            if (times[i] % 10 != 0) sum_time += 10 - times[i] % 10;
        }
        else {
            sum_time += times[i];
        }
//        cout << sum_time << endl;
    }
    cout << sum_time << endl;

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n; cin  >>n;
  map<string,int> MAP;
  vector<string> s(n);
  rep(i,n) {
  string a;
  cin >>a;
  s[i]=a;
  MAP[a]++;
  }
  int count=0;
  for(string S:s)  count =max(count,MAP[S]);
  for(auto it:MAP) {
      if (it.second == count) {
      cout << it.first << endl;
      }
  }
  //for(auto it=MAP.begin();it!=MAP.end();it++) if(MAP[it]==count) cout <<it<<endl;
  }

Measured memory_bytes: 26752
a, b, c, d = gets.chomp.split(" ").map(&:to_i)

a_multiple = a / c + a / d - a / c.lcm(d)
b_multiple = b / c + b / d - b / c.lcm(d)

ans = (b-b_multiple) - (a-a_multiple)
ans += 1 if a%c != 0
puts ans

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

int main(){
    int N;cin>>N;
    for(int i=1;i<=9;i++){
        if(N%i==0 and N/i<=9){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}

vector<int> getDegs(int h,int m,int s){
  vector<int> res({h,m,s});
  res[1] = (res[1] - res[0] + 60)%60;
  res[2] = (res[2] - res[0] + 60)%60;
  res[0] = 0;
  return res;
}


int toSec(int h,int m,int s){return s + 60*m + 60*60*(h/5);}
int toSec(vector<int> a){return toSec(a[0],a[1],a[2]);}
bool can(int hh,int mm,int ss){return hh%5 == mm/12;}

vector<vector<int> > calcSameTimes(vector<int> a){
  vector<vector<int> > res; 
  for(int h=0;h<60;h++)
    for(int m=0;m<60;m++)
      for(int s=0;s<60;s++){
        if(!can(h,m,s))continue;
        if(a == getDegs(h,m,s)) res.push_back(vector<int>({h,m,s}));
      }
  return res;
}

vector<vector<int> > calcSameTimes(int h,int m,int s){
  vector<int> a = {h,m,s}; sort(a.begin(),a.end());
  vector<vector<int> > res; 
  do{
    vector<vector<int> > tmp = calcSameTimes(getDegs(a[0],a[1],a[2]));
    for(vector<int> t:tmp) res.push_back(t);
  } while(next_permutation(a.begin(),a.end()));
  sort(res.begin(),res.end());
  res.erase(unique(res.begin(),res.end()),res.end());
  return res;
}

int n;
vector<vector<vector<int> > > times;
vector<int> calcTime(int h,int m,int s){
  vector<int> res;
  int mx = -1;
  for(int i=0;i<n;i++){
    vector<int> tmp;
    int mn = INF;
    for(vector<int> &t:times[i]){
      int a = toSec(h,m,s);
      int b = toSec(t[0],t[1],t[2]);
      if(b < a || mn <= b - a) continue;
      mn = b - a;
      tmp = t;
      break;
    }
    if(mn == INF) return vector<int>();
    if(mx < mn) mx = mn, res = tmp;
  }
  return res;
}

signed main(){
  while(1){
    cin>>n;
    if(!n) break;
    times.clear();
    times.resize(n);
    for(int i=0;i<n;i++){
      int h,m,s;
      cin>>h>>m>>s;
      times[i] = calcSameTimes(h,m,s);
    }
    
    vector<int> from,to;
    int mn = INF;
    for(int h=0;h<60;h++)
      for(int m=0;m<60;m++)
        for(int s=0;s<60;s++){
          if(!can(h,m,s))continue;
          vector<int> a = {h,m,s};
          vector<int> b = calcTime(h,m,s);
          if(b.empty()) continue;
          int as = toSec(h,m,s);
          int bs = toSec(b[0],b[1],b[2]);
          assert(bs >= as);
          if(mn > bs - as) mn = bs - as, from = a, to = b;
        }
  
    printf("%02lld:%02lld:%02lld ",from[0]/5,from[1],from[2]);
    printf("%02lld:%02lld:%02lld\n",to[0]/5,to[1],to[2]);
  }
  return 0;
}

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

namespace abc149_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var X = CIn.ReadInt();
      var ans = MathTools.PrimeNumbers(100003).First(e => e >= X);

      Console.WriteLine(ans);
    }
  }

  class MathTools
  {
    public static long Gcd(long a, long b)
    {
      while (b != 0)
      {
        var mod = a % b;
        a = b;
        b = mod;
      }
      return a;
    }

    public static long Lcm(long a, long b)
    {
      return a * b / Gcd(a, b);
    }

    public static List<long> PrimeNumbers(long n)
    {
      var list = new List<long>();
      var sieve = new bool[n + 1];

      for (var i = 2; i <= n; i++)
      {
        if (!sieve[i])
        {
          list.Add(i);
          for (var j = i * 2; j <= n; j += i)
          {
            sieve[j] = true;
          }
        }
      }
      return list;
    }

    public static List<long> PrimeFactors(long n)
    {
      var list = new List<long>();
      var primeNumbers = PrimeNumbers((long)Math.Sqrt(n));

      foreach (var p in primeNumbers)
      {
        if (n == 1)
        {
          break;
        }
        while (n % p == 0)
        {
          n /= p;
          list.Add(p);
        }
      }
      if (n > 1)
      {
        list.Add(n);
      }
      return list;
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }
  }
}

Measured memory_bytes: 13536
S=input()
check=S
flg=0
P=list(check)
while True:
    P.pop(-1)
    P.pop(-1)
    naga=int(len(P)/2)
    for i in range(0,naga):
        if P[i]==P[naga+i]:
            flg=1
        else:
            flg=0
            break
    if flg==1:
        break
print(len(P))

Measured memory_bytes: 3060
use proconio::input;
use std::cmp::min;

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
    }

    let mut mid = a / 2;
    let mut ans = ((a - mid) * b * c) - (mid * b * c);
    mid = b / 2;
    ans = min((a * (b - mid) * c) - (a * mid * c), ans);
    mid = c / 2;
    ans = min((a * b * (c - mid)) - (a * b * mid), ans);
    println!("{}", ans);
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli n;
	cin>>n;
	vector<lli> p(n+1);
	REP(i,1,n+1)cin>>p[i];

	lli cnt=0;
	for(lli i=1;i<=n;i++){
		lli num = i;
		if(p[i]!=num){
			lli next = p[i];
			if(p[next] != num){
				cout<<"NO"<<endl;
				return 0;
			}
			cnt++;
			swap(p[i],p[next]);
		}
	}
	if(cnt>=2)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=1e5+5;
int n,m;
int a[maxn];
ll sum[2][maxn];
void Add(int id,int l,int r,int num){
	if(l>r)return;
	sum[id][l]+=num;
	sum[id][r+1]-=num;
}
int main(){
	read(n);read(m);
	rep(i,1,n)read(a[i]);
	rep(i,2,n){
		if(a[i-1]<a[i]){
			Add(0,1,a[i-1],a[i]-a[i-1]);
			Add(0,a[i]+1,m,a[i]-a[i-1]);
			Add(0,a[i-1]+1,a[i],1+a[i]);
			Add(1,a[i-1]+1,a[i],-1);
		}else{
			Add(0,1,a[i],1+a[i]);
			Add(1,1,a[i],-1);
			Add(0,a[i]+1,a[i-1],m+a[i]-a[i-1]);
			Add(0,a[i-1]+1,m,1+a[i]+m);
			Add(1,a[i-1]+1,m,-1);
		}
	}
	rep(i,1,m)sum[0][i]+=sum[0][i-1],sum[1][i]+=sum[1][i-1];
	ll ans=1e18;
	rep(i,1,m){
		ll res=sum[0][i]+sum[1][i]*i;
		ans=min(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int n, a[N];
long long f[N], rev[N], fac[N], revfac[N];

long long C(int n, int k) {
    return fac[n] * revfac[k] % MOD * revfac[n - k] % MOD;
}
void prepare() {
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];

    fac[0] = 1;
    for(int i = 1; i < N; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
    rev[1] = 1;
    for(int i = 2; i < N; i++)
        rev[i] = MOD - (MOD / i) * rev[MOD % i] % MOD;
    revfac[0] = 1;
    for(int i = 1; i < N; i++) revfac[i] = revfac[i - 1] * rev[i] % MOD;

    f[0] = 0;
    for(int i = 1; i < n; i++) f[i] = (f[i - 1] + C(n, i + 1) * i % MOD * fac[i - 1] %MOD * fac[n - i - 1]) %MOD;
}
long long solve() {
    long long ans = 0;
    for(int i = 1; i <= n; i++) {
        ans = (ans + (fac[n] + f[i - 1] + f[n - i]) * a[i]) % MOD;
    }
    return ans;
}
int main() {
    prepare();
    cout << solve();
}


Measured memory_bytes: 3712