akhauriyash/Code-Regression huggingface dataset:
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val N = rd.readInt()
    val RNMAX = 448

    var ans = "No"
    var K = 0
    for (k in 1 .. RNMAX) {
        if (k*(k-1) == 2 * N) {
            ans = "Yes"
            K = k
            break
        }
    }

    println(ans)
    if (ans == "Yes") {
        println(K)

        var cnt = 1
        val S = Array(K){ArrayList<Int>()}
        for (i in 0 until K) {
            for (j in i+1 until K) {
                S[i].add(cnt)
                S[j].add(cnt)
                cnt++
            }
        }

        for (i in 0 until K) {
            println("${S[i].size} ${S[i].joinToString(" ")}")
        }
    }

    return
}


//val rd = debug.Reader("etc", "tenka1-2018-beginner", "d", "sample-3")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 58068
import sys
input = sys.stdin.readline
n = int(input())
nums = list(map(int, input().split()))

dic_c = {}
for e in nums:
    if e in dic_c:
        dic_c[e] += 1
    else:
        dic_c[e] = 1

allscore = 0
for key in dic_c.keys():
    allscore += dic_c[key]*(dic_c[key]-1)

for e in nums:
    if dic_c[e] == 1:
        print(int(allscore/2))
    elif dic_c[e] == 2:
        print(int((allscore-1)/2))
    else:
        print(int(       (allscore - (2*(dic_c[e]-1)))/2      ))



Measured memory_bytes: 25696
#include <bits/stdc++.h>
using namespace std;
#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()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
const bool debug = 0;
//----------------------//

int n;
int a[1123456];

int main() {
	cin >> n;
	REP(i, 1<<n) scanf("%d", a + i);
	
	REP(i, n) {
		for (int j = 0; j < 1<<n; j += 1<<i+1) {
			int nex = j + (1<<i);
			
			if (a[j] == a[nex]) continue;
			a[j] = max(a[nex], a[j]) - min(a[nex], a[j]);
		}
	}
	
	cout << a[0] << endl;
	
	return 0;
}


Measured memory_bytes: 1280
def main():
    N = int(input())
    lst_B = list(map(int, input().split()))
    
    ans = 0
    for i in range(N):
        if i == 0:
            ans += lst_B[0]
        elif i == N - 1:
            ans += lst_B[-1]
        else:
            ans += min(lst_B[i - 1], lst_B[i])

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <iostream>
#include <cstring>
#include <cstdio>


#define ll long long
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define f(n) for (ll i = 0; i < n; i++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define Rep(i,s,t) for(long long i=s;i<t;i++)
#define all(x) x.begin(),x.end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n==7||n==5||n==3){cout<<"YES"<<endl;}
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
cnt = Counter(A)
ans = 0

for v in cnt.values():
    ans += v*(v-1)//2
    
for Ai in A:
    ans_i = ans
    ans_i -= cnt[Ai]*(cnt[Ai]-1)//2
    ans_i += (cnt[Ai]-1)*(cnt[Ai]-2)//2
    
    print(ans_i)

Measured memory_bytes: 82892
import java.util.*;
public class Main {
  
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long C = sc.nextLong();
    long D = sc.nextLong();

    long lcm = (C * D) / gcd(D, C);
    
    System.out.println(count(B, C, D, lcm) - count(A-1, C, D, lcm));
  }
  
  private static long gcd(long a, long b) {
    if (b == 0) {
      return a;
    }
    return gcd(b, a%b);
  }
  
  private static long count(long n, long C, long D, long lcm) {
    return n - n/C - n/D + n/lcm;
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 100005
 
#define PI 3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007

 
int main()
{
	FAST;
	ll n, m, x, y;
	cin >> n >> m >> x >> y;
	ll a1= -555, a2 = 100; ll f;
	for(ll i = 0; i < n; i ++){
		cin >> f;
		a1 = max(a1, f);
	}
	for(ll i = 0; i < m; i ++){
		cin >> f;
		a2 = min(a2, f);
	}
	if(a1 < a2 && a2 <= y && a2 > x ){
		cout << "No War";
		return 0;
	}
	cout << "War";
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fi first
#define se second
#define MK make_pair
#define PB push_back
using namespace std;

typedef long long LL;
typedef pair<int ,int> PII;
const int N=510;
const LL oo = 1ll<<60;
LL pre[N][N],pre2[N][N], a[N][N], f[N][N];
template<class T>
void upmin(T&a, T b){if ( b<a) a=b;}

int n, m;
LL Inner(int i, int j){return pre2[j][j]-pre2[i-1][j]-pre2[j][i-1]+pre2[i-1][i-1];}
LL Outer(int i,int j, int k){return pre[k][i-1]-pre[j][i-1];}
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	scanf("%d", &n);
	for (int i=1; i<=n; ++i)
		for (int j=1; j<=n; ++j) if ( i!=j){
			scanf("%lld", a[i]+j);
			pre[i][j]= a[i][j];
			if ( i<j) pre2[i][j] = a[i][j];
		}
	for (int i=1; i<=n; ++i)
		for (int j=1; j<=n; ++j) pre[i][j] += pre[i-1][j], pre2[i][j]+=pre2[i-1][j];
	for (int i=1; i<=n; ++i)
		for (int j=1; j<=n; ++j) pre[i][j] += pre[i][j-1], pre2[i][j]+=pre2[i][j-1];
	
	for (int i=1; i<=n; ++i)
		for (int j=i; j<=n; ++j) f[i][j] = oo;
	
	for (int i=1; i<=n; ++i)
		for (int j=i; j<=n; ++j){
			if ( i==1) f[i][j] = Inner(i,j);
			for (int k=j+1; k<=n; ++k) upmin(f[j+1][k], f[i][j] + Inner(j+1,k)+Outer(i,j,k));
			#ifdef che
			debug("f[%d][%d] = %lld\n", i,j,f[i][j]);
			#endif
		}
	LL ans=oo;
	for (int i=1; i<=n; ++i) upmin(ans, f[i][n]);
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
 string S;
 bool ans=0;
 cin >> S;
 char a=S[0];
 int cnt=0,loc;
  for(int i=1;i<4;i++){
    if(S[i]==a){
      cnt++;
      loc=i;
    }
  }
  if(cnt==1){
    if(loc==1 && S[2]==S[3])ans=1;
    else if(loc==2 && S[1]==S[3])ans=1;
    else if(loc==3 && S[1]==S[2])ans=1;
  }

  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
function solve(n) {
  if ([3].indexOf(n % 10) >= 0) {
    return 'bon';
  }
  if ([0, 1, 6, 8].indexOf(n % 10) >= 0) {
    return 'pon';
  }
  return 'hon';
}

function main(input) {
  let n = parseInt(input);
  console.log(solve(n));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29568
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
 
        System.out.println(a * b / 2 * Math.sin(Math.toRadians(c)));
        System.out.println(a
                + b
                + Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b
                        * Math.cos(Math.toRadians(c))));
        System.out.println(b * Math.sin(Math.toRadians(c)));
    }
}


Measured memory_bytes: 26524
n = gets.chomp.to_i

n.times do
  chs = gets.chomp.split("")

  base = "a".ord
  found = false

  for a in (1..26)
    next if a % 2 == 0 || a % 13 == 0

    for b in (0..25)
      dec = ""

      for ch in chs
        if /[a-z]/ =~ ch
          dec += ((a * (ch.ord - base) + b) % 26 + base).chr
        else
          dec += ch
        end
      end

      if dec.include?("this") || dec.include?("that")
        puts dec
        found = true
        break
      end

      break if found
    end
  end
end

Measured memory_bytes: 6160
#include "bits/stdc++.h"
using namespace std;
int main(){
	char b, bb;
	cin >> b;
	if      (b == 'A') bb = 'T';
	else if (b == 'T') bb = 'A';
	else if (b == 'G') bb = 'C';
	else               bb = 'G';
	cout << bb << endl;
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define LL long long
#define maxn 100005
using namespace std;
int n,a[maxn],deg[maxn],cnt[maxn];
bool vis[maxn];
struct node { int v; node *nxt; } edge[maxn*2],*head[maxn],*ncnt;
void addedge(int u,int v)
{
	ncnt++;
	ncnt->v=v,ncnt->nxt=head[u];
	head[u]=ncnt; deg[u]++;
}
void dfs(int u,int fa)
{
	if(deg[u]==1) { cnt[u]=a[u]; return; }
	for(node *p=head[u];p;p=p->nxt)
	{
		int v=p->v;
		if(v==fa) continue;
		dfs(v,u);
		cnt[u]+=2*a[v]-cnt[v];
		if(2*a[v]-cnt[v]>a[v]||2*a[v]-cnt[v]>a[u]||cnt[u]>2*a[u]) { printf("NO\n"); exit(0); }
	}
}
int main()
{
	ncnt=&edge[0];
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	if(n==2) { printf("%s\n",a[1]==a[2]?"YES":"NO"); return 0; }
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v); addedge(v,u);
	}
	for(int i=1;i<=n;i++)
		if(deg[i]!=1)
		{
			dfs(i,0); 
			if(cnt[i]!=2*a[i]) { printf("NO\n"); return 0; }
			break;
		}
	printf("YES\n");
}

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

int main() {
    int N; cin>>N;
    vector<int> A(N);
    rep(i,N) {
        cin>>A[i];
        cout<<A[i];
        if(i!=N-1)cout<<' ';
        else cout<<endl;
    }

    for (int i=1;i<N;i++){
        int v = A[i];
        int j = i-1;
        while(j>=0&&A[j]>v){
            A[j+1] = A[j];
            j--;
            A[j+1] = v;
        }
        rep(i,N) {
            cout<<A[i];
            if(i!=N-1)cout<<' ';
            else cout<<endl;
        }
    }
}


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

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる
  ll cost; // e.costでその辺の重みにアクセスできる
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}
//素数判定 
//一つ一つの判定ではこっちの方が速い(一つ当たりO(√N))
//一方100までに何個あるかなどはEratosthenesの篩の方が良い（O(NlogN))
bool PN(int x) {
  if (x <= 1) return false; // 1や0,-1は素数ではない
  if (x == 2) return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) return false; // 割れたら素数じゃない
  }
  return true;
}
// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  long long ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  vector<vector<char>> C(3, vector<char>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> C.at(i).at(j);
    }
  }
  cout << C.at(0).at(0) << C.at(1).at(1) << C.at(2).at(2) << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
#define fprint(NUM,X) cout << fixed << setprecision(NUM) << (X) << endl
#define fprints(NUM,X,Y) cout << fixed << setprecision(NUM) << (X) << " " << (Y) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];

struct edge{ int to,cap,cost,rev; };
static const int MAX = 100000;
int V;
vector<edge> graph[MAX];
int dist[MAX];
int prevv[MAX],preve[MAX];

void add_edge(int from,int to,int cap,int cost){
  graph[from].push_back((edge){ to,cap,cost,(int)graph[to].size() });
  graph[to].push_back((edge){ from,0,-cost,(int)graph[from].size()-1 });
}

int min_cost_flow(int s,int t,int f){
  int res = 0;
  while(f > 0){
    fill(dist,dist + V,INF);
    dist[s] = 0;
    bool update = true;
    while(update){
      update = false;
      for(int v = 0;v < V;v++){
        if(dist[v] == INF)continue;
        for(int i = 0;i < graph[v].size();i++){
          edge &e = graph[v][i];
          if(e.cap > 0 && dist[e.to] > dist[v] + e.cost){
            dist[e.to] = dist[v] + e.cost;
            prevv[e.to] = v;
            preve[e.to] = i;
            update = true;
          }
        }
      }
    }
    if(dist[t] == INF)return -1;
    int d = f;
    for(int v = t;v != s;v = prevv[v]){
      d = min(d,graph[prevv[v]][preve[v]].cap);
    }
    f -= d;
    res += d * dist[t];
    for(int v = t;v != s;v = prevv[v]){
      edge &e = graph[prevv[v]][preve[v]];
      e.cap -= d;
      graph[v][e.rev].cap += d;
    }
  }
  return res;
}

int main(){
  cin >> V >> n >> m;
  rep(i,0,n){
    int a,b,c,e;
    cin >> a >> b >> c >> e;
    add_edge(a,b,c,e);
  }
  print(min_cost_flow(0,V-1,m));
  return 0;
}


Measured memory_bytes: 5644
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        String[] groups = {
            ",1,3,5,7,8,10,12,",
            ",4,6,9,11,",
            ",2,",
        };
 
        int x = sc.nextInt();
        int y = sc.nextInt();
 
        int g1;
        for (g1 = 0; g1 < groups.length; ++g1) {
            if (groups[g1].indexOf("," + x + ",") >= 0) {
                break;
            }
        }
        int g2;
        for (g2 = 0; g2 < groups.length; ++g2) {
            if (groups[g2].indexOf("," + y + ",") >= 0) {
                break;
            }
        }
        _out.println((g1 == g2 ? "Yes" : "No"));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if (a==1){
		cout << "YES\n";
		return 0;
	}
	for (int i=1;i<=100;i++){
		if ((a*i)%b==c){
		 cout << "YES\n";
		 return 0;
	}
	}
	cout << "NO\n";
} 

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
cha=[0,2,4,6,8,1,3,5,7,9]
m=int(input())
ans=0
from collections import deque
l=deque()
for _ in range(m):
    d,c=map(int,input().split())
    while c>1:
        if c%2:
            c-=1
            l.append(d)
        c//=2
        ans+=c if d<5 else c*2
        d=cha[d]
    l.append(d)

k=len(l)
while k>1:
    a=l.pop()
    b=l.pop()
    x=a+b
    ans+=1
    if x>9:
        s=str(x)
        l.append(int(s[0]))
        l.append(int(s[1]))
    else:
        l.append(x)
        k-=1
print(ans)


Measured memory_bytes: 124892
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
	long long int n;
	double d, x, y, ans = 0;
	cin >> n>> d;
	for(long long int i=0;i<n;i++)
	{
		cin >> x >> y;
		
		if (x * x + y * y < d * d+1) {
			ans += 1;
		}
	}
	cout << ans << endl;
	return 0;
}//どうして・・・(´･_･`)



Measured memory_bytes: 3784
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
string s;
int main()
{
	cin>>s;
	puts(((!(s[0]-s[2]))?("Yes"):("No")));
	return 0;
}

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

int main() {
	int N,a=-1,b,c,s,count=-1;
	cin >> N;
	vector<int>m(100000);
	for (int i = 0; i < N; i++) {
		cin >> m.at(i);
		if (m.at(i) == 1) {
			a = i;
			//cout << a<<"aの値"<<endl;
		}	
	}
	if (a == -1) {
		a = 0;
		count++;
	}
	for (int i = 0; i < N; i++) {
		s = m.at(a);
		 //cout << s <<"sの値"<< endl;
		count++;
		if (s == 2) {
			cout << count;
			break;
		}
		else {
			a = s-1;
		}
		if (i == N - 1 && s != 2) {
			cout << -1;
		}
	}
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    map<string, int> memo;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin>>s;
        
        memo[s] += 1;
    }
    
    int maxv = 0;
    for(const auto &x : memo)
    {
        int v = x.second;
        if(v > maxv)
            maxv = v;
    }
    
    for(auto it = memo.begin(); it != memo.end(); it++)
    {
        if(it->second == maxv)
        {
            cout<<it->first<<"\n";
        }
    }
    return 0;
}


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

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    
    int r, c;
    cin >> r >> c;
    
    
    string s, t;
    cin >> s >> t;
    
    int left = 1, right = w, top = 1, bottom = h;
    
    for (int i = n - 1; i >= 0; i--) {
        switch (t[i]) {
            case 'L':
                right = min(w, right + 1);
                break;
            case 'U':
                bottom = min(h, bottom + 1);
                break;
            case 'R':
                left = max(1, left - 1);
                break;
            case 'D':
                top = max(1, top - 1);
                break;
        }
        
        switch (s[i]) {
            case 'L':
                left = left + 1;
                break;
            case 'U':
                top = top + 1;
                break;
            case 'R':
                right = right - 1;
                break;
            case 'D':
                bottom = bottom - 1;
                break;
        }
        
        if (left > right || top > bottom) {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    if (left <= c && c <= right && top <= r && r <= bottom) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
     
    using namespace std;
    using namespace __gnu_pbds;
     
    void debug_out() { cerr << endl; }
    template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
    template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
    template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
    template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
    template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
    template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
     
    #define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
    #define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
    #define dbg_ok cerr<<"OK!\n"
    #define  st first
    #define  nd second
    #define int long long  
     
    template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
    typedef cc_hash_table<int, int, hash<int > > ht;
     
    const int  M    = 998244353;
    const int  MAXN = 10005 ;
    const int   INF  = 0x3F3F3F3F  ; // long long inf
    const long double eps = 1.084202e-19;


    int32_t main(){
         ios_base::sync_with_stdio(false);
         cin.tie(NULL);
         int n ; 
         cin >> n ;
         set<string> s; 
         while(n--){
           string x ; 
           cin >> x ; 
           s.insert(x);
         }
         cout<<s.size();
        
       
    }

Measured memory_bytes: 19236
k, n = map(int, input().split())
a_array = [int(x) for x in input().split()]
diff = []
tmp = 0
for i in range(n - 1):
    diff.append(abs(a_array[i + 1] - a_array[i]))
diff.append(k - a_array[-1] + a_array[0])
print(sum(diff) - max(diff))


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

int main()
{
    int n;
    cin >> n;
    std::vector<int> a;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    // 初期状態
    for(int ii=0; ii<n; ii++){
        if(ii != 0){
            printf(" ");
        }
        printf("%d", a[ii]);
    }
    printf("\n");

    for(int i=1; i<n; i++){
        int v = a[i];
        int j = 0;
        while(j<n && a[j]<v){
            j++;
        }
        a.erase(a.begin()+i);
        a.insert(a.begin()+j, v);
    
        // 途中経過
        for(int ii=0; ii<n; ii++){
            if(ii != 0){
                printf(" ");
            }
            printf("%d", a[ii]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 3276
n = int(input())
t = []
for i in range(n):
    ai,bi = map(int,input().split())
    t.append([ai,bi])
# t.sort(key=lambda x:x[1],reverse=True)
t.sort(key=lambda x:x[0])
if n % 2 == 1:
    a = t[n//2][0]
    t.sort(key=lambda x:x[1])
    b = t[n//2][1]
    print(b-a+1)
    exit()
if n % 2 == 0:
    a1 = t[n//2-1][0]
    a2 = t[n//2][0]
    t.sort(key=lambda x:x[1])
    b1 = t[n//2-1][1]
    b2 = t[n//2][1]
    print(b1+b2-a1-a2+1)


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

using namespace std;

#define pb push_back
#define mp make_pair
#define pi 2.0*acos(0.0)
#define INTM 1e18
#define mod 1e9+7
#define FOR(i,j,n)    for(ll i=j;i<n;i++)
#define RFOR(i,j,n)    for(ll i=j;i>=n;i--)

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;

int main(){
    ll n,a;
    cin>>n;
    ll breaked = 0;
    ll arr[n];
    FOR(i,0,n) cin>>arr[i];
    ll target = 1;
    FOR(i,0,n){
        if(arr[i] != target) breaked++;
        else{
            target++;
        }
    }

    if(target == 1){
        cout<<-1<<endl;
        return 0;
    }
    cout<<breaked<<endl;
}


Measured memory_bytes: 1792
from collections import deque
h,w=map(int,input().split())
s=[deque(input())for _ in range(h)]
for i in range(h):
  s[i].append('.')
  s[i].appendleft('.')
  s[i]=tuple(s[i])
s=deque(s)
s.append(['.']*(w+2))
s.appendleft(['.']*(w+2))
s=tuple(s)
for i in range(1,h+1):
  for j in range(1,w+1):
    l=[s[i-1][j],s[i][j+1],s[i+1][j],s[i][j-1]]
    if s[i][j]=='#' and all(k=='.' for k in l):
      print('No')
      exit()
print('Yes')

Measured memory_bytes: 3316
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	// Scanner sc=new Scanner(System.in);
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

	int INF=1<<28;
	double EPS=1e-12;

	int n, m;
	int[] a;

	void run(){
		try{
			String[] ss=br.readLine().split(" ");
			n=Integer.parseInt(ss[0]);
			m=Integer.parseInt(ss[1]);
			a=new int[n];
			for(int i=0; i<n; i++){
				a[i]=Integer.parseInt(br.readLine());
			}
			solve();
		}catch(IOException e){}
	}

	void solve(){
		TreeSet<Integer> set=new TreeSet<Integer>();
		int count=0;
		for(int i=n-1; i>=0; i--){
			if(!set.contains(a[i])){
				println(a[i]+"");
				if(++count==m){
					break;
				}
			}
			set.add(a[i]);
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 14000
P = str(input()).upper()
line = []
 
while True:
    tmp_line = str(input())
    if tmp_line == 'END_OF_TEXT':
        break
    line += tmp_line.upper().split()
 
ans = 0
 
for tmp_word in line:
    if tmp_word == P:
        ans += 1
 
print("%d"%(ans))


Measured memory_bytes: 5560
import java.util.*;

public class Main{

  static void check(String[][] s, int[][] a, int y, int x){
    if (!s[y][x].equals("#")){
      if (y!=0){
        if (s[y-1][x].equals("#"))
        a[y][x] += 1;
        if (x!=0){
          if (s[y-1][x-1].equals("#"))
          a[y][x] += 1;
        }
        if (x !=s[0].length-1){
          if (s[y-1][x+1].equals("#"))
          a[y][x] += 1;
        }
      }
      if (x !=s[0].length-1){
        if (s[y][x+1].equals("#"))
        a[y][x] += 1;
      }
      if (x !=0){
        if (s[y][x-1].equals("#"))
        a[y][x] += 1;
      }
      if (y!=s.length-1){
        if (s[y+1][x].equals("#"))
        a[y][x] += 1;
        if (x!=0){
          if (s[y+1][x-1].equals("#"))
          a[y][x] += 1;
        }
        if (x !=s[0].length-1){
          if (s[y+1][x+1].equals("#"))
          a[y][x] += 1;
        }
      }
    }else{
      a[y][x] = -1;
    }
  }


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

    int h = Integer.parseInt(sc.next());
    int w = Integer.parseInt(sc.next());

    String[][] s = new String[h][w];
    int[][] a = new int[h][w];

    for (int i=0; i<h; i++){
      s[i] = sc.next().split("", -1);
    }


    for (int i=0; i<h; i++){
      for (int j=0; j<w; j++){
        check(s, a, i, j);
        if (a[i][j] != -1)
        System.out.print(a[i][j]);
        else
        System.out.print("#");
      }
      System.out.println();
    }
  }
}


Measured memory_bytes: 23636
import java.util.*;

public class Main{
  
  public static void main (String[] args){
    
    Main main = new Main();
    main.solve();
  }
  
  private void solve(){
    
    Scanner scanner = new Scanner (System.in);
    
    String dates = scanner.nextLine();
    
    char month1 = dates.charAt(5);
    char month2 = dates.charAt(6);
    
    if (month1=='0'){
    	if (month2=='1'||month2=='2'||month2=='3'||month2=='4'){
			System.out.println("Heisei");
    	} else {
      		System.out.println("TBD");
    	}
    } else {
      System.out.println("TBD");
    }
  }
}

Measured memory_bytes: 21588
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int i,a,b,c,x,y,t;
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    int ans=a*x+b*y;
    for(i=1;i<=x&&i<=y;i++){
        t=ans-(a+b)+2*c;
        ans=min(t,ans);
    }
    for(;i<=x;i++){
        t=ans-a+2*c;
        ans=min(t,ans);
    }
    for(;i<=y;i++){
        t=ans-b+2*c;
        ans=min(t,ans);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int n;
vi a;

bool f(int c) {
  vp d;
  d.pb(P(0,a[0]));
  srep(i,1,n) {
    int p = a[i-1], l = a[i];
    if (l > p) {
      if (d.back().fi) d.pb(P(0,l-p));
      else d.back().se += l-p;
    } else {
      int w = p-l;
      while (w) {
        P x = d.back(); d.pop_back();
        int s = min(w,x.se);
        x.se -= s;
        w -= s;
        if (x.se) d.pb(x);
      }
      w = 0;
      while (1) {
        if (!sz(d)) return false;
        ++w;
        int e = d.back().fi;
        d.back().se--;
        if (!d.back().se) d.pop_back();
        ++e;
        if (e == c) continue;
        if (sz(d) && d.back().fi == e) d.back().se++;
        else d.pb(P(e,1));
        --w;
        break;
      }
      if (w) {
        if (d.back().fi) d.pb(P(0,w));
        else d.back().se += w;
      }
    }
  }
  return true;
}

int main() {
  scanf("%d",&n);
  a = vi(n);
  cin>>a;
  int l = 0, r = n+5;
  while (l+1<r) {
    int c = (l+r)/2;
    if (f(c)) r = c; else l = c;
  }
  cout<<r<<endl;
  return 0;
}






















Measured memory_bytes: 1024
n,k,*l=map(int,open(0).read().split())
for _ in range(min(k,99)):
  s=[0]*(n+1)
  for i in range(n):
    s[max(i-l[i],0)]+=1
    s[min(i+l[i]+1,n)]-=1
  l[0]=min(s[0],n)
  for i in range(1,n):
    l[i]=min(l[i-1]+s[i],n)
print(*l)

Measured memory_bytes: 171156
a,b=map(int,input().split())
s=[2**i for i in range(42)]
d=[0]*42
i=1
if ((b+1)//2-a//2)%2==1:
    d[0]+=1
while i<42:
    if s[i]>b:
        break
    elif s[i]>a: 
        a=s[i]
    p,q=a%s[i],a//s[i]
    o,t=b%s[i],b//s[i]
    if q==t:
        if q%2==1:
            if (b-a+1)%2==1:
                d[i]=1
    else:
        h=0
        if q%2==1:
            h+=(q+1)*s[i]-a  
        if t%2==1:
            h+=b-t*s[i]+1
        if h%2==1:
            d[i]=1
    i+=1
ans=0
for i in range(42):
    ans+=d[i]*s[i]
print(ans)

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

#define null               ""
#define endl               '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 50;
int n, m, a[nsz + 5], ans;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    cont (i, n) {
        cin >> a[i];
    }
    int t = 0, p;
    for (; t <= min(n, m); ++t) {
        p = m - t;
        int l = 0, r = t;
        for (; l <= t; ++l, --r) {
            int res = 0;
            vector<int> tmp;
            cont (i, l) {
                res += a[i];
                if (a[i] < 0) {
                    tmp.push_back(a[i]);
                }
            }
            for (int i = n; i > n - r; --i) {
                res += a[i];
                if (a[i] < 0) {
                    tmp.push_back(a[i]);
                }
            }
            sort(all(tmp));
            loop (i, min((int) tmp.size(), p)) {
                res -= tmp[i];
            }
            ans = max(ans, res);
        }
    }
    cout << ans << endl;
}


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

int main(){
    long long int N,ans=0;
    cin >> N;

    vector<long long int> A(N,0),B(N,0),C(N,0);
    for (int i=0;i<N;i++) cin >> A[i];
    for (int i=0;i<N;i++) cin >> B[i];
    for (int i=0;i<N;i++) cin >> C[i];
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());

    for(int i=0 ; i<N ; i++){
        auto low = lower_bound(A.begin(), A.end(), B[i])- A.begin();
        auto upp = C.end() - upper_bound(C.begin(),C.end(),B[i]);
        ans += low*upp;
    }
    cout << ans << endl;
    return 0;

}




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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int n;
  cin >> n;
  cout << n * 800 - n / 15 * 200 << endl;
}


Measured memory_bytes: 256
#include<cstdio>


int hoge(int x)
{
	return (x+9)%10+1;
}


void min_u(int&m, int v)
{
	if(m>v) m=v;
}


int main(void)
{
	int a, b, c, d, e;

	while(scanf("%d%d%d%d%d", &a, &b, &c, &d, &e)==5)
	{
		int ans=-10;
		int plus=10;

		ans+=(a+9)/10*10;
		ans+=(b+9)/10*10;
		ans+=(c+9)/10*10;
		ans+=(d+9)/10*10;
		ans+=(e+9)/10*10;

		min_u(plus, hoge(a));
		min_u(plus, hoge(b));
		min_u(plus, hoge(c));
		min_u(plus, hoge(d));
		min_u(plus, hoge(e));
		ans+=plus;

		printf("%d\n", ans);
	}

	return 0;
}


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

void q_sort(vector<int>& a , int l , int r){
	if(l>=r) return;
	int p=a[r];
	int i=l-1 , j=r , tmp;
	while(1){
		while(a[++i]<p );
		while(i<--j && a[j]>p );
		if(i>=j) break;
		a[i]^=a[j];
		a[j]^=a[i];
		a[i]^=a[j];
	}
	tmp=a[r];a[r]=a[i];a[i]=tmp;
	q_sort(a , l , i-1);
	q_sort(a , i+1 , r);
}



int main(){
	
	int n;
	cin >> n;
	vector<int> l(2*n);
	for(int i=0 ; i<2*n ;++i){
		cin >> l[i];
	}
	q_sort(l , 0 , 2*n-1);
	int sum=0;
	for(int i=0 ; i<2*n ; i=i+2){
		sum+=l[i];
	}
	cout << sum << endl;
	return 0;
}

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

int main() {
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    int dis = 1e8;
    for(int i = 0; i < N; i++) {
        if(i < N - 1) {
            dis = min(dis, K - A[i + 1] + A[i]);
        }
    }
    dis = min(dis, A[N - 1] - A[0]);
    cout << dis << endl;
    return 0;
}

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

int main() {
  string S;
  int K;
  string res;

  cin >> K >> S;
  
  if(S.size() <= K){
    cout << S << endl;
  }
  else{
    rep(i,K){
      res += S.at(i);
    }
    res += "...";
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 3628
import sys 
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    n,m = IL()
    h = LI()
    judge = [1]*n
    table = [[] for _ in range(n)]
    for _ in range(m):
        a,b = IL()
        table[a-1].append(b-1)
        table[b-1].append(a-1)
    for i in range(n):
        if judge[i]:
            piv = h[i]
            for rep in table[i]:
                if piv<=h[rep]:
                    judge[i] = 0
                    break
                else:
                    judge[rep] = 0
    print(judge.count(1))
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 30112
# 絶対値が一番低くなるものを食べる
N, L = map(int, input().split())

sum_apple=L*N+N*(N+1)//2-N
#print(sum_apple)

worst = L
for n in range(N):
  if abs(worst)>abs(L+n):
    worst=L+n
worst=worst-L+1
#print(worst)
worst_score=L+worst-1
print(sum_apple-worst_score)

Measured memory_bytes: 3060
import numpy as np
from numba import njit

S = input()
MOD = 2019
dp = np.zeros(MOD, dtype=np.int64)
dp[0] = 1

@njit
def hoge(dp, s):
    T = dp.copy()
    dp[s:] = T[:-s]
    dp[:s] = T[-s:]

ans = 0
for i, s in enumerate(S[::-1]):
    hoge(dp, (int(s) * pow(10, i, MOD)) % MOD)
    ans += dp[0]
    dp[0] += 1
print(ans)


Measured memory_bytes: 112812
import fractions

n, x = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
if len(l) == 1:
    print(abs(l[0] - x))
elif len(l) == 2:
    print(fractions.gcd(abs(l[0] - x), abs(l[1] - x)))
else:
    ans = fractions.gcd(abs(l[0] - x), abs(l[1] - x))
    for i in range(2, n):
        ans = fractions.gcd(ans, abs(l[i] - x))
    print(ans)

Measured memory_bytes: 16240
import java.util.Scanner;
//import java.util.Random;

class UnionFind{
	int[] par;
	int num;
	
	UnionFind(int n){//constructor.
		par=new int[n];
		for(int i=0;i<n;++i) par[i]=-1;
		num=n;
	}
	
	void init(int n){
		par=new int[n];
		for(int i=0;i<n;++i) par[i]=-1;
		num=n;
	}
	
	int root(int x){
		if(par[x]<0) return x;
		par[x]=root(par[x]);
		return par[x];
	}
	
	int size(int x){
		return -par[root(x)];
	}
	
	boolean same(int x,int y){
		return root(x)==root(y);
	}
	
	boolean unite(int x,int y){
		x=root(x);
		y=root(y);
		if(x==y) return false;
		par[x]+=par[y];
		par[y]=x;
		num--;
		return true;
	}
}

class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		
		int n=stdIn.nextInt();
		int m=stdIn.nextInt();
		
		int[] a=new int[m];
		int[] b=new int[m];
		for(int i=0;i<m;++i){
			a[i]=stdIn.nextInt();
			b[i]=stdIn.nextInt();
			a[i]--;
			b[i]--;
		}
		
		int ans=0;
		for(int i=0;i<m;++i){
			UnionFind uf=new UnionFind(n);
			for(int j=0;j<m;++j){
				if(i==j){}
				else uf.unite(a[j],b[j]);
			}
			if(uf.num>1) ans++;
		}
		
		System.out.println(ans);
	}
}

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

struct node{
	struct node *l;
	struct node *r;
	struct node *p;
	int key;
};

typedef struct node * Node;

void inorder(Node);
void preorder(Node);
void insert(int);

Node root;

int main(void){
	int n,in;
	char input[7];
	int i;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%s",input);

		if(input[0]=='i'){
			scanf("%d",&in);
			insert(in);		
		}
		else{
			if(root!=NULL){
				inorder(root);
				printf("\n");
				preorder(root);
				printf("\n");
			}
		}
	}

	return 0;
}


void insert(int in){
	Node new,work,move;

	new=(Node)malloc(sizeof(struct node));
	new->key=in;
	new->l=NULL;
	new->r=NULL;

	work=NULL;
	move=root;
	while(move!=NULL){
		work=move;
		if(move->key > in){
			move=move->l;
		}
		else{
			move=move->r;
		}
	}

	new->p=work;
	if(work==NULL) root=new;
	else if(work->key > in) work->l=new;
	else work->r=new;

}


void inorder(Node work){
	if(work->l != NULL) inorder(work->l);
	printf(" %d",work->key);
	if(work->r != NULL) inorder(work->r);
}


void preorder(Node work){
	printf(" %d",work->key);
	if(work->l != NULL) preorder(work->l);
	if(work->r != NULL) preorder(work->r);
}

Measured memory_bytes: 24036
#include <iostream>
#include <vector>

class Union_find_tree {
	Union_find_tree *_parent = nullptr;
	Union_find_tree* parent() {
		if (_parent == nullptr) return this;
		else {
			return _parent = _parent->parent();		
		}
	}
public:
	void join(Union_find_tree &other) {
		if (!is_same_union(other)) {
			parent()->_parent = other.parent();
		}
	}
	bool is_same_union(Union_find_tree &other) {
		return parent() == other.parent();
	}
};
int main() {
	int n, m;
	std::cin >> n >> m;
	std::vector<int> p(n);
	std::vector<Union_find_tree> uft(n);
	for (auto &ps : p) {
		std::cin >> ps;
	}
	for (auto i = 0; i < m; ++i) {
		int x, y;
		std::cin >> x >> y;
		uft[x - 1].join(uft[y - 1]);
	}
	int count = 0;
	for (auto i = 0; i < n; ++i) {
		if (uft[p[i] - 1].is_same_union(uft[i])) {
			++count;
		}
	}
	std::cout << count << std::endl;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void push(int);
int pop();

int top,stack[200];

int main(){
  int x,y,i=0;
  top=0;
  char data[100];
  /*while(1){
    scanf("%c",&data);
    if(!((data >= '0' && data <= '9')||data=='+'||data=='-'||data=='*')) break;
    switch(data){
    case '+':
      x=pop();
      y=pop();
      push(x+y);
      break;
    case '-':
      y=pop();
      x=pop();
      push(x-y);
      break;
    case '*':
      x=pop();
      y=pop();
      push(x*y);
      break;
    default:
      push(data);
      break;
    }
    for(i=1;i<=top;i++)
      printf(" &d\n",stack[i]);
      }*/
  while(scanf(" %s",data)==1){
    if(data[0] == '+'){
      x=pop();
      y=pop();
      push(x+y);
    }else if(data[0] == '-'){
      y=pop();
      x=pop();
      push(x-y);
    }else if(data[0] == '*'){
      x=pop();
      y=pop();
      push(x*y);
    }else if(data[i]>='0'&&data[i]<='9') push(atoi(data));
  }
  printf("%d\n",pop());
  return 0;
}

void push(int data){
  top++;
  stack[top]=data;
}

int pop(){
  top--;
  return stack[top+1];
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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 ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
const int nmax=100005;
vector<vector<pair<ll,ll>>> g(nmax);
ll d[nmax];
void dijkstra(ll s){
  priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
  fill(d,d+nmax,INF);
  d[s]=0;
  pq.push(make_pair(0,s));
  while(!pq.empty()){
    pair<ll,ll> p=pq.top();
    pq.pop();
    ll v=p.second;
    if(d[v]<p.first){
      continue;
    }
    for(auto x:g[v]){
      if(d[x.first]>d[v]+x.second){
        d[x.first]=d[v]+x.second;
        pq.push(make_pair(d[x.first],x.first));
      }
    }
  }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    vector<int> a(m),b(m),c(n,inf),ans(n);
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--,b[i]--;
        g[a[i]].push_back({b[i],1});
        g[b[i]].push_back({a[i],1});
    }
    dijkstra(0);
    rep(i,m){
        if(d[a[i]]<d[b[i]]){
            if(c[b[i]]>d[a[i]]){
                c[b[i]]=d[a[i]];
                ans[b[i]]=a[i];
            }
        }
        else if(d[a[i]]>d[b[i]]){
            if(c[a[i]]>d[b[i]]){
                c[a[i]]=d[b[i]];
                ans[a[i]]=b[i];
            }
        }
    }
    cout << "Yes" << endl;
    for(int i=1;i<n;i++){
        cout << ans[i]+1 << endl;
    }
}

Measured memory_bytes: 20996