akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

MOD = 1000000007


def prime_generator(limit):
    yield 2
    n, h = 3, {}
    while n <= limit:
        m = n
        if n in h:
            b = h[n]
            m += 2 * b
            while m in h:
                m += 2 * b
            h[m] = b
            del h[n]
        else:
            m += 2 * n
            while m in h:
                m += 2 * n
            h[m] = n
            yield n
        n += 2


def solve(n):
    ps = list(prime_generator(n))
    prev = defaultdict(int)
    for i in range(1, n):
        f = prev.copy()
        k = i + 1
        for p in ps:
            while k % p == 0:
                k //= p
                f[p] += 1
            if k == 1:
                break
        prev = f

    ans = 1
    for c in prev.values():
        ans *= c + 1
        ans %= MOD
    return ans


print(solve(int(input())))


Measured memory_bytes: 3316
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		String s;
		Scanner scan = new Scanner(System.in);
		s = scan.nextLine();
		scan.close();
		char[] c = s.toCharArray();
		for(int i=0;i<c.length;i++){
			if(c[i]>=65&&c[i]<=90){
				c[i]+=32;
			}
			else if(c[i]>=97&&c[i]<=122){
				c[i]-=32;
			}
			System.out.print(c[i]);
		}
		System.out.println();
	}
}


Measured memory_bytes: 26804
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> a;
    for(auto i=0;i<n;i++)
    {
        ll o;
        cin>>o;
        a.push_back(o);
    }
    sort(a.begin(),a.end());
    ll sum=0,i=0;;
    while(k--)
    {
        sum+=a[i];
        i++;
    }
    cout<<sum;
}

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

using namespace std;
int main(void)
{
	vector<string> arr(100);
	for (int i = 0; i < 100; i++)
	{
		if (i%7 == 1)
		{
			arr[i] = "fri";
		}
		if (i % 7 == 2)
		{
			arr[i]="sat";
		}
		if (i % 7 == 3)
		{
			arr[i] =  "sun" ;
		}
		if (i % 7 == 4)
		{
			arr[i] = "mon";
		}
		if (i % 7 == 5)
		{
			arr[i] = "tue";
		}
		if (i % 7 == 6)
		{
			arr[i] = "wed";
		}
		if (i % 7 == 0)
		{
			arr[i] = "thu" ;
		}
	}
	int a; cin >> a;
	cout << arr[a] << "\n";
}




Measured memory_bytes: 3180
'''
最大の繰り返し回数はN // K + 1
上記の回数回して結果のリストを作成し、
最小値を出力する

興味があるのは、差が正から負へ変わった瞬間の２つの値のみ

NをKで割った商をKにかけた数を引いた数とそれにKを一回足した数
上記２つの数の内小さい方を出力すればよい
'''
import math

N, K = map(int, input().split())

num1 = abs(N - math.ceil(N // K) * K)
num2 = abs(num1 - K)

print(num1) if num1 < num2 else print(num2)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll             long long int
#define lb             lower_bound
#define ub             upper_bound
#define fi             first
#define mp             make_pair
#define vll            vector<ll>
#define se             second
#define sz             size()
#define mod            1000000007
#define endl           "\n"
#define fast           ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define allr(v)        v.rbegin(),v.rend()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
               const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.second >b.second);
    }
    else
        return (a.fi<b.fi);
}

int main()
{
fast;
int q=1;
//cin>>q;
while(q--)
{
ll n,k,sum=0,ans=0,a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
  if(a==0)
    cout<<1<<endl;
  else if(b==0)
    cout<<2<<endl;
  else if(c==0)
    cout<<3<<endl;
  else if(d==0)
    cout<<4<<endl;
  else cout<<5<<endl;

}
return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int func(int y,int m, int d) {
  int yy = 1;
  int mm = 1;
  int dd = 1;
  REP(i,INF) {
    //cout << yy << " " << mm << " " << dd << endl;
    if (yy==y&&mm==m&&dd==d) return i+1;
    dd++;
    if (yy%3!=0 && mm%2==0) {
      if (dd == 20) {
        mm++;
        dd = 1;
      }
    } else {
      if (dd == 21) {
        mm++;
        dd = 1;
      }
    }
    if (mm == 11) {
      mm = 1;
      yy++;
    }
  }
}
int main() {
  int n;
  cin >> n;
  int a = func(1000,1,1);
  while(n--) {
    int y,m,d;
    cin>>y>>m>>d;
    cout << a-func(y,m,d) << endl;
  }
}

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

// n以下の素数テーブル
vector<bool> prime_table(int n) {
	vector<bool> prime(n + 1, true);
	if(n >= 0) prime[0] = false;
	if(n >= 1) prime[1] = false;
	for(int i = 2; i * i <= n; i++) {
		if(!prime[i]) continue;
		for(int j = i + i; j <= n; j += i) {	// j = i * iで良い？
			prime[j] = false;
		}
	}
	return prime;
}

int main() {
	int q;
	cin >> q;
	vector<int> l(q), r(q);
	rep(i, q) cin >> l[i] >> r[i];
	
	auto prime = prime_table(100000);
	vector<int> tot(100001);
	
	rep(i, prime.size()) {
		if(i<=2) continue;
		if(prime[i]) {
			if(prime[(i+1)/2]) {
				tot[i]++;
			}
		}
	}
	rep(i, tot.size()-1) {
		tot[i+1] += tot[i];
	}
	
	rep(i, q) {
		cout << tot[r[i]] - tot[l[i]-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    n %= 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) puts("hon");
    else if (n == 0 || n == 1 || n == 6 || n == 8) puts("pon");
    else puts("bon");
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>

#define MAX 100
#define N 100
#define WHITE 0
#define GRAY  1
#define BLACK 2

int isEmpty();
int isFull();
void enqueue(int);
int dequeue();
void bfs(int,int);

int head = 0, tail = 0;
int que[MAX];
int G[N][N];
char color[N];
int d[N];
int f[N];
int main()
{
    int n,i,k,u,v,j;
    
    scanf("%d", &n);
    
    for(i=0;i<n;i++)
    {
        scanf("%d%d", &u, &k);
        for(j=0;j<k;j++)
        {
            scanf("%d", &v);
            G[u-1][v-1]=1;
        }
    }
    
    bfs(0,n);
    
    for(i=0;i<n;i++)
    {
        printf("%d %d\n", i+1, d[i]);
    }
    return 0;
}

int isEmpty()
{
    return head == tail;
}
int isFull()
{
    return head == (tail+1)%MAX;
}
void enqueue(int x)
{
    if(isFull())
    {
        printf("OVF\n");
    }
    que[tail] = x;
    if(tail+1 == MAX)
    {
        tail = 0;
    }
    else
    {
        tail++;
    }
}
int dequeue()
{
    if(isEmpty())
    {
        printf("UNF\n");
    }
    int x = que[head];
    if(head+1 == MAX)
    {
        head = 0;
    }
    else
    {
        head++;
    }
    return x;
}
void bfs(int s, int n)
{
    int i,u;
    for(i=0;i<n;i++)
    {
        color[i]=WHITE;
        d[i]=-1;
    }
    color[s]=GRAY;
    d[s]=0;
    enqueue(s);
    while(!isEmpty())
    {
        u=dequeue();
        for(i=0;i<n;i++)
        {
            if(G[u][i])
            {
                if(color[i]==WHITE)
                {
                    color[i]=GRAY;
                    d[i]=d[u]+1;
                    enqueue(i);
                }
            }
        }
        color[u]=BLACK;
    }
}

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

ll slimes(ll arr[], int n){

    vector<vector<ll>> dp(n, vector<ll>(n, 0));
    vector<ll> prefix(n+1);
    prefix[0] = 0;
    for(int i=1; i<=n; i++)
        prefix[i] = prefix[i-1] + arr[i-1];

    for(int l=2; l<=n; l++){
        for(int i=0; i<=n-l; i++){
            int j = i+l-1;
            ll minCost = 1LL<<60;
            for(int p=i; p<j; p++){
                ll currCost = dp[i][p] + dp[p+1][j] +
                              (prefix[p+1]-prefix[i]) +
                              (prefix[j+1]-prefix[p+1]);
                if(currCost < minCost)
                    minCost = currCost;
            }
            dp[i][j] = minCost;
        }
    }
    return dp[0][n-1];
}

int main()
{
 int n;
 cin>>n;
 ll arr[n];
 for(int i=0; i<n; i++)
     cin>>arr[i];
 ll ans = slimes(arr, n);
 cout<<ans;
 return 0;
}



Measured memory_bytes: 4556
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int gcd(int a,int b){
  if(a%b==0)return b;
  return gcd(b,a%b);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll n,x,ans=0;
  cin >> n >> x;
  rep(i,n){
    int y;
    cin >> y;
    y-=x;
    if(y<0)y=-y;
    ans=gcd(ans,y);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,a,ans;
  int i;
  while(1){
    cin >> n;
    if(n==0) break;
    ans=0;
    for(i=0;i<n/4;++i){
      cin >> a;
      ans += a;
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
    int N,D;
    std::cin>>N>>D;
    std::vector<std::vector<int> > X(N,std::vector<int>(D));
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < D; ++j){
            std::cin >> X[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < N; ++i){
        for(int j = i+1; j < N; ++j){
            int norm = 0;
            for(int k = 0; k < D; ++k){
                int diff = abs(X[i][k] - X[j][k]);
                norm += diff * diff;
            }
            bool flag = false;
            for(int k = 0; k <= norm; ++k){
                if(k * k == norm){
                    flag = true;
                }
            }
            if(flag) ++ans;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int L = keyboard.nextInt();
		int Q = keyboard.nextInt();
		String N = keyboard.next();
		
		String[]moji = N.split("");
		int[]wa = new int[L+1];
		
		for(int i = 0; i<L-1; i++) {
			if(moji[i].equals("A")) {
				if(moji[i+1].equals("C")) {
					wa[i+2] = 1;
				}
			}
		}
		
		for(int j = 1; j<L+1; j++) {
			wa[j] = wa[j] + wa[j-1];
		}
		
		for(int k = 0; k<Q; k++) {
			int a = keyboard.nextInt();
			int b = keyboard.nextInt();
			if(a != 1 && moji[a-1].equals("C") && moji[a-2].equals("A")) {
				System.out.println(wa[b]- wa[a-1]-1);
			}else{
				System.out.println(wa[b]- wa[a-1]);
			}
		}
		keyboard.close();	
	}
}


Measured memory_bytes: 113820
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if (a==b&&b==c)
{
    cout<<1<<endl;
}
else if (a==b||b==c||c==a)
{
    cout<<2<<endl;
}

else
{
    cout<<3<<endl;
}


    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			System.out.println(Integer.toString(N).contains("7") ? "Yes" : "No");
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 32868
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int64 INF  = 0x3f3f3f3f3f3f3f3f;
const int MOD  = 1000000007;
const int MAXN = 200005;
const int MAXL = 1000;

int v[MAXN], w[MAXN], dp[MAXN][MAXL];

void run() {
    int a[6], ans = -1;
    for(int i=1;i<=5;i++) {
        cin >> a[i];
        if(a[i]==0) ans = i;
    }
    cout << ans << endl;
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}

Measured memory_bytes: 3636
#include<stdio.h>
#define N 5
int main(void){
	char s[N];
  	scanf("%s",&s);
  	if (s[1] == 'B')	
      	printf("ARC\n");
  	else if(s[1] == 'R')
      	printf("ABC\n");
  
  	return 0;
}

Measured memory_bytes: 1580
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    string S, T;
    cin >> S >> T;

    ll cnt = 0;
    rep(i, S.length()) {
        if (S[i] != T[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3816
#include  <functional>
#include  <algorithm>
#include  <exception>
#include  <stdexcept>
#include  <streambuf>
#include  <iterator>
#include  <string.h>
#include  <stdlib.h>
#include  <typeinfo>
#include  <valarray>
#include  <iostream>
#include  <sstream>
#include  <istream>
#include  <stdio.h>
#include  <climits>
#include  <clocale>
#include  <complex>
#include  <csetjmp>
#include  <csignal>
#include  <cstdarg>
#include  <cstddef>
#include  <ctype.h>
#include  <cassert>
#include  <cstdlib>
#include  <utility>
#include  <cstring>
#include  <numeric>
#include  <ostream>
#include  <cwctype>
#include  <fstream>
#include  <iomanip>
#include  <math.h>
#include  <bitset>
#include  <cctype>
#include  <string>
#include  <vector>
#include  <limits>
#include  <locale>
#include  <memory>
#include  <cerrno>
#include  <time.h>
#include  <iosfwd>
#include  <cfloat>
#include  <cstdio>
#include  <cwchar>
#include  <cmath>
#include  <ctime>
#include  <deque>
#include  <queue>
#include  <stack>
#include  <list>
#include  <ios>
#include  <map>
#include  <set>
#include  <new>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
using namespace std;
const int maxn=200005;
ll n,d,k;
ll a[maxn];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]-=i;
    }
    sort(a+1,a+n+1);
    ll b=0;
    if(n%2==0)
    b=(a[n/2]+a[n/2+1])/2;
    else
    b=a[n/2+1];
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=ans+abs(b-a[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
function main(input) {
    var num = input.split(" ");
    var result = parseInt(num[0]) * parseInt(num[1]);
    if(result % 2 == 0){
        console.log("Even")
    }else{
        console.log("Odd");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     debug(i)            cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    int n; cin>>n;
    cout<<(n/500)*1000+((n%500)/5)*5<<'\n';
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

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

#define ll long long
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf (int)(1e18)
#define ps(x, y) fixed << setprecision(y) << x
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(p) p.begin(), p.end()
#define ub(a, b) upper_bound(all(a), b)
#define lb(a, b) lower_bound(all(a), b)
#define PI 3.14159265
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void run()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int32_t main()
{
    run();
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(all(a));
    int ans = 0;
    for (int i = 0; i < k; i++)
    {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3668
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
        int m =sc.nextInt();
        int r;
        for(;;){
            r=n%m;
            if(r==0){
            	System.out.println(m);
            	break;
            }
            n=m;
            m=r;
        }

    }
}


Measured memory_bytes: 26240
import sys
sys.setrecursionlimit(10 ** 9)
N, A, B, C = map(int, input().split())
l_list = [int(input()) for _ in range(N)]


def dfs(now, a, b, c):
    if now == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else float("inf")
    res0 = dfs(now + 1, a, b, c)
    res1 = dfs(now + 1, a + l_list[now], b, c) + 10
    res2 = dfs(now + 1, a, b + l_list[now], c) + 10
    res3 = dfs(now + 1, a, b, c + l_list[now]) + 10
    return min(res0, res1, res2, res3)


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const long M = 1e9+7;

int main() {
    int H, W;
    cin >> H >> W;
    char a[H][W];
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            cin >> a[i][j];
        }
    }
    long ans[H+1][W+1];
    for(int i=H; i>=0; i--) {
        for(int j=W; j>=0; j--) {
            if(i == H || j == W) {
                ans[i][j] = 0;
                if(i == H && j == W-1) ans[i][j] = 1;
            } else if(a[i][j] != '#') {
                ans[i][j] = ans[i+1][j]%M + ans[i][j+1]%M;
            } else {
                ans[i][j] = 0;
            }
        }
    }
    
    cout << (ans[0][0])%(M);
    return 0;
}


Measured memory_bytes: 9088
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();int k=in();
	int m=n-k+1;
	vector<int> a(n);
	for(auto &i:a)i=in();
	vector<pair<int,int>> p(m);
	for(int i=0;i<m;i++)
	{
		p[i]={a[i],a[i+k-1]};
	}
	for(int i=0;i<m-1;i++)
	{
		if(p[i].first>=p[i+1].second)puts("No");
		else puts("Yes");
	}
	
}

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

typedef long long ll;

/* メモリ食い過ぎ注意 */
// #define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    string s, t;
    cin >> s >> t;

    int arr[100] = {};
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == '?' || s[i] == t[0])
        {
            int cnt = 1;
            for (int j = i + 1; j < s.length(); j++)
            {
                if (s[j] != '?' && s[j] != t[j - i])
                    break;
                cnt++;
            }
            arr[i] = min(cnt, (int)(t.length()));
        }
    }

    priority_queue<string, vector<string>, greater<string>> q;
    for (int i = 0; i < s.length(); i++)
    {
        if (arr[i] >= t.length())
        {
            string tmp = s;
            for (int j = 0; j < tmp.length(); j++)
            {
                if (j >= i && j < i + arr[i])
                    tmp[j] = t[j - i];
                else if (tmp[j] == '?')
                {
                    tmp[j] = 'a';
                }
            }
            q.push(tmp);
        }
    }

    // while (q.size() > 1)
    // {
    //     // cout << q.top() << endl;
    //     q.pop();
    // }
    if (q.size())
        cout << q.top() << endl;
    else
        cout << "UNRESTORABLE" << endl;
}

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

int main(){

    string S;
    cin >> S;
    string T = "";
    T += S[0];
    T += S[1];
    T += S[2];

    cout << T << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    
    int main() {
    
     
     int a,b,c;
     cin >> a >> b >> c;
     
     int count = 0;
     
     for(int i = a; i <= b; i++){
     	 if(c%i==0)	count++;
     	 
     }
     
     cout << count << '\n';
     return 0;
    }


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 N, M;
    cin >> N >> M;
    Vec<Vec<i32>> L(N + 1, Vec<i32>());
    Vec<bool> V(N + 1, false);
    for (u32 i = 0; i < M; i++) {
        i32 A, B;
        cin >> A >> B;
        L[A].push_back(B);
        L[B].push_back(A);
    }
    queue<i32> d;
    d.push(1);
    V[0] = V[1] = true;
    Vec<i32> ans(N + 1, 0);
    while(!d.empty()) {
        i32 current = d.front();
        for (i32 i = 0; i < L[current].size(); i++) {
            i32 next = L[current][i];
            if (V[next]) continue;
            ans[next] = current;
            d.push(next);
            V[next] = true;
        }
        d.pop();
    }
    bool exists = true;
    for (u32 i = 0; i <= N; i++) {
        if (!V[i]) exists = false;
    }
    if (!exists) {
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
    for (u32 i = 2; i <= N; i++) {
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 10260
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	bool prime[1000000];
	rep(i,1000000)prime[i]=true;
	prime[0]=prime[1]=false;
	for(long i=2;i<1000L;i+=1L){
		for(long j=i*2;j<1000000;j+=i){
			prime[j]=false;
		}
	}
	long n;
	while(cin>>n){
		long cnt=0;
		rep(i,n+1){
			if(prime[i])cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 2136
#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 x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

signed main(){
  string S;
  cin >> S;
  if(S.size() == 3)cout << S[2] << S[1] << S[0] << endl;
  else cout << S << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n, m;
    cin >> n >> m;
    int time = m*1900+(n-m)*100;
    cout << time*pow(2,m);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200100;
pair<int,int>a[N],s[N];
int R,C,n,cnt;
int id(int x,int y){
	if(!x)return y;if(x==R)return -R-y;
	if(!y)return -x;if(y==C)return C+x;
	return INT_MAX;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>R>>C>>n;
	for(int i=1;i<=n;++i){
		int x_1,x_2,y_1,y_2;cin>>x_1>>y_1>>x_2>>y_2;
		int x=id(x_1,y_1),y=id(x_2,y_2);
		if(x!=INT_MAX&&y!=INT_MAX){
			a[++cnt]=make_pair(x,i);
			a[++cnt]=make_pair(y,i);
		}
	}
	sort(a+1,a+cnt+1);
	int t=0;
	for(int i=1;i<=cnt;++i)
		if(!t||s[t].second!=a[i].second)s[++t]=a[i];
		else --t;
	cout<<(t?"NO\n":"YES\n");
	return 0;
}


Measured memory_bytes: 2432
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

N, X = LI()
L = LI()

D = 0
count = 1
for i in range(N):
    D = D+L[i]
    if (D <= X):
        count += 1
    else:
        break
print(count)

Measured memory_bytes: 39152
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)


int main() {
  int n;
  cin >> n;
  vector<int> n1, n2;
  rep(i, n){
      int num; cin >> num;
      if(i % 2 == 0) n1.push_back(num);
      else n2.push_back(num);
  }
  if(n % 2 == 0){
      reverse(all(n2));
      rep(i, n2.size()) cout << n2[i] << " ";
      rep(i, n1.size()){
          cout << n1[i];
          cout << " ";
          }
  } else{
      reverse(all(n1));
      rep(i, n1.size()) cout << n1[i] << " ";
      rep(i, n2.size()){
        cout << n2[i];
        cout << " ";
      }
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll N,D; cin >> N >> D;

    cout << (N-1)/(2*D+1)+1 << endl;

    return 0;

}

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

#define pb push_back
#define ss second
#define ff first
#define N 1000006
#define inf 1000000009
#define ll long long
#define mid(a,b) (a+b)/2
#define pii pair<int,int>

using namespace std;

const int mod = 1e9+7;
int a[N],lc[N],x,cnt,n,pr;
ll ans,jog,l;
int b[N];
vector <int> v;

ll pw(ll a,ll b){
	if(b == 0) return 1;
	ll x = pw(a,b / 2);
	if(b % 2) return (((x * x) % mod)*a)%mod;
	return (x * x) % mod;
}

int main()
{
	for(int i = 2;i <= 1e6;i++) b[i] = i;
	for(int i = 2;i*i <= 1e6;i++)
		if(b[i] == i) for(int j = i * i;j <= 1e6;j += i) if(b[j] == j) b[j] = i;
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
		x = a[i],cnt = 0,pr = 0;
		while(x > 1){
			if(b[x] != pr){
				lc[pr] = max(lc[pr],cnt);
				cnt = 0;
			}
			pr = b[x];
			x /= b[x];
			cnt++;
		}
		lc[pr] = max(lc[pr],cnt);
	}
	l = 1;
	for(int i = 2;i <= 1e6;i++)
		if(lc[i]) l = (l * pw(i,lc[i])) % mod;
	for(int i = 1;i <= n;i++){
		ans = (ans + (l * pw(a[i],mod - 2)) % mod) % mod;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 8448
use proconio::input;

fn main() {
    input! {
        n: usize,
    };
    let mut dp = vec![vec![vec![0_i64; 2]; 2]; n + 1];
    dp[0][0][0] = 1;
    for i in 0..n {
        for j in 0..2 {
            for k in 0..2 {
                for d in 0..=9 {
                    let j_next = if j == 1 || d == 0 { 1 } else { 0 };
                    let k_next = if k == 1 || d == 9 { 1 } else { 0 };
                    dp[i + 1][j_next][k_next] += dp[i][j][k];
                    dp[i + 1][j_next][k_next] %= 1_000_000_007;
                }
            }
        }
    }
    let ans = dp[n][1][1];
    println!("{}", ans);
}


Measured memory_bytes: 150316
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int N=51,MOD=1e9+7;
LL dp[N][N][N*N]; // dp(i,j,k): i之前,保留j個,分數為k

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,K;
    cin >> n >> K;
    dp[0][0][0]=1;
    REP(i,n) REP1(j,0,i) REP1(k,0,K) {
        // i-i
        dp[i+1][j][k+j*2]+=dp[i][j][k]; dp[i+1][j][k+j*2]%=MOD;
        // i-x i-x
        dp[i+1][j+1][k+(j+1)*2]+=dp[i][j][k]; dp[i+1][j+1][k+(j+1)*2]%=MOD;
        // i-j i-x
        dp[i+1][j][k+j*2]+=dp[i][j][k]*j*2; dp[i+1][j][k+j*2]%=MOD;
        // i-j i-j
        if ( j ) {
            dp[i+1][j-1][k+(j-1)*2]+=dp[i][j][k]*j*j; dp[i+1][j-1][k+(j-1)*2]%=MOD;
        }
    }

    cout << dp[n][0][K] << '\n';
    return 0;
}


Measured memory_bytes: 30616
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<set>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<stack>
#include<tuple>
#include<utility>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using namespace std;

int main(){
  ll n,m,min = 100000, max = 0;
  cin >> n >> m;
  rep(i,m){
    ll l,r;
    cin >> l >> r;
    if(max < l){
      max = l;
    }
    if(min > r){
      min = r;
    }
  }
  if(max <= min){
    cout << min - max + 1;
  }else{
    cout << 0;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(_, _, x) = sc.nextLine.split(" ").map(_.toInt)
    val targetArray = sc.nextLine.split(" ").map(_.toInt)
    val (small, big): (Array[Int], Array[Int]) = targetArray.partition(p => p < x)
    println(Array(small.length, big.length).min)
  }
}


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

int main() {
    int a, b;
    cin >> a >> b;

    string a_b = "";
    rep(i, b) a_b += to_string(a);

    string b_a = "";
    rep(i, a) b_a += to_string(b);

    if (a_b < b_a) cout << a_b << endl;
    else cout << b_a << endl;
    return 0;
}


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

class Program
{
    static int N, M;
    static bool[][] ConnectionTable;
    static bool[] VisitedTable;

    public static void Main(string[] args)
    {
        checked
        {
            N = Input.NextInt();
            M = Input.NextInt();

            ConnectionTable = new bool[N][];
            for (int i = 0; i < N; i++)
            {
                ConnectionTable[i] = new bool[N];
            }

            for (int i = 0; i < M; i++)
            {
                var s = Input.LineInt();
                var a = s[0] - 1;
                var b = s[1] - 1;
                ConnectionTable[a][b] = true;
                ConnectionTable[b][a] = true;
            }

            VisitedTable = new bool[N];

            NumberOfFound = 0;
            F(0, 0);

            Console.WriteLine(NumberOfFound);
        }
    }

    static int NumberOfFound;

    static void F(int nodeNo, int depth)
    {
        Debug.Assert(VisitedTable[nodeNo] == false);

        if (depth == N - 1)
            NumberOfFound++;

        VisitedTable[nodeNo] = true;
        var p = ConnectionTable[nodeNo];
        for (int i = 0; i < N; i++)
        {
            if (p[i] && !VisitedTable[i])
            {
                F(i, depth + 1);
            }
        }
        VisitedTable[nodeNo] = false;
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13524
s = list(input())
n = len(s)

def kaibun(st):
  sta = list()
  for k in range(len(st)//2):
    sta.append(st[k])
  for k in range(len(st)//2):
    if st[-(-len(st)//2)+k] != sta.pop():
      return False
  return True

if kaibun(s) == False:
  print('No')
elif kaibun(s[:(n-1)//2]) == False:
  print('No')
elif kaibun(s[(n+3)//2-1:]) == False:
  print('No')
else:
  print('Yes')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long n,a,b,p[100001],dp[100001];
int main()
{
	cin>>n>>a>>b;
	for (long long i=1;i<=n;i++)
	{
	cin>>p[i];
	dp[i]=99999999999999;
	}
	dp[1]=0;
	for (long long i=2;i<=n;i++)
	{
	dp[i]=min(dp[i],dp[i-1]+(p[i]-p[i-1])*a);
	dp[i]=min(dp[i],dp[i-1]+b);
	}
	cout<<dp[n];
	return 0; 
}

Measured memory_bytes: 1792
N = int(input())
s = input()
for t in ["SS","SW","WS","WW"]:
    for i in range(1,N-1):
        if (s[i] =="o" and t[i]=="S") or (s[i]=="x" and t[i]=="W"):
            t += t[i-1]
        else:
            if t[i-1] =="S":
              t += "W"
            else:
              t +="S"
    if (t[N-2]==t[0] and ((s[N-1]=="o" and t[N-1]=="S") or (s[N-1]=="x" and t[N-1]=="W"))) or (t[N-2]!=t[0] and ((s[N-1]=="o" and t[N-1]=="W") or (s[N-1]=="x" and t[N-1]=="S"))):
         if (t[N-1]==t[1] and ((s[0]=="o" and t[0]=="S") or (s[0]=="x" and t[0]=="W"))) or (t[N-1]!=t[1] and ((s[0]=="o" and t[0]=="W") or (s[0]=="x" and t[0]=="S"))):
             print(t)
             break
else:
    print(-1)

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

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

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

int main() {
	ll H, W; cin >> H >> W;
	if (H == 1 || W == 1) { cout << 1 << endl; }
	else if (H % 2 == 0 || W % 2 == 0) { cout << H * W / 2 << endl; }
	else {
		cout << H * W / 2 + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
const int size = 26;
using namespace std;

int main(int argc, char const *argv[]) {
  string line;
  vector<int> v(size,0);
  while(cin >> line){
    for (auto c : line){
      if(isalpha(c)) v[tolower(c)-'a']++;
    }
  }
  char a='a';
  for(auto n:v){
    cout<<a++<<" : "<<n<<endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>

typedef long long ll;

constexpr long long INFLL = 1e18;

using namespace std;

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

    ll temp = 26;
    ll count = 0;
    vector<ll> v;
    v.push_back(temp);

    while (temp < n)
    {
        count++;
        temp = temp * 26 + 26;
        v.push_back(temp);
    }
    vector<char> ans(count + 1);
    int x;
    for (int i = count; i >= 0; i--)
    {
        x = n % 26;
        if (x > 0)
        {
            ans.at(i) = (char)(97 + x - 1);
            n = n / 26;
        }
        else
        {
            ans.at(i) = 'z';
            n = n / 26 - 1;
        }
    }

    for (int i = 0; i <= count; i++)
    {
        cout << ans.at(i);
    }
    cout << endl;

    return 0;
}

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

int main() {
	int n, k; cin >> n >> k;
	vector<int> x(n);
	for (int i = 0; i < n; i++) cin >> x[i];

	int ans = 0;
	for (int i = 0; i < x.size(); i++) {
		ans += min(x[i] * 2, (k - x[i]) * 2);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
#define ll long long
ll N,S,len;
ll f(ll b,ll n)
{
	if(n<b)
	return n;
	else
	return f(b,n/b)+n%b;
}
int main()
{
	cin >> N >> S;
	len=sqrt(N);
	if(2>len)
	len=2;
	
	for(ll i=2; i<=len; i++)
	{
		if(f(i,N)==S)
		{	
			cout << i << "\n";
			return 0;
		}	
	}
	for(ll i=len-1; i>=1; i--)
	{
		
	 	ll x=N/i,k=S-i-N%x; 
	 	if(x-k/i<=0)
	 	continue;
		if(k%i==0&&S==i+N%(x-k/i)&&x-k/i>k/i)
	 	{
	 		cout << x-k/i;
		 	return 0;
	 	}
	}
	if(S==N)
	cout << N+1;
	else
	cout << -1 << "\n";	
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int p[n];
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    int k=0;
    for(int i=0;i<n;i++)
    {
        if(p[i]!=i+1)
        k++;
    }
    if(k<=2)
    cout<<"YES\n";
    else
    cout<<"NO\n";
}

Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    string s ;
    cin >> s;
    for(int i=0;i<s.size();i++){
        for(int j=1;j<=s.size()-i;j++){
            string t = s.substr(i,j);
            if(t.at(0) == 'C' && t.at(t.size()-1) == 'F'){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

 

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  pair<pair<string,int>,int> r[110];
  rep(i,n){
    string s;
    int a;
    cin >> s >> a;
    r[i]=make_pair(make_pair(s,-a),i+1);
  }
  sort(r,r+n);
  rep(i,n) cout << r[i].se << endl;
  return 0;
}


Measured memory_bytes: 256