akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main (){
	int L,R,d;
	scanf ("%d %d %d", &L, &R, &d);
	int cek=0;
	for (int i=L; i<=R; i++){
		if (i%d==0){
			cek++;
		}
	}
	printf("%d\n", cek);
	return 0;
}

Measured memory_bytes: 1736
#include <iostream>
using namespace std;
int w, h, n, x, y, a, s, v[105][105];
int main() {
	int i, j;
	cin>>w>>h>>n;
	while(n--) {
		cin>>x>>y>>a;
		if(a==1) for(i=0; i<h; i++) for(j=0; j<x; j++) v[i][j] = 1;
		if(a==2) for(i=0; i<h; i++) for(j=x; j<w; j++) v[i][j] = 1;
		if(a==3) for(i=0; i<y; i++) for(j=0; j<w; j++) v[i][j] = 1;
		if(a==4) for(i=y; i<h; i++) for(j=0; j<w; j++) v[i][j] = 1;
	}
	for(i=0; i<h; i++) for(j=0; j<w; j++) s += !v[i][j];
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007

int main()
{
    long long int n;
    cin >> n;
    long long int ans = 0;
    for (long long int i = 1; i <= n; i++)
    {
        ans += i * (n - i + 1);
    }
    for (long long int i = 0; i < n - 1; i++)
    {
        long long int u, v;
        cin >> u >> v;
        if (u > v)
            swap(u, v);
        ans -= u * (n - v + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
import sys
input = sys.stdin.buffer.readline
from fractions import gcd

def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    
    count = 0
    a = A[0]
    while a%2 == 0:
      a //= 2
      count += 1
      
    for num in A:
      c = 0
      while num%2 == 0:
        num //= 2
        c += 1
      if c != count:
        print(0)
        exit()
    
    def lcm(a):
        x = a[0]
        for i in range(1,N):
            x = (x*a[i]) // gcd(x,a[i])
        return x
    
    x = lcm(A)
    print(M//(x//2)-M//x)
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 14488
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b;
    cin >> a >> b ;
    //*/
    
    a %= 500;

    /*
    vector<int> vec(4);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    */
    
    ///*
    if(a <= b){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    //*/
    
    //cout << a << endl;

    return 0; 
}


Measured memory_bytes: 3576
#include <iostream>
#define N 3
 
using namespace std;
 
int main()
{
  int a[N][N];
  
  for(int i = 0; i < N; i++)
    for(int j = 0; j < N; j++)
      cin >> a[i][j];
  
  int n, t;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> t;
    for(int j = 0; j < N; j++) {
      for(int k = 0; k < N; k++) {
        if(a[j][k] == t) {
          a[j][k] = 0;
        }
      }
    }
  }
  
  bool flag = true;
  for(int i = 0; i < N; i++) {
    if(a[i][i] != 0) {
      flag = false;
      break;
    }
  }
  if(flag) {
    cout << "Yes" << endl;
    return 0;
  }
  
  for(int i = 0; i < N; i++) {
    flag = true;
    for(int j = 0; j < N; j++) {
      if(a[i][j] != 0) {
        flag = false;
        break;
      }
    }
    if(flag) {
      cout << "Yes" << endl;
      return 0;
    }
    flag = true;
    for(int j = 0; j < N; j++) {
      if(a[j][i] != 0) {
        flag = false;
        break;
      }
    }
    if(flag) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := newIo()
	defer io.Flush()
	H, W := io.NextInt(), io.NextInt()
	Wall := make([][]int, H)
	for h := range Wall {
		Wall[h] = make([]int, W)
	}
	pointMap := make(map[int][][2]int) // point => [[from, to]]
	maxPoint := 0
	minPoint := 1000
	var C [10][10]int
	for from, line := range C {
		for to := range line {
			p := io.NextInt()
			_, exists := pointMap[p]
			if !exists {
				pointMap[p] = [][2]int{}
			}
			pointMap[p] = append(pointMap[p], [2]int{from, to})
			C[from][to] = p
			if p > maxPoint {
				maxPoint = p
			}
			if p < minPoint {
				minPoint = p
			}
		}
	}

	for h := range Wall {
		for w := range Wall[h] {
			Wall[h][w] = io.NextInt()
		}
	}
	// fmt.Println(C)
	for point := minPoint; point <= maxPoint; point++ {
		for _, route := range pointMap[point] {
			i, j := route[0], route[1]
			if point != C[i][j] {
				continue
			}
			for tj := range C[i] {
				tp := C[i][tj]
				newPoint := point + C[j][tj]
				if tp > newPoint {
					C[i][tj] = newPoint
					pointMap[newPoint] = append(pointMap[newPoint], [2]int{i, tj})
				}
			}
		}
	}

	result := 0
	for h := range Wall {
		for _, point := range Wall[h] {
			if point == -1 {
				continue
			}
			result += C[point][1]
		}
	}
	fmt.Println(result)
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}


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

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define deb(x)     cout << #x << " = "<<x<<endl

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)

int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 200005;


ll gcd(ll  a , ll b) {
	return (b == 0) ? a : gcd(b, a % b);
}
ll binpow(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}
ll powmod(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinv(ll n, ll p)
{
	return powmod(n, MOD - 2, MOD);
}
void max_self(ll &a, ll b) {
	a = max(a, b);
}


int main(int argc, char const *argv[])
{
	// two magical lines to speed up IO
	cin.tie(0);
	ios_base::sync_with_stdio(false);
// #ifndef ONLINE_JUDGE
// 	freopen("in.txt", "r", stdin);
// 	freopen("out.txt", "w", stdout);
// #endif
	string s, t;
	cin >> s >> t;
	vector <vi> dp(s.size() + 1, vi (t.size() + 1));
	F0R(i, s.size()) {
		F0R(j, t.size()) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;

			}
			else {
				dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
			}
		}
	}
	string ans = "";
	int i = s.size();
	int j = t.size();
	while ( i > 0 && j > 0 ) {
		if (s[i - 1] == t[j - 1]) {
			ans += s[i - 1];
			i--;
			j--;

		}
		else if (dp[i - 1][j] == dp[i][j]) {
			i--;
		}
		else
			j--;
	}
	reverse(all(ans));
	cout << ans << endl;
	return 0;




}










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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[50];

int main() {
    scanf("%d", &n);
    forn(i, n) scanf("%d", a + i);
    int ind = 0;
    forn(i, n) if (abs(a[ind]) < abs(a[i])) {
        ind = i;
    }
    if (a[ind] == 0) {
        cout << 0 << endl;
    } else if (a[ind] > 0) {
        cout << 2 * n << endl;
        forn(i, n) {
            cout << ind + 1 << ' ' << i + 1 << endl;
            cout << ind + 1 << ' ' << i + 1 << endl;
            ind = i;
        }
    } else {
        cout << 2 * n << endl;
        for (int i = n - 1; i >= 0; --i) {
            cout << ind + 1 << ' ' << i + 1 << endl;
            cout << ind + 1 << ' ' << i + 1 << endl;
            ind = i;
        }
    }
    return 0;
}


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

int dp[3010][3010] = {0};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	while(t != 0) {
	    string s1, s2;
        cin >> s1 >> s2;
        int n = s1.length();
        int m = s2.length();
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= m; j++) {
                if(s1[i-1] == s2[j-1]) {
                    dp[i][j] = 1 + dp[i-1][j-1];
                }
                else {
                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                }
            }
        }
        // for(int i = 0; i <= n; i++) {
        //     for(int j = 0; j <= m; j++) {
        //         cout << dp[i][j] << " ";
        //     }
        //     cout << "\n";
        // }
        int i = n, j = m;
        string ans = "";
        while(i >= 1 && j >= 1) {
            int val = dp[i][j];
            if(dp[i-1][j] != val && dp[i][j-1] != val) {
                ans += s1[i-1];
                i--;
                j--;
            }
            else if(dp[i-1][j] == val) {
                i--;
            }
            else {
                j--;
            }
        }
        reverse(ans.begin(), ans.end());
        cout << ans << "\n";
	    t--;
	}
	return 0;
}


Measured memory_bytes: 35584
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.collection.mutable.ArrayBuffer
import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map[T](converter)
  }

  implicit val idConverter: String => String = s => s
  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def primes(n: Long): ArrayBuffer[Long] = {
    val buf = ArrayBuffer.empty[Long]
    val s = Math.sqrt(n).toInt

    var v = n
    for (i <- 2 to s) {
      if (v == 1 || v == 0) {
        return buf
      } else {
        while (v % i == 0) {
          buf.append(i)
          v /= i
        }
      }
    }
    if (v > s) {
      buf.append(v)
    }
    buf
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val (x, y) = get[Int, Int]

    val b = (y - 2.0 * x) / 2.0
    val a = 2.0 * x - y / 2.0

    out.println(
      if (a >= 0 && b >= 0 && Math.ceil(a) == a && Math.ceil(b) == b) {
        "Yes"
      } else {
        "No"
      }
    )


    out.flush()
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> data(n);
    float bunbo=0;
    rep(i,n){
        cin >> data.at(i);
        
    }
    float rev=0;
    rep(i,n){
        bunbo += std::pow(data.at(i),-1);
    }
    cout << 1 / bunbo << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;//Òç³ö»á±ä³É¸ºÖµ 
typedef long double ldb;
typedef unsigned long long ull;//×Ô¶¯È¡Ä£2^64 
const double pi=acos(-1.0);
const int mod = 1e9+7; // 998244353;
const int inf = 0x7fffffff;//2^31-1
const ll INF = 0x7fffffffffffffff;
const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
//ll begin_time=clock();    ll end_time=clock();  cout<<"time = "<<end_time-begin_time<<" ms!"<<endl;
//bool operator < (const mmp &a) const{return x<a.x||x==a.x&&y<a.y;}       //map<int,map<int,int> >z;
//map<int,int>::iterator it;for(it=z.begin();it!=z.end();it++)printf("%d %d\n",it->first,it->second);
//ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}  //¿ìËÙÃÝÈ¡Ä£ 
//lower_bound(begin,end,num); µÚÒ»¸ö>=numµÄÊý×Ö upper_bound(begin,end,num); µÚÒ»¸ö>numµÄÊý×Ö,·µ»ØµØÖ·
//freopen("input.in","r",stdin);     freopen("output.out","w",stdout);      //ÎÄ¼þ¶ÁÐ´Ìá½» 
//reverse(s.begin(),s.end());   //·­×ª×Ö·û´®        floor(); ÏòÏÂÈ¡Õû  ceil(); ÏòÉÏÈ¡Õû
//ÊýÖáÉÏµÄn¸öµãÒÆ¶¯µ½Í¬Ò»Î»ÖÃ£¬ÒÆ¶¯µ½¸Ã×éÊý×ÖµÄÖÐÎ»ÊýµÄ×Ü¾àÀë×î¶Ì
//bool isPrime(int n){if(n==2||n==3)return 1;if(n%6!=1&&n%6!=5)return 0;
//int t=sqrt(n);for(int i=5;i<=t;i+=6)if(n%i==0||n%(i+2)==0)return 0;return 1;}//ÅÐ¶ÏËØÊý   


int x[200005];
int y[1000005];
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	ll a,b,c,d,e,f,g,T;  
	memset(y,0,sizeof(y));
	cin>>a;
	int maxx=0;
	for(int i=0;i<a;i++)
	{
		cin>>x[i];
		y[x[i]]++;
		maxx=max(maxx,x[i]);
	}
	b=a;
	for(int i=0;i<a;i++)
	{
		if(y[x[i]]!=1)
		{
			b-=y[x[i]];
			y[x[i]]=0;
		}
		for(int j=x[i]*2;j<=maxx;j+=x[i])
		{
			if(y[j])
			{
				b-=y[j];
				y[j]=0;
			}
		}
	}
	cout<<b<<endl;
	

	
}
	


Measured memory_bytes: 8336
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int N, K;
    cin >> N >> K;
    vi d(K);
    set<int> A;
    rep(i, K){
        cin >> d[i];
        rep(j, d[i]){
            int a;
            cin >> a;
            A.insert(a);
        }

    }
    cout << N-A.size() << endl;
}

Measured memory_bytes: 3652
X = int(input())

X_MAX = 1000000000

for A in range(1, X_MAX + 1):
    if (A + 1) ** 5 - A ** 5 > X: break

A_MAX = A

for A in range(1, A_MAX + 1):
    l = -A_MAX
    r = A_MAX
    while l < r:
        m = l + (r - l) // 2
        if m ** 5 == A ** 5 - X:
            l = r = m
            break
        elif m ** 5 < A ** 5 - X:
            l = m + 1
        else:
            r = m - 1
    #
    B = l
    if A ** 5 - B ** 5 == X: break

print(A, B)

Measured memory_bytes: 9216
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

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

#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()
#define fi first
#define se second
#define sqrt(x) sqrt(abs(x))
#define sqr(x) ((x) * (x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define fill(x, y) memset(x, y, sizeof(x))
#define mp make_pair
#define pb emplace_back
#define popcnt __builtin_popcount
#define ctz __builtin_ctz

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
template <class T> using indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

template <class T>
istream& operator >> (istream &in, vector <T> &a) {
    for (T &i: a) in >> i;
    return in;
}

template <class T>
ostream& operator << (ostream &out, vector <T> &a) {
    for (T &i: a) out << i << ' ';
    return out;
}

template <class T>
ostream& operator << (ostream &out, set <T> &a) {
    for (auto &i: a) out << i << ' ';
    return out;
}

template <class T, class U>
istream& operator >> (istream &in, pair <T, U> &p) {
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator << (ostream &out, pair <T, U> &p) {
    out << p.first << ' ' << p.second;
    return out;
}

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

int n;

signed main() {
    fastIO();

    cin >> n;
    vector <int> a(n);
    map <int, ll> m;

    cin >> a;
    for (auto i: a) m[i]++;

    ll cnt = 0;
    for (auto i: m) {
        cnt += i.se * (i.se - 1) / 2;
    }

    for (auto i: a) {
        ll cur = cnt - m[i] * (m[i] - 1) / 2;
        cur += max(0LL, (m[i] - 1) * (m[i] - 2) / 2);

        cout << cur << '\n';
    }

    return 0;
}

/// ЗАПУСКАЕМ ГУСЯ:
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */



Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
ll N,T;
int t[200001];
ll sum,end_t;
int main(){
  cin >> N >> T;
  for(int i=1;i<=N;i++)cin >> t[i];
  sum=N*T;
  sum-=t[1];
  for(int i=2;i<=N;i++){
    ll temp=t[i]-t[i-1];
    if(temp<=T)
      sum-=(T-temp);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
// D.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 330, mod = 998244353;

int n, dp[MAX_N][MAX_N][MAX_N], vis[MAX_N][MAX_N][MAX_N];
bool verdict[MAX_N][MAX_N][MAX_N];
char str[MAX_N];

int main()
{
    scanf("%s", str + 1), n = strlen(str + 1);
    dp[n][0][0] = 1;
    for (int i = n; i >= 1; i--)
        for (int j = 0; j + (n - i) <= n - 1; j++)
            for (int k = 0; j + k + (n - i) <= n - 1; k++)
                if (str[i] == '0')
                {
                    dp[i - 1][j][k] = (0LL + dp[i - 1][j][k] + dp[i][j][k]) % mod;
                    dp[i][j][k + 1] = (0LL + dp[i][j][k + 1] + dp[i][j][k]) % mod;
                }
                else
                {
                    dp[i - 1][j][k] = (0LL + dp[i - 1][j][k] + dp[i][j][k]) % mod;
                    dp[i][j + 1][k] = (0LL + dp[i][j + 1][k] + dp[i][j][k]) % mod;
                }
    memset(vis, -1, sizeof(vis)), vis[0][0][0] = 0;
    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= (i >> 1); j++)
            for (int k = 0; j + k <= (i >> 1); k++)
                if (vis[i][j][k] != -1)
                {
                    int c = vis[i][j][k];
                    if (i + 1 <= n && c != 0)
                    {
                        if (str[i + 1] == '0')
                            vis[i + 1][j + 1][k] = max(vis[i + 1][j + 1][k], c - 1);
                        if (str[i + 1] == '1')
                            vis[i + 1][j][k + 1] = max(vis[i + 1][j][k + 1], c - 1);
                    }
                    if (i + 2 <= n)
                    {
                        if (str[i + 1] == '0' || str[i + 2] == '0')
                            vis[i + 2][j + 1][k] = max(vis[i + 2][j + 1][k], c);
                        if (str[i + 1] == '1' || str[i + 2] == '1')
                            vis[i + 2][j][k + 1] = max(vis[i + 2][j][k + 1], c);
                        vis[i + 2][j][k] = max(vis[i + 2][j][k], c + 1);
                    }
                }
    for (int i = 0; i <= n; i++)
        for (int j = n; j >= 0; j--)
            for (int k = n; k >= 0; k--)
            {
                verdict[i][j][k] = vis[i][j][k] != -1;
                if (i > 0)
                    verdict[i][j][k] |= verdict[i - 1][j][k];
                verdict[i][j][k] |= verdict[i][j + 1][k] || verdict[i][j][k + 1];
            }
    int ans = 0;
    for (int i = 0; i <= n; i++)
        for (int j = 0; j + (n - i) <= n; j++)
            for (int k = 0; j + k + (n - i) <= n; k++)
                if (dp[i][j][k] && (n - i) + j + k != 0 && verdict[i][j][k])
                    ans = (0LL + ans + dp[i][j][k]) % mod;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 233968
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <queue>
#include <stack>
#include <climits>
#include <array>
using namespace std;

typedef long long ll;
#define pb push_back

#define rep(i, n) for (int i=0;i<(n);++i)
#define rep2(i, s, n) for (int i=s;i<(n);++i)
#define rev(i, n) for (int i=(n);i>0;--i)
#define INF (1e9+1e9)

bool dfs(int depth, int calc, array<int, 4>&n, string& op) {
    if (depth == 4) {
        if (calc == 7) {
            cout << n[0];
            rep2(i,1,4)
                cout << op[i-1] << n[i];
            cout << "=7" << endl;
            return true;
        }
        return false;
    }

    if (depth >= 1) op[depth-1] = '+';
    if ( dfs(depth+1, calc+n[depth], n, op) ) return true;
    else {
        if (depth >= 1) op[depth-1] = '-';
        return dfs(depth+1, calc-n[depth], n, op);
    }
}

int main() {
    string num; cin >> num;
    array<int, 4> n;
    rep(i,4) {
        char a = num[i];
        n[i] = atoi(&a);
    }

    string op("+++");
    dfs(0, 0, n, op);
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 200100;

int A[MAX];

int ww(VI a)
{
/*	FOR (i, 0, SZ(a))
	{
		cout<<a[i]<<' ';
	}
	cout<<endl;*/
	int x = SZ(a) / 2;
	int c = a[x];
	int it = SZ(a) / 2;
	FOR (i, 0, it)
	{
		if (a[x - i - 1] == c || a[x + i + 1] == c)
		{
			//cout<<c<<endl;
			return c;
		}
		c ^= 1;
	}

	//cout<<a[0]<<endl;

	return a[0];
}

int go(VI a)
{
	while(SZ(a) != 1)
	{
		/*FOR (i, 0, SZ(a))
		{
			cout<<a[i]<<' ';
		}
		cout<<endl;*/
		VI b;
		FOR (i, 0, SZ(a) - 2)
		{
			VI c;
			c.PB(a[i]);
			c.PB(a[i+1]);
			c.PB(a[i+2]);

			sort(ALL(c));
			b.PB(c[1]);
		}

		a = b;
	}

	return a[0];
}

int solve(int n)
{
	VI a;

	int l = -1, r = n;
	while(r - l > 1)
	{
		int m = (r + l) / 2;
		//cout<<m<<endl;
		a.clear();
		FOR (i, 0, n)
		{
			if (A[i] < m) a.PB(0);
			else a.PB(1);
		}

		if (ww(a) == 1) l = m;
		else r = m;
	}

	return l + 1;
}

int main()
{
	//freopen("in.txt","r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	n = n * 2 - 1;
	VI b;
	FOR (i, 0, n)
	{
		scanf("%d", &A[i]);
		b.PB(A[i]);
		A[i]--;
	}

	cout<<solve(n)<<endl;

	/*while(true)
	{
		n = 47;
		n = n * 2 - 1;
		FOR (i, 0, n)
		{
			A[i] = i;
		}

		VI b;
		random_shuffle(A, A + n);
		FOR (i, 0, n)
		{
			b.PB(A[i] + 1);
		}

		int r = solve(n);
		int br = go(b);
		cout<<r<<' '<<br<<endl;

		if (r != br)
		{
			cout<<n<<endl;
			FOR (i, 0, n)
			{
				cout<<A[i]<<' ';
			}
			cout<<endl;
			throw -1;
		}
	}*/




}


Measured memory_bytes: 3444
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    for(int i=A; i<=B; i++){
      if(i%K == 0){
        System.out.print("OK");
        return;
      }
    }
    System.out.print("NG");
  }
}

Measured memory_bytes: 35660
#include <iostream>
#include <queue>
using namespace std;

long long n, a[200005], b[200005], m, k, ans, sumA[200005], sumB[200005];

long long bs(long long t) {
    if(t < sumB[1]) return 0;
    if(t >= sumB[m]) return m;

    long long l = 1, r = m;
    while(l <= r) {
        long long mid = (l+r)/2;
        if(sumB[mid] <= t && sumB[mid+1] > t) return mid;
        else if(sumB[mid] <= t) l = mid+1;
        else r = mid-1;
    }
    return -1;
}

int main() {
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        sumA[i] = sumA[i-1]+a[i];
    }
    for(int j = 1; j <= m; j++) {
        cin >> b[j];
        sumB[j] = sumB[j-1]+b[j];
    }

    for(long long i = 0; (i <= n) && (sumA[i] <= k); i++) {
        long long t = k-sumA[i];
        long long pos = bs(t);
        ans = max(ans, i+pos);
    }
    cout << ans;
}


Measured memory_bytes: 9848
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 100005;

int main() {
    LL n;
    cin >> n;
    int ans = 0;
    for (LL i = 1; i * i <= n - 1; i++) {
        if ((n - 1) % i == 0) {
            if (i > 1) ans++;
            if ((n - 1) / i != i) ans++;
        }
    }
    for (LL i = 1; i * i <= n; i++) {
        if (n % i != 0) continue;
        LL x = n;
        if (i > 1) {
            while (x % i == 0) {
                x /= i;
            }
            if (x % i == 1) ans++;
        }
        if (i * i == n) continue;
        x = n;
        LL t = n / i;
        while (x % t == 0) {
            x /= t;
        }
        if (x % t == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

char a[3][3];

int main(){

    for(int i=0; i<3; ++i){
        scanf("%s", a[i]);
    }

    printf("%c%c%c", a[0][0], a[1][1], a[2][2]);






    return 0;
}


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

#define INF 2147483647
#define LINF 9223372036854775807
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

int N;
ll W,w,tmp;
vector<ll> v[4];
ll dp[4][101];

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

	cin>>N>>W;
	cin>>w>>tmp;
	v[0].push_back(tmp);
	REP(i,N-1) {
		ll a,b; cin>>a>>b;
		v[a-w].push_back(b);
	}
	REP(i,4) sort(v[i].rbegin(),v[i].rend());
	REP(i,4) REP(j,v[i].size()) dp[i][j+1]=dp[i][j]+v[i][j];
	ll ans=0;
	REP(a,v[0].size()+1) {
		REP(b,v[1].size()+1) {
			REP(c,v[2].size()+1) {
				REP(d,v[3].size()+1) {
					ll sw=w*a+(w+1)*b+(w+2)*c+(w+3)*d;
					ll sv=dp[0][a]+dp[1][b]+dp[2][c]+dp[3][d];
					if(sw<=W) ans=max(ans,sv);
				}
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOR(i,n,m) for (int i=n; i<(int)(m); ++i)
#define ALL(x) x.begin(), x.end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define in(i, n) (0 <= (i) && (i) < (n))
#define on(bit, i) (((bit >> i) & 1) == 1)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int INF = 1e9+7;

struct UnionFind {
  vector<int> parent;
  UnionFind (int n) : parent(n, -1) {}
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (parent[y] < parent[x]) swap(x, y);
    if (parent[x] == parent[y]) --parent[x];
    parent[y] = x;
    return true;
  }
};

int N, M;
vector<int> v[100000];

int main(void) {
  cin >> N >> M;
  UnionFind uf(N);
  REP(i, N) {
    int K; cin >> K;
    REP(j, K) {
      int l; cin >> l; l--;
      v[l].push_back(i);
    }
  }
  REP(i, M) {
    REP(j, v[i].size() - 1) {
      uf.merge(v[i][j], v[i][j + 1]);
    }
  }
  set<int> st;
  REP(i, N) st.insert(uf.root(i));
  if ((int)st.size() == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	ll n,m,sum=0;
	cin>>n>>m;
	ll x=m;
	vector<ll> v(n);
	for(ll i=0;i<n;i++){
		cin>>v[i];
		sum+=v[i];
	}
	for(ll i=0;i<n;i++)
	if(4*m*v[i]>=sum)
	x--;
	if(x<=0)
	cout<<"Yes";
	else
	cout<<"No";
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll qc=1;
	for(ll i=1;i<=qc;i++)
	solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)  
#define rep(i,n) for(long long int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int maxInt = 2147483647;
const int mx=100005;
vector<int> edge[100005];
int dp[100005];

void dfs(int u){
	if(dp[u])return;
	for(auto v:edge[u]){
		dfs(v);
		dp[u]=max(dp[u],dp[v]+1);
	}
	return;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n,m;cin >> n >> m;
	rep(i,m){
		int u,v;cin >> u >> v;
		edge[u].push_back(v);
	}

	int ans=0;
	for(int i=1;i<=n;++i){
		dfs(i);
		ans=max(ans,dp[i]);
	}
	cout << ans << endl;
  return 0;	
}

Measured memory_bytes: 8192
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int a[4] = {4, 6, 9, 11};
  int b[7] = {1, 3, 5, 7, 8, 10, 12};
  int x, y;
  cin>>x>>y;
  if(x==2 || y==2) cout<<"No"<<endl;
  else {
    rep(i, 4) rep(j, 4) if(x==a[i]&&y==a[j]) {cout<<"Yes"<<endl; return 0;}
    rep(i, 7) rep(j, 7) if(x==b[i]&&y==b[j]) {cout<<"Yes"<<endl; return 0;}
    cout<<"No"<<endl;
  }
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]


INF = float("inf")


def main():
    ans = 0
    N = INT()
    for i in range(N):
        ans += (N-i)*(N-i+1)//2
    uv = ZIP(N-1)
    for u, v in uv:
        if v < u:
            u, v = v, u
        ans -= u * (N-v+1)
    print(ans)

    return


if __name__ == '__main__':
    main()


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

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

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll n; cin >> n;
    vll a(n);
    ll s = 0;
    rep(i, n){
        cin >> a[i];
        s ^= a[i];
    }

    rep(i, n) cout << (s^a[i]) << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 4792
function Main(input){
	input = input.split("\n");
	var a = input[1].split(" ").map(Number);
	var b = input[2].split(" ").map(Number);
	var sum = 0;
	for(var i=0;i<a.length;i++){
		if((a[i]-b[i])>0) sum+=(a[i]-b[i]);
	}
	console.log(sum);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) ); 
// 大文字65-90(-32)
// 小文字97-122(+32)

int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n,k;cin >> n >> k;
  int mod = n;
  int d = 1;
  while(n>=k){
    n/=k;
    d++;
  }
  cout << d << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import Counter

def root(par, x):
    if par[x] == x:
        return x
    par[x] = root(par, par[x])
    return par[x]

def unite(par, x, y):
    rx, ry = root(par, x), root(par, y)
    if rx == ry:
        return

    if rank[rx] > rank[ry]:
        par[ry] = rx
    elif rank[rx] < rank[ry]:
        par[rx] = ry
    else:
        par[ry] = rx
        rank[rx] += 1
        
N, K, L = map(int, input().split())

rank = [1] * N
roads = [i for i in range(N)]
for _ in range(K):
    unite(roads, *map(lambda x: int(x) - 1, input().split()))

rank = [1] * N
rails = [i for i in range(N)]
for _ in range(L):
    unite(rails, *map(lambda x: int(x) - 1, input().split()))

count = Counter((root(roads, i), root(rails, i)) for i in range(N))
print(*(count[root(roads, i), root(rails, i)] for i in range(N)))

Measured memory_bytes: 55972
N = list(input())
N = list(map(int, N))
N = [0] + N
n = len(N)

answer = 0
for i in range(n - 1, -1, -1):
    j = N[i]
    if j == 10:
        N[i - 1] += 1
        continue
    if j == 5 and N[i - 1] >= 5:
        N[i - 1] += 1
        answer += 5
    elif j <= 5:
        answer += j
    else:
        N[i - 1] += 1
        answer += 10 - j

print(answer)


Measured memory_bytes: 21348
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int n, a[3];
	cin >> n >> a[0] >> a[1] >> a[2];
	int l[8];
	rep(i, n) cin >> l[i];
	int ans = INF;
	rep(i, pow(4, n)) {
		int tmp = i;
		int sum_l[4] = {0, 0, 0, 0};
		int cnt[4] = {0, 0, 0, 0};
		rep(j, n) {
			sum_l[tmp % 4] += l[j];
			cnt[tmp % 4]++;
			tmp /= 4;
		}
		int tmp_ans = 0;
		rep(j, 3) {
			if(cnt[j] == 0) {
				tmp_ans = INF;
				break;
			}
			tmp_ans += abs(a[j] - sum_l[j]);
			tmp_ans += 10 * (cnt[j] - 1);
		}
		ans = min(tmp_ans, ans);
	}
	cout << ans << endl;
}


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

int main() {
	int K;
	string S;
   int s; 
  
  cin >> K >> S; //Kに数字、Sに文字列
  s = S.size();
  if ( K < s ){
  
    int n = 0;
    while ( n < K ) {
    cout << S.at(n);
      n = n + 1;
    }
      cout << "..." << endl;
    }
  else {
    cout << S << endl;
  }
  
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
	static final long all = (long)1e15;
	static int n,m,s,t;
	static int u[],v[],a[],b[],first[],next[];
	static boolean vis[];
	static long yen[],snuuk[],cost[],mincost = all;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		m = in.nextInt();
		s = in.nextInt();
		t = in.nextInt();
		u = new int[m * 2 + 1];
		v = new int[m * 2 + 1];
		a = new int[m * 2 + 1];
		b = new int[m * 2 + 1];
		first = new int[m * 2 + 1];
	    next = new int[m * 2 + 1];
	    vis = new boolean[n + 1];
	    yen = new long[n + 1];
	    snuuk = new long[n + 1];
	    cost = new long[n + 1];
	    Arrays.fill(first, -1);
	    Arrays.fill(yen,all);
	    Arrays.fill(snuuk, all);
	    for(int i = 0;i < m;i ++) {
	    	u[i] = in.nextInt();
	    	v[i] = in.nextInt();
	    	a[i] = in.nextInt();
	    	b[i] = in.nextInt();
	    	u[i + m] = v[i];
	    	v[i + m] = u[i];
	    	a[i + m] = a[i];
	    	b[i + m] = b[i];
	    	next[i] = first[u[i]];
	    	first[u[i]] = i;
	    	next[i + m] = first[u[i + m]];
	    	first[u[i + m]] = i + m;
	    }
	    yen[s] = 0;
	    int head = 0,tail = 0;
	    int queue[] = new int[n];
	    queue[tail ++] = s;
	    vis[s] = true;
	    while(head != tail) {
	    	int k = first[queue[head]];
	    	while(k != -1) {
	    		if(yen[u[k]] + a[k] < yen[v[k]]) {
	    			yen[v[k]] = yen[u[k]] + a[k];
	    			if(!vis[v[k]]) {
	    				queue[tail] = v[k];
	    			    vis[v[k]] = true;
	    			    tail = (tail + 1) % n;
	    			}
	    		}
	    		k = next[k];
	    	}
	    	vis[queue[head]] = false;
	    	head = (head + 1) % n;
	    }
	    snuuk[t] = 0;
	    head = tail = 0;
	    queue[tail ++] = t;
	    vis[t] = true;
	    while(head != tail) {
	    	int k = first[queue[head]];
	    	while(k != -1) {
	    		if(snuuk[u[k]] + b[k] < snuuk[v[k]]) {
	    			snuuk[v[k]] = snuuk[u[k]] + b[k];
	    			if(!vis[v[k]]) {
	    				queue[tail] = v[k];
	    			    vis[v[k]] = true;
	    			    tail = (tail + 1) % n;
	    			}
	    		}
	    		k = next[k];
	    	}
	    	vis[queue[head]] = false;
	    	head = (head + 1) % n;
	    }
	    for(int i = n;i > 0;i --) {
	    	cost[i - 1] = Math.min(mincost, yen[i] + snuuk[i]);
	    	mincost = Math.min(mincost, cost[i - 1]);
	    	cost[i - 1] = all - cost[i - 1];
	    }
	    for(int i = 0;i < n;i ++) {
	    	System.out.println(cost[i]);
	    }
	}
}


Measured memory_bytes: 130368
{-# LANGUAGE BangPatterns #-}
import qualified Data.ByteString.Char8 as BS
import Data.Array
import Data.Array.ST
import Control.Monad

-- Input: s t
-- Output: arr
--   arr!(i,j) == length of lcs of (take i s, take j t)
lcsTable :: BS.ByteString -> BS.ByteString -> Array (Int, Int) Int
lcsTable xs ys = runSTArray $ do
  arr <- newArray ((0,0), (n,m)) 0
  forM_ [0..n-1] $ \i -> do
    forM_ [0..m-1] $ \j -> do
      let x = xs `BS.index` i
          y = ys `BS.index` j
      if x == y then do
        a <- readArray arr (i, j)
        writeArray arr (i+1, j+1) $! a+1
      else do
        a <- readArray arr (i+1, j)
        b <- readArray arr (i, j+1)
        writeArray arr (i+1, j+1) $! max a b
  return arr
  where n = BS.length xs
        m = BS.length ys

solve :: BS.ByteString -> BS.ByteString -> String
solve !s !t = let !table = lcsTable s t
                  !n = BS.length s
                  !m = BS.length t
                  recon !i !j acc | i == 0 || j == 0 = acc
                                  | x == y = recon (i-1) (j-1) (x : acc)
                                  | table!(i-1,j) >= table!(i,j-1) = recon (i-1) j acc
                                  | otherwise = recon i (j-1) acc
                    where x = BS.index s (i-1)
                          y = BS.index t (j-1)
              in recon n m []

main = do
  s <- BS.getLine
  t <- BS.getLine
  -- BS.length s <= 3000, BS.length t <= 3000, BS.all isAsciiLower s, BS.all isAsciiLower t
  putStrLn (solve s t)


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

const int di[]  = {0,0,-1,1} ;
const int dj[]  = {-1,1,0,0} ;
const int INF = 1001001001 ;

int main(){
    ll h , w ;
    cin >> h >> w ;
    ll si , sj ;
    cin >> si >> sj ;
    ll gi , gj ;
    cin >> gi >> gj ;
    si-- ;sj-- ;gi-- ;gj-- ;
    vector<string> S(h) ;
    rep(i,h) cin >> S[i] ;
    vector<vector<int>> dist(h,vector<int>(w,INF)) ;
    deque<P> q ;
    dist[si][sj] = 0 ;
    q.emplace_back(si,sj) ;
    while(!q.empty()){
        ll i = q.front().first ;
        ll j = q.front().second ;
        q.pop_front() ;
        ll d = dist[i][j] ;
        if(dist[i][j] != d )continue ;
        rep(v,4){
            ll ni = i + di[v] , nj = j + dj[v] ;
            if(ni < 0 || ni >=h || nj < 0 || nj >= w) continue ;
            if(S[ni][nj] == '#' ) continue ;
            if (dist[ni][nj] <= d) continue;
            dist[ni][nj] = d ;
            q.emplace_front(ni,nj) ;
        }
        for (ll ei = -2 ; ei <= 2 ; ei++ ){
            for (ll ej = -2; ej <= 2 ;ej++ ){
                ll ni = i + ei , nj = j + ej ;
                if(ni < 0 || ni >=h || nj < 0 || nj >= w) continue ;
                if(S[ni][nj] == '#' ) continue ;
                if (dist[ni][nj] <= d+1) continue;
                dist[ni][nj] = d + 1  ;
                q.emplace_back(ni,nj) ;
            }
        }
    }
  int ans = dist[gi][gj];
  if (ans == INF) ans = -1;
  cout << ans << endl;
}


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

int main() {
    while (true) {
        int r, c;
        cin >> r >> c;
        if ((r | c) == 0) {
            break;
        }
        if (r * c % 2 == 0) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n;
	str s;
	cin >> n >> s;
	str s2 = "";
	int cnt=0;
	REP(i, n) {
		if (s[i] == '(')
			cnt++;
		else
			cnt--;
		s2 += s[i];
		if (cnt < 0) {
			s2 = '(' + s2;
			cnt++;
		}
	}
	str s3 = "";
	cnt = 0;
	REP(i, s2.length()) {
		if (s2[s2.length()-1-i] == '(')
			cnt++;
		else
			cnt--;
		s3 += s2[s2.length() - 1 - i];
		if (cnt > 0) {
			s3 = ')' + s3;
			cnt--;
		}
	}
	REP(i, s3.length())
		cout << s3[s3.length() - 1 - i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int N,M,H,K,S[1001],Y[100001][2],W[100001][2],P[1001],Q[1001],i,j,R,t,r,x,y;
void s(int *a,int *b){*a^=*b^=*a^=*b;}
int c(const void *a, const void *b){return ((int*)a)[1]-((int*)b)[1];}
int main()
{
	for(;scanf("%d%d%d%d",&N,&M,&H,&K),N;)
	{
		for(i=0;i<N;S[i],P[i]=i++)scanf("%d",&S[i]);
		for(i=0;i<M;Y[i][0]--,i++)scanf("%d%d",&Y[i][0],&Y[i][1]);
		qsort(Y,M,sizeof(int[2]),c);
		for(i=0;i<M;i++)
		{
			W[i][0]=P[Y[i][0]];
			W[i][1]=P[Y[i][0]+1];
			s(&P[Y[i][0]],&P[Y[i][0]+1]);
		}
		for(i=0;i<N;i++)Q[P[i]]=i;
		for(i=R=0;i<K;i++)R+=S[Q[i]];
		for(i=0,r=t=R;i<M;i++,t=r)
		{
			x=W[i][0],y=W[i][1];
			if(x<K&&y>=K)t=t-S[Q[x]]+S[Q[y]];
			if(y<K&&x>=K)t=t-S[Q[y]]+S[Q[x]];
			R=R>t?t:R;
		}
		printf("%d\n",R);
	}
	return 0;
}

Measured memory_bytes: 2296
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  string a,b;
  cin >> a >> b;
  int cnt = 0;
  for(int i=atoi(a.c_str()); i<=atoi(b.c_str()); i++){
    string tmp = to_string(i);
    string tmp1 = tmp;
    reverse(tmp.begin(),tmp.end());
    if(tmp == tmp1) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N, M, a, b;
    cin >> N >> M;
    vector<int> vec1(N, 0);
    vector<int> vec2(N, 0);
    for(int i = 0; i< M; i++)
    {
        cin >> a >> b;
        if(a == 1){
            vec1[b - 1] = 1;
        }else if(b == N)
        {
            vec2[a - 1] = 1;
        }
    }
    for(int i = 0; i< N; i++){
        if( vec1[i] == 1 and vec2[i] == 1)
        {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 1792
l, r = map(int,input().split())

n = min(l+2020, r)

ans = 2018

for i in range(l,n+1):
    if ans == 0:
        break
    for j in range(i+1,n+1):
        ans = min(ans, (i*j) % 2019)

print(ans)

Measured memory_bytes: 3060