akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  string before, now;
  vector<string> W(N);
  for (int j=0; j < N; ++j) {
    cin >> W[j];
  }
  before = W[0];
  bool f = true;
  for (int j=1; j < N; ++j) {
    now = W[j];
    if (before.back() != now[0]) {
     f = false;
    } else {
      bool g = true;
      for (int k=0; k < j; ++k) {
        if (W[k] == now) {
          g = false;
        }
      }
      if (!g) {
        f = false;
        break;
      }
    }
    if (f) {
      before = now;
    } else {
      break;
    }
  }
  if (f) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
let sort a b c =
  let lst = [a; b; c] in
  let rec ins_sort l res =
    let rec insert a ls = match ls with
        [] -> [a]
      | first :: rest -> if a <= first then a :: first :: rest
                         else first :: (insert a rest)
    in
    match l with
      [] -> res
    | first :: rest -> ins_sort rest (insert first res)
  in
  let rec make_string = function
      [] -> ""
    | [x] -> (string_of_int x) 
    | first :: rest -> (string_of_int first) ^ " " ^(make_string rest)
  in
  print_endline (make_string (ins_sort lst [])) ;;

let f s = Scanf.sscanf s "%d %d %d" sort ;;

f (read_line());;


Measured memory_bytes: 2324
import java.util.Scanner;

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

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

	int count = 0;
	int p = 1;
	while (p < B) {
	    p += A - 1;
	    count++;
	}

	System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
int main(void) {
	int i,max=0;
	double l[40],r[40];
	for(i=0;i<40;i++){
		int ret=scanf("%lf %lf",&l[i],&r[i]);
		if(ret==EOF) break;
		if(i>max) max=i;
	}
	int al=0,bl=0,cl=0,dl=0;
	for(i=0;i<=max;i++){
		if(l[i]>=1.1){
			al++;
		}
		else if(l[i]>=0.6&&l[i]<1.1){
			bl++;
		}
		else if(l[i]>=0.2&&l[i]<0.6){
			cl++;
		}
		else{
			dl++;
		}
	}
	int ar=0,br=0,cr=0,dr=0;
	for(i=0;i<=max;i++){
		if(r[i]>=1.1){
			ar++;
		}
		else if(r[i]>=0.6&&r[i]<1.1){
			br++;
		}
		else if(r[i]>=0.2&&r[i]<0.6){
			cr++;
		}
		else{
			dr++;
		}
	}
	printf("%d %d\n",al,ar);
	printf("%d %d\n",bl,br);
	printf("%d %d\n",cl,cr);
	printf("%d %d\n",dl,dr);
	return 0;	
}



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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int n = (int) s.size();
  int m = (int) t.size();
  int res = n;
  for (int i = 0; i + m <= n; i++) {
    int cur = 0;
    for (int j = i; j < i + m; j++) {
      cur += (s[j] != t[j - i]);
    }
    res = min(res, cur);
  }
  cout << res << endl;
  return 0;
}


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

int main()
{
    int n;
    std::cin >> n;
    std::string s;
    s.resize(n);
    std::fill(s.begin(), s.end(), 'a');
    while (s[0] == 'a')
    {
        bool b = true;
        std::cout << s << '\n';
        for (int i = 1; i <= n; ++i)
        {
            bool flag = false;
            for (int j = 0; j < n - i; ++j)
            {

                if (s[j] == s[n - i])
                {
                    flag = true;
                    break;
                }
            }
            if (flag)
            {
                s[n - i] += 1;
                for (int j = n - i + 1; j < n; ++j)
                {
                    s[j] = 'a';
                }
                break;
            }
            if (i == n)
            {
                b = false;
            }
        }
        if (!b)
        {
            break;
        }
    }
    return 0;
}

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

#define debug(x) cout<<#x<<"="<<x<<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int) (x).size())
#define pii pair<int,int>
#define PQ priority_queue
#define sqr(x) (x)*(x)
#define ll long long
#define pb push_back
#define mp make_pair
#define re return

const int INF=0x7fffffff;

double a,b;

int main(){
	cin>>a>>b;
	cout<<a-2*(a-b);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            a[i] = temp;
        }
        long ans1 = 0;
        long ans2 = 0;
        long temp = 0;
        for (int i = 0; i < n; i++) {
            long num = a[i];
            if (i % 2 == 0 && temp + num >= 0) {
                ans1 += temp + num + 1;
                num -= temp + num + 1;
            }
            if (i % 2 != 0 && temp + num <= 0) {
                ans1 += Math.abs(temp + num - 1);
                num += Math.abs(temp + num - 1);
            }
            temp += num;
        }
        temp = 0;
        for (int i = 0; i < n; i++) {
            long num = a[i];
            if (i % 2 == 0 && temp + num <= 0) {
                ans2 += Math.abs(temp + num - 1);
                num += Math.abs(temp + num - 1);
            }
            if (i % 2 != 0 && temp + num >= 0) {
                ans2 += temp + num + 1;
                num -= temp + num + 1;
            }
            temp += num;
        }
        System.out.println(Math.min(ans1, ans2));
    }
}

Measured memory_bytes: 48396
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        // 格納
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = a%10;
        //System.out.println(b);
        if(b==2 || b==4 || b==5 || b==7 || b==9){
            System.out.println("hon");
        }else if(b==3){
            System.out.println("bon");
        }else{
            System.out.println("pon");
        }
        
        
    }
}
        

Measured memory_bytes: 35736
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

ll nxt_pos[45][100010], nxt_sum[45][100010];

int main() {
    ll N, X, M; scanf("%lld%lld%lld", &N, &X, &M);

    int B = 40;
    for(int i=0; i<M; i++) {
        nxt_pos[0][i] = 1LL*i*i%M;
        nxt_sum[0][i] = i;
    }
    for(int k=1; k<=B; k++) {
        for(int i=0; i<M; i++) {
            nxt_pos[k][i] = nxt_pos[k-1][ nxt_pos[k-1][i] ];
            nxt_sum[k][i] = nxt_sum[k-1][i] + nxt_sum[k-1][ nxt_pos[k-1][i] ];
        }
    }

    ll ans = 0;
    for(int k=0; k<=B; k++) {
        if(!(N >> k & 1)) continue;
        ans += nxt_sum[k][X];
        X = nxt_pos[k][X];
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	ll a,b;
	cin>>a>>b;
	ll p=min(a,b);
	ll q=max(a,b);
	for (ll i=0;i<q;i++)
		cout<<p;
	return 0;
}

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

def oneTurn(x):
    if not dic[x]:
        print x.upper()
        return ""
    ans = (dic[x])[0]
    dic[x] = (dic[x])[1:]
    return ans

a = (raw_input())
b = (raw_input())
c = (raw_input())

# 出力
dic = {"a":a,"b":b,"c":c}

ans = "a";
while(ans!=""):
    ans = oneTurn(ans)

Measured memory_bytes: 2568
#include<stdio.h>
void insert(int [],int,int);
void shell(int [],int);
int cnt;
#define max 1000000
int main(){
  int number;
  int i;
  int list[max];
  scanf("%d",&number);
  for(i=0;i<number;i++){
    scanf("%d",&list[i]);
  }
  shell(list,number);
  printf("%d\n",cnt);
  for(i=0;i<number;i++){
    printf("%d\n",list[i]);
  }
  return 0;
}
void insert(int l[],int n,int g){
  int i;
  int j;
  int v;
  for(i=g;i<n;i++){
    v=l[i];
    j=i-g;
    while(j>=0&&l[j]>v){
      l[j+g]=l[j];
      j=j-g;
      cnt++;
    }
    l[j+g]=v;
  }
}
void shell(int l[],int n){
  int i;
  int m=1;
  int G[max];
  int g=1;
  cnt=0;
  G[0]=g;
  while((1+g*3)<n){
    g=1+g*3;
    G[m]=g;
    m++;
  }
  printf("%d\n",m);
  for(i=m-1;i>=0;i--){
    printf("%d",G[i]);
    if(i==0)printf("\n");
    else printf(" ");
  }
  for(i=m-1;i>=0;i--){
    insert(l,n,G[i]);
  }
}



Measured memory_bytes: 5596
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<pair<int, pii>> data(n); 
    REP(i, n){
        int s, t, x;
        cin >> s >> t >> x;
        data[i] = {x, {s-x, t-x}};
    }
    vector<int> vd(q);
    set<pii> d;
    REP(i, q){
        cin >> vd[i];
        d.insert({vd[i], i});
    }

    sort(data.begin(), data.end());
    vector<int> ans(q);

    REP(i, n){
        auto left = d.lower_bound({data[i].second.first, -1});
        auto right = d.lower_bound({data[i].second.second, -1});
        // left-rightまではXiで止まることになる
        for(auto p=left;p!=right;p++){
            ans[p->second] = data[i].first;
        }
        // 一回止まったやつは以降はもう止まらない。
        d.erase(left, right);
    }
    for(auto p: d){
        ans[p.second] = -1;
    }

    for(auto t: ans)
        cout << t << endl;
    
    return 0;
}

Measured memory_bytes: 15232
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5+7;
int n,m,x,y,xi,yi,mx=-101,my=101;
int peace(int z){
  if(!(x<z && z<=y)) return 0;
  if(!(mx<z)) return 0;
  if(!(my>=z)) return 0;
  return 1;
}
int main(){
   std::cin >> n >> m >> x >> y;
   for(int i = 0; i<n; i++){
     std::cin >> xi;
     mx = max(mx, xi);
   }
   for(int i = 0; i<m; i++){
     std::cin >> yi;
     my = min(my, yi);
   }
   for(int Z = -100; Z<=100; Z++){
     if(peace(Z)){
       std::cout << "No War" << '\n';
       return 0;
     }
   }
   std::cout << "War" << '\n';
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int piza(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    int total=0;
    for(int i=1; i<=N; i++){
        int sum=piza(i);
        if(sum>=A&&sum<=B){
            total+=i;
        }
    }
    cout<<total<<endl;
}

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

int n,a[100001];
queue<int> q;

int main()
{
	int cnt=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		if(a[a[i]]==i) cnt++;
	printf("%d\n",cnt/2);
	return 0;
}


Measured memory_bytes: 640
import math
n=int(input())
p1=(0,0)
p2=(100,0)

def koch(n,p1,p2):
    if n==0:
        return

    sx=2/3*p1[0]+1/3*p2[0]
    sy=2/3*p1[1]+1/3*p2[1]
    s=(sx,sy)

    tx=1/3*p1[0]+2/3*p2[0]
    ty=1/3*p1[1]+2/3*p2[1]
    t=(tx,ty)

    ux=math.cos(math.radians(60))*(tx-sx)-math.sin(math.radians(60))*(ty-sy)+sx
    uy=math.sin(math.radians(60))*(tx-sx)+math.cos(math.radians(60))*(ty-sy)+sy
    u=(ux,uy)

    koch(n-1,p1,s)
    print(*s)
    koch(n-1,s,u)
    print(*u)
    koch(n-1,u,t)
    print(*t)
    koch(n-1,t,p2)

print(*p1)
koch(n, p1, p2)
print(*p2)


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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pb emplace_back
#define pf emplace_front
#define mp make_pair
#define ld long double

const int MAXN = 2e5 + 9;
int dp[MAXN];
int n;
int mod = 998244353;

int binpow(int a, int p)
{
    if (p == 0)
        return 1;
    if (p == 1)
        return a % mod;
    int b = binpow(a, p / 2);
    b = (b * b) % mod;
    if (p % 2)
        b = (b * a) % mod;
    return b;
}

bool ch(int u, string& s)
{
    if (u == n)
        return true;
    string kek = s.substr(0, u);
    for (int i = 0; i < u; i++)
        kek += ('0' + ('1' - kek[i]));
    string w = "";
    for (int i = 0; i <= (n / u) / 2; i++)
        w += kek;
    return w.substr(0, n) <= s;
}

void f(int u, string& s)
{
    //cout << u << "\n";
    int check = ch(u, s);
    //cout << "x";
    int cur = 0;
    for (int i = 0; i < u; i++)
    {
        if (s[i] == '0')
            continue;
        cur = (cur + binpow(2, u - i - 1)) % mod;
    }
    dp[u] = (cur + check) % mod;
}

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin >> n >> s;
    for (int u = 1; u * u <= n; u++)
    {
        if (n % u == 0 && (n / u) % 2 == 1)
            f(u, s);
        if (n % u == 0 && u % 2 == 1 && u * u != n)
            f(n / u, s);
    }
    //cout << "a";
    int ans = 0;
    for (int i = 1; i < MAXN; i++)
    {
        if (n % i != 0 || (n / i) % 2 == 0)
            continue;
        ans = (ans + dp[i] * i * 2) % mod;
        for (int e = i * 3; e < MAXN; e += 2 * i)
        {
            if (n % e != 0 || (n / e) % 2 == 0)
                continue;
            dp[e] -= dp[i];
            if (dp[e] < 0)
                dp[e] += mod;
        }
    }
    cout << ans;
}


Measured memory_bytes: 1176
/*input
5
1 2
2 3
2 4
4 5
3
3 1
5 4
1 1

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 1e5+1;
vector<int> adj[N];
int root = 0;
int closest[N];
int dist[N];
int val[N];
int assval[N];
int many[N];
int minvalue[N];
int maxvalue[N];
int n,k;

void dfs1(int u,int p){
	minvalue[u] = -INF;
	maxvalue[u] = INF;
	if(val[u] != INF){
		many[u]++;
 		minvalue[u] = val[u]-dist[u];
 		maxvalue[u] = val[u]+dist[u];
 	}
	for(int v:adj[u]){
		if(v == p)continue;
		dist[v] = dist[u]+1;
		dfs1(v,u);
		many[u] += many[v];
		minvalue[u] = max(minvalue[u],minvalue[v]);
		maxvalue[u] = min(maxvalue[u],maxvalue[v]);
//		if(dist[closest[v]] < dist[closest[u]])closest[u] = closest[v];
	}
}

void dfs2(int u,int p,int cur){
	assval[u] = cur;
	for(int v:adj[u]){
		if(v == p)continue;
		if(cur-1 >= minvalue[v])dfs2(v,u,cur-1);
		else dfs2(v,u,cur+1);
	}
}

void solve(){
  	cin >> n;
  	RE(i,n-1){
  		int a,b;cin >> a >> b;
  		adj[a].pb(b);
  		adj[b].pb(a);
  	}
  	cin >> k;
  	RE(i,n)val[i] = INF;
  	RE(i,k){
  		int v,p;cin >> v >> p;
  		val[v] = p;
  		root = v;
  	}
  	dist[root] = 1;
  	dist[0] = INF;
  	dfs1(root,root);
  	RE(i,n){
  		minvalue[i] += dist[i];
  		maxvalue[i] -= dist[i];
  		//cout << i << " " << minvalue[i] << " " << maxvalue[i] << endl;
  	}
  	dfs2(root,root,val[root]);
  	RE(i,n){
  		if(val[i] == INF)continue;
  		if(val[i] != assval[i]){
  			cout << "No";
  			return;
  		}
  	}
  	cout << "Yes\n";
  	RE(i,n)cout << assval[i] << endl;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 19712
#include<stdio.h>

int main(void)

{

int a,b,d,r;

double f;

scanf("%d",&a);

scanf("%d",&b);

d=a/b;

r=a%b;

f=(double)a/b;

printf("%d %d %lf\n",d,r,f);

return 0;

}
 

Measured memory_bytes: 632
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int calc_s (P a, P b, P c, P d )
{
	vector<P> p (4 );
	p[0] = a, p[1] = b, p[2] = c, p[3] = d;
	int maxx = -1, minx = 5001, maxy = -1, miny = 5001;
	int res = 0;

	rep (i, 4 ){
 		maxx = max (maxx, p[i].second );
		minx = min (minx, p[i].second );
		maxy = max (maxy, p[i].first );
		miny = min (miny, p[i].first );
	} // end rep
	res = (maxx - minx)*(maxy - miny );
	res -= 2*abs(p[1].first - p[0].first )*abs(p[1].second - p[0].second );

	return res; 
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.oldest_site2", "r", stdin );
	int n;
	while (cin >> n, n ){
		vector <P> p (n );
		set<P> pp;
		pp.clear();
		rep (i, n ){
			int x, y;
			cin >> x >> y;
			p[i].first = y;
			p[i].second = x;
			pp.insert (p[i] );
		} // end rep
		int maxS = 0;
		rep (i, n ){
			for (int j = i+1; j < n; j++ ){
				P v1 = P (-1, -1 );
				rep (k, 2 ){
					if (k == 0 ){
						v1 = P (p[i].first - p[j].first, p[i].second - p[j].second );
					}else{
						v1 = P (p[j].first - p[i].first, p[j].second - p[i].second );
					} // end if
					P vv1 = P (v1.second, -v1.first );
					P vv2 = P (-v1.second, v1.first );

					P p1 = P (p[i].first + vv1.first, p[i].second + vv1.second );
					P p2 = P (p[j].first + vv1.first, p[j].second + vv1.second );
					if (pp.count (p1 ) && pp.count (p2 ) ){
						maxS = max (maxS, calc_s (p[i], p[j], p1, p2 ) );
					} // end if
				} // end rep
			} // end for
		} // end rep
		cout << maxS << endl;
	} // end while
		
	return 0;
}

Measured memory_bytes: 1032
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(N: int, v: "List[int]"):
    v.sort()
    c = (v[0] + v[1]) / 2
    for vv in v[2:]:
        c = (c+vv)/2
    print(c)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, v)

if __name__ == '__main__':
    main()


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,s,t) for(auto (i) = (s); (i) <= (t); ++(i))
#define repD(i,t,s) for(auto (i) = (t); (i) >= (s); --(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) ((a)^(b) & 1LL ^ 1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,n,s = 1,l = 0; cin>>n;
	int ans = 0;
	rep(i,n){
		cin>>a;
		if(a == l) ++s;
		else{ ans += s/2; s =1; }
		if(i == n-1) ans += s/2; 
		l = a;
	}
	cout<<ans<<endl;
	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int  i,j,cur=0,t,k,a,b,c=0;
    cin>>a>>b;
    for(i=0;i<=a;i++)
    {
        for(j=0;j<=a;j++)
        {
            cur=b-(i+j);
            if(cur>=0&&cur<=a)
               c++;
        }
    }
    cout<<c<<"\n";


return 0;
}


Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main()
{
    char a[5];
    cin>>a;
    int sum=700;
    if (a[0]=='o')
        sum+=100;
    if (a[1]=='o')
        sum+=100;
    if (a[2]=='o')
        sum+=100;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
using namespace __gnu_cxx;
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     f0(n)     for(int i=0;i<n;i++)
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))

ll dp[5][111111],a,b,c;
int main()
{
   /* #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif*/
     __

    int n;
    cin>>n;

    for(int i=0;i<n;i++)
    {
        cin>>a>>b>>c;
        dp[0][i+1]= max(dp[1][i],dp[2][i])+a;
        dp[1][i+1]=max(dp[0][i],dp[2][i])+b;
        dp[2][i+1]=max(dp[1][i],dp[0][i])+c;
    }
    cout<<max(dp[0][n],max(dp[1][n],dp[2][n]));
    return 0;
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	string t = "CODEFESTIVAL2016";
	int r = 0;
	for (int i = 0; i < 16; ++ i) if (s[i] != t[i]) ++ r;
	cout << r << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define SUM(v) accumulate(v.begin(),v.end(),lli(0))
#define rev(n,d) for(int i=n;i>=d;i--)
#define FOR0(n) for(int i=0;i<n;i++)
#define FOR(a,n) for(int i=a;i<n;i++)
#define FORQ(a,n) for(int i=a;i<=n;i++)
#define inf 1000000009
#define inff 0x3f3f3f3f
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define mem(ar,x) memset(ar,x,sizeof ar)
#define present(container, element) (container.find(element) != container.end())
#define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c))
#define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d)
#define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c))
#define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d)
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii>ppii;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<pii>vpii;
const int N=1000005;
int dr8[]={0,0,1,-1,1,1,-1,-1};
int dc8[]={1,-1,0,0,-1,1,-1,1};
int dr4[]={0,1,-1,0};
int dc4[]={1,0,0,-1};
int main(){
	fast
	int n;
	cin>>n;
	lli a[n];
	int hs[N];
	mem(hs,0);
	FOR0(n){
		cin>>a[i];
		hs[a[i]]++;
	}
	int cn=n;
	FOR0(n){
		lli tm=a[i];
		int f=0;
		hs[a[i]]--;
		for(lli j=1;j*j<=tm;j++){
			if(tm%j==0){
				if(hs[j]){
				    // cout<<j<<endl;
					f=1;break;
				}
				if(hs[tm/j]){
				    // cout<<tm/j<<endl;
					f=1;break;
				}
			}
		}
		hs[a[i]]++;
		cn-=f;
	}
	cout<<cn;
}



Measured memory_bytes: 9116
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main()
{
	int test[20],num1,num2,num3,num4;

	for(int i=0;i<20;i++){
		cin>>test[i];
	}
	for(int u=0;u<9;u++){
		for(int k=u+1;k<10;k++){
		if(test[u]<test[k]){
			num1=test[u];
			test[u]=test[k];
			test[k]=num1;
		}
		}
	}
	for(int o=10;o<19;o++){
		for(int l=o+1;l<20;l++){
		if(test[o]<test[l]){
			num2=test[o];
			test[o]=test[l];
			test[l]=num2;
		}
		}
	}
	num3=test[0]+test[1]+test[2];
	num4=test[10]+test[11]+test[12];
	cout<<num3<<" "<<num4;
	cout<<"\n";

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

int bs(int t, std::vector<long int>::iterator b, std::vector<long int>::iterator e) {
    int size = e - b;
    if (size >= 2) {
        if (t < *(b+(size/2))) {
            return bs(t, b, b+(size/2));
        } else {
            return bs(t, b+(size/2), e);
        }
    } else {
        if (*b == t) {
            return 1;
        } else {
            return 0;
        }
    }
}

int main() {
    int n, q, C = 0;
    std::vector<long int> S;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        long int a;
        std::cin >> a;
        S.push_back(a);
    }
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        long int t;
        std::cin >> t;
        C += bs(t, S.begin(), S.end());
    }

    std::cout << C << std::endl;

    return 0;
}


Measured memory_bytes: 3768
K,X = map(int,input().split())

if X-K+1 < -1000000:
    for i in range(-1000000,X-K):
        print(i,end=" ") 
elif X+K-1 > 1000000:
    for i in range(X-K+1,1000001):
        print(i,end=" ")
else:
    for i in range(X-K+1,X+K):
        print(i,end=" ")

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

int main(){
  
  long long A,B,K;
  cin >>A>>B>>K;
  
  if(K < A){
    cout << A-K << " " << B << endl;
  }
  else if(K < A + B){
    cout << 0 << " " << B-K+A << endl;
  }
  else{
    cout << 0 << " " << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

int mat[502][502];

int main()
{
	unsigned long long N, M, Q;
	cin >> N >> M >> Q;

	for (auto i = 0; i < M; ++i)
	{
		int L, R;
		cin >> L >> R;
		++mat[0][R];
		--mat[L + 1][R];
	}
	for (auto i = 1; i <= N + 1; ++i)
	{
		for (auto j = 0; j <= N + 1; ++j)
		{
			mat[j][i] += mat[j][i - 1];
		}
	}
	for (auto i = 1; i <= N + 1; ++i)
	{
		for (auto j = 0; j <= N + 1; ++j)
		{
			mat[i][j] += mat[i - 1][j];
		}
	}

	vector<int> result;
	for (auto i = 0; i < Q; ++i)
	{
		int p, q;
		cin >> p >> q;

		result.push_back(mat[p][q]);
	}
	for (auto i = 0; i < Q; ++i)
	{
		cout << result[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;

template <class T, class BinOp, T id>
class SegTree {
    vector<T>& A;
    vector<T> tree;
    BinOp op;
    int from, to;

    int left(int i) { return 2 * i; }
    int right(int i) { return 2 * i + 1; }

    void build(int node, int l, int r) {
        // l and r are in the main array
        if(tree.size() <= node) tree.resize(node + 1);
        if(l == r) {
            tree[node] = A[l];
        } else {
            int mid = (l + r) / 2;
            build(left(node), l, mid);
            build(right(node), mid + 1, r);
            tree[node] = op(tree[left(node)], tree[right(node)]);
        }
    }

    T rq(int node, int l, int r, int ql, int qr) {
        if(l > qr || ql > r) return id;
        if(ql <= l && r <= qr) return tree[node];
        int mid = (l + r) / 2;
        return op(rq(left(node), l, mid, ql, qr), rq(right(node), mid + 1, r, ql, qr));
    }

    void upd(int node, int l, int r, int qi, T qval) {
        if(l == r && l == qi) {
            tree[node] = qval;
            return;
        }
        int mid = (l + r) / 2;
        if(qi <= mid) upd(left(node), l, mid, qi, qval);
        else          upd(right(node), mid + 1, r, qi, qval);

        tree[node] = op(tree[left(node)], tree[right(node)]);
    }

public:
    SegTree(vector<T>& A, int from, int to)
    : A(A), from(from), to(to), op(BinOp()) {
        build(1, from, to); // 1 based tree // it means root of the tree is index
    }

    T rq(int ql, int qr) {
        return rq(1, from, to, ql, qr);
    }

    void upd(int qi, T qval) {
        A[qi] = qval;
        upd(1, from, to, qi, qval);
    }  
};

struct OP {
    int operator()(int a, int b) { return max(a, b); }
};

const int N = 200009;
int n, a[N], h[N];
vector<int> dp(N, 0);


void read_input()
{
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> h[i];
    for(int i = 1; i <= n; ++i) cin >> a[i];
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    read_input();
    SegTree<int, OP, -1> st(dp, 0, N - 1);

    int mx = -1;
    for(int i = 1; i <= n; ++i) {
        int H = h[i];
        int val = a[i];

        int tmp = val + st.rq(0, H - 1);
        if(tmp > dp[H]) st.upd(H, tmp);
        mx = max(mx, dp[H]);
    }
    cout << mx << endl;
}


Measured memory_bytes: 11248
N = int(input())
a = tuple(map(int, input().split()))

ans = []
t = 0
for i, aa in enumerate(a):
    if i % 2 == 0:
        t += aa
    else:
        t -= aa
ans.append(t)

s = t // 2
for i, aa in enumerate(a[:-1]):
    # print(aa, '-', s)
    s = aa - s
    # print(s, end='')
    ans.append(s * 2)
    # print(ans)
print(*ans)


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int d = b - a;
  cout << d * (d + 1) / 2 - b << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
    int n,i,a[100005],t=0;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);int c=0;
    for(i=0; i<n; i++)
    {

        if(a[i]==a[i+1])
            c++;
        else
        {
            if(c%2==0)
                t++;
                c=0;
        }
    }
    cout<<t<<" "<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>

using namespace std;

#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);

#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)

#define DEB(X) if(mode==1)cout<< #X <<": "<<X<<" ";
#define DEB2(X) if(mode==1)cout<<X<<" ";
#define ARDEB(i,X) if(mode==1)cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define FORDEB(n,X) if(mode==1)for(int i=0;i<(n);i++)ARDEB(i,X)
#define END if(mode==1)cout<<endl;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
struct P2{int x,y;};
//struct edge{int from,cost,to;};

const int MOD7=1000000007;
const int INF=100000000;
int mode=0;

int main(){
	int n,k,x[1000],ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	for(int i=0;i<n;i++){
		ans+=std::min(x[i]*2,abs(k-x[i])*2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
const int mod=1e9+7;
const int maxn=1e5+50;
int n;
int f[maxn];
int nex[maxn];
int sum[maxn];
char s[maxn];
vector<int> pos[3];
inline int add(int x)
{
	return x>=mod?x-mod:x;
}
inline int idx(char c)
{
	return c=='a'?1:2;
}
int solve()
{
	bool flag=true;
	for(int i=1;i<n;++i)
	{
		if(s[i]==s[i+1])
		{
			flag=false;
			break;
		}
	}
	if(flag)
	{
		return 1;
	}
	for(int i=1;i<=n;++i)
	{
		sum[i]=(sum[i-1]+idx(s[i]))%3;
		pos[sum[i]].push_back(i);
	}
	nex[n]=n+1;
	for(int i=n-1;i>=0;--i)
	{
		nex[i]=s[i]==s[i+1]?i+1:nex[i+1];
	}
	f[0]=1;
	for(int i=0;i<n;++i)
	{
		f[i+1]=add(f[i+1]+f[i]);
		int c=idx('a'+'b'-s[i+1]);
		const vector<int> &v=pos[(sum[i]+c)%3];
		int p=lower_bound(v.begin(),v.end(),nex[i])-v.begin();
		if(p!=int(v.size()))
		{
			f[v[p]]=add(f[v[p]]+f[i]);
		}
	}
	int an=0;
	for(int i=1;i<=n;++i)
	{
		if(sum[i]==sum[n])
		{
			an=add(an+f[i]);
		}
	}
	return an;
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	printf("%d\n",solve());
	return 0;
} 

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

int main(){
    long long X;
    cin >> X;
    long long A[501], B[501];
    for(int i = 0; i < 501; i++){
        A[i] = i-250;
        B[i] = i-250;
    }
    for(int i = 0; i < 501; i++){
        for(int j = 0; j < 501; j++){
            if(A[i]*A[i]*A[i]*A[i]*A[i]-B[j]*B[j]*B[j]*B[j]*B[j] == X){
                cout << A[i] << endl;
                cout << B[j] << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3644
N = int(input())
A = list(map(int, input().split()))
D = {}
for i in A:
    if i in D:
        D[i] += 1
    else:
        D[i] = 1
cnt = 0
for k in D.keys():
    if D[k] % 2 < 1:
        cnt += 1
print(len(D) - (cnt % 2))

Measured memory_bytes: 17396
import numpy as np
import bisect
n,m,k=map(int,input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
A=np.cumsum(np.array([0]+a))
B=np.cumsum(np.array(b))
ans=0
for i in range(n+1):
    if A[i]>k:
        break
    t=k-A[i]
    tmp=bisect.bisect_right(B,t)
    ans=max(ans, i+tmp)
print(ans)

Measured memory_bytes: 58576
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	    	
    	int all = 1;
    	while(all<=N) {
    			all *= 2;
    	   	}
    	if(all>N) {
    	System.out.println(all/2);
    	}else {
    	System.out.println(all);
    }
    }
}


Measured memory_bytes: 35688
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)


int main() {

	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	//1
	REP(i, ty - sy) {
		cout << "U";
	}
	REP(i, tx - sx) {
		cout << "R";
	}

	//2
	REP(i, ty - sy) {
		cout << "D";
	}
	REP(i, tx - sx) {
		cout << "L";
	}

	//3
	cout << "L";
	REP(i, ty - sy + 1) {
		cout << "U";
	}
	REP(i, tx - sx + 1) {
		cout << "R";
	}
	cout << "D";

	//4
	cout << "R";
	REP(i, ty - sy+1) {
		cout << "D";
	}
	REP(i, tx - sx+1) {
		cout << "L";
	}
	cout << "U"<<endl;

	
	



	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int sYear, sMonth, sDay;
		int eYear, eMonth, eDay;

		while (true) {
			sYear  = sc.nextInt();
			sMonth = sc.nextInt();
			sDay   = sc.nextInt();
			eYear  = sc.nextInt();
			eMonth = sc.nextInt();
			eDay   = sc.nextInt();
			if (sYear == -1) {
				break;
			}
			System.out.println(g(sYear, sMonth, sDay, eYear, eMonth, eDay));
		}
	}

	public static int g(int sy, int sm, int sd, int ey, int em, int ed) {
		int startDay;
		int endDay;

		startDay = (sy-1)*365 + (sy-1)/400*97 + (sy-1)%400/4 - (sy-1)%400/100;
		if (1 < sm) {
			startDay += 31;
		}
		if (2 < sm) {
			if (sy % 4 == 0 && (sy % 100 != 0 || sy % 400 == 0)) {
				startDay += 29;
			} else {
				startDay += 28;
			}
		}
		if (3 < sm) {
			startDay += 31;
		}
		if (4 < sm) {
			startDay += 30;
		}
		if (5 < sm) {
			startDay += 31;
		}
		if (6 < sm) {
			startDay += 30;
		}
		if (7 < sm) {
			startDay += 31;
		}
		if (8 < sm) {
			startDay += 31;
		}
		if (9 < sm) {
			startDay += 30;
		}
		if (10 < sm) {
			startDay += 31;
		}
		if (11 < sm) {
			startDay += 30;
		}
		startDay += sd;

		endDay = (ey-1)*365 + (ey-1)/400*97 + (ey-1)%400/4 - (ey-1)%400/100;
		if (1 < em) {
			endDay += 31;
		}
		if (2 < em) {
			if (ey% 4 == 0 && (ey % 100 != 0 || ey % 400 == 0)) {
				endDay += 29;
			} else {
				endDay += 28;
			}
		}
		if (3 < em) {
			endDay += 31;
		}
		if (4 < em) {
			endDay += 30;
		}
		if (5 < em) {
			endDay += 31;
		}
		if (6 < em) {
			endDay += 30;
		}
		if (7 < em) {
			endDay += 31;
		}
		if (8 < em) {
			endDay += 31;
		}
		if (9 < em) {
			endDay += 30;
		}
		if (10 < em) {
			endDay += 31;
		}
		if (11 < em) {
			endDay += 30;
		}
		endDay += ed;

		return endDay - startDay;
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N,D,X;
    cin >> N >> D >> X;
    int res = 0;
    rep(i,N) {
      int A;
      cin >> A;
      int num = (D-1) / A;
      res += num + 1;
    }
    res += X;
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {

    char s[101];
    char p[101];
    char s2[202];

    scanf("%s %s", s, p);

    strcpy(s2, s);
    strcat(s2, s);
    if (strstr(s2, p) == NULL) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }

    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int A,B,C; cin>>A>>B>>C;
  vi a={A,B,C};
  sort(ALL(a));
  string ans="NO";
  if(a[0]==5&&a[1]==5&&a[2]==7){
    ans="YES";
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 764
#include<iostream>
#include<cmath>
#include<map>
using namespace std;


int main(){
    int K, n = 1;//n = n項目
    int sept = 7;
    int found = 0;
    map<int, int> hist;
    std::cin >> K;

    if(K%2 == 0){
        n = -1;
    }else{
        while(found == 0){
            if(sept%K == 0){
                found = 1;
            }else{
                //次のseptを作りに行く
                sept = sept%K;
                if(hist.count(sept)){
                    n = -1;
                    break;
                }else{
                    hist[sept] = 1;
                }
                sept = 10 * sept + 7;
//                std::cout << sept << "\n";
                n++;
            }

        }
    }
    std::cout << n;
}



Measured memory_bytes: 50448
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int N,D1,D2;
    vector<bool> Ans;
    cin>>N;
    for(int i=1;i<=N;i++) cin>>D1>>D2,Ans.push_back(D1==D2);
    for(int i=0;i<N-2;i++)
        if(Ans[i]&&Ans[i+1]&&Ans[i+2]){
            cout<<"Yes"<<endl;
            return 0;
        }
    cout<<"No"<<endl;
    return 0;
}

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

int main(){
    ll h;
    cin >> h;
    ll t = 1;
    ll i = 1;
    while(h > 1){
        h /= 2;
        t += pow(2, i);
        i ++;
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
import collections
N = int(input())
A = list(map(int,input().split()))
SUMA = sum(A)
C = collections.Counter(A)
Q = int(input())
BC = [list(map(int,input().split())) for _ in range(Q)]
for bc in BC:
    SUMA += C[bc[0]]*bc[1]-C[bc[0]]*bc[0]
    print(SUMA)
    C[bc[1]] = C[bc[1]]+C[bc[0]]
    C[bc[0]] = 0


Measured memory_bytes: 105568
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
int n,a,b;scanf("%d %d %d",&n,&a,&b);
int sum;
int truesum=0;
for(int i=1;i<=n;i++){
    int aa=i;
    sum=0;
    for(;;){
        if(aa<=9){sum=sum+aa;break;}
        else{sum=sum+aa%10;aa=aa/10;}
    }
    if(sum>=a&&sum<=b){truesum=truesum+i;}
}

printf("%d\n",truesum);
}

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int i,j,k,n,tmp;
  int data[10];
  int print;
  int f[1<<10];

  scanf("%d",&n);
  while(n--){
    rep(i,10) scanf("%d",&data[i]);
    rep(i,1<<10) f[i] = i;
    print = 0; //begin flag is false;

    rep(i,1<<10){
      tmp = 1; //ok

      rep(j,10){
        if(((f[i] >> j) & 1) == 1){
          rep(k,j-1) if(((f[i] >> k) & 1) == 1) if(data[j] < data[k]) tmp = 0;
        }
        if(((f[i] >> j) & 1) != 1){
          rep(k,j-1) if(((f[i] >> k) & 1) != 1) if(data[j] < data[k]) tmp = 0;
        }
      }

      if(tmp) print = 1; //if there are 1 ok, then print is ok
    }

    if(print) printf("YES\n");
    else printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main ()
{
  
 int a, b, c, d; 
 d=0;
 cin >> a >> b>> c;
 
 
 while (a<=b) {
     if (c%a==0) {
         
         d++;
     }
     a++;
 }
 cout <<d << endl;


}


Measured memory_bytes: 3116
import java.util.*

fun main(args: Array<String>) = agc043a()

fun agc043a() {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val board = Array(h) { readLine()!!.map { it == '.' } }

    val distances = Array(h) { IntArray(w) { Int.MAX_VALUE / 100 } }
    val queue = ArrayDeque(listOf(Position(0, 0, 0, true)))

    while (queue.isNotEmpty()) {
        val (y, x, beforeDist, isBeforeWall) = queue.pollFirst()
        val dist = beforeDist + if (isBeforeWall == board[y][x]) 0 else 1

        if (dist < distances[y][x]) {
            distances[y][x] = dist

            around.map { y + it.first to x + it.second }
                .filter { it.first in 0 until h && it.second in 0 until w }
                .map { Position(it.first, it.second, dist, board[y][x]) }
                .let { queue.addAll(it) }
        }
    }

    val answer = Math.ceil(distances.last().last().toDouble() / 2).toInt()

    println(answer)
}

private val around = listOf(1 to 0, 0 to 1)

private data class Position(val y: Int, val x: Int, val beforeCost: Int, val isBeforeWall: Boolean)


Measured memory_bytes: 73904
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=998244353;
#define INF 2*1e9
#define N 510000
using namespace std;

ll n,a[N];
ll bit[N];
void init(int n){
    rep(i,n)bit[i]=0;
}
ll sum(int i){
    ll s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}
void add(int i,int x){
    while(i<=n*3){
        bit[i]+=x;
        i+=i&-i;
    }
}
bool check(int x){
    ll b[N];
    rep2(i,1,n){
        if(a[i-1]<x) b[i]=-1;
        else b[i]=1;
    }
    b[0]=0;
    rep2(i,1,n){
        b[i]+=b[i-1];
    }
    rep(i,n+1)b[i]+=n+1;
    init(n*3);
    ll ans=0;
    rep(i,n+1){
        ans+=sum(b[i]);
        add(b[i],1);        
    }
    if((n*(n+1)/2+1)/2<=ans) return true;
    else return false;
}
main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    int r=1e9+1e8,l=0;
    while(l+1<r){
        int mid=(l+r)/2;
        if(check(mid)) l=mid;
        else r=mid;
    }
    cout<<l;
    return 0;
}

Measured memory_bytes: 8960
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {

	ll X, K, D;
	cin >> X >> K >> D;

	X = abs(X);
	ll cnt = X / D, G;

	if (cnt + 1 >= K) {
		G = X - D * K;
	}
	else if(K > cnt + 1){
		if ((K - cnt) % 2 == 0) G = X - D * cnt;
		else G = X - D * (cnt + 1);
	}
	
	cout << abs(G);


	return 0;
}


ll gcd(ll a, ll b) {
	if (a % b == 0)return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

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

typedef long long ll;
#define int ll


const int N=2e5+5;
int t[4*N]={0},lazy[4*N]={0};

void push(int node)
{
  for(auto child:{2*node,2*node+1})
  {
    t[child]+=lazy[node];
    lazy[child]+=lazy[node];
  }
  lazy[node]=0;
}

void update(int node, int tl, int tr, int l, int r, int add)
{
  if(l>r)
    return;
  if(tl==l&&tr==r)
  {
    t[node]+=add;
    lazy[node]+=add;
  }
  else
  {
    push(node);
    int tm=(tl+tr)>>1;
    update(2*node,tl,tm,l,min(r,tm),add);
    update(2*node+1,tm+1,tr,max(l,tm+1),r,add);
    t[node]=min(t[2*node],t[2*node+1]);
  }
}

int query(int node, int tl, int tr, int l, int r)
{
  if(l>r)
    return 0;
  if(tl==l&&tr==r)
    return t[node];
  push(node);
  int tm=(tl+tr)>>1;
  return min(query(2*node,tl,tm,l,min(r,tm)),query(2*node+1,tm+1,tr,max(l,tm+1),r));
  
}


signed main()
{
  ll n,m,tot=0,l,r,x;
  cin>>n>>m;
  vector<pair<ll,ll>> en[n+1];
  for(int i=0;i<m;i++)
  {
    cin>>l>>r>>x;
    tot+=x;
    en[r].push_back({l,x});
  }
  ll best=tot;
  
  for(int i=1;i<=n+1;i++)
  {
    for(auto p:en[i-1])
    {
      l=p.first;
      x=p.second;
      update(1,0,N-1,0,l-1,x);
    }
    best=query(1,0,N-1,0,i-1);
    update(1,0,N-1,i,i,best);
  }
  cout<<tot-best;
  return 0;
  
}

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

int main(void){
	long n;
	scanf("%ld", &n);
	long l = sqrt(n);
	for(l++; l>0; l--){
		if(n%l==0) break;
	}
	printf("%ld\n", n/l+l-2);
}


Measured memory_bytes: 128