akhauriyash/Code-Regression huggingface dataset:
/* author   : mpily :-()
    title : Competing.cpp
    time :Fri Apr 10 17:19:34 2020
     
    */
    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const ll mod = 1e9+7;
    int dp[201][201];//dp[i][0] = number of R.. [i][1] number of B...[i][2] number of G
    int getgcd(int a, int b){
    	if(dp[a][b]){
    		return dp[a][b];
    	}
    	else{
    		int g = __gcd(a,b);
    		dp[a][b] = g;
    		dp[b][a] = g;
    	}
    	return dp[a][b];
    }
    int main(){
    	ios_base::sync_with_stdio(0);
    	cin.tie(0);
    	int k;
    	cin>>k;
    	for(int i = 0; i <= k;++i)for(int j = 0; j <= k; ++j)dp[i][j] = 0;
    	long long ans = 0;
    	for(int i = 1; i <= k; ++i){
    		for(int j = 1; j <= k; ++j){
    			for(int l = 1; l <= k; ++l){
    				int p1 = getgcd(i,j);
    				int t = getgcd(p1,l);
    				ans+=t;	
    			}
    		}
    	}
    	cout<<ans<<"\n";
    	return 0;
    }

Measured memory_bytes: 3800
from itertools import chain
import sys
def input(): return sys.stdin.readline().strip()

def main():
    d = {}
    n=int(input())
    for _ in range(n):
        s = input()
        d.setdefault(s, 0)
        d[s]+=1
    m=int(input())
    for _ in range(m):
        t = input()
        d.setdefault(t, 0)
        d[t]-=1
    print(max(chain([0], d.values())))

main()

Measured memory_bytes: 3064
s = int(input())

def f(n):
    if n % 2 == 0:
        return int(n/2)
    else:
        return int(3*n + 1)

m = 2
a = [s]
ai = f(s)
while 1:
    if ai in a:
        print(m)
        break
    a.append(ai)
    ai = f(ai)
    m += 1


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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    set<ll> prime;
    ll tn = n;
    while (tn % 2 == 0) {
        tn /= 2;
        prime.insert(2);
    }
    for (ll i = 3; i * i <= tn; i += 2) {
        while (tn % i == 0) {
            prime.insert(i);
            tn /= i;
        }
    }
    if (tn > 2) prime.insert(tn);
    ll ans = 0;
    for (ll p: prime) {
        int cnt = 0;
        while (n % p == 0) {
            n /= p;
            cnt++;
        }
        ll cur = 1;
        while (cur * (cur + 1) <= 2 * cnt) cur++;
        cur--;
        ans += cur;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<string.h>
#define MAX 1001

int psearch(char str[],int start){
 int i;
 char word[5];

 for(i=start;i<start+5;i++)
  word[i-start]=str[i];
 
 word[5]='\0';


 if(strcmp(word,"peach")==0)return 1;
 else return 0;

}

int asearch(char str[],int start){
 int i;
 char word[5];

 for(i=start;i<start+5;i++)
  word[i-start]=str[i];
 
 word[5]='\0';


 if(strcmp(word,"apple")==0)return 1;
 else return 0;

}



int main(){
 char str[MAX];
 int x,i;

 scanf("%[^\n]",str);
 x=strlen(str);

 for(i=0;i<x;i++){
  
   if(str[i]=='p'){
   
     if(psearch(str,i)){
         str[i]='a'; 
         str[i+1]='p';
         str[i+2]='p';
         str[i+3]='l';
         str[i+4]='e';
         i=i+5;
     }

   }else if(str[i]=='a'){

      if(asearch(str,i)){
         str[i]='p'; 
         str[i+1]='e';
         str[i+2]='a';
         str[i+3]='c';
         str[i+4]='h';
         i=i+5;
      }

   }

 }


 printf("%s\n",str);

return 0;
}


Measured memory_bytes: 2000
#include <iostream>
inline int ab(int a) {return a > 0 ? a : -a;}
int n, a[100005], pref[100005];
int main() {
	std::ios_base::sync_with_stdio(0);std::cin.tie(0);std::cin >> n;
	for (int i = 0;i < n;i++) std::cin >> a[i], pref[i] = (i ? pref[i - 1] : 0) + ab(a[i] - (i ? a[i - 1] : 0));
	pref[n] = ab(a[n - 1]) + pref[n - 1];
	for (int i = 0;i < n;i++) std::cout << (i ? pref[i - 1] : 0) + ab((i < n - 1 ? a[i + 1] : 0) - (i - 1 >= 0 ? a[i - 1] : 0)) + pref[n] - pref[i + 1] << "\n";
}

Measured memory_bytes: 4396
#include <stdio.h>
int main()
{
	int a;
	scanf("%d\n",&a);
	if(a%1==0&&a/1>=1&&a<=9){
		printf("Yes\n");}
		else if(a%2==0&&a/2>=1&&a/2<=9){
			printf("Yes\n");}	else if(a%3==0&&a/3>=1&&a/3<=9){
			printf("Yes\n");}	else if(a%4==0&&a/4>=1&&a/4<=9){
			printf("Yes\n");}	else if(a%5==0&&a/5>=1&&a/5<=9){
			printf("Yes\n");}	else if(a%6==0&&a/6>=1&&a/6<=9){
			printf("Yes\n");}	else if(a%7==0&&a/7>=1&&a/7<=9){
			printf("Yes\n");}	else if(a%8==0&&a/8>=1&&a/8<=9){
			printf("Yes\n");}	else if(a%9==0&&a/9>=1&&a/9<=9){
			printf("Yes\n");}else
			{printf("No\n");}
				return 0;
				}

Measured memory_bytes: 128
import java.util.*;

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

    int[][] array = new int[4][2];

    array[0][0] = sc.nextInt();
    array[0][1] = sc.nextInt();
    array[1][0] = sc.nextInt();
    array[1][1] = sc.nextInt();

    int[][] vec = new int[2][2];

    vec[0][0] = array[1][0] - array[0][0];
    vec[0][1] = array[1][1] - array[0][1];
    vec[1][0] = -vec[0][1];
    vec[1][1] = vec[0][0];

    array[2][0] = array[1][0] + vec[1][0];
    array[2][1] = array[1][1] + vec[1][1];
    array[3][0] = array[0][0] + vec[1][0];
    array[3][1] = array[0][1] + vec[1][1];


    String x_3 = String.valueOf(array[2][0]);
    String y_3 = String.valueOf(array[2][1]);
    String x_4 = String.valueOf(array[3][0]);
    String y_4 = String.valueOf(array[3][1]);

    System.out.println(x_3+" "+y_3+" "+x_4+" "+y_4);
  }
}

Measured memory_bytes: 23252
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;
typedef long long ll;

ll n, k, l = 20;
vector<ll> g[2100];
ll up[2100][25];
ll timer;
ll tin[2100];
ll tout[2100];
ll height[2100];
ll res = 1000000000;

bool upper(int a, int b) { return tin[a] <= tin[b] && tout[b] <= tout[a]; };

int lca(int a, int b) {
	if (upper(a, b))return a;
	if (upper(b, a))return b;
	for (int i = l; i >= 0; i--) {
		if (upper(up[a][i], b))continue;
		a = up[a][i];
	}
	return up[a][0];
}

int d(int a, int b) {
	int c = lca(a, b);
	return height[a] + height[b] - 2 * height[c];
}

void dfs(int v, int p, int lev) {
	tin[v] = ++timer;
	up[v][0] = p;
	height[v] = lev;
	for (int i = 1; i <= l; i++) {
		up[v][i] = up[up[v][i - 1]][i - 1];
	}
	for (auto to : g[v]) {
		if (to != p)dfs(to, v, lev + 1);
	}
	tout[v] = ++timer;
};

void dealnep() {
	k--;
	k /= 2;
	for (int from = 1; from <= n; from++) {
		for (auto to : g[from]) {
			if (to < from)continue;
			ll current = 0;
			for (int i = 1; i <= n; i++) {
				int temp = min(d(from, i), d(to, i));
				current += temp > k;
			}
			res = min(res, current);
		}
	}
}

void dealp() {
	k /= 2;
	for (int center = 1; center <= n; center++) {
		ll current = 0;
		for (int i = 1; i <= n; i++) {
			current += d(i, center) > k;
		}
		res = min(res, current);
	}
}

int main() {
	scanf("%lld %lld", &n, &k);
	for (int i = 0; i < n - 1; i++) {
		ll a, b; scanf("%lld %lld", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1, 1, 1);
	if (k % 2)dealnep();
	else dealp();
	cout << res;
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ull unsigned long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
#define lson o<<1
#define rson o<<1|1
const double E=exp(1);
const int maxn=1e6+10;
const int mod=1e9+7;
using namespace std;
char a[maxn],b[maxn],c[maxn];
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	scanf("%s %s %s",a,b,c);
	int la=strlen(a);
	int lb=strlen(b);
	// int lc=strlen(c);
	int flag=0;
	if(a[la-1]!=b[0])
		flag++;
	if(b[lb-1]!=c[0])
		flag++;
	if(flag)
		cout<<"NO"<<endl;
	else
		cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int N = cin.NextInt();
            int A = cin.NextInt();

            while (N >= 500) N -= 500;
            if (N - A <= 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}



Measured memory_bytes: 27508
from functools import reduce
import fractions
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
N = int(input().rstrip())
As = input().rstrip().split(" ")
As = [int(p) for p in As]
 
cand = lcm_list(As)
 
sum = 0
 
for num in As:
    sum = sum + cand // num
 
print(sum % (10**9 + 7))


Measured memory_bytes: 6080
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i, a, b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
 
using namespace std;
 
const int mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long int LINF = 1LL<<56;

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



int main(){
	
		
	string s, t; cin >> s >> t;
	
	int dp[s.size()+1][t.size()+1], mark[s.size()+1][t.size()+1];
	memset(dp, 0, sizeof dp); memset(mark, 0, sizeof mark);
	
	for(int i=s.size()-1; i>=0; i--){
		for(int j=t.size()-1; j>=0; j--){
			if(s[i]==t[j]) dp[i][j] = dp[i+1][j+1]+1, mark[i][j] = 1;
			else if(dp[i+1][j]>dp[i][j+1]) dp[i][j] = dp[i+1][j], mark[i][j] = 2;
			else dp[i][j] = dp[i][j+1], mark[i][j] = 3;
		}
	}
	
	//cout << dp[0][0] << '\n';
	
	string ans;
	int i = 0, j = 0;
	while(mark[i][j]){
		if(mark[i][j]==1){
			ans.pb(s[i]);
			i++, j++;
		}
		else if(mark[i][j]==2){
			i++;
		}else{
			j++;
		}
	}
	
	cout << ans << '\n';
	
	
	
	return 0;
}

Measured memory_bytes: 70656
#include <iostream>
using namespace std;
int num;

int main(void) {
    cin >> num;
    int array[num] = {};
    array[0] = 1;
    array[1] = 1;
    for (int i= 2; i <= num; i++) {
        array[i] = array[i - 1] + array[i - 2];
    }
    cout << array[num] << endl;
}




Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

struct edge {
    int from, to; ll cost;
    edge(int s, int t, ll w = 0) : from(s), to(t), cost(w) {}
};
int main() {
    init();

    int n;
    cin >> n;
    vector<VI> a(n, VI(n)), wh(n, VI(n, -1));
    FOR(i, 0, n)FOR(j, 0, n - 1) {
        cin >> a[i][j];
        wh[i][--a[i][j]] = j;
    }

    int v = n * (n - 1) / 2;
    vector<vector<edge>> g(v);
    map<pair<int, int>, int> map;
    int o = 0;
    FOR(i, 0, n)FOR(j, 0, n - 1) {
        int x = i, y = a[i][j];
        if (x > y)swap(x, y);
        if (map[{x, y}])continue;
        if ((i != 0 || j != 0) && (x == 0 && y == a[0][0]))continue;
        map[{x, y}] = o++;
    }
    FOR(i, 0, n)FOR(j, 0, n - 2) {
        int x = i, y = a[i][j], X = i, Y = a[i][j + 1];
        if (x > y)swap(x, y);
        if (X > Y)swap(X, Y);
        g[map[{ x, y }]].emplace_back(map[{ x, y }], map[{ X, Y }], 1);
    }
    
    VI ans, len(v, 0), in(v, 0);
    for (auto es : g)for (edge e : es)in[e.to]++;
    queue<int> que;
    FOR(i, 0, v)if (in[i] == 0) {
        que.push(i);
        len[i] = 1;
    }

    while (!que.empty()) {
        int now = que.front(); que.pop();
        ans.push_back(now);
        for (edge next : g[now]) {
            if (--in[next.to] == 0) {
                que.push(next.to);
                chmax(len[next.to], len[now] + 1);
            }
        }
    }

    if (v == ans.size()) {
        int mlen = 0;
        for (int i : len)chmax(mlen, i);
        cout << mlen << "\n";
    }
    else cout << "-1\n";
}


Measured memory_bytes: 82420
while true
    line = gets.chomp
    break if line == "#"
    g, y, m, d = line.split.map(&:to_i)
    if y <= 30 || (y == 31 && m <= 4)
        g = "HEISEI"
    else
        g = "?"
        y -= 30
    end
    puts "#{g} #{y} #{m} #{d}"
end


Measured memory_bytes: 6848
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#define IFD(...)
#ifndef NDEBUG
#define NDEBUG
#endif
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <boost/hana/functional/fix.hpp>
using boost::hana::fix;
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, b, a) for (int i = (b); i >= (a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;

    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;
class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String s = sc.next();
      	switch(s){
          case "A":
          case "B":
          case "C":
          case "D":
          case "E":
          case "F":
          case "G":
          case "H":
          case "I":
          case "J":
          case "K":
          case "L":
          case "M":
          case "N":
          case "O":
          case "P":
          case "Q":
          case "R":
          case "S":
          case "T":
          case "U":
          case "V":
          case "W":
          case "X":
          case "Y":
          case "Z":
            System.out.println("A");
            break;}
      	switch(s){
          case "a":
          case "b":
          case "c":
          case "d":
          case "e":
          case "f":
          case "g":
          case "h":
          case "i":
          case "j":
          case "k":
          case "l":
          case "m":
          case "n":
          case "o":
          case "p":
          case "q":
          case "r":
          case "s":
          case "t":
          case "u":
          case "v":
          case "w":
          case "x":
          case "y":
          case "z":
            System.out.println("a");
        
              
            
              
        }
    }
}

Measured memory_bytes: 26868
import java.util.*;
public class Main{
	public static void main(String[]args){
      Scanner scan=new Scanner(System.in);
    	int n=scan.nextInt();
		int flag=0;
		boolean done=false;
		while(n--!=0){
			int a=scan.nextInt();
			int b=scan.nextInt();
			if(a==b)flag++;
			if(flag==3){
				done=true;
			}
			if(a!=b)flag=0;
		}
		if(!done)
		System.out.println("No");
		else
		System.out.println("Yes");
    }	
  
}

Measured memory_bytes: 36024
//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;


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



int main() {
	int h, w;
	cin >> h >> w;
	char field[10][10];
	REP(i, h) {
		REP(j, w) {
			cin >> field[i][j];
		}
	}

	int px = 0, py = 0;
	while (px < w && py < h) {
		
		field[py][px] = '.';
		if (field[py][px - 1] == '#' || field[py - 1][px] == '#') {
			cout << "Impossible" << endl;
			return 0;
		}
		if (px == w - 1 && py == h - 1) {
			break;
		}
		if (field[py][px + 1] == '#' && field[py+1][px] == '#') {
			cout <<"Impossible" << endl;
			return 0;
		}
		else if (field[py][px + 1] == '#') {
			px++;
			//cout <<"px="<< px << endl;
		}
		else if (field[py+1][px] == '#') {
			py++;
			//cout << "py=" << py << endl;
		}
		else {
			cout << "Impossible" << endl;
			return 0;
		}
	}
	cout << "Possible" << endl;


	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int youbi(int a,int const c[]){
	int t=a-1;
	if(t==0) return 0;
	return c[t-1]+youbi(a-1,c);
}
int main(void)
{
	int n=50;
	while(n){
		int a,b,t;
		scanf("%d %d",&a,&b);
		if(a==0) break;
		int c[12]={31,29,31,30,31,30,31,31,30,31,30,31};
		t=(youbi(a,c)+b-1)%7;
		switch(t){
			case 0:
				puts("Thursday");
				break;
			case 1:
				puts("Friday");
				break;
			case 2:
				puts("Saturday");
				break;
			case 3:
				puts("Sunday");
				break;
			case 4:
				puts("Monday");
				break;
			case 5:
				puts("Tuesday");
				break;
			case 6:
				puts("Wednesday");
				break;
		}
		n--;
}
return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> M;
    rep(i,N) {
        cin >> A[i];
    }
    ll sum = 0;
    for (int i = N - 1; i >= 0; i--) {
        sum += M[i + 1 + A[i]];
        M[(i + 1) - A[i]]++;
    }
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 21036
#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)



int main() {
   string s;
   cin >> s;
   bool flag=true;
   for (int i = 0;i < s.size();i++){
       if(s[i]!=s[s.size()-1-i]) flag=false;
   }
   rep(i,(s.size()-1)/2){
       if(s[i]!=s[(s.size()-1)/2-1-i]) flag=false;
   }
   for (int i = (s.size()+3)/2-1;i<s.size();i++){
       if(s[i]!= s[s.size()-1-i]) flag=false;
   }
   if(flag) cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    vector<string>v_s;
    cin >> n;
    for(int i = n; i>0;i--){
        string tmp;
        cin >> tmp;
        v_s.push_back(tmp);
    }
    sort(v_s.begin(),v_s.end());
    int result = 0;
    for(int i = 0; i<v_s.size();i++){
        if(i==0){
            result++;
        }else{
            if(v_s[i].compare(v_s[i-1])!=0){
                result++;
            }
        }
    }
    cout << result << endl;
    #if 0
    cout << "n:" << n << endl;
    for(int i = 0; i < v_s.size(); i++){
        cout << "i:"<<i<<" "<<v_s[i]<<endl;
    }
    #endif
    return 0;
}

Measured memory_bytes: 11580
n, x, m = map(int, input().split())
lis = set()
loop_lis = []
cnt = 0
while x not in lis:
    cnt += 1
    lis.add(x)
    loop_lis.append(x)
    x = pow(x, 2) % m
    if cnt == n:
        print(sum(lis))
        exit()

start = loop_lis.index(x)
length = len(loop_lis) - start
loop_sum = sum(loop_lis[start:])
before = sum(loop_lis[:start])
loop = loop_sum * ((n - start) // length)
remain = sum(loop_lis[start : (start + (n - start) % length)])

print(before + loop + remain)


Measured memory_bytes: 13328
#include <iostream>

using namespace std;

int main(void){
  
  int num[] = {0,1,2,3,5,7,8,9};
  int n;
  long long a = 0;
  long long b = 1;
  
  while( cin >> n , n ){
    
    a = 0;
    b = 1;
    while(n){
      a += num[n % 8] * b;
      b *= 10;
      n /= 8;
    }
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
import math
a,b,x=map(int,input().split())

if (a*a*b/2<=x):
  if (a*a*b==x):
    print(0)
  else:
    theta=math.atan((a*a*a)/(2*(a*a*b-x)))
    print(90.0-theta*180.0/math.pi)
else:
  theta=math.atan(2*x/(a*b*b))
  print((math.pi/2-theta)*180.0/math.pi)

Measured memory_bytes: 9388
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll d,t,s;
    cin>>d>>t>>s;
    if(d%s==0){
        ll k=d/s;
        if(k<=t)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;
    }
    else{
        int k=d/s+1;
        if(k<=t)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;
    }
    return 0;
    
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n;
long a[200005];
long ans;

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define maxn 202333
#define LL long long
using namespace std;
int main() {
	long long n, d, c = 0;
	cin >> n >> d;
	for(int i = 1; i <= n; ++i) {
		long long x, y;
		cin >> x >> y;
		if(d * d >= x * x + y * y) ++c;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
 
//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//infinity
#define INTINF 2000000000
#define LONGINF 20000000000
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(){
	int a, b;
	cin >> a >> b;
	if(a+b==15){
		cout << '+' << endl;
	}else if(a*b==15){
		cout << '*' << endl;
	}else{
		cout << 'x' << endl;
	}
	return 0;
}


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

int main() {
	int x1 = 1000;
	int n, sum = 0;
	scanf("%d", &n);
	while(n--) {
		int x;
		scanf("%d", &x);
		if(x%10!=0) x1 = min(x1, x);
		sum += x;
	}
	if(sum%10!=0) printf("%d\n", sum);
	else printf("%d\n", x1==1000?0:(sum-x1));
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::io::*;
use std::cmp::*;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = AtRead::from(i);
    let n = i.read::<usize>();

    let mut ta_min = (1, 1);
    for _ in 0..n {
        let ta = i.read2::<usize, usize>();
        let s = max((ta_min.0 + ta.0 - 1) / ta.0, (ta_min.1 + ta.1 - 1) / ta.1);
        ta_min = (ta.0 * s, ta.1 * s);
    }
    writeln!(o, "{}", ta_min.0 + ta_min.1).unwrap();
}

mod utils {
    use super::*;

    pub struct AtRead<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                $(
                    let $v = next(i);
                )*
                ($($v),*)
            }
        };
    }

    impl<R: BufRead> AtRead<R> {
        pub fn from(r: R) -> Self {
            AtRead {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(v1: T1, v2: T2) }
    }

    fn next<'a, T: FromStr, I: std::iter::Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int maxn=200005;
typedef long long ll;
ll a[maxn];
map<ll,int>mp;
int main(){
	ll n;
	scanf("%d",&n);
	for(ll i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(i>=a[i]) mp[i-a[i]]++;
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ans+=mp[a[i]+i];
	}
	printf("%lld\n",ans);
}

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

int main() {
  string a; cin >> a;
  if((a[0]==a[1]&&a[1]==a[2]) || (a[1]==a[2]&&a[2]==a[3])) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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

int main() {
    int a,b;
    cin>>a>>b;
    if (a%3==0||b%3==0||(a+b)%3==0) {
        cout<<"Possible"<<endl;
    } else {
        cout<<"Impossible"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    
    vector <int> x(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    ll sum = 1e18;
    for (int i = 0; i < N - K + 1; i++) {
        ll tmp = x[i+K-1] - x[i];
        sum = min(sum, min(tmp+abs(x[i+K-1]),tmp+abs(x[i])));
        //cout << sum << endl;
    }
    cout << sum << endl;

    
    return 0;
}

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


int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }
typedef pair<int,int> P;
int N;

int main(void) {
    cin>>N;

    vector<vector<int>> A(N, vector<int>(N-1));
    for(int i = 0;i < N;i++) {
        for(int j = 0;j < N-1;j++) {
            cin>>A[i][j];
            A[i][j]--;
        }

        reverse(A[i].begin(),A[i].end());
    }

    vector<P> q;
    auto check = [&](int i) {
        if(A[i].size() == 0)
            return;
        int j = A[i].back();
        if(A[j].size() == 0)
            return;
        if(A[j].back() == i) {
            if(i > j)
                swap(i,j);
            P p(i, j);
            q.push_back(p);
        }
    };

    for(int i = 0;i < N;i++) {
        check(i);
    }

    int ans = 0;
    while(q.size()) {
        ans++;
        sort(q.begin(),q.end());
        q.erase(unique(q.begin(),q.end()),q.end());
        vector<P> Q;
        swap(Q, q);
        for(auto u: Q) {
            int i = u.first;
            int j = u.second;
            A[i].pop_back();
            A[j].pop_back();

            check(i);
            check(j);
        }
    }

    for(int i = 0;i < N;i++) {
        if(A[i].size() != 0) {
            cout<<-1<<endl;

            return 0;
        }
    }

    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 4224
import collections

a, b, c = map(int, input().split())

def prime_factorize(n):
    arr = []
    while n % 2 == 0:
        arr.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            arr.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        arr.append(n)
    return arr
    
aa = collections.Counter(prime_factorize(a))
bb = collections.Counter(prime_factorize(b))

gcm = 1

if aa != []:
    for i in aa.keys():
        if i in bb.keys():
            gcm *= i ** (min([aa[i], bb[i]]))

if c % gcm == 0:
    print("YES")

else:
    print("NO")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int conbi[4001][4001];
void conbimemo(int n,int r){ //動的計画法での組み合わせ
    int i,j;
    for(i=0;i<=n;i++){
        conbi[i][0] = 1;
        
    }
    for(j=1;j<=n;j++){
    conbi[j][1] = j;
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=r;j++){
            conbi[i][j] = conbi[i-1][j-1] + conbi[i-1][j];
        }
    }
    //return conbi[n][r];
}
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    map<char,int64_t> p;
    rep(i,n){
        p[s[i]]++;
    }
    int64_t f=p['G']*p['B']*p['R'];
    for(int p=1;p<=n/2+1;p++){
        rep(i,n){
            if(i+2*p>=n){
                break;
            }
            if(s[i]!=s[i+p] && s[i]!=s[i+2*p] && s[i+p]!=s[i+2*p]){
                f--;
            }
        }
    }
    //cout<<p['G']<<" "<<p['B']<<" "<<p['R']<<endl;
    //cout<<p['G']*p['B']*p['R']<<endl;
    cout<<f<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
long long n,a,b;
int main(){
	std::cin>>n>>a>>b;
	if(a>b)std::swap(a,b);
	long long ans=LLONG_MAX;
	if((b-a)%2==0)ans=std::min(ans,b-a>>1);
	ans=std::min(ans,b-1);
	ans=std::min(ans,n-a);
	if((b-a)%2==1){
		ans=std::min(ans,a+(b-a-1>>1));
		ans=std::min(ans,n-b+1+(-a+b-1>>1));
	}
	std::cout<<ans<<std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    Int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    vector<int> color(N);
    bool stop = false;
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    function<void(int, int)> recur = [&](int node, int c) {
        if (color[node] == c) return;
        if (color[node] == -c) stop = true;
        if (stop) return;
        color[node] = c;
        for (auto next : G[node]) recur(next, -c);
    };
    recur(0, +1);
    if (stop) {
        cout << N * (N-1) / 2 - M << endl;
    } else {
        int a = 0;
        for (auto c : color) if (c == +1) a++;
        cout << a * (N - a) - M << endl;
    }
    return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    rep(i, k)
    {
        vector<int> b(n);
        rep(j, n)
        {
            int l, r; //範囲
            l = max(0, j - a[j]);
            r = min(n - 1, j + a[j]);
            b[l]++;
            if (r + 1 < n)
                b[r + 1]--;
        }
        rep(j, n - 1) b[j + 1] += b[j];
        if (a == b)
            break;
        a = b;
    }
    rep(i, n) cout << a[i] << " ";
    cout << endl;
}

Measured memory_bytes: 4816
#include<bits/stdc++.h>
using namespace std;
const int maxn=110;
int a[maxn];
int main()
{
	int n,temp,num=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n-1;i++)
	{
		int min=a[i];
		int mark=i;
		for(int j=i+1;j<=n;j++)
		{
			if(min>a[j])
			{
				mark=j;
				min=a[j];
			}
		} 
		if(mark!=i)
		{
			swap(a[mark],a[i]);
			num++;
		}
	}
	cout<<a[1];
	for(int i=2;i<=n;i++)
	{
			cout<<" "<<a[i];
	}
	cout<<endl;
	cout<<num<<endl;
	return 0;
}


Measured memory_bytes: 3092
import itertools


X = int(input())
ans_A = 0
ans_B = 0
for i, j in itertools.combinations(range(-120, 120), 2):
    j *= -1
    if i**5 - j**5 == X:
        ans_A = i
        ans_B = j
        break
print(ans_A, ans_B)


Measured memory_bytes: 84116
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
// ll p;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	int p;
	cin>>p;
	mod = p;
	string s;
	cin>>s;
	vector<ll> v(n);
	vector<ll> po(n);
	po[0] = 1;
	repa(i,1,n){
		po[i] = po[i-1]*10;
		po[i] %= p;
	}
	rep(i,n){
		v[i] = s[i] - '0';
		v[i] %= p;
	}	
	if(p == 2 || p == 5){
		ll res = 0;
		rep(i,n){
			if(v[i] == 0){
				res += (i+1);
			}
		}
		cout<<res;
		return 0;
	}

	// vector<ll> ans(n);
	// rep(i,n){
	// 	ans[i] = v[i]*po[n-i-1];
	// 	ans[i] %= p;
	// }
	// vi sum1(p,0);
	// sum1[0] = 1;
	// ll s1=0;
	// rep(i,n){
	// 	s1 += ans[i];
	// 	s1 %= p;
	// 	sum1[s1]++;
	// }
	// ll res = 0;
	// rep(i,p){
	// 	res += sum1[i]*(sum1[i]-1)/2;
	// }
	// cout<<res;
	vector<ll> c(p,0);
	c[0] = 1;
	ll cur = 0;
	rep(i,n){
		cur *= 10; cur += s[i]-'0';cur %= p;
		// cout<<mod;
		ll va = fastexp(10,n-i-1)*cur;va %= p;
		c[va]++;
	}
	ll res = 0;
	// rep(i,n){
	// 	cout<<
	// }
	rep(i,p){
		res += c[i]*(c[i]-1)/2;
	}
	cout<<res;
	return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        call(Integer.parseInt(line));

    }
    static void call(int n) {
        for(int i=1;i <= n;i++) {
            int x = i;
            if(x % 3 == 0){
                System.out.print(" " + i);
                continue;
                
            }
            while(true) {
                if(x % 10 == 3) {
                    System.out.print(" " + i);
                    break;
                }
                x = x / 10;
                if(x != 0) {
                    continue;
                }else {
                    break;
                }
            }
        }
        System.out.println();

    }
}

Measured memory_bytes: 22012
#include<iostream>
#include<string.h>
#define MAX_NUMBER 2000000

struct Data{
    int num;
    int next;
    int before;
};

Data data[MAX_NUMBER];
int head = -1,tail = -1,cp = 0;

void insert(int x){
    data[cp].num = x;
    data[cp].next = head;
    data[cp].before = -1;
    if(head!=-1){
        data[head].before = cp;
    }else{
        tail = cp;
    }
    head = cp++;
}

void delete1(int x){
    int p=head;
    if(data[p].num==x){
        head = data[p].next;
        data[data[p].next].before =-1;
    }else{
        while(p!=-1){
            int tmp=data[p].next;
            if(tmp==tail && data[tmp].num==x){
                data[p].next = -1;
                tail = p;
            }else if(data[tmp].num==x){
                data[p].next = data[tmp].next;
                data[data[tmp].next].before = p;
                return;
            }
            p = data[p].next;
        }
    }
}
            

void deleteFirst(){
    int tmp=data[head].next;
    if(tmp==-1){
        head=-1;
        tail=-1;
    }else{
        data[tmp].before = -1;
        head = tmp ;
    }
}

void deleteLast(){
    int tmp = data[tail].before;
    if(tmp==-1){
        head = -1;
        tail = -1;
    }else{
        data[tmp].next = -1;
        tail = tmp;
    }
}

int main(){
    int n,x;
    char command[20];
    std::cin >> n;
    for(int i=0;i<n;i++){
        std::cin >> command ;
        if(strcmp(command,"insert")==0){
            std::cin >> x;
            insert(x);
        }else if(strcmp(command,"delete")==0){
            std::cin >> x;
            delete1(x);
        }else if(strcmp(command,"deleteFirst")==0){
            deleteFirst();
        }else if(strcmp(command,"deleteLast")==0){
            deleteLast();
        }
    }
    int p = head;
    if(p!=-1){
        std::cout << data[p].num ;
    }
    p = data[p].next;
    while(p!=-1){
        std::cout << ' ' << data[p].num ;
        p = data[p].next;
    }
    std::cout << '\n';
    return 0;
}




Measured memory_bytes: 15892
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
using namespace std;
signed main(){
    int n; cin >> n;
    vector<vector<int>>edge(n);
    rep(i,n-1){
        int s,t; cin >> s >> t;
        edge[--s].push_back(--t);
        edge[t].push_back(s);
    }
    vector<bool>visit(n,false);
    vector<bool>ispath(n,false);
    function<bool(int)> dfs = [&](int v){
        visit[v] = true;
        bool flag = (v == n-1);
        for(auto nv : edge[v]){
            if(visit[nv])continue;
            if(dfs(nv))flag = true;
        }
        return ispath[v] = flag;
    };
    dfs(0);
    // all vertex was checked.
    int margin = accumulate(all(ispath),0LL) - 2;
    margin = margin / 2 + margin % 2;
    vector<int>grid(n,-1);
    function<int(int,int)>cntup = [&](int v, int atrb){
        int res = 1;
        grid[v] = atrb;
        for(auto nv : edge[v]){
            if(grid[nv] != -1)continue;
            if(ispath[nv] == false or atrb == 1) res += cntup(nv,atrb);
            else if(ispath[nv] and margin > 0 )--margin,res += cntup(nv,atrb);
        }
        return res;
    };
    int f = cntup(0,0), s = cntup(n-1,1);
    assert(f + s == n);
    cout << (f > s ? "Fennec" : "Snuke") << endl;
}





Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int pt[1234], n, m, a, b, d;
vector<pair<int, pair<int, int>>>v;
void f() {
	for0(i, n)pt[i] = i;
	return;
}
int root(int i) {
	if (pt[i] == i)return i;
	else return pt[i] = root(pt[i]);
}
void unite(int a, int b) {
	pt[root(b)] = root(a);
	root(b);
	return;
}
void input() {
	string s; cin >> s;
	int p = 0; bool b00l = 0;
	for (char ch : s) {
		if (ch == ',') {
			if (b00l)b = p; else a = p;
			p = 0; b00l = 1;
		}
		else { p *= 10; p += ch - '0'; }
	}
	d = p;
	v.push_back(mp(d / 100 - 1, mp(a, b)));
}
signed main() {
	while (cin >> n, n) {
		int ans = 0;
		cin >> m;
		v.clear(); f();
		for0(i, m)input(); sort(all(v));
		for (pair<int, pair<int, int>>p : v) {
			a = p.second.first;
			b = p.second.second;
			if (root(a) != root(b)) {
				unite(a, b);
				ans += p.first;
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3224
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;


int main() {

	int h, w; cin >> h >> w;

	vector<vector<int>> c(10, vector<int>(10, 0));

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}

	for (int x = 0; x < 3; x++) {
		for (int i = 0; i < 10; i++) {//なんとかフロイド法だっけ？
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) {
					if (c[i][k] > c[i][j] + c[j][k]) {
						c[i][k] = c[i][j] + c[j][k];
					}
				}
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int x; cin >> x;
			if (x == -1) {

			}
			else {
				ans += c[x][1];
			}
		}
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	double a[n],sum=0.0;
	for(int i=0;i<n;i++){
		scanf("%lf",&a[i]);
		sum+=1.0/a[i];
	}
	printf("%.18lf\n",1.0/(sum));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	string s;
	cin >> s;
	int ans=0;
	for(int i=0; i<4; i++){
		if(s[i]=='+') ans++;
		else ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool used[111][111];
int dp[111][111];
int n;
int a[111];
int dfs(int l,int r){
  if(used[l][r]) return dp[l][r];
  if(l+1==r) return 0;
  used[l][r]=1;
  int res=0;
  for(int i=1;(l+i)%n!=r;i++){
    int m=(l+i)%n;
    res=max(res,dfs(l,m)+dfs(m,r)+abs(a[l]-a[m]));
  }
  //cout<<l<<" "<<r<<":"<<res<<endl;
  return dp[l][r]=res;
}
signed main(){
  int T;
  cin>>T;
  while(T--){
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    memset(used,0,sizeof(used));
    memset(dp,0,sizeof(dp));
    int ans=0;
    for(int i=0;i<n;i++) ans=max(ans,dfs(i,i));
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3208
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

template <std::uint_fast64_t Modulus>
class modint {
  using u64 = std::uint_fast64_t;

 public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept
      : a(x % Modulus) {
  }
  constexpr u64 &value() noexcept {
    return a;
  }
  constexpr const u64 &value() const noexcept {
    return a;
  }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(const modint rhs) noexcept {
    return *this *= ~rhs;
  }
  constexpr modint operator^(u64 exp) const noexcept {
    modint v = 1, x = *this;
    while (exp) {
      if (exp & 1) {
        v *= x;
      }
      x *= x;
      exp >>= 1;
    }
    return v;
  }
  constexpr modint operator~() const noexcept {
    return *this ^ (Modulus - 2);
  }
};

using mint = modint<1000000007>;

const int BITS = 62;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<ll> A(N);
    for (auto &x : A) cin >> x;
    vector<int> ones(BITS, 0);
    for (ll x : A) {
      for (int b = 0; b < BITS; b++) ones[b] += (x >> b) & 1;
    }
    mint res = 0;
    for (ll x : A) {
      for (int b = 0; b < BITS; b++) {
        int cnt[] = {N - ones[b], ones[b]};
        int p = (x >> b) & 1;
        res += (mint(2) ^ b) * cnt[p ^ 1];
      }
    }
    res /= 2;
    cout << res.value() << endl;
  }
  return 0;
}


Measured memory_bytes: 2560