akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pq priority_queue
using namespace std;

int main() {
//	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	vector<int> ca(n+1), cb(n+1);
	for (int i=0; i<n; i++) {
		cin >> a[i];
		ca[a[i]]++;
	}
	for (int i=0; i<n; i++) {
		cin >> b[i];
		cb[b[i]]++;
	}
	bool poss = true;
	for (int i=1; i<=n && poss; i++) {
		if (ca[i]+cb[i] > n) poss = false;
	}
	if (!poss) {
		cout << "No\n"; // LOWERCASE
		return 0;
	}
	cout << "Yes\n";
	
	vector<int> at(n+1);
	for (int i=0; i<n; i++) {
		if (i && a[i]==a[i-1]) continue;
		at[a[i]] = i;
	}
	pq<pii> pa, pb;
	for (int i=1; i<=n; i++) {
		if (ca[i]) pa.push({ca[i], i});
		if (cb[i]) pb.push({cb[i], i});
	}
	vector<int> ans(n);
	while (!pa.empty() && !pb.empty()) {
		int fa = pa.top().first;
		int ia = pa.top().second;
		pa.pop();
		int fb = pb.top().first;
		int ib = pb.top().second;
		pb.pop();
		if (ia == ib) {
			if (!pb.empty()) {
				int tfb = pb.top().first;
				int tib = pb.top().second;
				pb.pop();
				pb.push({fb, ib});
				fb = tfb;
				ib = tib;
			}
			else if (!pa.empty()) {
				int tfa = pa.top().first;
				int tia = pa.top().second;
				pa.pop();
				pa.push({fa, ia});
				fa = tfa;
				ia = tia;
			}
		}
//		cout << fa << ' ' << ia << ' ' << fb << ' ' << ib << ' ' << at[ia] << '\n';
		int take = min(fa, fb);
		fa -= take;
		fb -= take;
		while (take--) {
			ans[at[ia]] = ib;
			at[ia]++;
		}
		if (fa) pa.push({fa, ia});
		if (fb) pb.push({fb, ib});
	}
	
	int idx = -1;
	for (int i=0; i<n; i++) {
		if (ans[i] == a[i]) {
			idx = i;
			break;
		}
	}
	if (idx>=0) {
		for (int j=0; j<n && idx<n && ans[idx]==a[idx]; j++) {
			if (ans[j] != a[idx] && ans[idx] != a[j]) {
				swap(ans[j], ans[idx]);
				idx++;
			}
		}
	}
	for (int x : ans) cout << x << ' ';
	cout << '\n';
}

Measured memory_bytes: 10992
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    int n, m, k, i, j, a, b;
    cin >> n >> m >> k;
    int frd[n] = {};
    UnionFind tree(n);
    for(i=0; i<m; i++){
        cin >> a >> b;
        frd[a-1]++;
        frd[b-1]++;
        tree.unite(a-1, b-1);
    }
    for(i=0; i<k; i++){
        cin >> a >> b;
        if(tree.find(a-1) == tree.find(b-1)){
            frd[a-1]++;
            frd[b-1]++;
        }
    }
    for(i=0; i<n; i++){
        cout << tree.size(i) - frd[i] - 1 << ' ';
    }
    return 0;
}

Measured memory_bytes: 1664
arr = Array.new
while lineA = gets and lineB = gets
   a = Array.new
   a << lineA
   a << lineB
   arr << a
end
arr.each do |i|
   a = i[0].split(" ")
   a.map!{|j| j.to_i}
   b = i[1].split(" ")
   b.map!{|j| j.to_i}
   hit = 0
   blow = 0
   0.upto(3) do |j|
      if a[j] == b[j]
         hit += 1
      end
   end
   0.upto(3) do |j|
      0.upto(4) do |k|
         if j == k
            next
         elsif a[j] == b[k]
            blow += 1
         end
      end
   end
   puts "#{hit} #{blow}"
end

Measured memory_bytes: 6116
/*input
2 10
*/
 

#include <bits/stdc++.h>

using namespace std;

#define ld long double
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define se second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<long long int, long long int> mpi;
typedef set<long long int> seti;
typedef multiset<long long int> mseti;
typedef priority_queue<long long int> pq;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define PI 3.14159265
#define dbg(x) cerr << "\n" << (#x) << " = " << (x) << endl ;
//#define cerr if(false)cerr
 
#define mod 998244353
 
struct node{
    ll val;
};
struct Interval {int start, end;};
bool compare(struct node n1, struct node n2) {
    return (n1.val < n2.val);
}

 
 
 
int main() 
{
	ll a,b; cin>>a>>b;
	ll mx = max(a-b, a+b);
	mx = max(mx, a*b);
	cout<<mx<<endl;
	return 0;  
}






Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let S: String = read();
    let S2: Vec<char> = S.chars().collect();
    let ans = if S2.last().unwrap() == &'s' {
        S + "es"
    } else {
        S + "s"
    };
    println!{"{}", ans}
}


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

 int main()
{

 long long n,k,sum=0;
 cin>>n>>k;

 long long ans = 1;

  while(n--){

  long long ans2 = ans*2;
  long long ani = ans+k;

  if(ans2 < ani)
    ans = ans2;
  else ans = ani;

  }

  cout<<ans<<endl;

 return 0;
}


Measured memory_bytes: 3632
# coding: utf-8
# Your code here!
import sys
import numpy as np
import math
input=sys.stdin.readline

def LI():return list(map(int,input().split()))

n,m=LI()
a=LI()
suma=sum(a)

ans=n-suma
if ans<0:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 27764
#include <stdio.h>
int main(void){
    int a, b, c, d, e, i;
    e = 10000000000;
    scanf("%d\n", &a);
    for(i = 0; i < a; i++){
        d = 0;
        scanf("%d", &b);
        while(b % 2 == 0){
            b = b / 2;
            d = d + 1;
            //printf("%d", d);
        }
    if(d < e){
        e = d;
    }
    } 
    printf("%d", e);

}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(N: int, X: int, x: "List[int]"):
    from fractions import gcd
    from functools import reduce
    return reduce(gcd, [abs(xx-X) for xx in x])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, X, x))

def test():
    import doctest
    doctest.testmod()

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


Measured memory_bytes: 21432
// Sasageyo! Sasageyo! Shinzou wo Sasageyo !
// https://goo.gl/IwJzbx

#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define endl '\n'
const int N = 1e5;
int c[N];
int main()
{
  int n;
  cin >> n;
  VI x(n);
  int min_c = N;
  int max_c = 0;
  for(int i=0;i<n;i++)
    cin >> x[i], c[x[i]]++, min_c = min(min_c, x[i]), max_c = max(max_c, x[i]);
  if(c[1]==n || c[n-1]==n)
    return 0*puts("Yes");
  if(max_c - min_c > 1)
    return 0*puts("No");
  bool all_eq = true;
  for(int i=1;i<n;i++)
    if(x[i]!=x[i-1])
      all_eq = false;
  string ans = "No";
  if(all_eq) {
    int k = x[0];
    if(2*k <= n)
      ans = "Yes";
    cout << ans << endl;
    return 0;
  }
  int k = max_c;
  int exact_1 = 0;
  for(int i=0;i<n;i++)
    if(x[i]!=k)
      exact_1++;
  int atleast_2 = k - exact_1;
  if(atleast_2*2 + exact_1 <= n && atleast_2 > 0)
    ans = "Yes";
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
using P = pair<int, int>;
int N, M;

int main() {
  cin >> N >> M;
  vector<P> ba(M);
  rep(i, 0, M) {
    int a, b;
    cin >> a >> b;
    ba[i] = P(b, a);
  }
  sort(ba.begin(), ba.end());

  int ans = 0;
  int last = 0;
  for (auto e : ba) {
    int b = e.first;
    int a = e.second;
    if (a > last) {
      last = b - 1;
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main()
{
    string W, T;
    int count = 0;
    int i, len;
    bool exist = true;

    cin >> W;
    len = 0;
    for(i = 0; W[i]; i++) len++;

    while(1){
        cin >> T;
        if(T == "END_OF_TEXT") break;

        for(i = 0; T[i] && (i < len); i++){
            exist = true;
            if((T[i] != W[i]) && (T[i] != W[i] - 32) && (T[i] != W[i] + 32)){
                exist = false;
                break;
            }
        }
        if((i == len) && (!T[i]) && (exist == true)) count++;
    };

    cout << count << endl;

    return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, D;
    cin >> N >> D;
    unsigned long cnt{0};
    for(unsigned long i{0}, X, Y; i < N; ++i){
        cin >> X >> Y;
        cnt += X * X + Y * Y <= D * D;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(void)
{
	int N, K, x[100], Amin = 0, Bmin = 0;
	
	scanf("%d", &N);
	scanf("%d", &K);
	
	for(int i = 0; i < N; i++) scanf("%d", &x[i]);
	
	for(int i = 0; i < N; i++){
		if(x[i] < (K - x[i])){
			Amin += 2*x[i];
		} else {
			Bmin += 2*(K - x[i]);
		}
	}
	
	printf("%d\n", Amin + Bmin);
	
	return 0;
}


Measured memory_bytes: 128
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
from functools import lru_cache, reduce
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

# UnionFind
class UnionFind():
    def __init__(self, n):
        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 union(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)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

#　素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#最小公倍数
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


# ここから書き始める
n = int(input())
t = [0] * n
for i in range(n):
    t[i] = int(input())
ans = lcm(*t)
print(ans)

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

class AtCoder {
  public static void Main() {
    var inputs = Console.ReadLine().Trim().Split(' ');
    long A = long.Parse(inputs[0]);
    long B = long.Parse(inputs[1]);
    long K = long.Parse(inputs[2]);
    
    /*
    for(long i = 0; i < K; i++) {
      if(A > 0) {
        A--;
      } else if(B > 0) {
        B--;
      }
    }
    */
    
    if(A < K) {
      K -= A;
      A = 0;
    } else {
      A -= K;
      K = 0;
    }
    if(B < K) {
      K -= B;
      B = 0;
    } else {
      B -= K;
      K = 0;
    }
    Console.WriteLine(A + " " + B);
  }
}

Measured memory_bytes: 13140
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int sx = sc.nextInt();
    int sy = sc.nextInt();
    int tx = sc.nextInt();
    int ty = sc.nextInt();
    for(int i = 0;i < tx - sx;i++){
      System.out.print("R");
    }
    for(int j = 0;j < ty - sy;j++){
      System.out.print("U");
    }
    for(int k = 0;k < tx - sx;k++){
      System.out.print("L");
    }
    for(int l = 0;l < ty - sy;l++){
      System.out.print("D");
    }
    System.out.print("D");
    for(int m = 0;m < tx - sx + 1;m++){
      System.out.print("R");
    }
    for(int n = 0;n < ty - sy + 1;n++){
      System.out.print("U");
    }
    System.out.print("LU");
    for(int o = 0;o < tx - sx + 1;o++){
      System.out.print("L");
    }
    for(int p = 0;p < ty - sy + 1;p++){
      System.out.print("D");
    }
    System.out.print("R");
  }
}


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

#define int long long
const int mod = 1e9 + 7 ;
int modexp(int a , int n){
	if(n == 0) return 1 ;
	if(n == 1) return a ;
	int x = modexp(a , n / 2 ) ;
	x = (x*x) % mod ;
	if(n&1)  x = (x*a) % mod ;
	return x ;
}

int solve(int ans , int nn , int pp){
	ans = (ans*nn) % mod ;
	ans = ( ((ans*modexp(pp , mod - 2)) % mod)*-1 + mod * mod ) % mod ;
	return ans ;
}

int32_t main(){
	int n , k ;
	cin >> n >> k ;
	vector<pair<int,int>> v; 
	int z = 0 ;
	for(int i = 0 ; i < n ; i++){
		int x ;
		cin >> x ;
		if(x < 0){
			v.push_back({-x,1}) ;
		} else if(x > 0){
			v.push_back({x,0}) ;
		} else {
			z = 1 ;
		}
	}
	if(v.size() < k){
		cout << 0 ;
		return 0 ;
	}
	sort(v.begin() , v.end() , greater<pair<int,int>>()) ;
	int cnt = 0 ;
	int ans = 1 ;
	for(int i = 0 ; i < k ; i++){
		cnt += v[i].second ;
		int f = 1 ;
		if(v[i].second) f = -1 ;
		ans = (ans*v[i].first*f + mod*mod) % mod ;
	}
	if(cnt%2 == 0){
		cout << ans ;
		return 0 ;
	}
	int pp = -1 , pn = -1 ;
	int np = -1 , nn = -1 ;
	for(int i = k-1 ; i >= 0 ; i--){
		if(v[i].second && pn == -1) {
			pn = v[i].first ;
		}
		if(!v[i].second && pp == -1){
			pp = v[i].first ;
		}
	}
	for(int i = k ; i < n ; i++){
		if(v[i].second && nn == -1){
			nn = v[i].first ;
		}
		if(!v[i].second && np == -1){
			np = v[i].first ;
		}
	}
	bool x = (~nn) && (~pp) ;
	bool y = (~np) && (~pn) ;
	if(x && y){
		if(nn*pn > pp*np){
			ans = solve(ans , nn , pp) ;	
		} else {
			ans = solve(ans , np , pn) ;
		}
	} else if(x){
		ans = solve(ans , nn , pp) ;
	} else if(y){
		ans = solve(ans , np , pn) ;
	} else if(z){
		ans = 0 ;
	} else {
		ans = 1 ;
		for(int i = n - 1 ; i >= (n-k) ; i--){
			int f = 1 ;
			if(v[i].second) f = -1 ;
			ans = (ans * v[i].first * f + mod*mod) % mod ;
		}
	}
	cout << ans ;
	return 0 ;
}



Measured memory_bytes: 7444
# 到達可能な頂点の集合
def reachable_nodeset(start, inc):
  reachable = set()
  reachable.add(start)
  nodes = [start]
  
  while nodes:
    n = nodes.pop()
    for i in inc[n]:
      if i not in reachable:
        nodes.append(i)
        reachable.add(i)
  return reachable

def bellmanford(num, start, goal, edges):
  cost = [float('inf')]*num
  cost[start] = 0
  # 負の閉路が無ければ更新はV-1回までで終わる
  for _ in range(num):
    updated = False
    for a, b, c in edges:
      # aまでのコスト+辺abのコストがbまでのコストより小さければ更新
      if cost[b] > cost[a]+c:
        cost[b] = cost[a]+c
        updated = True
    if not updated: break
  else:
    # V回目まで更新があったら負の閉路がある
    return -1
  return max(0, -cost[goal])

N, M, P = map(int, input().split())
to = [[] for _ in range(N)]
ot = [[] for _ in range(N)]
edges = []

for _ in range(M):
  a, b, c = map(int, input().split())
  a -= 1
  b -= 1
  c = -(c-P)
  
  to[a].append(b)
  ot[b].append(a)
  edges.append((a,b,c))
  
reachableFromZero = reachable_nodeset(0, to)  
reachableToN = reachable_nodeset(N-1, ot)  
ok = reachableFromZero.intersection(reachableToN)
edges = tuple((a,b,c) for a,b,c in edges if a in ok and b in ok)

print(bellmanford(N, 0, N-1, edges))

Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int64_t N, M, sum = 0;
    cin >> N >> M;
    for (int i = 0; i < M; i++){
        int a;
        cin >> a;
        sum += a;
    }
    if (sum > N){
        cout << -1 << endl;
    }
    else {
        cout << N - sum << endl;
    }
}

Measured memory_bytes: 3652
import java.util.Scanner;

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

        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());

        if (n % 500 <= a)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 23124
fun main(args: Array<String>) {
    // Your code here!
    var n = readLine()!!.toInt()
    var list = readLine()!!.split(" ").map{it.toInt()}
    var aslist = list.sorted()
    var msg = "YES"
    var cnt = 0
    var index = 1
    
    if(list != aslist){
        for(i in 0..list.size-1){
            if(index != list[i]){
                cnt += 1
            }
            index += 1
        }
    
        if(cnt > 2){
            msg = "NO"     
        }
    }

    print(msg)
}


Measured memory_bytes: 36072
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }




#define MAX 50
    void printString(ll int n)
{
    char str[MAX];
    ll int i = 0;

    while (n > 0) {
        
        ll int rem = n % 26;


        if (rem == 0) {
            str[i++] = 'Z';
            n = (n / 26) - 1;
        }
        else // If remainder is non-zero
        {
            str[i++] = (rem - 1) + 'A';
            n = n / 26;
        }
    }
    str[i] = '\0';


    reverse(str, str + strlen(str));
    string s = str;
    transform(s.begin(), s.end(), s.begin(), ::tolower);
    cout << s << endl;

    return;
}


int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll int n , n1;cin>>n;
    printString(n);
    return 0;
}


Measured memory_bytes: 3656
{-# LANGUAGE TypeApplications #-}

-- | C - H and V
module Main where

import Control.Monad (join, filterM)

main :: IO ()
main = do
  (h : w : k : _) <- map (read @Int) . words <$> getLine
  board <- index h w . lines <$> getContents
  let rows = powerset [1 .. h]
  let cols = powerset [1 .. w]
  let pattern = [(row, col) | row <- rows, col <- cols]
  print $ length $ filter (== k) $ (countBlack . flip repaint board) <$> pattern
  where
    powerset :: [a] -> [[a]]
    powerset xs = filterM (\x -> [True, False]) xs

    index :: Int -> Int -> [[a]] -> [(Int, [(Int, a)])]
    index h w mtx = zip [1 .. h] (zip [1 .. w] <$> mtx)

    repaint :: ([Int], [Int]) -> [(Int, [(Int, a)])] -> [[a]]
    repaint (rs, cs) = map (deindex . dropIdxIn cs) . (deindex . dropIdxIn rs)

    deindex :: [(Int, a)] -> [a]
    deindex = map snd

    dropIdxIn :: [Int] -> [(Int, a)] -> [(Int, a)]
    dropIdxIn is = filter $ \(i, _) -> not (elem i is)

    countBlack :: [String] -> Int
    countBlack = length . filter (== '#') . join


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

using namespace std;

int main(void){
	int num, all;
	cin >> num;
	all = (999 - 999 / 3) * (20 * 5 + 19 * 5) + 999 / 3 * 20 * 10;

	for(int i = 0; i < num; i++){
		int y, m, d;
		int millenium;
		cin >> y >> m >> d;
		
		millenium = ((y-1) - (y-1) / 3) * (20 * 5 + 19 * 5) + (y-1) / 3 * 20 * 10;
		if(y % 3 != 0){
			millenium += ((m - 1) / 2) * 19 + ((m - 1) - ((m - 1) / 2)) * 20 + d;
		}else{
			millenium += (m - 1) * 20 + d;
		}
		cout << all -  millenium + 1 << endl;	
	}
	return 0;
}

Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int n,a=1,MOD;
    cin >> n;
    MOD = 1000000007;
    for(int i=1;i<n+1;i++){
        a%=MOD;
        a*=i;
        a%=MOD;
    }
    cout << a << endl;



}

Measured memory_bytes: 3580
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
	int K,A,B,out;
	long long int ans=0;
	cin>>K>>A>>B;
	out=K;
	if(K>A-1){
		K=K-A+1;
		ans=A;
	}else{
		cout<<out+1<<endl;
		return 0;
	}
	if(A+2>=B){
		cout<<out+1<<endl;
		return 0;
	}
	while(K>0){
		if(K==1){
			ans+=1;
			K--;
		}else{
			ans+=B-A;
			K=K-2;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int R = in.i();
        int C = in.i();
        int K = in.i();
        int[][] v = new int[R][C];        
        for (int i = 0; i < K; i++) {
            int r = in.i() - 1;
            int c = in.i() - 1;
            v[r][c] = in.i();
        }
        
        long[][][] dp = new long[R + 1][C + 1][4];
        for (int i = R - 1; i >= 0; i--) {
            for (int j = C - 1; j >= 0; j--) {
                dp[i][j][0] = max(dp[i + 1][j][3], dp[i][j + 1][0]);
                for (int k = 1; k < 4; k++) {
                    dp[i][j][k] = max(dp[i][j + 1][k], dp[i][j][k - 1]);
                }

                if (v[i][j] > 0) {
                    for (int k = 1; k < 4; k++) {
                        dp[i][j][k] = max(dp[i][j][k], v[i][j] + max(dp[i][j + 1][k - 1], dp[i + 1][j][3]));
                        dp[i][j][k] = max(dp[i][j][k], dp[i][j][k - 1]);
                    }
                } 

            }
        }
        long ans = dp[0][0][3];
        out.println(ans);
    }

    static long max(long a, long b) {
        return a < b ? b : a;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = read(cbuf, 0, cbuf.length);
            } catch (IOException e) {}
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                back();
                break;
            }
        }
    }

    char[] s(final int N) {
        skip();
        char[] s = new char[N];
        for (int i = 0; i < s.length; i++) {
            s[i] = next();
        }
        return s;
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 588212
#include <iostream>
#include <set>

using namespace std;

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

    set<int> s;
    while (n--) {
        int a;
        cin >> a;
        if (s.find(a) == s.end()) {
            s.insert(a);
        } else {
            s.erase(a);
        }
    }

    cout << s.size() << endl;
}

Measured memory_bytes: 4864
#N = gets.to_i               # 単一整数
#a = gets.split.map(&:to_i)  # スペースで区切られた複数の整数
#a = N.times.map{gets.to_i}  # 縦に並んだ複数の整数。たまにある
#S = gets.chomp              # 文字列。chompを付けないと改行文字がついてくる

=begin
def solveABC177A
  D,T,S = gets.split.map(&:to_f)
  if D/S <= T 
    puts "Yes"
  else
    puts "No"
  end
end

def solveABC177B
  S = gets.chomp
  T = gets.chomp
  s_len = S.length
  t_len = T.length
  max_count = 0
  for i in 0..(s_len - t_len)
    match_count = 0
    extracted_str = S[i,t_len]
    for i2 in 0..(t_len-1)
      if extracted_str[i2] == T[i2]
        match_count += 1
      end
    end
    max_count = [match_count,max_count].max
  end
  puts t_len - max_count
end
=end

=begin
N = gets.to_i
An = gets.split.map(&:to_i)
Sn = [An[0]]
ans = 0
for i in 1..(An.length-1)
  Sn.push Sn[i-1] + An[i]
end

for i in 0..(An.length-1-1)
  ans += (An[i] * (Sn[N-1] - Sn[i])) % (10**9 + 7)
  ans %= (10**9 + 7)
end

puts ans
=end

N,M = gets.split.map(&:to_i)
$tree = []
for i in 0..(N-1)
  $tree.push []
end
Ms = []
for i in 0..(M-1)
  Ms.push gets.split.map(&:to_i).sort
  $tree[Ms[i][0]-1].push Ms[i][1]-1
  $tree[Ms[i][1]-1].push Ms[i][0]-1
end

$used_nums = [-1]*N # nil is non used

def search(start_number,next_number)
  if $used_nums[next_number] != -1
    return
  end
  $used_nums[next_number] = start_number

  for n in $tree[next_number]
    search(start_number,n)
  end
end

for i in 0..(N-1)  
  search(i,i)
end

max_count = [0]*N
for used_num in $used_nums
  max_count[used_num] += 1
end
puts max_count.max

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

int n, m, mx, midx;
int a[333][333], idx[333], cnt[333], used[333];

int main() {
  scanf("%d%d", &n, &m);
  for(int i=0; i < n; ++i) for(int j=0; j < m; ++j) scanf("%d", &a[i][j]);

  int ans = 1e9;
  while(true) {
    bool update = false;
    mx = 0, midx = 0;
    for(int i = 1; i <= m; ++i) cnt[i] = 0;
    for(int i = 0; i < n; ++i) {
      if(idx[i] == m) continue;
      else {
        ++cnt[a[i][idx[i]]];
        update = true;
      }
    }
    if(!update) break;

    for(int i = 1; i <= m; ++i) {
      if(mx < cnt[i]) {
        mx = cnt[i];
        midx = i;
      }
    }
    used[midx] = 1;
    for(int i = 0; i < n; ++i) while(used[a[i][idx[i]]]) ++idx[i];
    ans = min(ans, mx);
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        var S = ReadLine();
        WriteLine(S.Count(i => i == '+') - S.Count(i => i == '-'));
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

int main() {
  int a,b; cin>>a>>b;
  if(a<=b) cout<<a<<endl;
  else cout << a-1 << endl;
  return 0;
}


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

using namespace std;

// input
int n;

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

    cin >> n;

    if(n % 2 == 0){
        cout << (n/2) * (n/2) << "\n";
    }
    else{
        cout << floor(n/2) * (floor(n/2) + 1) << "\n";
    }
    
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,q;
	int box[100000];
	int x;
	int i;
	cin>>n;
	for(i=0;i<n;i++)	cin>>box[i];
	cin>>q;
	for(i=0;i<q;i++){
		cin>>x;
		auto it=equal_range(box,box+n,x);
		cout<<it.first-box<<" "<<it.second-box<<endl;
	}
	return 0;
}


Measured memory_bytes: 3484
#include<stdio.h>
#define MAXs 100000
#define MAXt 50000

int binarySearch(int S[], int key, int left, int right)
{

	while(left < right) {
		int mid = (left + right) / 2;
		if(S[mid] == key)
			return 1;
		else if(key < S[mid])
			right = mid;
		else
			left = mid + 1;
	}
	return 0;
}

int main()
{	
	int i;
	int s, q;
	int count = 0;
	int S[MAXs], T[MAXt];

	scanf("%d", &s);
	for(i = 0; i < s; ++i)
		scanf("%d", &S[i]);

	scanf("%d", &q);
	for (i = 0; i < q; ++i)
	{
		scanf("%d", &T[i]);
		count += binarySearch(S, T[i], 0, s);
	}

	printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 1180
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools, random
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right; sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n, k = wi()
s = s()

p = s[k - 1].lower()
t = ""
for i in range(n):
    if i == k - 1:
        t += p
    else:
        t += s[i]
print(t)

Measured memory_bytes: 7124
N,A,B=map(int,input().split())
S=input()

nowA=0
nowB=0

for s in S:
    if s=='c':
        print('No')
    elif s=='a':
        if nowA+nowB<A+B:
            print('Yes')
            nowA+=1
        else:
            print('No')
    else:
        if nowA+nowB<A+B and nowB<B:
            print('Yes')
            nowB+=1
        else:
            print('No')


Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int n;

int main(){
    int i = 1;
    while(cin >> n) {
        if(n == 0) break;
        cout << "Case " << i << ':' << ' ' << n << endl;
        i++;
    }

    return 0;
}


Measured memory_bytes: 3012
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    int ma=-10000000,mi=10000000,ma_p,mi_p;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>ma)ma=a[i],ma_p=i;
        if(a[i]<mi)mi=a[i],mi_p=i;
    }
    cout<<n*2-1<<endl;
    if(ma>-mi){
        for(int i=1;i<=n;i++)cout<<ma_p+1<<" "<<i<<endl;
        for(int i=1;i<n;i++)cout<<i<<" "<<i+1<<endl;
    }
    else{
        for(int i=0;i<n;i++)cout<<mi_p+1<<" "<<i+1<<endl;
        for(int i=n;i>1;i--)cout<<i<<" "<<i-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x7f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
const int mod = 1e9+7;
const int maxn = 1e3+5;
const double EPS = 1e-6;
using namespace std;
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b) return 0,printf("%d",c),0;
	if(a==c) return 0,printf("%d",b),0;
	if(b==c) return 0,printf("%d",a),0;
	return 0;
}


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

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

int V,k;

class edge
{
	public:

	int to;
	int cost;
	edge(int _to,int _cost)
	{
		this->to=_to;
		this->cost=_cost;
	}

};

vector<edge> G[107];
int d[107];

//s->tの最短距離
int dijkstra(int s,int t)
{
	priority_queue<P,vector<P>,greater<P> > que;
	fill(d,d+107,INF);
	d[s]=0;
	que.push(P(0,s));

	while(que.size())
	{
		P p=que.top();
		que.pop();

		if(p.sc==t) return d[t];

		rep(i,G[p.sc].size())
		{
			edge e = G[p.sc][i];
			if(d[e.to] > d[p.sc] + e.cost)
			{
				d[e.to] = d[p.sc] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
	return INF;
}

void solve()
{
	rep(i,107) G[i].clear();

	rep(i,k)
	{
		int a,b,c,e;
		cin>>a;
		if(a==0)
		{
			cin>>b>>c;
			int ans=dijkstra(b,c);
			if(ans==INF) cout<<"-1"<<endl;
			else cout<<ans<<endl;
		}
		else
		{
			cin>>b>>c>>e;
			G[b].pb(edge(c,e));
			G[c].pb(edge(b,e));
		}

	}


}

int main()
{
	while(cin>>V>>k)
	{
		if(V==0&&k==0) return 0;
		solve();
	}
		return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
    const int p = 10;
   const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
    const int p = 179;
   const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")`

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int r;
    cin >> r;
    cout << fixed << setprecision(10) << PI * (ld)r * 2.0;
}
/*

*/


Measured memory_bytes: 3780
#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>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}


#include <iostream>

int main()
{
    vector<vector<char> > c((3), vector<char>(3));

    cin >> c[0][0] >> c[0][1] >> c[0][2];
    cin >> c[1][0] >> c[1][1] >> c[1][2];
    cin >> c[2][0] >> c[2][1] >> c[2][2];

    cout << c[0][0] << c[1][1] << c[2][2] << endl;

}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int k;cin>>k;
    if(k%2){
        cout<<(k/2)*(k/2+1)<<endl;
    }
    else{
        cout<<(k/2)*(k/2)<<endl;
    }
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
 
K, N, *A = map(int, read().split())
 
max_distance = K + (A[0] - A[-1])
 
for i in range(1, N):
  max_distance = max(max_distance, A[i] - A[i - 1])
  
print(K - max_distance)

Measured memory_bytes: 20448
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
 
typedef long long ll;
 
 
int main(){
	int n;
	string s;
	cin >> n;
	cin >> s;
	
	if(n %2== 1){
		cout << "No" <<endl;
		return 0;
	}
	
	int nn = n/2;
	bool f = true;
	for(int i=0;i<nn;i++){
//		cout << s[i] << " " << s[i+nn] <<endl;
		if(s[i] != s[i+nn]){
			f = false;
			break;
		}
	}
	
	if(f) cout << "Yes" <<endl;
	else cout << "No" <<endl;
	
	return 0;
}



Measured memory_bytes: 256
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")



n=II()
l=LI()

cnt = 0
for i in range(1, n+1):
    if l[i-1] != i:
        cnt+=1
if cnt == 0 or cnt == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)

    string A[1005];
    int h,w;
    int kyori[1005][1005];
    bool visit[1005][1005];








signed main(){

    cin >> h >> w;
    string t;
    REP(i,w + 2) t += "a";
    A[0] = t;
    A[h + 1] = t;
    REP(i,h){
        string s;
        A[i + 1] = "a";
        cin >> s;
        A[i + 1] += s;
        A[i + 1] += "a";
    }



    REP(i,h + 2) REP(j,w + 2){
        if(i == 0  or i == h + 1 or j == 0 or j == w + 1 ) visit[i][j] = true;
        else visit[i][j] = false;
        kyori[i][j] = INF;
    }

    int num = 0;
    vector<pair<int,int>> now,next_vec;
    FOR(i,1,h +1){
        FOR(j,1,w + 1){
            if(A[i][j] == '#'){
                now.push_back(mp(i,j));
                num ++;
                visit[i][j] = true;
                kyori[i][j] = 0;
            }
        }
    }
    int tmp = 0;
    while(num < h * w){
        tmp ++;
        itrfor(itr,now){
            int x = itr->fi;
            int y = itr->se;
            if(not visit[x + 1][y]){
                kyori[x + 1][y] = tmp;
                visit[x+1][y] = true;
                next_vec.push_back(mp(x + 1,y));
                num ++;
            }
            if(not visit[x-1][y]){
                kyori[x-1][y] = tmp;
                next_vec.push_back(mp(x -1,y));
                visit[x-1][y] = true;
                num ++;
            }
            if(not visit[x][y+1]){
                kyori[x][y+1] = tmp;
                next_vec.push_back(mp(x ,y+1));
                visit[x][y+1] = true;
                num ++;
            }
            if(not visit[x][y-1]){
                kyori[x][y-1] = tmp;
                next_vec.push_back(mp(x ,y-1));
                visit[x][y-1] = true;
                num ++;
            }

        }
        now = next_vec;
        next_vec.clear();
    }






    int res = 0;
    FOR(i,1,h + 1){
        FOR(j,1,w +1){
        res = max(res,kyori[i][j]);
        }
            }
    cout << res << endl;


}


Measured memory_bytes: 34028