akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N, K;
    vector<vector<int>> G;

    void input() {
        cin >> N >> K;
        G.resize(N);
    }

    void solve() {
        input();
        for (int i = 1; i < N; ++i) {
            G[i].push_back(0);
        }

        ll val = (N - 1) * (N - 2) / 2;
        if (val < K) {
            cout << -1 << endl;
            return;
        }


        for (int i = 1; i < N; ++i) {
            for (int j = i + 1; j < N; ++j) {
                if (val > K) {
                    val--;
                    G[i].push_back(j);
                }
            }
        }

        vector<pair<int, int>> edges;
        for (int i = 0; i < N; ++i) {
            for (auto e : G[i]) {
                edges.push_back(pair<int, int>(i, e));
            }
        }

        cout << edges.size() << endl;
        for (auto e : edges) {
            cout << e.first + 1 << " " << e.second + 1 << endl;
        }


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define N 20
#define M 200

int solve(int,int);

int n,a[N];

int main()
{
  int m[M],q,i,b;

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

  scanf("%d",&q);
  for(i=0 ; i<q ; i++)
    {
      scanf("%d",&m[i]);
    }
  for (i = 0; i < q; i++) {
      if (solve(0, m[i]) == 1)
      {
        printf("yes\n");
      }
      else
      {
        printf("no\n");
      }
    }

  return 0;
}


int solve(int i,int m)
{
  int res;
  if(m==0) return 1;
  else if(i>=n) return 0;

  res = solve(i+1,m-a[i]) || solve(i+1,m);
  return res;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pii pair<int,int>
using namespace std;
int main()
{
    fast;
  
    ll n,p,i,di = 1 , sum = 0,ans=0;
    cin>>n>>p;
    string s;
    cin>>s;
    if(p==2 or p==5)
    {
    	for(i=0;i<n;i++)
    	{
    		ll da = s[i] - '0';
    		if(da%p==0) ans += i+1;
    	}
    	cout<<ans;
    	return 0;
    }
    reverse(s.begin(),s.end());
    ll a[n+2];
    for(i=0;i<n;i++)
    {
    	ll da = s[i] - '0';
    	a[i] = (da%p * di%p)%p;
    	di = (di * 10LL)%p;
    }
    map<ll,ll> ma;
    for(i=0;i<n;i++)
    {
    	sum += a[i];
    	ma[((sum%p) + p )%p]++;
    }
    for(i=0;i<p;i++)
    {
    	if(ma[i]>1)
    	{
    		ans += (ma[i] * (ma[i]-1)) / 2;
    	}
    }
    ans += ma[0];
    cout<<ans;
}

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

int main(void)
{
    string s, t;
    cin >> s >> t;
    int len = s.length();
    map<char, set<int>> mps, mpt;
    for (int i = 0; i < len; ++i)
    {
        mps[s[i]].insert(i);
        mpt[t[i]].insert(i);
    }

    map<char, bool> cs, ct;
    for (int i = 0; i < len; ++i)
        cs[s[i]] = true, ct[t[i]] = true;
    for (auto i : mps)
    {
        for (auto j : mpt)
        {
            if (cs[i.first] && ct[j.first] && i.second == j.second)
                cs[i.first] = false, ct[j.first] = false;
        }
    }
    for (auto i : cs)
    {
        if (i.second)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    for (auto i : ct)
    {
        if (i.second)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 31760
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define endl "\n"
#define loop(i,s,e) for(int i=s;i<e;i++)
#define int long long
#define mp make_pair
#define pii pair<int,int>
#define mset(a,f)  memset(a , f , sizeof(a))
#define pb push_back
const int N = 2e6 + 6;
const int M = 1e9 + 7;
int A[N];
int n;

void solve()
{
	int n ,m;
	cin >> n >> m;

	int to = 0;

	loop(i,0,n) 
	{
		cin >>  A[i];
		to += A[i];
	}

	int k = to/(4*m);
	int r=4*m;
	if(to%r)k++;
	int ct = 0;
	loop(i,0,n)
	{
		if(A[i] >= k)ct++;
	}

	if(ct >= m)cout << "Yes";
	else cout << "No";

}
 
int32_t main()
{
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
    

 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll MOD = 998244353;
signed main(){
    int n,s; cin >> n >> s;
    ll dp[n+1][s+1][3];
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    rep(i,n){
        int a; cin >> a;
        rep(j,s+1){
            dp[i+1][j][0]+=dp[i][j][0];
            dp[i+1][j][1]+=dp[i][j][0]+dp[i][j][1];
            dp[i+1][j][2]+=dp[i][j][0]+dp[i][j][1]+dp[i][j][2];
            rep(k,3)dp[i+1][j][k]%=MOD;
            if(j+a<=s){
                dp[i+1][j+a][1]+=dp[i][j][0]+dp[i][j][1];
                dp[i+1][j+a][2]+=dp[i][j][0]+dp[i][j][1];
                rep(k,3)dp[i+1][j+a][k]%=MOD;
            }
        }
    }
    cout << dp[n][s][2] << endl;
}


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

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    map<int, int> w;
    REP(i, N) w[i-A[i]]++;

    ll ret = 0;
    REP(i, N) {
        w[i-A[i]]--;
        ret += w[A[i]+i];
    }
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 21144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
#define MP make_pair
struct t{
	ll r,s1,s2;
	t(void){r=0,s1=0,s2=0;}
	void up(ll x){
		if(s1<x)swap(s1,x);
		s2=max(s2,x);
	}
	void mn(ll x){
		if(s1==x){
			s1=s2;
			s2=0;
		}
	}
};
ll n,cs[100005],ans;
vector<ll>g[100005];
map<ll,t>dp[100005];
t dfs(ll v,ll p,ll f){
	if(dp[v].count(p))return dp[v][p];
	t res;
	if(p==-1||f){
		for(int i=0;i<g[v].size();i++){
			ll u=g[v][i];
			if(u==p)continue;
			t x=dfs(u,v,f);
			x.r-=2;
			x.s1--;
			if(x.r>0){
				res.r+=x.r;
				res.up(-x.r+x.s1);
			}else res.up(x.s1);
		}
		res.r+=cs[v];
		res.s1+=res.r;
		res.s2+=res.r;
	}else{
		res=dfs(v,-1,0);
		t x=dfs(p,v,0);
		x.r-=2;
		x.s1--;
		if(x.r>0){
			res.r-=x.r;
			res.mn(res.r+x.s1);
			res.s1-=x.r;
		}else res.mn(res.r+x.s1);
	}
	return dp[v][p]=res;
}
int main(void){
	scanf("%lld",&n);
	for(int i=0;i<n;i++)scanf("%lld",cs+i);
	ll ma=-INF;
	for(int i=0;i<n;i++)ma=max(ma,cs[i]);
	if(ma<=0){
		printf("%lld\n",ma);
		return 0;
	}
	for(int i=0;i<n-1;i++){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		g[--a].PB(--b);
		g[b].PB(a);
	}
	dfs(0,-1,1);
	for(int i=0;i<n;i++){
		t res=dfs(i,-1,0);
		ans=max(ans,max(res.s1,res.r));
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<g[i].size();j++){
			t res=dfs(i,g[i][j],0);
		}
	}
	printf("%lld\n",ans);
}



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

public class Main{
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int K=sc.nextInt(),X=sc.nextInt();
	 int min=X-K+1;
	 int max=X+K-1;
	 for(int i=min;i<=max;i++) {
		 System.out.println(i);
	 }
	 
	 
	
	 
	 
	 
 }
	


}



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

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

    int sum = 0;
    int number = N;
    while (number > 0) {
        sum += number % 10;
        number /= 10;
    }

    string ans = (N % sum == 0) ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
	int h, a;
	cin >> h >> a;
	int res = h / a;
	if (h % a > 0)
		res += 1;
	cout << res;
	return 0;
}


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

double outer_product(double x1, double y1, double x2, double y2){
	return x1 * y2 - x2 * y1;
}

int main(){
	double x1, y1, x2, y2, x3, y3, xp, yp;
	while(std::cin >> x1){
		std::cin >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;
		bool dir = (outer_product(xp - x1, yp - y1, x2 - x1, y2 - y1) > 0);
		if ( dir == (outer_product(xp - x2, yp - y2, x3 - x2, y3 - y2) > 0) &&
			dir == (outer_product(xp - x3, yp - y3, x1 - x3, y1 - y3) > 0) ) {
			std::cout << "YES" << std::endl;
		} else {
			std::cout << "NO" << std::endl;
		}
	}
}

Measured memory_bytes: 1216
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};
const main=()=>{
  let n=tn()
  let ans=0
  for(let i=0;i<n;i++)ans+=abs(tn()-tn())+1
  to(ans)
}
main()


Measured memory_bytes: 7500
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

S = str(input())
al = list("abcdefghijklmnopqrstuvwxyz")

for i in al:
    if i in S:
        pass
    else:
        print(i)
        break
else:
    print("None")

Measured memory_bytes: 11032
/* HARDWORK IS THE KEY TO SUCCESS.
   RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define T int t = 1; cin>>t; while(t--)
#define ain ll n,k,i; cin>>n; ll a[n]; for(i=0;i<n;i++) cin>>a[i]
#define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1]; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define I insert
#define pb push_back

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;
inline ll add(ll a, ll b) { return (mod + a + b) % mod;}
inline ll sub(ll a, ll b) {return (a - b + mod) % mod;}
inline ll mul(ll a, ll b) {return (1ll * a * b) % mod;}
ll fastpow(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) { if(y & 1) res = (res * x) % mod; y = y >> 1;x = (x * x) % mod;}return res;}
ll inv(ll x) {
    return fastpow(x, mod - 2);
}



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ain;
    ll Xor = 0;
    for(i = 0;i < n;++i)
        Xor = Xor ^ a[i];
    for(i = 0;i < n;++i)
    {
        ll val = Xor ^ a[i];
        cout << val << " ";
    }
    
    
    
}

Measured memory_bytes: 5140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
int main(void) {
    int n; cin >> n;
    if(n&1) cout << 2*n;
    else cout << n;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MaxN = 100, Pt = 1e9 + 7;
int n;
char s[MaxN + 5];
char t[MaxN + 5];
LL f[MaxN + 5];

int main()
{
	while (~scanf("%d", &n)) {
		scanf("%s", s); scanf("%s", t);
		int p = 0;
		if (s[0] == t[0]) f[0] = 3, p = 1;
		else f[1] = 6, p = 2;
		while (p < n) {
			if (s[p] == t[p]) {
				if (s[p - 1] == t[p - 1]) f[p] = (f[p - 1] * 2) % Pt;
				else f[p] = f[p - 1];
				p++;
			}
			else {
				if (s[p - 1] == t[p - 1]) f[p + 1] = (f[p - 1] * 2) % Pt;
				else f[p + 1] = (f[p - 1] * 3) % Pt;
				p += 2;
			}
		}
		printf("%lld\n", f[n - 1]);
	}
	return 0;
}

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

const int MAXN = 110;
const int mod = 1000000007;
void reduce(int & x) { x += x >> 31 & mod; }
int A[MAXN], n, f[MAXN][MAXN][MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n; int m = n * 2 - 1;
	for (int i = 1; i <= m; ++i) std::cin >> A[i];
	std::sort(A + 1, A + 1 + m);
	f[n][0][0] = 1;
	for (int i = n - 1, j = n + 1; i; --i, ++j) {
		bool ld = A[i] != A[i + 1], rd = A[j] != A[j - 1];
		for (int j = 0; j <= m; ++j)
		for (int k = 0; k <= m; ++k)
		if (int t = f[i + 1][j][k]) {
			reduce(f[i][j + ld][k + rd] += t - mod);
			for (int l = 1; l <= j + ld; ++l)
				reduce(f[i][j + ld - l][k + rd + 1] += t - mod);
			for (int l = 1; l <= k + rd; ++l)
				reduce(f[i][j + ld + 1][k + rd - l] += t - mod);
		}
	}
	int ans = 0;
	for (int i = 0; i <= m; ++i)
		for (int j = 0; j <= m; ++j)
			reduce(ans += f[1][i][j] - mod);
	std::cout << ans << std::endl;
	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  vector<ll> x(n);
  vector<ll> y(n);
  rep(i, 0, n) cin >> x[i] >> y[i];
  
  ll kaijou = 1;
  rep(i, 2, n+1) kaijou *= i;
  
  long double cal = (kaijou/n);
  long double sum = 0;
  
  rep(i, 0, n) {
    rep(j, 0, n) {
      if(i == j) continue;
      else
        sum += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))*cal;
    }
  }
  
  long double ans = sum/kaijou;
  cout << fixed << setprecision(15) << ans << "\n";

}

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

int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;

  if ((a+b)>(c+d)) {
    cout <<"Left"<< endl;
  }else if((a+b)<(c+d)){
    cout<<"Right"<<endl;
  }else{
    cout<<"Balanced"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;
using pint = pair<int, int>;

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

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

int main()
{
  int k;
  cin >> k;
  int s = 7;
  bool found = false;
  rep(i, k)
  {
    if (s % k == 0)
    {
      cout << i + 1 << endl;
      found = true;
      break;
    }

    s = s % k * 10 + 7;
  }

  if (!found)
    cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3596
defmodule Main do
  def main do
    [n, _m, x] =
      IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)

    list =
      Enum.reduce(1..n, [], fn _, acc ->
        [IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)] ++
          acc
      end)

    Enum.reduce(1..n, [], fn i, acc ->
      combination(list, i) ++ acc
    end)
    |> Enum.filter(&pass?(&1, x))
    |> Enum.map(&bill/1)
    |> Enum.min(fn -> -1 end)
    |> IO.puts()
  end

  defp pass?(list_of_lists, x) do
    List.zip(list_of_lists)
    |> tl()
    |> Enum.map(&(Tuple.to_list(&1) |> Enum.sum()))
    |> Enum.all?(&(&1 >= x))
  end

  defp bill(list_of_lists) do
    List.zip(list_of_lists) |> hd() |> Tuple.to_list() |> Enum.sum()
  end

  defp combination(_, 0), do: [[]]
  defp combination([], _), do: []

  defp combination([x | xs], n) do
    for(y <- combination(xs, n - 1), do: [x | y]) ++ combination(xs, n)
  end
end


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

typedef vector<vector<char>> field_t;
typedef pair<int,int> point_t;

//point_tの足し算
point_t operator+(const point_t &lhs,const point_t &rhs){
    point_t res;
    res.first=lhs.first+rhs.first;
    res.second=lhs.second+rhs.second;
    return res;
}

//範囲内外判定
bool is_in_field(int col,int row,const point_t &point){
    int c=point.first;
    int r=point.second;
    return ((c>=0&&c<col)&&(r>=0&&r<row));
}

//配列要素の最大値
int max_v(vector<vector<int>> &v){
    int res=v.at(0).at(0);
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v.at(0).size();j++){
            res=max(res,v.at(i).at(j));
        }
    }
    return res;
}

//多点WFS
int solve(int H,int W,queue<point_t> &que,vector<vector<int>> &v){
    vector<point_t> points={{1,0},{-1,0},{0,1},{0,-1}};
    while(!que.empty()){
        point_t cur = que.front();
        que.pop();
        int col_cur=cur.first;
        int row_cur=cur.second;
        for(const auto &p : points){
            point_t next = cur + p;
            int col_next=next.first;
            int row_next=next.second;
            if(is_in_field(H,W,next)){
                if(v.at(col_next).at(row_next)==-1){
                    v.at(col_next).at(row_next)=v.at(col_cur).at(row_cur)+1;
                    que.push(next);
                }
            }
        }
    }
    return max_v(v);
}

int main(){
    //入力
    int H,W;
    cin >> H >> W;

    field_t A(H,vector<char>(W));
    queue<point_t> que;
    
    vector<vector<int>> v(H,vector<int>(W,-1)); //訪問までに必要な回数
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> A.at(i).at(j);
            if(A.at(i).at(j)=='#'){
                que.push({i,j});//開始位置の代入
                v.at(i).at(j)=0;//開始位置の訪問回数を0に
            }
        }
    }    

    //出力
    cout << solve(H,W,que,v) << endl;
    return 0;
}

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

const int N = 60;
typedef long long ll;
const int INF = 0x7f7f7f7f;

bool vis[N][N];
int a[N], b[N];
int dp[N][N];

int main(){
	memset(dp, 0x7f, sizeof(dp));
	for (int i = 0; i < N; ++ i){
		for (int j = 0; j < i; ++ j){
			for (int k = j + 1; k <= i; ++ k){
				if (dp[i % k][j] != INF){
					dp[i][j] = k;
					break;
				}
			}
		}
		dp[i][i] = 0;
	}
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
		vis[i][a[i]] = true;
	}
	for (int i = 0; i < n; ++ i){
		scanf("%d", &b[i]);
	}
	std::vector <int> vec;
	while (true){
		int max = 0;
		for (int i = 0; i < n; ++ i){
			if (!vec.empty()){
				int x = vec[vec.size() - 1];
				for (int j = a[i]; j >= x; -- j){
					if (vis[i][j]){
						vis[i][j % x] = true;
					}
				}
			}
			int min = INF;
			for (int j = 0; j <= a[i]; ++ j){
				if (vis[i][j]){
					min = std::min(min, dp[j][b[i]]);
				}
			}
			max = std::max(max, min);
		}
		if (max == INF){
			puts("-1");
			return 0;
		}
		if (!max){
			break;
		}
		vec.push_back(max);
	}
	ll ans = 0;
	for (auto u : vec){
		ans |= 1ll << u;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s, t;
	cin >> s >> t;
	int ans = INT_MAX;
	for (int i = 0; i + t.size() <= s.size(); i++) {
		int change = 0;
		for (int j = 0; j < t.size(); j++) {
			if (s[i + j] != t[j])
				++change;
		}
		ans = min(ans, change);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3624
from collections import deque

def P(n, r):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+30
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


n,k=map(int,input().split())
G=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a=a-1
  b=b-1
  G[a].append(b)
  G[b].append(a)
D=deque([0])
DD=[0]
V=[0]*n
V[0]=1
GG=[[] for i in range(n)]
while len(D)>0:
  x=D[0]
  D.popleft()
  for i in range(len(G[x])):
    if V[G[x][i]]==0:
      V[G[x][i]]=1
      GG[x].append(G[x][i]) #子ノードのlist
      D.append(G[x][i])
      DD.append(G[x][i])
ans=k*P(k-1,len(GG[0]))%mod  #頂点0,0の子の色の付け方
for i in range(1,n):  #子の色を決めていく
  if len(GG[i])==0:
    continue
  ans=ans*P(k-2,len(GG[i]))%mod
print(ans)

Measured memory_bytes: 46776
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n,x;
    cin>>n>>x;
    int ans = n;
    n-=x;
    while(1)
    {
        if(n<x) swap(n,x);
        if(x==0)
        {
            ans -= n;
            break;
        } 
        ans += 2*x*((n/x));
        n%=x;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Array.IO
import Data.Bits
import Data.List
import Debug.Trace

main = do
    n <- read <$> getLine
    a <- map read <$> words <$> getLine
    a <- newListArray (1, n) a
    r <- solve n a
    putStrLn $ show $ length r
    putStrLn $ intercalate " " $ map show $ r


solve :: Int -> IOArray Int Int -> IO [Int]
solve n a = do
    b <- (flip filterM) [n, n - 1 .. 1] $ \i -> do
        b <- readArray a i
        if b == 1 then do
            let s = (floor . sqrt . fromIntegral) i
            forM_ [1 .. s] $ \j -> do
                if i /= 1 && i `mod` j == 0 then do
                    flipValue a j
                    if j /= 1 && (j /= s || i /= s * s) then do
                        flipValue a (i `div` j)
                    else return ()
                else return ()
            return True
        else
            return False
    return $ reverse b

flipValue a j = readArray a j >>= \c -> writeArray a j (1 - c)

Measured memory_bytes: 72060
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

using ll = long long;

const ll arr[] = { 2, 5, 63, 20, 30 };

ll N;
std::set<ll> vs;
ll sum;

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

  if( N <= 5 )
  {
    rep( i, N )
      std::cout << arr[i] << (i==N-1?'\n':' ');

    return 0;
  }

  ll k = 0;
  
  while( vs.size() < N )
  {
    rep( i, 7 ) if( i && i != 1 && i != 5 )
    {
      vs.emplace( 6*k+i );

      sum += 6*k+i;

      if( i == 6 )
        ++k;

      if( vs.size() == N )
        goto end;
    }
  }
end:;

  if( sum % 6 == 2 )
  {
    vs.erase( vs.find(8) );


    repi( K, k-2, k+2 ) if( K >= 0 && 6*K > 0 && vs.find(6*K) == vs.end() )
    {
      vs.emplace( 6*K );
      
      break;
    }
  }
  else if( sum % 6 == 3 )
  {
    vs.erase( vs.find(9) );

    repi( K, k-2, k+2 ) if( K >= 0 && 6*K > 0 && vs.find(6*K) == vs.end() )
    {
      vs.emplace( 6*K );
      
      break;
    }
  }
  else if( sum % 6 == 5 )
  {
    vs.erase( vs.find(9) );

    repi( K, k-2, k+2 ) if( K >= 0 && 6*K+4 > 0 && vs.find(6*K+4) == vs.end() )
    {
      vs.emplace( 6*K+4 );
      
      break;
    }
  }

  itr( it, vs )
    std::cout << *it << (std::distance(it, vs.end())==1?'\n':' ');

  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  int sum = 0;
  vector<int> a(m);
  for(int i = 0; i < m; i++){
    cin >> a[i];
    sum+=a[i];
  }
  if(sum > n) cout << "-1" << endl;
  else cout << n-sum << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, p[50], pp[50], c;

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> p[i];
		pp[i] = p[i];
	}
	sort(p, p + N);
	for (int i = 0; i < N; ++i) {
		if (p[i] != pp[i])++c;
	}
	if (c <= 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let acc = Array.make (2 * m + 1) 0 in
  for i = 0 to n - 2 do
    let a = as_.(i) in
    let b = as_.(i + 1) + if as_.(i) <= as_.(i + 1) then 0 else m in
    acc.(a + 1) <- acc.(a + 1) + 1;
    acc.(b) <- acc.(b) - 1
  done;
  for i = 0 to 2 * m - 1 do
    acc.(i + 1) <- acc.(i) + acc.(i + 1)
  done;
  for i = 0 to n - 2 do
    let a = as_.(i) in
    let b = as_.(i + 1) + if as_.(i) <= as_.(i + 1) then 0 else m in
    acc.(b) <- acc.(b) - b + a + 1
  done;
  for i = 0 to 2 * m - 1 do
    acc.(i + 1) <- acc.(i) + acc.(i + 1)
  done;
  for i = m to 2 * m - 1 do
    acc.(i - m) <- acc.(i) + acc.(i - m)
  done;
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0
    (Array.init (n - 1) (fun i -> (m + as_.(i + 1) - as_.(i)) mod m))
  - Array.fold_left max min_int (Array.sub acc 0 m)


Measured memory_bytes: 6784
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

vector<ll>a,p;//aはバーガーの総枚数,pはパティの枚数

ll rec(int n,ll x){
	if(n==0)return 1;
	ll res;
	if(x==1)res=0;//バンズ1枚
	else if(1<x&&x<=a[n-1]+1)res=rec(n-1,x-1);
	else if(x==a[n-1]+2)res=p[n-1]+1;
	else if(a[n-1]+2<x&&x<=2*a[n-1]+2)res=p[n-1]+1+rec(n-1,x-a[n-1]-2);
	else res=2*p[n-1]+1;
	return res;
}
 
void solve(){
	int n;
	ll x;
	cin>>n>>x;
	a.resize(n+1,1);
	p.resize(n+1,1);
	rep(i,n){
		a[i+1]=2*a[i]+3;
		p[i+1]=2*p[i]+1;
	}
	cout<<rec(n,x)<<"\n";
}
 
signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}

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

using namespace std;

#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define dump(x) cerr << "~ " << #x << " = " << x << endl


int main() {

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

	cout << a * b << endl;
	
	
	
	return 0;
}

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

int main() {
  const long double pi = 3.141592653589793;
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  long double t1 = h*pi/6 + m*pi/360;
  long double t2 = m*pi/30;
  long double xa = a*sin(t1);
  long double ya = a*cos(t1);
  long double xb = b*sin(t2);
  long double yb = b*cos(t2);
  cout << fixed << setprecision(20);
  long double ans = sqrt((xa-xb) * (xa-xb) + (ya-yb) * (ya-yb));
  cout << ans << endl;
}

Measured memory_bytes: 4164
#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

string s,t;
unordered_map<char,char> us,ut;

int main(){
    cin >> s >> t;
    int N = s.size();
    for(int i=0;i<N;i++){
        if(us.find(s[i])==us.end()){
            us[s[i]] = t[i];
            continue;
        }
        if(us[s[i]] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i=0;i<N;i++){
        if(ut.find(t[i])==ut.end()){
            ut[t[i]] = s[i];
            continue;
        }
        if(ut[t[i]] != s[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define eps 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N;
int a[110000];
vector<int> v;

int main () {
  cin >> N;
  Rep(i, N) cin >> a[i];

  Rep(i, N) v.push_back(a[i]);

  sort(All(v));
  v.erase(unique(All(v)), v.end());

  if (v.size() > 2) {
    cout << "No\n";
    return 0;
  }

  if (v.size() == 1) {
    if ((v[0] == N-1) || ((1 <= v[0]) && (v[0] <= N/2))) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }

    return 0;
  }

  if (v[1] != v[0] + 1) {
    cout << "No\n";
    return 0;
  }

  int k = v[1];
  int m = 0;

  Rep(i, N) {
    if (a[i] == k-1) {
      ++m;
    }
  }

  int s = k - m;

  if ((1 <= s) && (s <= (N-m)/2)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a-b)%c<<NL;
    return 0;
}


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();
		int k = sc.nextInt();
		int ans = 0;
		ArrayList<Integer> N = new ArrayList<Integer>();

		while(N.size() < n){
			int l = sc.nextInt();
			N.add(l);
		}		

		Collections.sort(N);
		Collections.reverse(N);

		while(k>0){
			ans = ans + N.get(k-1);
			k = k-1;
		}


		System.out.print(ans);
		
		sc.close();
	}
}

Measured memory_bytes: 21332
N =int(input())
R = []
for i in range(N):
        R.append(int(input()))
maxv=-2000000000
minv=R[0]
for i in range(1,N):
    maxv=max(maxv,R[i]-minv)
    minv=min(minv,R[i])
print(maxv)

Measured memory_bytes: 13584
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

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

    ll en = 100;
    ll counter=0;
    while(en<x) {
        double t = en;
        t = t * 1.01;
        en = t;
        counter++;
    }
    print(counter);
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
typedef long long int lli;

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

    vector<char> vec;
    for(int i = 0; i < s.length(); ++i){
        if(s[i] == 'S'){
            vec.push_back('S');
        }else if(vec.empty()){
            vec.push_back('T');
        }else if(vec.back() == 'S'){
            vec.pop_back();
        }else{
            vec.push_back('T');
        }
        
    }
    
    int ans = vec.size();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 772
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod=1e9+7;

int main(){
  int a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a), t(b), x(q);
  rep(i,a) cin >> s[i];
  rep(i,b) cin >> t[i];
  rep(i,q) cin >> x[i];
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  rep(i,q){
    auto s1=lower_bound(s.begin(),s.end(),x[i]);
    auto s2=s1;
    s1--;
    auto t1=lower_bound(t.begin(),t.end(),x[i]);
    auto t2=t1;
    t1--;
    ll ans=1e11;
    if(s1!=s.begin()-1 && t1!=t.begin()-1)
      ans = min(ans, x[i]-min(*s1,*t1));
    if(s1!=s.begin()-1 && t2!=t.end())
      ans = min(ans, *t2-*s1+min(*t2-x[i],x[i]-*s1));
    if(s2!=s.end() && t1!=t.begin()-1)
      ans = min(ans, *s2-*t1+min(*s2-x[i],x[i]-*t1));
    if(s2!=s.end() && t2!=t.end())
      ans = min(ans, max(*s2,*t2)-x[i]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3712
import Control.Applicative
import Control.Monad
import Data.Char

main :: IO () 
main = do
      [a,b,c] <- map read . words <$> getLine
      print $ countDivisor a b c 
      
countDivisor :: Int -> Int -> Int -> Int
countDivisor a b c = 
    length $ filter(\x -> c `mod` x == 0)  range
      where range = [a..b]


Measured memory_bytes: 4116
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        
        int r = in.nextInt();
        int d = in.nextInt();
        int x = in.nextInt();
        int ans=0;
        for(int i=0;i<10;i++){
            ans = r*x-d;
            out.println(ans);
            x = ans;
        }
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

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

		int a = ac.nextInt();
		int b = ac.nextInt();
		int c = ac.nextInt();
		
		if (a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}

}



Measured memory_bytes: 26244
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int a, ans = 0, tmp = 0;
  for (int i = 0; i < 5; i++)
  {
    scanf("%d", &a);
    ans += a;
    for (int j = 0;; j += 10)
    {
      if (a <= j)
      {
        ans += j - a;
        tmp = MAX(tmp, j - a);
        break;
      }
    }
  }
  printf("%d\n", ans - tmp);
}

Measured memory_bytes: 128
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    string s; cin >> s;
    int q; cin >> q;
    bool l_is_head = true;

    deque<char> deque;
    for (char c: s) deque.push_back(c);

    int t, f; char c;
    for (int i=0; i<q; i++) {
        cin >> t;
        if (t == 1) {
            l_is_head = !l_is_head;
            continue;
        }

        cin >> f >> c;
        if (t == 2 && f == 1) {
            if (l_is_head) deque.push_front(c);
            else deque.push_back(c);
        }
        if (t == 2 && f == 2) {
            if (l_is_head) deque.push_back(c);
            else deque.push_front(c);
        }
    }

    string ans = "";
    for (char s: deque) {
        ans += s;
    }

    if (!l_is_head) reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1340
#include<stdio.h>
struct _list{
	int i;
	int j;
	int k;
	int r;
}typedef _list;
_list d[1005];

void sort(int N){
	int i,j,t;
	for(i=1;i<=N;i++){
		for(j=i;j<=N;j++){
			if(d[i].r<d[j].r){
				t=d[i].i;
				d[i].i=d[j].i;
				d[j].i=t;

				t=d[i].j;
				d[i].j=d[j].j;
				d[j].j=t;

				t=d[i].k;
				d[i].k=d[j].k;
				d[j].k=t;

				t=d[i].r;
				d[i].r=d[j].r;
				d[j].r=t;
			}
		}
	}

}
int main(){

	int aNm,bNm,cNm;
	int N,i,j,k,r,s;
	for(;scanf("%d %d %d",&aNm,&bNm,&cNm)&&(aNm||bNm||cNm);){
		int L[399]={2};
		for(s=1;s<=300;s++)
			L[s]=2;
		scanf("%d",&N);
	//	printf("N:%d\n",N);
		for(s=1;s<=N;s++){
//			printf("s:%d\n",s);
			scanf("%d %d %d %d",&d[s].i,&d[s].j,&d[s].k,&d[s].r);
		}
		sort(N);
		for(s=1;s<=N;s++){
	//		printf("%d %d %d\n",L[d[s].i],L[d[s].j],L[d[s].k]);
			if(d[s].r){
		//		printf("r:1\n");
				L[d[s].i]=1;
				L[d[s].j]=1;
				L[d[s].k]=1;
			}
			else{
			//	printf("r:0\n");
				if(L[d[s].i]==2&&L[d[s].j]==1&&L[d[s].k]==1)L[d[s].i]=0;
				if(L[d[s].j]==2&&L[d[s].i]==1&&L[d[s].k]==1)L[d[s].j]=0;
				if(L[d[s].k]==2&&L[d[s].i]==1&&L[d[s].j]==1)L[d[s].k]=0;
			}
		}
		for(s=1;s<=aNm+bNm+cNm;s++){
			if(L[s]==1)printf("1\n");
			else if(L[s]==0)printf("0\n");
			else printf("2\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"bufio"
	. "fmt"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	var n,v,w int64
	Fscan(in, &n)
	s := n*(n+1)*(n+2)/6
	for m:=n-1;m>0;m-- {
		Fscan(in, &v, &w)
		if v > w {
			v, w = w, v
		}
		s-=v*(n-w+1)
	}
	Print( s)
}


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

#define rep(i,N) repv(i,0,N)
#define reps(i,N) repvs(i,0,N)
#define repv(i,a,b) for(int i=a;i<b;i++)
#define repvs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<","
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d
#define da(arr,N){if(isDebugMode){rep(i,N+1){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N+1){rep(j,M+1){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back
#define s(a) cout<<a<<endl;

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 100000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
int n,a,b;
int x[100000];

void solve(){
	int tp=b/a;
	int pre;
	ll ans=0;
	cin>>pre;
	rep(i,n-1){
		int x;
		cin>>x;
		if(x-pre>tp) ans+=b;
		else ans+=(x-pre)*a;
		pre=x;
	}
	s(ans);
}

int main(){
	cin>>n>>a>>b;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

LL N,M,a,b,c,d;
string s;
map<char,int> mp;
int main(){
    cin>>s;
    LL ans=1;
    for(int i=0;i<s.size();i++){
        ans+=i-mp[s[i]];
        mp[s[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
const ll INF=0x3f3f3f3f;
const int N=1e5+5;

ll a[N],c[N];
int b[N];
int T,n,m,k;
int main()
{
    int n;
    ll sum=0,minx=INF;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        ll a,b;
        scanf("%lld%lld",&a,&b);
        sum+=a;
        if(a>b)
            minx=min(minx,b);
    }
    printf("%lld\n",minx==INF?0:sum-minx);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,c,m=0;
    cin>>n>>a>>b>>c;
    int z[n+1][3];
    z[1][0]=a;
    z[1][1]=b;
    z[1][2]=c;
    for(int i=2;i<=n;i++)
    {
        cin>>a>>b>>c;
        for(int j=0;j<3;j++)
        {
            if(j==0)
            {
                z[i][j]=a+max(z[i-1][1],z[i-1][2]);
            }
            else if(j==1)
            {
                z[i][j]=b+max(z[i-1][0],z[i-1][2]);
            }
            else
            {
                z[i][j]=c+max(z[i-1][0],z[i-1][1]);
            }
        }
    }
    m=max(z[n][0],z[n][1]);
    m=max(m,z[n][2]);
    cout<<m<<endl;

}


Measured memory_bytes: 1408