akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	stack<int> staLeft;
	vector<pair<int, int>> vecArea;
	char chIn;
	int nLeft;
	int nSum = 0;
	for (int i = 0; cin >> chIn; ++i)
	{
		if ('\\' == chIn)
		{
			staLeft.push(i);
		}
		else if (!staLeft.empty() && '/' == chIn)
		{
			nLeft = staLeft.top();
			staLeft.pop();
			int nTArea = i - nLeft;
			nSum += nTArea;
			while (!vecArea.empty() && vecArea.back().first > nLeft)
			{
				nTArea += vecArea.back().second;
				vecArea.pop_back();
			}
			vecArea.push_back(make_pair(nLeft, nTArea));
		}
	}
	cout << nSum << endl;
	cout << vecArea.size();
	pair<int, int> pA;
	for (auto a = vecArea.begin(); a != vecArea.end(); ++a)
	{
		pA = *a;
		cout << " " << pA.second;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3208
#include <stdio.h>

int gcd(int a, int b)
{
  int x, y;
  x = a;
  y = b;
  int tmp;
  if (x < y)
  {
    tmp = x;
    x = y;
    y = tmp;
  }
  
  int r;
  r = x % y;
  while (r != 0)
  {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

int main(void)
{
  int k;
  scanf("%d", &k);
  
  int sum = 0;
  int a = 1, b, c;
  int i = 1;
  int tmp;
  while (a <= k)
  {
    b = 1;
    while (b <= k)
    {
      c = 1;
      while (c <= k)
      {
        tmp = gcd(a, b);
        sum += gcd(tmp, c);
        c++;
      }
      b++;
    }
    a++;
  }
  printf("%d", sum);
  return 0;
}

Measured memory_bytes: 1732
import java.io.PrintWriter;
import java.util.*;

import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.mapping;

// Solution
public class Main {
  private static Scanner in;
  private static PrintWriter out;
  private static final String INPUT = ""; // input file name

  /**
   * Interactive get next command
   */
  static int get(int pos) {
    out.println(pos + 1);
    out.flush();
    return ni();
  }

  static void solve() {
    int n = ni();
    int m = ni();

    Map<Integer, Set<Integer>> adj = new HashMap<>();

    for (int i = 1; i <= n; i++) {
      adj.put(i, new HashSet<>());
    }

    for (int i = 0; i < m; i++) {
      adj.get(ni()).add(ni());
    }

    boolean[] visited = new boolean[n];
    int[] score = new int[n];
    int max = 0;


    for (int i = 1; i <= n; i++) {
      max = Math.max(max, helper(adj, i, visited, score));
    }

    out.println(max);
  }

  static int helper(Map<Integer, Set<Integer>> adj, int index, boolean[] visited, int[] score) {
    if (!visited[index - 1]) {
      int max = 0;

      // get all adjacents of index
      for (int neighbour: adj.get(index)) {
        max = Math.max(max, 1 + helper(adj, neighbour, visited, score));
      }

      visited[index - 1] = true;
      score[index - 1] = max;
    }

    return score[index - 1];
  }

  public static void main(String[] args) throws Exception {
    long S = System.currentTimeMillis();
    in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
    out = new PrintWriter(System.out);

    solve();
    out.flush();
    long G = System.currentTimeMillis();
    tr(G - S + "ms");
  }

  private static int gcd(int a, int b) {
    while (b != 0) {
      int t = b;
      b = a % b;
      a = t;
    }

    return a;
  }

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

  private static String ns() {
    return in.nextLine();
  }

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

  // Math Utils
  private static int pi(int num, int pow) {
    int result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        result *= num;
      }

      num *= num;
      pow /= 2;
    }

    return result;
  }

  private static int pim(int num, int pow, int mod) {
    int result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        // keep collecting `odd` num in result
        result = (result * num) % mod;
      }

      num = (num * num) % mod;
      pow /= 2;
    }

    return result;
  }

  private static long pl(long num, long pow) {
    long result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        result *= num;
      }

      num *= num;
      pow /= 2;
    }

    return result;
  }

  private static long plm(long num, long pow, long mod) {
    long result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        // keep collecting `odd` num in result
        result = (result * num) % mod;
      }

      num = (num * num) % mod;
      pow /= 2;
    }

    return result;
  }

  static void tr(Object... o) {
    if (!INPUT.isEmpty())
      out.println(Arrays.deepToString(o));
  }
}


Measured memory_bytes: 93540
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>

/* template start */

using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...)                                                    \
  std::cerr << "LINE: " << __LINE__ << "  [" << #__VA_ARGS__ << "]:", \
      debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << std::endl; }

template <typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
  std::cerr << " " << h;
  if (sizeof...(t) > 0) std::cout << " :";
  debug_out(t...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  return a > b && (a = b, true);
}

template <typename Num>
constexpr Num mypow(Num a, u64 b, Num id = 1) {
  if (b == 0) return id;
  Num x = id;
  while (b > 0) {
    if (b & 1) x *= a;
    a *= a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  std::string s;
  std::cin>>s;

  std::stack<char> stack;

  for(const auto& e:s){
    if(e=='S'){
      stack.emplace(e);
    }else if(e=='T'){
      if(!stack.empty()&&stack.top()=='S')stack.pop();
      else stack.emplace(e);
    }
  }

  std::cout<<stack.size()<<"\n";

  return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

int main()
{
  INT(N);
  INT(T);
  VEC(ll,A,N);
  ll MAXdiff = 0;
  ll MIN = INF;
  int cnt = 0;
  REP(i,N){
    if(MIN>A[i]){
      MIN=A[i];
    }else{
      if(A[i]-MIN>MAXdiff){
        MAXdiff=A[i]-MIN;
      }
    }
  }
  
  ll MIN2 = INF;
  REP(i,N){
    if(MIN2>A[i]){
      MIN2=A[i];
    }else{
      if(A[i]-MIN2==MAXdiff){
        cnt++;
      }
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 4032
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int count = 0;
  int k;
  for (int i = 0; i < N; i ++) {
    cin >> k;
    if (k % 2 == 1) count ++;
  }
  if (count % 2 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

using namespace std;

struct Team
{
	int num;
	vector<int> corrects;
	vector<int> incorrects;
	int time;

	Team(int p) : num(0), corrects(p, 0), incorrects(p, 0), time(0) {}

	bool operator < (const Team& t) const {
		int c = count(corrects.begin(), corrects.end(), 1);
		int tc = count(t.corrects.begin(), t.corrects.end(), 1);

		if (c == tc) {
			if (time == t.time) {
				return num > t.num;
			}
			return time < t.time;
		}

		return c > tc;
	}
};

int main()
{
	while (1)
	{
		int M, T, P, R;
		cin >> M >> T >> P >> R;

		if (M == 0 && T == 0 && P == 0 && R == 0) { break; }

		vector<Team> teams(T, Team(P));

		for (int i = 0; i < T; ++i) {
			teams[i].num = i + 1;
		}

		for (int i = 0; i < R; ++i) {
			int m, t, p, j;
			cin >> m >> t >> p >> j;

			// judge is incorrect.
			if (j != 0) {
				teams[t - 1].incorrects[p - 1]++;
				continue;
			}

			// judge is correct.
			teams[t - 1].corrects[p - 1] = 1;

			int time = m + teams[t - 1].incorrects[p - 1] * 20;
			teams[t - 1].time += time;
		}

		sort(teams.begin(), teams.end());

		int time = 0;
		for (int i = 0; i < teams.size(); ++i) {
			auto&& t = teams[i];

			int c = count(t.corrects.begin(), t.corrects.end(), 1);

			//cout << t.num << ": " << c << " " << t.time << endl;
			//continue;

			if (i == teams.size() - 1) {
				cout << t.num << endl;
				break;
			}

			auto&& nt = teams[i + 1];

			int nc = count(nt.corrects.begin(), nt.corrects.end(), 1);

			if (c == nc && nt.time == t.time) {
				cout << t.num << '=';
			}
			else {
				cout << t.num << ',';
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
typedef long long ll;
typedef long double ld;
long long dx[] = {1,0,-1,0};
long long dy[] = {0,1,0,-1};
long long dx8[] = {1,1,0,-1,-1,-1,0,1};
long long dy8[] = {0,1,1,1,0,-1,-1,-1};
long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};

signed main(){
    ll H,W;
    cin >> H >> W;
    char a[H][W];
    FOR(i,0,H)FOR(j,0,W)cin >> a[i][j];
    ll DP[H][W];
    FOR(i,0,H)FOR(j,0,W)DP[i][j] = 0;
    FOR(i,0,H)FOR(j,0,W){
        if(a[i][j] == '#'){
            DP[i][j] = 0;
        }
        else if(i == 0 && j == 0){
            DP[i][j] = 1;
        }
        else if(i == 0){
            DP[i][j] = DP[i][j-1];
        }
        else if(j == 0){
            DP[i][j] = DP[i-1][j];
        }
        else{
            DP[i][j] = DP[i-1][j]+DP[i][j-1];
        }
        DP[i][j] %= INF;
    }
    cout << DP[H-1][W-1] << endl;
}

Measured memory_bytes: 9088
var ir,ig,r,g,b,n,ans,temp: longint;

begin
  read(r,g,b,n);
  ans := 0;
  for ir := 0 to 3000 do begin
    for ig := 0 to 3000 do begin
      temp:=n - ir * r - ig * g;
      if temp<0 then break;
      if temp mod b = 0 then ans := ans + 1;
    end;
  end;
  writeln(ans)
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    ll N,K,S;
    cin >> N >> K >> S;
    ll maxim = 1e9;
    if(S == maxim){
        REP(i,K){
            cout << S << "\n";
        }
        REP(i,N-K){
            cout << 1 << "\n";
        }
    }else{
        REP(i,K){
            cout << S << "\n";
        }
        REP(i,N-K){
            cout << maxim << "\n";
        }
    }
}

Measured memory_bytes: 1280
# coding: utf-8
d = {}
for ch in list(input()):
    if ch not in d:
        d[ch] = 1
    else:
        d[ch] += 1

for k,v in d.items():
    if v % 2 == 0:
        pass
    else:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var a, b, n int
	fmt.Scan(&a, &b, &n)

	var x int
	if b-1 <= n {
		x = b - 1
	} else {
		x = n
	}

	ans := (a * x / b) - a*(x/b)
	fmt.Println(ans)
}


Measured memory_bytes: 1752
import sys
#input = sys.stdin.buffer.readline
import bisect

def main():
    s = input()
    t = input()
    
    index = [[] for _ in range(26)]
    for x,st in enumerate(s):
        index[ord(st)-ord("a")].append(x)
    
    roop,now = 0,-1
    for st in t:
        num = ord(st)-ord("a")
        if index[num] == []:
            print(-1)
            exit()
        else:
            pos = bisect.bisect_right(index[num],now)
            if pos == len(index[num]):
                roop += 1
                now = index[num][0]
            else:
                now = index[num][pos]
                
    print(roop*len(s)+now+1)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 7668
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.abs

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    /** O(log(n)): n = min(a, b) */
    tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

    val (_, x) = readLongList()
    val ans = readLongList()
        .map { abs(it - x) }
        // .filter { it != 0L }
        .reduce(::gcd)
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
template<class T> lint gcd(T a, T b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T> lint lcm(T a, T b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353
#define inf ((1LL << 62) - 1 + (1LL << 62))

// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    lint N, M;
    cin >> N >> M;
    cou(min(N % M, abs(M - N % M)));
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N,K=map(int,input().split())
l=[0]*(10**5+1)

for i in range(N):
    a,b=map(int,input().split())
    l[a]+=b

all=0
for index,item in enumerate(l):
    all+=item
    if all>=K:
        print(index)
        exit()

Measured memory_bytes: 5748
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
class UnionFind:
    def __init__(self,n): # 頂点数 親ならばその集合に∉頂点数に-1をかけたもの
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
n,m = readInts()
uni = UnionFind(n)
for i in range(m):
    a,b = map(lambda x:int(x)-1, input().split())
    uni.unite(a,b)
ans = -1
for i in range(n):
    ans = max(ans, uni.size(i)) # 一番大きいサイズを全部分割する必要があるため
print(ans)


Measured memory_bytes: 15504
import java.util.Scanner;

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

			int X = sc.nextInt();
			int A = sc.nextInt();

			if (X < A) {
				System.out.println("0");
			} else {
				System.out.println("10");
			}
		}
}


Measured memory_bytes: 25044
using System;
using System.Linq;

namespace ABC121_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var A = AB[0];
            var B = AB[1];

            var a = A % 2L != 0 ? A : 0;
            var b = B % 2L != 0 ? 0 : B;
            var c = (B - A) / 2 % 2 == 0 ? 0 : 1;

            long ans = 0;
            if (A % 2 == 0 && B % 2 == 0) ans = ((B - A) / 2) % 2 ^ B;
            else if (A % 2 == 1 && B % 2 == 0) ans = ((B - A) / 2) % 2 ^ A ^ B;
            else if (A % 2 == 0 && B % 2 == 1) ans = ((B - A + 1) / 2) % 2;
            else ans = ((B - A + 1) / 2) % 2 ^ A;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for_each(begin(A), end(A), [](auto& x) { cin >> x; });
  sort(begin(A), end(A));
  auto B = A;  // copy
  A.erase(unique(begin(A), end(A)), end(A));

  string ans = "NO";
  if (A.size() == B.size()) {
    ans = "YES";
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
import sys
s = input()
t = input()
templist = list(s)
# print(templist)
# print(templist[-0])
for i in range(len(s)):
    # print(templist)
    if "".join(templist)==t:
        print("Yes")
        sys.exit()
    else:
        temp = templist[-1]
        # print(temp)
        templist.insert(0, temp)
        # print(templist)
        templist.pop(-1)
print("No")

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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    string S;
    cin >> S;
    int c0, c1;
    c0 = c1 = 0;
    for (int i = 0; i < S.length(); i++)
    {
        if (S[i] == '0')
        {
            c0++;
        }
    }
    for (int i = 0; i < S.length(); i++)
    {
        if (S[i] == '1')
        {
            c1++;
        }
    }
    cout << min(c0, c1) * 2 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<"\n"
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void solve()
{
	ll x, k, d; cin >> x >> k >> d;
	x = abs(x);
	ll num = x / d;
	if (x % d == 0)
	{
		if (k <= num)
			cout << x - k*d;
		else
		{
			if ((num - k) % 2 == 0)
				cout << 0;
			else
				cout << d;
		}
	}
	else
	{
		if (k <= num)
			cout << x - k*d;
		else
		{
			ll tum = x % d;
			if (tum > abs(tum - d))
			{
				num++;
				if ((k - num) % 2 == 0)
					cout << abs(tum - d);
				else
					cout << tum;
			}
			else
			{
				if ((k - num) % 2 == 0)
					cout << tum;
				else
					cout << abs(tum - d);
			}

		}
	}

}
int main()
{
	fast;
	//cp();
	ll t = 1;
	//cin >> t;
	while (t--)
		solve();


	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define cool 1000000000000000000
using namespace std;

void ini() {

}

void Solve() {
    long double a, b;
    cin >> a >> b;
    a *= b;
    cout << (long long)(a) << endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ini();
    Solve();
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <numeric>
#include <utility>
#include <map>
#include <vector>
#include <climits>
#include <cmath>
#include <stdlib.h>

#define max_n 100001

using namespace std;

int main()
{
    int n; cin >> n;
    vector<pair<int, int>> points;
    for (int i = 0; i < n; i++)
    {
        int x, y; cin >> x >> y;
        points.push_back({x, y});
    }
    vector<long long> sum, diff;
    for (int i = 0; i < n; i++)
    {
        sum.push_back(points[i].first + points[i].second);
        diff.push_back(points[i].first - points[i].second);
    }
    sort(sum.begin(), sum.end());
    sort(diff.begin(), diff.end());
    cout << max(sum[sum.size() - 1] - sum[0], diff[diff.size() - 1] - diff[0]) << endl;
    return 0;
}

Measured memory_bytes: 9828
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n,m;
	cin >> n >> m;
	int a[1010],b[1010];
	int dp[100000];
	FOR(i,100000)dp[i]=MOD;
	vector<pair<int,int>> v;
	FOR(i,m){
		cin >> a[i] >> b[i];
		int c,sum=0;
		FOR(j,b[i]){
			cin >> c;
			sum+=1<<(c-1);
		}
		v.push_back(make_pair(a[i],sum));
	}
	dp[0]=0;

	FOR(i,1<<n){
		FOR(j,v.size()){
			chmin(dp[i|v[j].second],dp[i]+v[j].first);
		}
	}
	if(dp[(1<<n)-1]==MOD)cout << -1 << endl;
	else cout << dp[(1<<n)-1] << endl;
}

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

int main()
{
	int n, i, a;
	vector<int> v(25);
	int o;
	while (cin>>n, n) {
		for (i = 0; i < n; i++) {
			cin>>a;
			v[i] = a;
		}
		o = 31;
		cout<<o<<endl;
		for (i = 0; o > 0; i++) {
			o -= v[i%n];
			if (o<0) o = 0;
			cout<<o<<endl;
			if (o==0) break;
			o -= (o-1)%5;
			cout<<o<<endl;
		}
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n,x,l,m,s,t;
    cin >> n >> x >> l >> m >> s >> t;
    if(n==0) return 0;
    vector<vector<pair<int,int>>> e(n),ne(l+2);
    vector<int> rei(n,-1);
    int a;
    rei[s]=0,rei[t]=1;
    rep(i,l){
      cin >> a;
      rei[a]=i+2;
    }
    int u,v,d;
    rep(i,m){
      cin >> u >> v >> d;
      e[u].push_back({v,d});
      e[v].push_back({u,d});
    }
    rep(i,n){
      if(rei[i]!=-1){
        priority_queue<pair<int,int>,vector<pair<int,int>>,function<bool(pair<int,int>,pair<int,int>)>>
          heap([](const pair<int,int> &a, const pair<int,int> &b){return a.second>b.second;});
        vector<int> dist(n,IINF);
        heap.push({i,0});
        while(!heap.empty()){
          auto now = heap.top();
          heap.pop();
          if(dist[now.first]!=IINF) continue;
          dist[now.first]=now.second;
          if(now.first!=i&&rei[now.first]!=-1&&now.second<=x){
            ne[rei[i]].push_back({rei[now.first],now.second});
          }else{
            for(auto nx:e[now.first]){
              if(dist[nx.first]!=IINF) continue;
              heap.push({nx.first,now.second+nx.second});
            }
          }
        }
      }
    }
    priority_queue<pair<int,int>,vector<pair<int,int>>,function<bool(pair<int,int>,pair<int,int>)>>
      heap([](const pair<int,int> &a, const pair<int,int> &b){return a.second>b.second;});
    vector<int> dist(l+2,IINF);
    heap.push({rei[s],0});
    while(!heap.empty()){
      auto now = heap.top();
      heap.pop();
      if(dist[now.first]!=IINF) continue;
      dist[now.first]=now.second;
      if(now.first==rei[t]){
        cout << now.second+max(0,now.second-x) << endl;
        goto next;
      }
      for(auto nx:ne[now.first]){
        if(dist[nx.first]!=IINF) continue;
        heap.push({nx.first,now.second+nx.second});
      }
    }
    cout << "Help!" << endl;
    next:;
  }
  return 0;
}



Measured memory_bytes: 3232
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int a, b, ans = 0;
        cin >> a >> b;
        rep2(i, a, b + 1)
        {
                string s, t;
                s = to_string(i);
                t = s;
                reverse(s.begin(), s.end());

                if (s == t)
                        ans++;
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
import java.util.HashSet;
import java.util.Iterator;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int xc = sc.nextInt();
        int yc = sc.nextInt();
        for(int y=0;y<H;y++){
            String str = "";
            for(int x=0;x<W;x++){
                if(y<yc){
                    if(x<xc){
                        str+="0";
                    }else{
                        str+="1";
                    }
                }else{                    
                    if(x<xc){
                        str+="1";
                    }else{
                        str+="0";
                    }
                }
            }
            System.out.println(str);
        }
    }
}

Measured memory_bytes: 345172
#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
  string s;
  cin>>s;
  int len=s.length();
  int ans=0;
  for(int i=0;i<len/2;i++){
    if(s[i]!=s[len-1-i])
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
def is_pali(s):
    for ind, i in enumerate(s[:len(s)//2]):
        if(i==s[-ind-1]):
            continue
        else:
            return False
    return True

if(is_pali(S) and is_pali(S[:(N-1)//2]) and is_pali(S[(N+3)//2-1:])):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        if((a[i]%2) == 0){
            if((a[i]%3 != 0) && (a[i]%5 != 0)){
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
int fa[500050];
set<int> se[100010];
map<pi,int> mp;
queue<pi> q;
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main(){
	int n; cin>>n;
	for(int i=1;i<=n*2-2;i++){
		int x,y; scanf("%d%d",&x,&y);
		se[x].insert(y); se[y].insert(x);
		mp[make_pair(x,y)]++; mp[make_pair(y,x)]++;
		if(mp[make_pair(x,y)]==2) q.push(make_pair(x,y));
	}
	for(int i=1;i<=n;i++) fa[i]=i;
	set<int>::iterator it;
	while(!q.empty()){
		int x=q.front().first; int y=q.front().second; q.pop();
		x=find(x); y=find(y);
		se[x].erase(y); se[y].erase(x);
		if(se[x].size()<se[y].size()) swap(x,y);
		for(it=se[y].begin();it!=se[y].end();it++){
			int v=*it;
			mp[make_pair(v,y)]=mp[make_pair(y,v)]=0;
			se[v].erase(y); 
			se[v].insert(x);  se[x].insert(v);
			mp[make_pair(v,x)]++; mp[make_pair(x,v)]++;
			if(mp[make_pair(v,x)]==2) q.push(make_pair(v,x));
		}
		fa[y]=x; se[y].clear();
	}
	int flag=0;
	for(int i=1;i<=n;i++){
		if(fa[i]==i&&flag){
			return puts("NO"),0;
		}
		if(fa[i]==i) flag=1;
	}
	puts("YES");
}

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

int main() {
    int n;
    cin >> n;
    string s;
    map<string,int>M;
    for (int i=0;i<n;i++) {
        cin >> s;
        M[s]++;
    }

    cout << "AC x " << M["AC"] << endl;
    cout << "WA x " << M["WA"] << endl;
    cout << "TLE x " << M["TLE"] << endl;
    cout << "RE x " << M["RE"] << endl;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string A;
  cin >> A;
  if (A == "SUN" ){
    cout<< 7 << endl;
  }
  else if (A == "MON" ){
    cout<< 6 << endl;
  }  
  else if (A == "TUE" ){
    cout<< 5 << endl;
  }
  else if (A == "WED" ){
    cout<< 4 << endl;
  }
  else if (A == "THU" ){
    cout<< 3 << endl;
  }
  else if (A == "FRI" ){
    cout<< 2 << endl;
  }
  else if (A == "SAT" ){
    cout<< 1 << endl;
  }

}

Measured memory_bytes: 256
using System;
using System.IO;
namespace abc160_1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetIn(new StreamReader(Console.OpenStandardInput(1000000)));
            var first = Console.ReadLine().Trim().Split(' ');
            var k = int.Parse(first[0]);
            var n = int.Parse(first[1]);
            var houses = Console.ReadLine().Trim().Split(' ');
            var tmp = 0;
            for (int i = 0; i < n; i++)
            {
                var c_len = int.Parse(houses[i]);
                var islast = i+1 == n;
                var n_len = int.Parse(houses[islast ? 0 : i+1]);
                if(islast){
                    n_len += k;
                }
                if(tmp <=  n_len - c_len){
                    tmp = n_len - c_len;
                }
            }
            Console.WriteLine(k-tmp);
       }
    }
}


Measured memory_bytes: 30940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <map>
 
using namespace std;
 
int main (void) {
  int N ,M;
  string s;
  map<string, int> blue;
  map<string, int> red;
  cin >> N;
  string key[101];
  for (int i=0; i<=N-1; i++) {
     cin >> s;
     key[i]=s;
     blue[s] = int (blue[s]) +1;
     s= ' ';
  }
  cin >> M;
  for (int i=0; i<=M-1; i++) {
     cin >> s;
     red[s] = int (red[s]) +1;
     s =' ';
  }
  int ans =0;
  int NM = max(N,M);
  for (int i=0; i<=NM; i++) {
    ans=max(ans,blue[key[i]]-red[key[i]] );
  }
  cout << ans;
}

Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = int(input())
    b = int(input())
    c = a %500

    if c <= b:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3828
//API???????????????
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
  	
	final static int INF = 100;
	static int[] list;
	static int a = 0;
	static int b = 1;
	
	
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[][] Graph = new int[n + 1][n];
		int[] depth = new int[n + 1];
		
		for(int i = 0; i < n; i++){
			String[] str = br.readLine().split(" ");
			int x = Integer.parseInt(str[0]);
			int y = Integer.parseInt(str[1]);
			depth[x] = -1;
			for(int j = 0; j < y; j++){
				Graph[x][j] = Integer.parseInt(str[j + 2]);
			}
		}
		
		depth[1] = 0;
		list = new int[n + 1];
		list[0] = 1;
		
		search(Graph, depth);
		
		for(int i = 1; i <= n; i++){
			System.out.println(i + " " + depth[i]);
		}
	}
	
	public static void search(int[][] Graph, int[] depth){
		for(;a < b; a++){
			int fr = list[a];
			for(int i = 0; i < Graph[fr].length;i++){
				int to = Graph[fr][i];
				if(depth[to] == -1){
					depth[to] = depth[fr] + 1;
					list[b++] = to;
				}
			}
		}
	}
}

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

using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    int count = 0;
    for(int i=3;i<=N;i+=2){
        int n = 0;
        for(int j=1;j*j<i;j+=2){
            if(i % j == 0) n += 1;
        }
        if(n==4){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

string s;

void input(){
	cin>>s;
	return;
}

void solve(){
	for(int i=1;i<s.size();i++){
		if((s.size()-i)%2==1)continue;
		string t=s.substr(0,(s.size()-i)/2);
		string r=s.substr((s.size()-i)/2,(s.size()-i)/2);
		if(t==r){
			cout<<s.size()-i<<endl;
			return;
		}
	}
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 256
l, r = list(map(int, input().split()))
ans = float('inf')
for i in range(l, r):
    for j in range(i + 1, r + 1):
        ans = min(ans, i * j % 2019)
        if ans == 0:
            break
    else:
        continue
    break
print(int(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int n,k;
string s;
signed main(){
	cin>>n>>k>>s;
	s[k-1]+=32;
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    string s;
    cin >> s;
    ll n = s.size();
    ll r = 0;
    rep(i, 0, n){
        if(s[i] == '0') r++;
    }
    ll b = n-r;
    ll ans = 2*min(r,b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
int main()
{
    int K;
    string S;
    cin >> K;
    cin >> S;

    if (S.size() <= K)
    {
        cout << S << endl;
        return 0;
    }

    cout << S.substr(0, K) << "..." << endl;

    return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3

n, x = list(map(int, input().split()))

a, p = [1], [1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)


def calc(N, X):
    if X == 1:
        if N == 0:
            return 1
        else:
            return 0
    elif X <= 1+a[N-1]:
        return calc(N-1, X-1)
    elif X == 2+a[N-1]:
        return p[N-1]+1
    elif X <= 2*a[N-1]+2:
        return p[N-1]+1+calc(N-1, X-2-a[N-1])
    elif X == 2*a[N-1]+3:
        return 2*p[N-1]+1
    else:
        raise("Error")


print(calc(n, x))


Measured memory_bytes: 3064
h,w = map(int, input().split())
a = [[0] for i in range(h)]
for i in range(h):
    a[i] = input()
    a[i] = "#"+a[i]+"#"
s=["#"*(w+2)]
a.extend(s)
s.extend(a)
for a_ in s:
    print(a_)


Measured memory_bytes: 3060
N = int(input())

B = input().split()
B = [int(n) for n in B]

A = []
A.append(B[0])

for i in range(N-2) :
  A.append(min(B[i], B[i+1]))

A.append(B[N-2])

#print(N)
#print(B)

print(sum(A))

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

#define int long long
#define MOD (int)(1e9+7)

#define MAX 110000
int A[MAX];

signed main(){
  int N, sum = 0, hoge;
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin>>N;

  hoge = N*(N+1)/2;

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

  //cout<<hoge<<" "<<sum<<endl;
  if(sum%hoge){
    cout<<"NO"<<endl;
    return 0;
  }
  
  hoge = sum/hoge;

  sum = 0;

  for(int i = 0; i < N; i++){
    int a = A[(i+1)%N]-A[i];
    if(a > hoge || a < hoge*(-(N-1))){
      cout<<"NO"<<endl;
      return 0;
    }
    //cout<<a<<" "<<hoge<<" "<<(a-hoge)<<" "<<(a-hoge)%5<<endl;
    if((a-hoge)%N){
      cout<<"NO"<<endl;
      return 0;
    }
    sum += a;
  }

  if(sum){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
int cntw[300001];
inline int cnts(int i){return i-cntw[i];}
int main(){
    int n,mmin=1e9;
    char c;
    scanf("%d\n",&n);
    cntw[0]=0;
    for(int i=1;i<=n;i++){
        scanf("%c",&c);
        if(c=='W')cntw[i]=cntw[i-1]+1;
        else cntw[i]=cntw[i-1];
    }
    for(int i=1;i<=n;i++){
        mmin=std::min(mmin,cntw[i-1]+cnts(n)-cnts(i));
    }
    printf("%d",mmin);
    return 0;
}

Measured memory_bytes: 1280
#169 値A＊Bを整数として出力せよ。

#1 入力をプログラムで扱えるように受け取ること
a, b = map(int, input().split())
#print(a, b)

#2 受け取った入力値を使って、適切に処理{計算}すること
answer = a * b

#3 計算した結果を出力すること
print(answer)

Measured memory_bytes: 9148
ans = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
num = [0] * 26
s = input()
for i in range(len(s)):
	num[ans.index(s[i])]+=1
for i in range(len(num)):
	if num[i] == 0:
		print(ans[i])
		exit()
print("None")

Measured memory_bytes: 3188
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

T RD(T = long)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto M = RD;
	auto edge = new long[2][][](N);
	auto use  = new long[][](N, N);
	foreach (i; 0..N) fill(use[i], -1);
	foreach (i; 0..M)
	{
		auto a = RD-1;
		auto b = RD-1;
		auto c = RD;
		edge[a] ~= [b, c];
		edge[b] ~= [a, c];
		use[a][b] = 0;
		use[b][a] = 0;
	}

	long[][] f(long from)
	{
		auto path = new long[][](N);
		auto cost = new long[](N);
		fill(cost, long.max);
		long[] open = [from];
		path[from] = [from];
		cost[from] = 0;
		while (!open.empty)
		{
			auto n = open.front; open.popFront;
			foreach (e; edge[n])
			{
				auto pos = e[0];
				auto c   = e[1] + cost[n];
				if (c < cost[pos])
				{
					path[pos] = path[n] ~ pos;
					cost[pos] = c;
					open ~= pos;
				}
			}
		}
		return path;
	}

	foreach (i; 0..N)
	{
		auto r = f(i);
		foreach (e; r)
		{
			foreach (j; 0..e.length-1)
			{
				use[e[j]][e[j+1]] = 1;
				use[e[j+1]][e[j]] = 1;
			}
		}
	}
	long ans;
	foreach (e; use)
	{
		foreach (ee; e)
		{
			if (ee == 0) ++ans;
		}
	}
	
	writeln(ans / 2);
	stdout.flush();
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);
using namespace std;
const int N = 1e5 + 5;
map<int, int> nm;

int main() {
    fast;
    int n; cin >> n;
    cout << n * n;
    return 0;
}



Measured memory_bytes: 256
/*
    Author:zzugzx
    Lang:C++
    Blog:blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=2e6+10;
const ll inf=0x3f3f3f3f;
const int dir[][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};

ll fact[maxn],inv1[maxn];
ll Pow(ll a, ll b){
	ll ans = 1;
	while(b > 0){
		if(b & 1){
			ans = ans * a % mod;
		}
		a = a * a % mod;
		b >>= 1;
	}
	return ans;
}
//逆元
ll inv(ll b){
    return Pow(b,mod-2)%mod;
}



ll C(ll n,ll m){
    if(m>n||n<0||m<0)return 0;
    if(m==0||m==n) return 1;
    ll res=(fact[n]*inv1[m]%mod*inv1[n-m])%mod;
    return res;
}

void init() {
	fact[0] = 1;
	for (int i = 1; i < maxn; i++) {
		fact[i] = fact[i - 1] * i %mod;
	}
	inv1[maxn - 1] = Pow(fact[maxn - 1], mod - 2);
	for (int i = maxn - 2; i >= 0; i--) {
		inv1[i] = inv1[i + 1] * (i + 1) %mod;
	}
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int k;
    cin>>k;
    string s;
    cin>>s;
    init();
    int n=s.length();
    ll ans=0;
    for(int i=n;i<=n+k;i++)
        ans=(ans+C(n+k,i)*Pow(25,k+n-i)%mod)%mod;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 35664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        A[i]--;
    }
    ll roop = 1;
    ll city = 0;
    ll num = 0;
    ll roop_start;
    vector<ll> visited(N, -1);
    while (num < N) {
        if (visited[city] != -1) {
            roop = num - visited[city];
            break;
        }
        if (num == K) goto Exit;
        visited[city] = num;
        city = A[city];
        num++;
    }
    roop_start = num - roop;
    K = (K - roop_start) % roop;
    city = 0;
    for (ll i = 0; i < K + roop_start; i++) {
        city = A[city];
    }
Exit:
    cout << ++city << endl;
    return 0;
}


Measured memory_bytes: 6428