akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}


signed main(){
	
	ll a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;

}

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

int main() {
    int count = 0;
    string str;
    cin >> str;
    if (str[0] == '1') count++;
    if (str[1] == '1') count++;
    if (str[2] == '1') count++;
    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int h = 0;
  int a = 0;
  
  scanf("%d %d",&h,&a);
  if(h%a == 0)
  {
    
  printf("%d",h/a);
  }
  else
  {
    printf("%d",h/a+1);
  }
    return 0;
}

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

int main() {
	int n;
	char a;
	string str1,str2;
	cin >> n;
	if (n%2 != 1) {
		for (int m = 1; m <= n; m++) {
			cin >> a;
			if (m <= n/2)
				str1 += a;
			else
				str2 += a;
		}

		if (str1 == str2)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}	else
			cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define posA 0
#define posB 1
#define posC 2

int label(char c)
{
    if(c=='A')return posA;
    if(c=='B')return posB;
    else return posC;
}


int main()
{
    int cup[3] = {1,0,0};
    int temp;
    char c1,c2,t;
    while(cin >> c1 >> t >>c2)
    {
        temp = cup[label(c1)];
        cup[label(c1)] = cup[label(c2)];
        cup[label(c2)] = temp;
    }
    if(cup[posA]) cout << 'A' << endl;
    else if(cup[posB]) cout << 'B' << endl;
    else cout << 'C' << endl;


    return 0;
}

Measured memory_bytes: 0
// C - 4-adjacent

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int a;
	int m4 = 0, m2 = 0, other = 0;

	for (int i=0; i<N; i++) {
		cin >> a;
		if (a % 4 == 0) m4++;
		else if (a % 2 == 0) m2++;
		else other++;
	}

	string ans = "Yes";
	if (m2 > 0) {
		if (other + 1 > m4 + 1) ans = "No";
	} else {
		if (other > m4 + 1) ans = "No";
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
const ll MAX = 2*(ll)pow(10, 5);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll res = 0;
  vector <ll> v;
  rep(i, 5) {
    ll a; cin >> a;
    if (a%10) {
      res += a/10*10;
      v.push_back(a%10);
    } else res += a;
  }
  sort(v.begin(), v.end());
  if (v.size()) {
    res += 10*(v.size()-1);
    res += v.at(0);
  }
  cout << res << endl;
}

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

public class Main{

	int N;
	int[] ps;
	int[] ts;

	void run(){
		Scanner in = new Scanner(System.in);
		for(;;){
			N = in.nextInt();
			if(N==0) return ;
			ps = new int[N];
			ts = new int[N];
			for(int i=0; i<N; i++){
				ps[i] = in.nextInt();
				ts[i] = in.nextInt();
			}
			int ans = solve();
			if(ans > 0) System.out.println("OK " + ans);
			else System.out.println("NG " + (-ans));
		}
	}

	int solve(){
		int[][] dp = new int[N][3];
		for(int i=0; i<N; i++){
			Arrays.fill(dp[i], Integer.MAX_VALUE);
		}
		if(ts[0] < ps[0]) return -1;
		dp[0][0] = ps[0];
		for(int i=0; i<N-1; i++){
			for(int j=0; j<3; j++)if(dp[i][j] < Integer.MAX_VALUE){
				if(ts[i] + (j+2)*ps[i] + ps[i+1] <= ts[i+1]){
					dp[i+1][0] = Math.min(dp[i+1][0], dp[i][j] + ps[i] + ps[i+1]);
				}
				if(j<2 && ts[i] + (j+2)*Math.abs(ps[i]-ps[i+1]) <= ts[i+1]){
					dp[i+1][j+1] = Math.min(dp[i+1][j+1], dp[i][j] + Math.abs(ps[i] - ps[i+1]));
				}
			}
			boolean ok = false;
			for(int j=0; j<3; j++){
				if(dp[i+1][j] < Integer.MAX_VALUE){
					ok = true;
				}
			}
			if(!ok){
				return -(i+2);
			}
		}
		int ans = Integer.MAX_VALUE;
		for(int j=0; j<3; j++){
			ans = Math.min(ans, dp[N-1][j]);
		}
		return ans + ps[N-1];
	}

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

Measured memory_bytes: 12000
n = int(input())

A = [0]*(n+1)

ans = 0
for i in range(n):
    A[i] = int(input())
    
    
for i in range(n):
    ans += A[i]//2
    A[i] = A[i]%2
    
    if A[i] and A[i+1]:
        ans += 1
        A[i+1] -= 1
        
print(ans)

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

//Euclid's algorithm
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

int main(){
    ll n;
    cin>>n;
    map <string, ll> m;
    for(ll i=0;i<n;i++){
        string temp;
        cin>>temp;
        if (m.find(temp) == m.end()){
          m[temp]=0;
        }
    }
    cout<<m.size();
}

Measured memory_bytes: 19180
#include <stdio.h>
#include <string.h>

int main(void)
{
    int sum,len;
    char x[1000];

    while(1){
        scanf("%s",x);
        if(x[0]=='0'){
            break;
        }
        len = strlen(x);
        sum=0;
        for(int n=0;n<len;n++){
            sum+=(x[n]-'0');
        }
        printf("%d\n",sum);
    }
  return 0;
}

Measured memory_bytes: 964
fun main(arg: Array<String>) {
    val N = nextInt()
    val P = listOfInt(-1).toIntArray()
    var t = 0
    fun swap(n: Int) {
        val w = P[n]
        P[n] = P[n + 1]
        P[n + 1] = w
    }
    for (n in 0 until N - 1) {
        if (P[n] == n) {
            t += 1
            swap(n)
        }
    }
    if (P[N - 1] == N - 1) t += 1
    val ans = t
    println(ans)
}
//49998
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(D: Int = 0) = listOfString().map { Integer.parseInt(it) + D }
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }


Measured memory_bytes: 51572
"""dfs"""

import sys
sys.setrecursionlimit(10**6)

n = int(input())
 
G = {}
for i in range(n):
    G.update({i:[]})

for i in range(n-1):
    u,v,w = map(int, input().split())
    u -= 1; v -= 1
    G[u].append([v, w%2])
    G[v].append([u, w%2])

color = [-1 for i in range(n)]

def dfs(graph, v, c):
    color[v] = c
    
    for next_v in graph[v]:
        if color[next_v[0]] != -1: continue
        dist = next_v[1]
        if dist == 0:
            next_c = c
        elif dist == 1:
            next_c = 1 - c
        
        dfs(graph, next_v[0], next_c)

dfs(G, 0, 0)

print(*color)

Measured memory_bytes: 91448
// Problem: D - Moving Piece
// Contest: AtCoder - AtCoder Beginner Contest 175
// URL: https://atcoder.jp/contests/abc175/tasks/abc175_d
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int n , k;
           cin >> n >> k;
           vector<ll> p(n + 5),c(n + 5),mark(n + 5),sum(n + 5);
           for(int i = 1 ; i <= n ; i++)
           {
               cin >> p[i];
           }
           
           for(int i = 1 ; i <= n ; i++)cin >> c[i];
           
           for(int i = 1 ; i <= n ; i++)
           {
               int m = i;
               ll s = 0;
               vector<int> vis(n + 5);
               
               for(int j = 0 ; j <= n ; j++)
               {
                   if(vis[m])
                   {
                       mark[i] = j;
                       sum[i] = s;    
                       break;
                   }
                   vis[m] = 1;
                   m = p[m];
                   s += c[m];
               }
           }
           
           ll ans = LLONG_MIN;
           
           for(int i = 1 ; i <= n ; i++)
           {
               int m = i;
               ll s = 0;
               for(int j = 1 ; j <= mark[i] ; j++)
               {
                   if(j > k)break;
                   m = p[m];
                   s += c[m];
                   int t = (k - j) / mark[i];
                   ll s2 = s + t * sum[i];
                   ans = max(ans , s);

                   ans = max(ans , s2);
               }
           }
           
           cout << ans << endl;
        }
    }



Measured memory_bytes: 3792
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
typedef long long ll;
using namespace std;

int main()
{
	double N, K;
	cin >> N >> K;
	double ans = 0;
	rep1(i, N)
	{
		double prob;
		if (i < K)
		{
			int p = ceil(log2(K / (double)i));
			prob = (double)pow(0.5, p) / N;
		}
		else
		{
			prob = 1 / N;
		}
		ans += prob;
	}
	cout << setprecision(15);
	co(ans);
	return 0;
}

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

int n, k, mx;
string s;
int main() {
	int i, j, c;
	cin >> n >> k >> s;
	for(i=0; i<n && s[i]=='1'; i++);
	for(c=0; c<k; c++) {
		for(; i<n && s[i]=='0'; i++);
		for(; i<n && s[i]=='1'; i++);
	}
	mx = i;
	for(j=0; i<n; ) {
		for(; i<n && s[i]=='0'; i++);
		for(; i<n && s[i]=='1'; i++);
		for(; s[j]=='1'; j++);
		for(; s[j]=='0'; j++);
		mx = max(mx, i-j);
	}
	cout << mx;
	return 0;
}

Measured memory_bytes: 512
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
lr, ls, lp = -n, -n, -n
ans = 0

for i in range(k):
    if t[i] == "r":
        ans += p
    elif t[i] == "s":
        ans += r
    else:
        ans += s
for i in range(k,n):
    if t[i] == "r" and t[i-k] != "r":
        ans += p
    elif t[i] == "s" and t[i-k] != "s":
        ans += r
    elif t[i] == "p" and t[i-k] != "p":
        ans += s
    else:
        t[i] = "2"

print(ans)

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

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if(s[i] != t[i])ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3916
#include <iostream>

using namespace std;
int counting(int x) {
    int ans = 0;
    for (int i=1; i * i <= x; i++) {
        if (x % i == 0) {
            if (i * i == x) ans++;
            else ans += 2;
        }
    }
    return ans;
}
int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int nc = 1; nc <= N-1; nc++) {
        ans += counting(nc);
    }
    cout << ans << endl;
    return 0;
}



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

template <typename t>
void print (const t &v){
        for ( auto i :v){
                cout << i << " " ;
        }
        cout << endl;
} 

inline void saveme(){
        ios_base::sync_with_stdio(false);
        cout.tie(0);
        cin.tie(0);
}

int main (){
        ll h, n;
        cin >> h >> n;
        vector <ll> v;

        while(n--){
                ll no;
                cin >> no;
                v.push_back(no);
        }

        ll sum=accumulate(v.begin(), v.end(), 0.0 );

        if ( sum >=  h){
                cout << "Yes" << endl;
        }
        else {
                cout << "No" << endl;
        }
        
        return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
const ll BetsuMOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n;
	cin >> n;
	double invsum = 0.0;
	rep(i, n) {
		double b;
		cin >> b;
		invsum += 1.0 / b;
	}
	output(1.0 / invsum, 10);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int a,b;

int main()
{

    int cmmdc=0;
    long long cmmmc;

    cin>>a>>b;

    cmmdc=__gcd(a,b);

    cmmmc=(long long) a*b/cmmdc;

    cout<<cmmmc;

    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int numMax(int num[],int n){
    int nummax=num[0];
    for(int i=1;i<n;i++){
        nummax=max(num[i],nummax);
    }

    return nummax;
}

int numMin(int num[],int n){
    int nummin=num[0];
    for(int i=1;i<n;i++){
        nummin=min(num[i],nummin);
    }

    return nummin;
}

int main(){

    int n=0;
    int num[100];

    cin>>n;

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

    int nummax=numMax(num,n);
    int nummin=numMin(num,n);

    cout<<(nummax-nummin)<<endl;;

    return 0;
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    grid = dict() #絶対値
    zero = 12800
    dist = dict()
    for h in range(H):
        grid[h] = dict()
        dist[h] = dict()
        for w in range(W):
            grid[h][w] = 0
            dist[h][w] = 0

    for h in range(H):
        for x, v in enumerate(map(int, input().split())):
            grid[h][x] = v
    for h in range(H):
        for x, v in enumerate(map(int, input().split())):
            grid[h][x] = abs(grid[h][x] - v)

    dist[0][0] |= 2 ** zero >> grid[0][0]
    dist[0][0] |= 2 ** zero << grid[0][0]

    for h in range(H):
        for w in range(W):
            if h < H - 1:
                n = grid[h+1][w]
                dist[h+1][w] |= dist[h][w] >> n
                dist[h+1][w] |= dist[h][w] << n
            if w < W - 1:
                n = grid[h][w+1]
                dist[h][w+1] |= dist[h][w] >> n
                dist[h][w+1] |= dist[h][w] << n
    
    ans = 100000000
    for i in range(zero*2):
        if dist[H-1][W-1] & 1:
            ans = min(ans, abs(i - zero))
        dist[H-1][W-1] >>= 1

    print(ans)

    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 21364
import java.util.Scanner;

public class Main {

  private static final long MOD = 998244353;
  private static long FACT[];
  private static long IFACT[];

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    solve(N);
  }

  static void solve(int N) {
    long ans = Long.MAX_VALUE;
    for (int i=0; i<=N; i++) {
      int tmpI = i;
      int tmpJ = N-i;
      int tmpAns = 0;
      while (tmpI > 0) {
        tmpAns += tmpI % 9;
        tmpI /= 9;
      }
      while (tmpJ > 0) {
        tmpAns += tmpJ % 6;
        tmpJ /= 6;
      }
      ans = Math.min(tmpAns, ans);
    }
    System.out.println(ans);
  }

  // Pre-calculate factorial and its mod_inverse for calculate nCr in O(1)
  private static void create_fact(int N) {
    FACT = new long[N+1];
    IFACT = new long[N+1];
    FACT[0] = 1;
    IFACT[0] = 1;
    for (int i=1; i<=N; i++) {
      FACT[i] = FACT[i-1] * i % MOD;
      IFACT[i] = mod_inverse(FACT[i]);
    }
  }

  // Return nCr
  private static long comb(int n, int r) {
    if (n < 0 || r < 0 || n < r) {
      return 0;
    }
    if (r > n/2) {
      r = n - r;
    }
    return FACT[n]*IFACT[n-r]%MOD*IFACT[r]%MOD;
  }

  // Fast mod inverse
  private static long mod_inverse(long a) {
    long b = MOD;
    long p = 1, q = 0;
    while (b > 0) {
      long c = a / b;
      long d;
      d = a;
      a = b;
      b = d % b;
      d = p;
      p = q;
      q = d - c * q;
    }
    return p < 0 ? p + MOD : p;
  }
}


Measured memory_bytes: 23636
#include <stdio.h>

int main(void){
  int n;
  int i;
  int b=100000;
  int a;
  scanf("%d ",&n);
  for(i=0;i<n;i++){
    b+=( b*0.05 );
    a=(b/1000)*1000;
    if( a!=b )
      a+=1000;
    b=a;
  }
  printf("%d\n",b);

  return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
string s;
void solve(){
	cin >> s;
	n = s.size();
	
	vector<char> v;
	for(int i = 0; i < n; i++){
		if(s[i] == 'B'){if(!v.empty()) v.pop_back();}
		else v.push_back(s[i]);
	}
	for(int i = 0; i < v.size(); i++){
		cout << v[i];
	}
	cout << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll l;
 
struct edge {
    ll from,to,weight;
    edge(ll from, ll to, ll weight) : from(from), to(to), weight(weight){}
};
 
int main(void) {
    cin >> l;
    vector<edge> e;
    ll cnt;
    ll max_n=0;
    for(cnt=1;(1LL<<cnt)<=l;cnt++){
       e.push_back(edge(cnt,cnt+1,0)); 
       e.push_back(edge(cnt,cnt+1,(1LL<<cnt-1))); 
        max_n+=1LL<<cnt-1;
    }
    ll cur;
    while(max_n!=l-1){
        cur=log2(l-max_n-1)+1;
        DEBUG{
            cout << cur << endl;
        }
        e.push_back(edge(cur,cnt,max_n+1));
        max_n+=(1LL<<cur-1);
    }
    cout << cnt << " " << e.size() << endl;
    for(auto x:e){
        printf("%lld %lld %lld\n",x.from, x.to, x.weight);
    }
 
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		char[] c = n.toCharArray();
		if((c[0] == c[1] && c[1] == c[2]) || (c[1] == c[2] && c[2] == c[3])) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
// AOJ ALDS1_5_A Exhaustive Search
// 2018.4.30 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char f[2002];
short que[2002]; int top, end;

int main()
{
	int n, a, q;
	int stop, x;
	
	n = in(), que[0] = 0, end = 1;
	while (n--) {
		stop = end;
		a = in();
		for (top = 0; top < stop; top++) {
			x = que[top] + a;
			if (f[x]) continue;
			f[x] = 1, que[end++] = x;
		}
	}

	q = in();
	while (q--) {
		puts(f[in()]? "yes": "no");
	}
	return 0;
}


Measured memory_bytes: 2144
#include <algorithm>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)


int Check(tuple<long, int, int>& ans, vector<tuple<long, int, int, bool>>& hint_collection)
{
	int correct = 0;

	for (const auto& e : hint_collection)
	{
		if (get< 3 >(e))
		{
			if (get< 0 >(e) == 0)
			{	// 例外処理 ヒントの高さが0のとき
				if (0 < get< 0 >(ans) - abs(get< 1 >(ans) - get< 1 >(e)) - abs(get< 2 >(ans) - get< 2 >(e)))
					break;
			}
			else if (get< 0 >(e) != get< 0 >(ans) - abs(get< 1 >(ans) - get< 1 >(e)) - abs(get< 2 >(ans) - get< 2 >(e)))
				break;

			correct++;
		}
	}

	return correct;
}

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

	vector<tuple<long, int, int, bool>> hint_collection;
	hint_collection.resize(101 * 101);
	loop(x, 101)
	{	// ヒントコンテナの初期化
		loop(y, 101)
		{
			tuple<long, int, int, bool> t = make_tuple(0, x, y, false);
			hint_collection[x * 101 + y] = t;
		}
	}

	loop(i, n)
	{	// ヒントコンテナを作る
		int x; cin >> x;
		int y; cin >> y;
		long h; cin >> h;
		tuple<long, int, int, bool> t = make_tuple(h, x, y, true);
		hint_collection[x * 101 + y] = t;
	}

	tuple<long, int, int, bool> max = make_tuple(-1, 0, 0, false);
	loop(i, 101 * 101)
	{	// ヒントのうち最大の高さを調べる
		if (get< 3 >(hint_collection[i]) && get< 0 >(max) < get< 0 >(hint_collection[i]))
			max = hint_collection[i];
	}

	vector<tuple<long, int, int>> ans_collection;
	ans_collection.resize(101 * 101);
	loop(x, 101)
	{	// 答えを予想するコンテナの作成
		loop(y, 101)
		{
			long h = get< 0 >(max) + abs(x - get< 1 >(max)) + abs(y - get< 2 >(max));
			tuple<long, int, int> t = make_tuple(h, x, y);
			ans_collection[x * 101 + y] = t;
		}
	}

	loop(x, 101)
	{	// 予想したコンテナから答えを探す
		loop(y, 101)
		{
			if (Check(ans_collection[x * 101 + y], hint_collection) == n)
			{
				cout << get< 1 >(ans_collection[x * 101 + y]) << " " << get< 2 >(ans_collection[x * 101 + y]) << " " << get< 0 >(ans_collection[x * 101 + y]);
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 640
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;

bool check(const string & s, int lo, int hi) {
    while(lo < hi) {
        if(s[lo] != s[hi]) return false;
        ++lo;
        --hi;
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.length();
    int valid = check(s, 0, n - 1) && check(s, 0, (n - 1)/2 - 1) && check(s, (n + 3)/2 - 1, n - 1);
    cout << (valid ? "Yes" : "No") << "\n";
    return 0;
}



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

using namespace std;

#define ll long long 
#define Coming ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

int main()
{
	
	string ch;
	int n, k;
	
	cin >>n >> k;
	
	cin >> ch;
	
	for(int i = 0; i< n; i++)
	{
		if(i+1 == k)
		{
			ch[i] = ch[i] + 32;
		}
	}
	
	cout << ch << endl;
	
	return 0;
}


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

#define ll long long 
const int MAXN = 2e5 + 5;

int n;
ll k;
int a[MAXN], nex[MAXN];
vector<ll> drainTime;
int ans[MAXN];
int cnt[MAXN];

map<int,int> lis;

int main(){
	scanf("%d %lld", &n, &k);
	for(int i = 0; i < n; ++i){
		scanf("%d", &a[i]);
	}
	for(int j = 0; j < 2; ++j)
	for(int i = 0; i < n; ++i){
		if(lis.count(a[i])){
			nex[lis[a[i]]] = i;
		}
		lis[a[i]] = i;
	}
	// Simulate pattern
	drainTime.push_back(0);
	ll pos = 0, tmp = 0;
	do{
		if(nex[pos] > pos){
			tmp += nex[pos]-pos+1;
		}else{
			tmp += nex[pos]-pos+n+1;
		}
		drainTime.push_back(tmp);
		//printf("Add %lld\n", tmp);
		pos = (nex[pos]+1)%n;
	} while(pos != 0);

	ll tot = k*n;
	tot = tot%drainTime.back();
	//printf("Rem moves = %lld\n", tot);
	ll startTime = *(upper_bound(drainTime.begin(), drainTime.end(), tot)-1);
	ll startPos = ((startTime%n)-1+n)%n;
	tot -= startTime;
	//printf("Rem = %lld %lld\n", tot, startPos);

	lis.clear();
	int finalPos = 0;
	while(tot--){
		startPos = (startPos+1)%n;
		if(cnt[a[startPos]] > 0){
			while(cnt[a[startPos]] > 0){
				--finalPos;
				--cnt[ans[finalPos]];
			}
		}else{
			ans[finalPos++] = a[startPos];
			++cnt[a[startPos]];
		}
	}
	for(int i = 0; i < finalPos; ++i){
		if(i)
			printf(" ");
		printf("%d", ans[i]);
	}
	printf("\n");
}

Measured memory_bytes: 15732
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int sum = 0;
    boost::multi_array<int, 2> mat(boost::extents[3][3]);
    for (auto p = mat.data(); p < (mat.origin() + mat.num_elements()); ++p) {
        std::cin >> *p;
        sum += *p;
    }

    std::vector<int> B{mat[0][0], mat[0][1], mat[0][2]};
    std::vector<int> A{0, mat[1][0] - B[0], mat[2][0] - B[0]};

    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (A[i] + B[j] != mat[i][j]) {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "Yes" << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args){
	  Scanner scan = new Scanner(System.in);
	  String S = scan.next();
      String N = "";
      int num = 0;
      for(int i = S.length(); i > 0; i--){
        N = S.substring(i-1, i);
        num += Integer.parseInt(N);
      }
      if(num%9==0) System.out.println("Yes");
      else System.out.println("No");
	}
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n, m, d;
  cin >> n >> m >> d;

  int tmp;
  if(d == 0) {
    tmp = n;
  } else if(2*d >= n) {
    tmp = n;
  } else {
    tmp = 2*(n-d);
  }
  // cout << tmp << endl;
  // cout << (double)tmp/n/n << endl;
  cout << fixed << setprecision(15) << (double)tmp/n/n*(m-1) << endl;

  return 0;
}


Measured memory_bytes: 256
mod = 1000000007

n, m = list(map(int, input().split()))
nums = [int(input()) for _ in range(m)]
 
dp = [1] + [0 for _ in range(n)]

if len(nums) > 0 and nums[0] == 1:
	del nums[0]
else:
	dp[1] = 1
	

for i in range(2, n + 1):
	#print(i, dp, nums)
	if len(nums) ==  0:
		dp[i] = (dp[i - 1] + dp[i - 2]) % mod
	else:
		for j in range(len(nums)):
			if nums[j] > i:
				dp[i] = (dp[i - 1] + dp[i - 2]) % mod
				break
			elif nums[j] == i:
				del nums[:(j + 1)]
				break
#print(nums)
#print(dp)
print(dp[-1])



Measured memory_bytes: 8624
#include<iostream>
using namespace std;
bool second(int a,int b,int c)
{
if(a>b&& b>c)
  return true;
  else if(b>a && b<c)
    return true;
  else
    return false;
}

int main()
{
int n;
  int c=0;
  cin>>n;
  int a[n],i;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(i=1;i<n-1;i++)
  {
    if(second(a[i-1],a[i],a[i+1]))
      c++;
  }
  cout<<c;
  return 0;
}
  


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b) {
  return *(long *)a - *(long *)b;
}

int main(){
   long a[100001],b,d;
   int i,n,dn;
    
   scanf("%d",&n);
   for (i=0;i<n;i++) scanf("%ld",&a[i]);
   d=dn=0;
   for (i=0;i<n;i++) {
      scanf("%ld",&b);
      a[i]-=b;
      if (a[i]<0) {
         d+=a[i];
         dn++;
      }
   }
   if (d==0) {
      puts("0");
      return 0;
   }
   qsort(a,n, sizeof(long),asc);
   for (i=n-1;i>=0 && d<0;i--) {
      if (a[i]<0) {
         puts("-1");
         return 0;
      }
      d+=a[i];
   }
   printf("%d\n",dn+n-i-1);
   return 0;
}


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

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

const int N = 3333;
ll inpX[N], inpY[N], inpZ[N];
struct Node {
    int x, y, z;
    bool operator<(const Node &others) const
    {
        ll s1 = inpX[x] + inpY[y] + inpZ[z];
        ll s2 = inpX[others.x] + inpY[others.y] + inpZ[others.z];

        return s1 < s2;
    }

    ll val()
    {
        return inpX[x] + inpY[y] + inpZ[z];
    }
};

int main()
{
    int x, y, z, k;
    scanf("%d %d %d %d", &x, &y, &z, &k);

    for (int i = 0; i < x; i++)
        scanf("%lld", &inpX[i]);
    sort(inpX, inpX + x);
    for (int i = 0; i < y; i++)
        scanf("%lld", &inpY[i]);
    sort(inpY, inpY + y);
    for (int i = 0; i < z; i++)
        scanf("%lld", &inpZ[i]);
    sort(inpZ, inpZ + z);

    priority_queue<Node> pq;
    set<iii> used;
    used.insert({x - 1, {y - 1, z - 1}});
    pq.push({x - 1, y - 1, z - 1});
    while (pq.size() > 0 && k--) {
        Node cur = pq.top();
        pq.pop();
        printf("%lld\n", cur.val());

        if (cur.x > 0) {
            auto newNode = cur;
            newNode.x--;
            iii c = {newNode.x, {newNode.y, newNode.z}};
            if (used.find(c) == used.end())
                pq.push(newNode), used.insert(c);
        }
        if (cur.y > 0) {
            auto newNode = cur;
            newNode.y--;
            iii c = {newNode.x, {newNode.y, newNode.z}};
            if (used.find(c) == used.end())
                pq.push(newNode), used.insert(c);
        }
        if (cur.z > 0) {
            auto newNode = cur;
            newNode.z--;
            iii c = {newNode.x, {newNode.y, newNode.z}};
            if (used.find(c) == used.end())
                pq.push(newNode), used.insert(c);
        }
    }

    return 0;
}


Measured memory_bytes: 768
def main():
  S = input()[::-1]
  i = 0
  while i < len(S):
    if S[i:i+5] == 'maerd' or S[i:i+5] == 'esare':
      i += 5
    elif S[i:i+6] == 'resare':
      i += 6
    elif S[i:i+7] == 'remaerd':
      i += 7
    else:
      print('NO')
      break
  else:
    print('YES')
  return

if __name__ == '__main__':
  main()
    

Measured memory_bytes: 3188
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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 ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

map< int, int > prime_factor(int n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  vector<map<int,int>> vmp(n-1);
  FOR(i,2,n+1) {
    vmp[i-2] = prime_factor(i);
  }
  map<int,int> mp;
  int ans = 1;
  REP(i,n-1){
    for(auto p: vmp[i]){
      mp[p.first] += p.second;
    }
  }
  for(auto p:mp){
    ans *= (p.second + 1);
    ans %= MOD;
  }
  OUT(ans);
}

Measured memory_bytes: 512
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>

#define p(a, b) pair<a, b>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    uint64_t n;
    cin >> n;
    for(uint64_t i = 1;;i++){
        if(i*i > n){
            int x = i-1;
            cout << x*x;
            return 0;
        }
    }
    return 0;
}


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

using namespace std;

const long long MOD = 1000000007LL;
long long a[50][50], b[50][50];

void multiply(long long a[50][50], long long b[50][50], long long c[50][50], int sz){

    long long d[50][50] = {};

    int i, j, k;

    for(i = 0; i < sz; ++i)
        for(k = 0; k < sz; ++k)
            for(j = 0; j < sz; ++j)
                d[i][j] = (d[i][j] + a[i][k] * b[k][j] % MOD) % MOD;

    for(i = 0; i < sz; ++i)
        for(j = 0; j < sz; ++j)
            c[i][j] = d[i][j];

}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;
    long long k;

    cin >> n >> k;

    for(int i = 0; i < n; ++i){
        a[i][i] = 1;
        for(int j = 0; j < n; ++j)
            cin >> b[i][j];
    }

    for(;k; k >>= 1){
        if((k & 1) == 1) multiply(a, b, a, n);
        multiply(b, b, b, n);
    }

    long long tot = 0;

    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            tot = (tot + a[i][j]) % MOD;

    cout << tot << "\n";

    return 0;
}

Measured memory_bytes: 384
from collections import deque
def bfs(maze, visited, l,n_w):
    queue = deque(l)
    for i in queue:
        visited[i[0]][i[1]] = 0
    while queue:
        y, x = queue.popleft()
        if n_w==0:
            s=set()
            tmp=0
            for i in visited:
                if max(i)>tmp:tmp=max(i)
            return(tmp)
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
                n_w-=1

R, C = map(int, input().split())


maze = ["$"*(C+2)]+["$"+input()+"$" for i in range(R)]+["$"*(C+2)]
visited = [[-2]*(C+2)]+[[-2]+[-1]*(C)+[-2] for j in range(R)]+[[-2]*(C+2)]
l_b=[]
for i in range(R+2):
    for j in range(C+2):
        if maze[i][j]=="#":
            l_b.append([i,j])
n_w=R*C-len(l_b)

print(bfs(maze, visited,l_b,n_w))

Measured memory_bytes: 153304
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.*;
public class Main
{
    public static void main(String[] args)throws IOException
    {
        FastReader in=new FastReader(System.in);
        StringBuffer st=new StringBuffer();
        
            int n=in.nextInt();
            long intervals[][]=new long[n][2];
            for(int i=0;i<n;i++){
              long x=in.nextLong(),l=in.nextLong();
              long x1=x-l,y1=x+l;
              intervals[i][0]=x1;intervals[i][1]=y1;
            }
            
        Arrays.sort(intervals, (a, b) -> Long.compare(a[0], b[0]));
        long prevEnd = intervals[0][1];
        int count = 0;
        for (int i = 1; i < intervals.length; i++) {
            if (prevEnd > intervals[i][0]) {
                count++;
                prevEnd = Math.min(intervals[i][1], prevEnd);
            } else {
                prevEnd = intervals[i][1];
            }
        }
        
          
        System.out.println(n-count);
    }
    static class FastReader{
 
        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;
 
        FastReader(InputStream is) {
            in = is;
        }
 
        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }
 
        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan());
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }
 
        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan());
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
 
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan());
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}      

Measured memory_bytes: 29596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	double sum = 0;
	while(n--) {
		double a; cin >> a;
		sum += 1.0/a;
	} 
	printf("%.10f\n", 1.0/sum);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cassert>
#include <unordered_set>
#include <set>
#include <bitset>
#include <memory.h>
#include <algorithm>
#include <cmath>

using namespace std;

#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()

int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    string a;
    cin >> a;

    if (n % 2) {
        cout << "No\n";
        return 0;
    }

    string b = a.substr(0, n / 2);
    string c = b + b;

    cout << (c == a ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
  int n;
  cin >> n;
  double suma = 0;
  for (int i = 0; i < n; i++){
    double t;
    cin >> t;
    suma = suma + 1/t;
  }
  suma = 1/suma;
  cout << setprecision(7) << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << suma;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set> 
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
int n,k; 
using namespace std;
int main() 
{cin>>n>>k; 
 if (k<n)
 n-=1; 
 cout<<n; 
 
 system("pause");
 return 0;
}        


Measured memory_bytes: 504
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class t>
using table = vector<vector<t>>;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt"

int N, M, P;
vector<vector<vector<int>>>field;

void put(const int x, const int y, const int c) {
	for (int z = 0; z < N; ++z) {
		if (!field[y][x][z]) {
			field[y][x][z] = c;
			return;
		}
	}
}
bool isin(const int x, const int y, const int z) {
	return (x >= 0 && x < N&&y >= 0 && y < N&&z >= 0 && z < N);
}
int check(const int c) {
	for (int nx = 0; nx < N; ++nx) {
		for (int ny = 0; ny < N; ++ny) {
			for (int nz = 0; nz < N; ++nz) {
				for (int dx = -1; dx <= 1; ++dx) {
					for (int dy = -1; dy <= 1; ++dy) {
						for (int dz = -1; dz <= 1; ++dz) {
							if (!dx&&!dy&&!dz)continue;
							bool aok = true;
							for (int i = 0; i <M; ++i) {
								const int ax = nx + dx*i;
								const int ay = ny + dy*i;
								const int az = nz + dz*i;
								if (isin(ax, ay, az) && field[ay][ax][az] == c) {

								}
								else {
									aok = false;
								}
							}
							if (aok)return true;
						}
					}
				}
			}
		}
	}
	return false;
}
int main() {
	while (1) {
		cin >> N >> M >> P;
		field.clear();
		field = vector<vector<vector<int>>>(N, vector<vector<int>>(N, vector<int>(N)));
		if (!N)break;
		int ans = -1;
		for (int i = 0; i < P; ++i) {
			int x, y; cin >> x >> y; x--; y--;
			put(x, y, i % 2 + 1);
			if (check(i % 2 + 1) && ans == -1) {
				ans = i + 1;
			}
		}
		if (ans == -1) {
			cout << "Draw" << endl;
		}
		else if (ans % 2) {

			cout << "Black" << " " << ans << endl;
		}
		else {
			cout << "White" << " " << ans << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 3132
open System

let n, k =
    let l = Console.ReadLine().Split(' ')
    let n = l.[0] |> int
    let k = l.[1] |> Int64.Parse
    n, k

let a =
    Console.ReadLine().Split(' ')
    |> Array.map (fun x -> int(x) - 1)

let ans =
    let loopOrigin, path =
        let rec search (path: int list) (towns: Set<int>) =
            let tail =
                match path with
                | tail :: _ -> tail
                | _ -> -1
            let next = a.[tail]

            if towns.Contains next then
                let path = path |> List.rev
                let loopOrigin =
                    path |> List.findIndex (fun t -> t = next)
                loopOrigin, path
            else
                search (next :: path) (towns.Add next)

        search [0] (Set [0])

    let ans =
        let idx =
            let loopOrigin = int64 loopOrigin
            let freq = int64 (List.length path) - loopOrigin
            if k < loopOrigin then
                k |> int
            else
                loopOrigin + (k - loopOrigin) % freq |> int
        path.[idx] + 1

    ans

ans |> Console.WriteLine


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    vector< tuple<string, int, int> > v;
    rep(i, n){
        string s;
        int p;
        cin >> s >> p;
        v.push_back(make_tuple(s, -p, i + 1));
    }
    SORT(v);

    rep(i, n){
        cout << get<2>(v[i]) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import kotlin.math.abs

fun main(args: Array<String>) {

    val (x, k, d) = readLine()!!.split(" ").map { it.toLong() }


    //val (x, k, d) = Triple<Long, Long, Long>(1000000000000000 , 1000000000000000 , 1000000000000000 )

    val absx = abs(x)

    val needBestTimes = absx / d
    val bestPos = absx % d

    //println("needBestTimes: $needBestTimes, bestPos: $bestPos")

    val answer = when {
        needBestTimes > k -> {
            //println("case1")
            absx - d * k
        }
        (k - needBestTimes) % 2 == 0L -> {
            //println("case2")
            bestPos
        }
        (k - needBestTimes) % 2 == 1L -> {
            //println("case3")
            abs(bestPos - d)
        }

        else -> {
            0L
        }
    }

    println("$answer")
}


Measured memory_bytes: 36352
if __name__ == '__main__':
    n = int(input())
    sp = []
    for i in range(n):
        a, b = input().split()
        b = int(b)
        sp.append([a, b, i])
    sp.sort(key=lambda x:(x[0], -x[1]))
    for arr in sp:
        print(arr[2]+1)


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


namespace ConsoleApp6
{
	class Program
	{
		static void Main(string[] args)
		{
			while (true)
			{
				int A = 0;
				var x = Console.ReadLine();

				if (x == "0")
					break;

				char[] n = x.ToCharArray();

				for(int i = 0; i < n.Length; i++)
				{
					string s = n[i].ToString();
					A += int.Parse(s);
				}
				Console.WriteLine(A);
			}
		}
	}
}



Measured memory_bytes: 17948
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum = 0;
        
        for(int a=1; a<=n; a++){
            if(a%3!=0 && a%5!=0)
                sum += a;
        }
        
        System.out.println(sum);
    }
}

Measured memory_bytes: 35748
while True:
    m, f, r = [int(i) for i in input().split()]

    if m == f == r== -1:
        break

    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')

    elif total < 50 and r < 50:
        print('D')

    elif total < 65:
        print('C')

    elif total < 80:
        print('B')

    else:
        print('A')

Measured memory_bytes: 7680
var
	H,W,i,j,f,t:Longint;
	S:Array[1..8]of String;
begin
	readln(H,W);
	for i:=1 to H do readln(S[i]);
	for i:=1 to H do for j:=1 to W do begin
		t:=0;
		if(i+1<=H)and(S[i+1][j]='#')then inc(t);
		if(j+1<=W)and(S[i][j+1]='#')then inc(t);
		if t=2 then f:=1;
	end;
	if f=0 then writeln('Possible')else writeln('Impossible');
end.


Measured memory_bytes: 128