akhauriyash/Code-Regression huggingface dataset:
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;

LL s[101010];

int main(){
    cin >> n;
    REP(i, n)cin >> s[i];
    
    LL ans = 0;
    for(int c = 1;c <= n - 1;c++){
        if((n - 1) % c == 0){
            LL tmp = 0;
            LL cur = 0;
            int i = 0, j = n - 1;
            for(;i < j;i += c, j -= c){
                cur += s[i] + s[j];
                tmp = max(tmp, cur);
            }
            ans = max(ans, tmp);
        }else{
            LL tmp = 0;
            LL cur = 0;
            int i = 0, j = n - 1;
            for(;i < n - 1 && j > c;i += c, j -= c){
                cur += s[i] + s[j];
                tmp = max(tmp, cur);
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque

def prime_factorization(x):
    """素因数分解"""
    import math
    re = []
    i = 2
    while x != 1:
        if x % i == 0:
            re.append(i)
            x //= i
        else:
            i += 1
            if i > math.sqrt(x):
                re.append(x)
                break
    return re


# from decorator import stop_watch
#
#
# @stop_watch
def solve(N):
    pf = []
    for i in range(1, N + 1):
        pf += prime_factorization(i)
    pf_nums = [0] * (N + 1)
    for p in pf:
        pf_nums[p] += 1

    def num(m):
        return len([i for i in pf_nums if i >= m - 1])

    ans = num(75) + \
          num(25) * (num(3) - 1) + \
          num(15) * (num(5) - 1) + \
          num(5) * (num(5) - 1) * (num(3) - 2) // 2

    print(ans)


if __name__ == '__main__':
    N = int(input())
    solve(N)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


Measured memory_bytes: 9248
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
 
int n;
vector < pair < int , int > > E[100005];
int color[100005];
 
void dfs( int u, int par, int c ){
	color[u] = c;
  	for ( pair < int , int > e : E[u] ){
    	if ( e.first == par ) continue;
      	int v = e.first;
     	if ( e.second & 1 ) dfs(v,u,c^1);
      	else dfs(v,u,c);
    }
}
 
int main(){
  scanf("%d",&n);
  for ( int i = 0; i < n-1; i++ ){
  	int u,v,z;
    scanf("%d%d%d",&u,&v,&z);
    E[u].push_back(make_pair(v,z));
    E[v].push_back(make_pair(u,z));
  }
  
  dfs(1,-1,0);
  for ( int i = 1; i <= n; i++ ) printf("%d\n",color[i]);
  return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
int main(){
    int n, k, h[100000], ans = 1000000000;
    cin >> n >> k;
    rep(i,n) cin >> h[i];
    sort(h, h + n);
    rep(i, n - k + 1){
        ans = min(ans, h[i + k - 1] - h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
input()
p = [int(i) for i in input().split(' ')]
cnt = 0
for i in range(1, len(p) - 1):
    if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]):
        cnt += 1

print(cnt)


Measured memory_bytes: 3060
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    a, v = LI()
    b, w = LI()
    t = II()
    if (v - w) * t >= abs(a - b):
        print("YES")
    else:
        print("NO")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 76748
import java.util.Scanner;

public class Main {
	static int n,m;
	static int count;
	static char[][]maze = new char[105][105];
	static boolean[][]vis = new boolean[105][105];
	static int dir[][] = {{0,1},{0,-1},{1,-1},{1,1},{1,0},{-1,0},{-1,-1},{-1,1}};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt(); m = sc.nextInt();
		for(int i = 0;i<n;i++) {
			maze[i] = sc.next().toCharArray();
		}
		for(int i = 0;i<n;i++) {
			for(int j = 0;j<m;j++) {
				count = 0;
				if(maze[i][j]=='#') {
					continue;
				}else {
					dfs(i,j);
					maze[i][j] = Integer.toString(count).charAt(0);
				}
			}
		}
		for(int i = 0;i<n;i++) {
			System.out.println(maze[i]);
		}
	}
	public static void dfs(int x,int y) {
		for(int i = 0;i<8;i++) {
			int tx = x + dir[i][0];
			int ty = y + dir[i][1];
			if(in(tx,ty)&&maze[tx][ty]=='#') {
				count++;
			}
		}
	}
	public static boolean in(int x,int y) {
		return 0<=x && x<n && 0<=y && y<m;
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    string  a,b,c;
    cin >> a >> b >> c;
    cout << ( a[a.size()-1]==b[0]&&b[b.size()-1]==c[0] ? "YES" : "NO" ) << endl;
}


Measured memory_bytes: 256
while (1):
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        exit()
    else:
        tile = str()
        for i in range(w):
            tile += '#'
        tile += '\n'

        for i in range(h-2):
            tile += '#'
            for ii in range(w-2):
                tile += '.'
            tile += '#\n'

        for i in range(w):
            tile += '#'
        tile += '\n'
        print(tile)



Measured memory_bytes: 5628
def prime(p):
    memo = set()
    for i in range(2,(int(p**0.5)+1)):
        while p%i==0:
            p //= i
            memo.add(i)
    if p != 1:
        memo.add(p)
    return memo

from math import gcd

N = int(input())

A = list(map(int,input().split()))

tmp_gcd = A[0]

for i in range(1,N):
    tmp_gcd = gcd(tmp_gcd, A[i])

if 1 < tmp_gcd:
    print('not coprime')
    exit()

servive_prime = set()
for a in A:
    now_prime = prime(a)
    ls,ln = len(servive_prime), len(now_prime)
    servive_prime.update(now_prime)
    if len(servive_prime) < ls + ln:
        print('setwise coprime')
        exit()
print('pairwise coprime')
    

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

int main(void){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(i%2==1) continue;
        if(a%2==1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(key=lambda x: -x)
q.sort(key=lambda x: -x)

p = p[:x]
q = q[:y]

r.extend(p)
r.extend(q)
r.sort(key=lambda x: -x)
print(sum(r[:x+y]))


Measured memory_bytes: 30808
using System;

namespace ALDS1_1_D_nextAnswer
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Int32.Parse(Console.ReadLine());
            var array = new int[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = Int32.Parse(Console.ReadLine());
            }

            var max = Int32.MinValue;
            var min = array[0];
            for (int i = 1; i < n; i++)
            {
                max = Math.Max(max,array[i]-min);
                min = Math.Min(min, array[i]);
            }

            Console.WriteLine("{0}", max);
        }
    }
}

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

int main(){
    int n, T;
    cin >> n >> T;
    int ans = 100010;
    for(int i = 0; i < n; ++i){
        int c, t;
        cin >> c >> t;
        if(t <= T){
            if(c < ans) ans = c;
        }
    }
    if(ans != 100010) cout << ans << endl;
    else cout << "TLE" << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
// end of Template

int x,y,z,ans;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>x>>y>>z;
    ans = (x)/(y+z);
    if( (x % (y+z)) < z ) ans--;
    ans = max(ans,0);

    cout<<ans<<newl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std ;

int main(void){
    int s=0;
    int N, K, n, a[100000];

    cin >> N >> K;

    for(int i=0; i<N; i++)
        cin >> a[i];

    // if(N <= K) cout << 1 << endl;
    // else if(K == 2) cout << N - 1 << endl;
    // else if(N % K != 0) cout << N / (K-1)<< endl;
    // else cout << N / (K-1) - 1 << endl;
   
    if(K == 2) cout << N - 1 << endl;
    else if(N % (K-1) > 1) cout << N / (K-1) + 1 << endl;
    else cout << N / (K-1) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;

int main()
{
	int N, D, x;
	cin >> N >> D >> x;
	vector<int> A(N);
	rep(i, N)
	{
		cin >> A[i];
	}
	int sum = 0;
	rep(i, N)
	{
		int j = 1;
		while(1)
		{
			sum++;
			j += A[i];
			if (j > D)
			{
				break;
			}
		}
	}
	cout << sum + x << endl;
	return 0;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main() {

	int N;
	pair<string, int> p[100], orig[100];
	cin >> N;
	rep(i, N) {
		cin >> p[i].first >> p[i].second;
		p[i].second *= -1;
	}
	rep(i, N) orig[i] = p[i];
	sort(p, p + N);

	rep(i, N) {
		rep(j, N) {
			if (p[i] == orig[j]) {
				cout << j + 1 << endl;
				break;
			}
		}
	}


	return 0;
}


Measured memory_bytes: 256
//Keep Working Hard
  // I__Like__Food  

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define tracel5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)


int32_t main()
{



    IOS

  	string s;
  	cin >> s;

  	int j = 0;
  	int ans = 0;

  	for(int i = 0; i < s.length(); i++)
  	{
  		if(s[i] == 'W')
  		{
  			ans += i-j;
  			j++;
  		}
  	}



  	cout << ans << endl;
  	





    return 0;
}




Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define For(i, s, e) for(int i = s;i <= e;i++)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n) {
        cin >> a[i];
    }
    int num = 0;
    rep(i,n) {
        num ^= a[i];
    }
    if(num)cN
    else cY
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    DPeopleonaLine solver = new DPeopleonaLine();
    solver.solve(1, in, out);
    out.close();
  }

  static class DPeopleonaLine {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      boolean f = true;
      int n = in.nextInt();
      int m = in.nextInt();
      PotentialUnionFind puf = new PotentialUnionFind();
      puf.init(n);
      for (int i = 0; i < m; i++) {
        int l = in.nextInt() - 1;
        int r = in.nextInt() - 1;
        long dis = in.nextLong();
        if (puf.find(l, r)) {
          // out.println(i + ": find true");
          // out.println("dif(l, r):" + puf.dif(l, r));
          if (puf.dif(l, r) != dis) {
            f = false;
          }
        } else {
          // out.println(i + ": find false");
          puf.union(l, r, dis);
        }
        // out.println(f);
      /*
      for (int j = 0; j < n; j++) {
        out.println(j + "th weight: " + puf.potential(j));
      }
      */
      }

      out.println(f ? "Yes" : "No");
    }

  }

  static class UnionFind {

    int[] par;
    int[] rank;

    int root(int x) {
      if (par[x] == x) {
        return x;
      } else {
        par[x] = root(par[x]); // 経路を圧縮しておく.
        return par[x];
      }
    }

    boolean find(int x, int y) {
      return root(x) == root(y);
    }

  }

  static class PotentialUnionFind extends UnionFind {

    long[] pot;

    void init(int n) {
      par = new int[n];
      rank = new int[n];
      pot = new long[n];
      for (int i = 0; i < n; i++) {
        par[i] = i; // はじめは全員が根である
        rank[i] = 0;
        pot[i] = 0;
      }
    }

    int root(int x) {
      if (par[x] == x) {
        return x;
      } else {
        int r = root(par[x]);
        pot[x] += pot[par[x]];
        par[x] = r;
        return par[x];
      }
    }

    void union(int x, int y, long w) {
      w = w + potential(x) - potential(y);
      int rx = root(x);
      int ry = root(y);
      if (rx == ry) {
        return;
      }
      if (rank[rx] < rank[ry]) {
        int tmp = rx;
        rx = ry;
        ry = tmp;
        w = -w;
      }
      if (rank[rx] == rank[ry]) {
        rank[rx]++;
      }
      par[ry] = rx;
      pot[ry] = w;
    }

    long potential(int x) {
      root(x);
      return pot[x];
    }

    long dif(int x, int y) {
      return potential(y) - potential(x);
    }

  }
}



Measured memory_bytes: 154740
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
	map<int,vvi> mp;
	rep(i,1,5){
		vvi vec(3,vi(10));
		mp[i]=vec;
	}
	int n; cin>>n;
	rep(i,0,n){
		int a,b,c,d; cin>>a>>b>>c>>d;
		--b; --c;
		mp[a][b][c]+=d;
	}
	rep(i,1,5){
		rep(j,0,3){
			rep(k,0,10){
				cout<<" "<<mp[i][j][k];
			}
			cout<<endl;
		}
		if(i!=4)cout<<"####################"<<endl;
	}


	return 0;
}


Measured memory_bytes: 3172
#include <iostream>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;

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

    float A[N];
    float sum = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum += A[i];
    }

    int cnt = 0;
    for(int i=0; i<N; i++){
        if(A[i] >= (float)1*sum/4/M) cnt++;
    }

    if(cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

int main(){
    int a,b,ans=0;
    cin>>a>>b;
    for(int i=0;i<2;i++){
        if(a>b){
            ans+=a;
            a--;
        }
        else{
            ans+=b;
            b--;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep2(i,m,n) for(int i=int(m);i<int(n);i++)
#define drep2(i,m,n) for(int i=int(m-1);i>=int(n);i--)
#define rep(i,n) rep2(i,0,n)
#define drep (i,n) drep2(i,n,0)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int MOD = int(1e9)+7;


int main()
{
    ll n;cin >>n;
    ll a[n];rep(i,n)cin >>a[i];
    ll k=n/2;
    ll ans;
    if(n%2==0){
        ll dp[k+1][2];rep(i,k+1)rep(j,2)dp[i][j]=0;
        rep(i,k){
            dp[i+1][1]=max(dp[i][1]+a[2*i+1],dp[i][0]+a[2*i+1]);
            dp[i+1][0]=dp[i][0]+a[2*i];
        }
        ans=max(dp[k][0],dp[k][1]);
    }
    else {
         ll dp[k+1][3];rep(i,k+1)rep(j,3)dp[i][j]=0;
        rep(i,k){
            dp[i+1][2]=max(max(dp[i][1]+a[2*i+2],dp[i][0]+a[2*i+2]),dp[i][2]+a[2*i+2]);
            dp[i+1][1]=max(dp[i][1]+a[2*i+1],dp[i][0]+a[2*i+1]);
            dp[i+1][0]=dp[i][0]+a[2*i];
        }
        ans=max(max(dp[k][0],dp[k][1]),dp[k][2]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7536
// https://atcoder.jp/contests/abc144/tasks/abc144_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

// 約数列挙
vector<int> divisor(int n) {
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(ALL(ret));
    return ret;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    auto t = divisor(n);
    int x = t[t.size() / 2];
    cout << x + (n / x) - 2 << endl;

    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  } else if (A + B < C + D) {
    cout << "Right" << endl;
  } else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define MAXN 100010
#define LL long long

const LL P=1000000007;

int n;
LL L1,L2,d[MAXN];
int pre1[MAXN],pre2[MAXN];
LL f1[MAXN],sf1[MAXN],f2[MAXN],sf2[MAXN];

void pre_gao(){
	pre1[1]=pre2[1]=1;
	pre1[n]=pre2[n]=n;
	for(int i=2;i<n;i++){
		int temp=pre1[i-1];
		while(temp<i && d[i+1]-d[temp]>=L2) temp++;
		pre1[i]=temp;
	}
	for(int i=2;i<n;i++){
		int temp=pre2[i-1];
		while(temp<i && d[i+1]-d[temp]>=L1) temp++;
		pre2[i]=temp;
	}
}

void gao(){
	f1[0]=sf1[0]=f2[0]=sf2[0]=1;
	int lim1=1,lim2=1;
	for(int i=1;i<=n;i++){
		if(i>1 && d[i]-d[i-1]<L1) lim1=i;
		if(i>1 && d[i]-d[i-1]<L2) lim2=i;
		if(lim1<=pre1[i])
			f1[i]=(sf2[pre1[i]-1]-(lim1>1?sf2[lim1-2]:0)+P)%P;
		if(lim2<=pre2[i])
			f2[i]=(sf1[pre2[i]-1]-(lim2>1?sf1[lim2-2]:0)+P)%P;
		sf1[i]=(sf1[i-1]+f1[i])%P;
		sf2[i]=(sf2[i-1]+f2[i])%P;
	}
}

int main(){
#ifdef DEBUG
	freopen("C.in","r",stdin);
#endif
	scanf("%d%lld%lld",&n,&L1,&L2);
	for(int i=1;i<=n;i++) scanf("%lld",d+i);
	pre_gao();
	gao();
	printf("%lld\n",(f1[n]+f2[n])%P);
	return 0;
}


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

int main()
{
	int i, j, H, W;
	char s[52][52] = {};
	scanf("%d %d", &H, &W);
	for (i = 1; i <= H; i++) scanf("%s", &(s[i][1]));
	
	int flag = 1;
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			if (s[i][j] == '#' && s[i-1][j] != '#' && s[i+1][j] != '#' && s[i][j-1] != '#' && s[i][j+1] != '#') flag = 0;
		}
	}
	
	if (flag == 1) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf 1000000000000000000

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

#define N 10000000
int p[N+1];

void eratosthenes(void){
    int i,j;
    for(i=2;i<N;i++)
        p[i]=1;
    for(i=2;i*i<N;i++){
        if(p[i]){
            for(j=2*i;j<=N;j=j+i){
                p[j]=0;
            }
        }
    }
}

void run(){
    int n;
    cin>>n;
    if(n<=2){
        cout<<0<<endl;
        return;
    }
    eratosthenes();
    int ans=0;
    REP(i,3,n){
        if(p[i+2]&&p[i])ans++;
    }
    cout<<ans*2<<endl;
}


Measured memory_bytes: 81288
#include <bits/stdc++.h>
#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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 Yes (bool condition) { if(condition) { cout << "Yes" << endl; } else { cout << "No" << endl;} }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int x;
	cin>>x;
	int ret=0;
	ret+=x/500*1000;
	x-=500*(x/500);
	ret+=x/5*5;
	cout<<ret<<endl;
}

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

using namespace std;

int n;
pair <int, int> a[25];
int res;

void solve(int id, int v, int c) {
	if (id == n) {
		res = max(res, v - c);
		return;
	}
	
	solve(id + 1, v, c);
	solve(id + 1, v + a[id].first, c + a[id].second);
}

int main() {
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) scanf("%d", &a[i].first);
	for (int i = 0; i < n; i++) scanf("%d", &a[i].second);
	
	solve(0, 0, 0);
	
	printf("%d\n", res);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
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; }
const long long MOD = 1000000007;
const long long INF = (1LL << 60);
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	string a = s;
	int ans = 0;
	for (int i = 1; i < s.size(); i++) {
		if (s.at(i - 1) == s.at(i)) {
			ans++;
			if (s.at(i - 1) == '0') {
				s.at(i) = '1';
			}
			else {
				s.at(i) = '0';
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int x; cin >> x;
    if(x==7 || x == 5 | x == 3){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))

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

double x[300], y[300];
int n;

int count(double x0, double y0, int p, int q){
	int ret = 2;
	REP(i,n){
		if(i==p||i==q)continue;
		double dx = x0-x[i];
		double dy = y0-y[i];
		if(pow(dx, 2.0)+pow(dy, 2.0)<1.0)ret++;
	}
	return ret;
}

int main(){
	while(1){
		int ret = 1;
		cin>>n;
		if(n==0)break;
		REP(i,n)scanf("%lf %lf", &x[i],&y[i]);
		REP(i,n){
			FOR(j, i+1,n){
				double dx = x[j]-x[i];
				double dy = y[j]-y[i];
				double d = sqrt(pow(dx, 2.0)+pow(dy, 2.0));
				if(d < 2.0){
					double mx = (x[j]+x[i])*0.5;
					double my = (y[j]+y[i])*0.5;
					{
						double x1 = mx-dy/d*sqrt(1.0-d*d/4.0);
						double y1 = my+dx/d*sqrt(1.0-d*d/4.0);
						ret = max(ret, count(x1, y1, i, j));
					}
					{
						double x1 = mx+dy/d*sqrt(1.0-d*d/4.0);
						double y1 = my-dx/d*sqrt(1.0-d*d/4.0);
						ret = max(ret, count(x1, y1, i, j));
					}
				}
			}
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int [] [] [] buidings = new int[4][3][10];
        for(int b = 0; b < 4; b++){
            for(int f = 0;  f< 3; f++){
                for(int r = 0; r < 10; r++){
                    buidings [b] [f] [r] = 0;
                }
            }
        }
        for(int x = 0; x <n; x++){
            int b = scan.nextInt() - 1;
            int f = scan.nextInt() - 1;
            int r = scan.nextInt() - 1;
            int v = scan.nextInt();
            buidings [b] [f] [r] = buidings [b] [f] [r] + v;
        }
        for(int b = 0; b < 4; b++){
            for(int f = 0;  f< 3; f++){
                System.out.print(" ");
                for(int r = 0; r < 10; r++){
                    if(r == 9){
                        System.out.println(buidings [b] [f] [r]);
                    }
                    else {
                        System.out.print(buidings[b][f][r] + " ");
                    }
                }
            }
            if(b < 3) {
                System.out.println("####################");
            }
        }
    }
}


Measured memory_bytes: 30044
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
  
struct Node{
  int key;

  struct Node *right;

  struct Node *left;

  struct Node *parent;
};
  
struct Node *root,*NIL;

struct Node* treeGet(struct Node *,int );

void treeInsert(int);

void inorder(struct Node *);

void preorder(struct Node *);

int main(){

  int n,i,x;
  
  char com[7];

  struct Node *t;

  scanf("%d",&n);

  for(i = 0;i < n;i ++)
    {

      scanf("%s",com);
      
      if(strcmp(com,"find") == 0)
	{
	  scanf("%d",&x);
	  
	  t = treeGet(root,x);
	  
	  if(t != NIL)
	    {
	      printf("yes\n");
	    }
	  else{
	    printf("no\n");
	  }
	}
      else if(strcmp(com,"insert") == 0)
	{
	  scanf("%d",&x);
	  treeInsert(x);
	}
      else if(strcmp(com,"print") == 0)
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	}
    }
  return 0;
}

struct Node* treeGet(struct Node *u,int k){

  while(u != NIL && k != u -> key)
    {
      if(k < u -> key)
	{
	u = u -> left;
	}
      else {
	u = u -> right;
      }
    }
  return u;
}

void treeInsert(int k){

  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;
  
  z = (struct Node*)malloc(sizeof(struct Node));
  
  z -> key = k;
  z -> left = NIL;
  z -> right = NIL;

  while(x != NIL)
    {
      y = x;
      if(z -> key < x -> key)
	{
	  x = x -> left;
	}
      else{
	x = x -> right;
      }
    }
  z -> parent = y;
  if(y == NIL)
    {
      root= z;
    }
  else{
    if(z -> key < y -> key)
      {
	y -> left = z;
      }
    else{
      y -> right = z;
    }
  }
}

void inorder(struct Node *u){

  if(u == NIL)return ;
  inorder(u -> left);
  printf(" %d",u -> key);
  inorder(u -> right);
}
  
void preorder(struct Node *u){

  if(u == NIL) return ;
  printf(" %d",u -> key);
  preorder(u -> left);
  preorder(u -> right);
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std ;
void Read ( int &x, char c = getchar() ) {
	for ( x = 0 ; !isdigit(c) ; c = getchar() ) ;
	for ( ; isdigit(c) ; c = getchar() ) x = 10*x + c - '0' ;
}
const int maxn = 1005 ;
int n, m, cnt[maxn][maxn][2], s[maxn][maxn][2] ;
char tp[10] ;
void check ( bool v ) {
	printf ( "check %d\n", v ) ;
	for ( int i = 0 ; i < n ; i ++, puts("") )
		for ( int j = 0 ; j < n ; j ++ )
			printf ( "%d ", cnt[i][j][v] ) ;
	puts("") ;
}
int main() {
	int i, j, k, x, y ;
	Read(m) ; Read(n) ;
	bool t ;
	for ( i = 1 ; i <= m ; i ++ ) {
		Read(x) ; Read(y) ;
		scanf ( "%s", tp ) ;
		t = tp[0] == 'B' ;
		if ((x/n)%2 == 1) t ^= 1 ;
		if ((y/n)%2 == 1) t ^= 1 ;
		x %= n, y %= n ;
		//printf ( "%d %d %c\n", x, y, tp[0] ) ;
		++ cnt[x][y][t] ;
	}
	for ( i = 0 ; i <= n ; i ++ )
		for ( j = 0 ; j <= n ; j ++ )
			for ( k = 0 ; k ^ 2 ; k ++ ) {
			s[i][j][k] = cnt[i][j][k] ;
			if (i) s[i][j][k] += s[i - 1][j][k] ;
			if (j) s[i][j][k] += s[i][j - 1][k] ;
			if (i && j) s[i][j][k] -= s[i - 1][j - 1][k] ;
		}
	//check(0), check(1) ;
	int ans = 0, rec ;
	for ( i = 0 ; i ^ n ; i ++ )
		for ( j = 0 ; j ^ n ; j ++ )
			for ( k = 0 ; k ^ 2 ; k ++ ) {
				rec = 2*s[i][j][k] + s[n-1][n-1][k] - s[i][n-1][k] - s[n-1][j][k] ;
				rec += s[i][n-1][k^1] + s[n-1][j][k^1] - 2*s[i][j][k^1] ;
				ans = max(ans, rec) ;
			}
	printf ( "%d\n", ans ) ;
	return 0 ;
}

Measured memory_bytes: 16000
#include <cstdio>

int a, b, c;

int main()
{
	scanf("%d%d%d", &a, &b, &c);
	if(a+b==c || a+c==b || b+c==a){
		printf("Yes\n");
	}
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
H,W = map(int, input().split())
S = []

for _ in range(H):
  S.append([s for s in input()])

for h in range(H):
  for w in range(W):
    if S[h][w] == ".":
      a = 0
      for x in [-1, 0, 1]:
        for y in [-1, 0, 1]:
          if 0 <= h+x < H and 0 <= w+y < W:
            if S[h+x][w+y] == "#":
              a += 1
      S[h][w] = str(a)

for _ in range(H):
  print("".join(S[_]))

Measured memory_bytes: 3188
n, l = map(int, input().split())
a = list(map(int, input().split()))
for i in range(1, n):
    if a[i] + a[i - 1] >= l:
        print("Possible")
        for j in range(1, i):
            print(j)
        for j in range(n - 1, i, -1):
            print(j)
        print(i)
        exit()
print("Impossible")

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    vector<string> A(N);
    vector<string> B(M);

    REP(i, N){
        cin >> A[i];
    }
    REP(i, M){
        cin >> B[i];
    }

    REP(i, N-M+1){
        REP(j, N-M+1){
            bool flag = true;
            REP(ii, M){
                REP(jj, M){
                    if(B[ii][jj] != A[i+ii][j+jj]){
                        flag=false;
                        break;
                    }
                }
                if(flag==false) break;
            }
            if(flag){
                cout << "Yes" << endl;
                return 0;
            }

        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-08-31 09:51:31
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

int n , dp[MAXN][2];
vector<int> adj[MAXN];

void DFS(int v , int p = -1){
	for(int u : adj[v]){
		if(u == p)	continue;
		DFS(u , v);
		dp[v][1] += dp[u][0];
	}
	dp[v][0] = dp[v][1];
	for(int u : adj[v]){
		if(u == p)	continue;
		dp[v][0] = max(dp[v][0] , dp[v][1] - dp[u][0] + dp[u][1] + 1);
	}
}

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

	cin >> n;
	for(int i = 1 ; i < n ; i++){
		int v , u;
		cin >> v >> u;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	DFS(1);
	if(dp[1][0] == (n + 1) / 2)	cout << "Second" << endl;
	else	cout << "First" << endl;

    return 0;
}
/*

*/

Measured memory_bytes: 31120
def main():
    import sys
    N = int(sys.stdin.readline())
    L = [0 for i in range(45)]
    L[0], L[1] = 1, 1
    for i in range(2, 45):
        L[i] = L[i-1] + L[i-2]
    #print(L)
    print(L[N])
    



if __name__=='__main__':
    main()


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int a = N % 10;
    string ans;
    if(a == 2 or a == 4 or a == 5 or a == 7 or a == 9) ans = "hon";
    if(a == 0 or a == 1 or a == 6 or a == 8) ans = "pon";
    if(a == 3) ans = "bon";
    cout << ans << endl;
    return 0;
}


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

int main() { 
  string s;
  cin >> s;
  int a = 0;
  int z = 0;
  for(int i = 0; i < s.length(); i++) {
    if(s.at(i) == 'A') {
      a = i;
      break;
    }
  }
  for(int i = 0; i < s.length(); i++) {
    if(s.at(i) == 'Z') {
      z = i;
    }
  }
  cout << z - a + 1 << endl;
}

Measured memory_bytes: 3732
public class Main {

  private static void solve() {
    int a = ni();
    long b = nl();
    long n = nl();

    long x = Math.min(b - 1, n);

    System.out.println(x * a / b);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	ll k , a, b ;
	cin >> k >> a>> b ;
	ll bis = 1 ;
	if ( k >= (a-1)) {
		bis = a; 
		k-= (a-1);
	}
	//とりあえずA枚作った。こっから割るのが良いか買うのが良いかを考える
	if( b - a >= 2){
		//交換シまくる
		bis += (k / 2) * (b-a) + (k%2);
	} else {
		bis += k;
	}
	cout << bis << endl;
}


Measured memory_bytes: 256
def main():
    X,Y,A,B,C = [int(x) for x in input().split()]
    P = sorted([int(x) for x in input().split()])[-X:]
    Q = sorted([int(x) for x in input().split()])[-Y:]
    R = sorted([int(x) for x in input().split()])

    ans = sum(sorted(P+Q+R, reverse=True)[:X+Y])
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 21552
import java.util.*;

class Main {
	Scanner sc;
	
	private void calc() {
		sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println((long)A*B/extgcd(A, B)[0]);
	}
	static final int[] extgcd(int a, int b) {
		int aa = a, bb = b;
		int x0 = 1, x1 = 0;
		int y0 = 0, y1 = 1;
	
		while (b != 0) {
			int q = a / b;
			int r = a % b;
			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;
	
			a = b; b = r;
			x0 = x1; x1 = x2;
			y0 = y1; y1 = y2;
		}
		if (bb > 0 && x0 < 0) {
			int n = -x0/bb;
			if (-x0%bb != 0) n++;
			x0 += n*bb; y0 -= n*aa;
		}
	    return new int[]{a, x0, y0};
	}
	

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

Measured memory_bytes: 21844