akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include<vector>
#include<cstring>
#include<set>
#include <cstdio>
#include<queue>
#include<map>
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define endl '\n'
#define forup(i,a,n) for( int i =a; i < n; i++)
#define llforup(i,a,n) for( ll i =a; i < n; i++)
#define fordown(i,a,n) for( int i =a; i >= n; i--)
#define fornot(i,a,n) for( int i=a;!n;i++)
#define mod  (ll)(1e9+7)
#define ifempty(a)  if(!a)
using namespace std;
typedef long long ll;
inline int readnum()
{
	int p, data = 0; char ch = 0;
	while ((ch != '-') &&( ch < '0' || ch>'9') )//注意运算优先级，逻辑与大于逻辑非
		ch = getchar();//相当于正则表达式的搜索，跳过不需要的字符
	if (ch == '-')
		p = -1, ch = getchar();//不能与if平行放置，不懂为什么，可能是bug
	else p = 1;
	while (ch >= '0' && ch <= '9') data = data * 10 + ch - '0', ch = getchar();//搜索需要的字符
	return data * p;
}
inline int ReadPossitive()
{
	char ch; int data = 0;
	ch = getchar();
	while (ch == ' ' || ch == '\n')ch = getchar();
	while (ch != ' ' && ch != '\n' && ch != EOF)
	{
		data = data * 10 + ch - '0';
		ch = getchar();
	}
	return data;
}
//E-mail 374656045@qq.com
#define MAX 100
#define INFTY (1LL<<32)
class solve {
private:
    ll edge[MAX][MAX];
	int n, e;
public:
	solve()
	{
		initial();
		Floyd();
		bool negative = false;
		forup(i, 0, n)
			if (edge[i][i] < 0)negative = true;//任意两点间如果存在负环，则两点间最小成本可以无限小，因此无法定义最短路径。
		//用弗洛伊德算法判断时只需判断edge[i][i]是否为负数就可以了，edge[i][i]表示多次插点后的最小成本，也表示去外面转一圈回来后的权值.
		//将edge[i][i]初始值设置为0可以加速判断的过程。只需一次Floyd算法即可判断。环上有多少个点，edge[i][i]就会被计算多少次，插点法的概念
		if (negative)printf("NEGATIVE CYCLE\n");
		else
		{
			forup(i, 0, n)
			{
				forup(j, 0, n)
				{
					if (j)printf(" ");
					if (edge[i][j] != INFTY)
						printf("%lld", edge[i][j]);
					else
						printf("INF");
				}
				printf("\n");
			}
		}
	}
	void initial()
	{
		n = ReadPossitive(); e = ReadPossitive();
		forup(i, 0, n)
			forup(j, 0, n)
			edge[i][j] = ((i == j) ? 0 : INFTY);
		int u, v, value;
		forup(i, 0, e)
		{
			u = ReadPossitive(); v = ReadPossitive(); value = readnum();
			edge[u][v] = value;//无向图不用ver[v][u]在连边。
		}
	}
	void Floyd()
	{
		forup(k, 0, n)
			forup(i, 0, n)
		{
			if(edge[i][k]!=INFTY)//小优化，插点失败就跳过
				forup(j, 0, n)
			{
				if (edge[k][j] != INFTY)
					if (edge[i][j] > edge[i][k] + edge[k][j])//避免使用min函数，用布尔运算代替赋值提高速度
						edge[i][j] = edge[i][k] + edge[k][j];
			}
		}
	}

};
int main(void)
{
	ios_base::sync_with_stdio(0); cin.tie(0);//慎用，cin和scanf混用会导致非MSC++WA
#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve solution;
#ifdef DEBUG
	fclose(stdin);//关闭文件 
	fclose(stdout);//关闭文件 
#endif
	return 0;

}




Measured memory_bytes: 3308
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val A = map(N)(_ => sc.nextInt())
    val ans = A.grpBy(identity).sumBy { case (num, as) =>
      val cnt = as.length
      if (cnt >= num) cnt - num
      else cnt
    }

    out.println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = {
    var i = 0
    while(i < n) {
      f(i)
      i += 1
    }
  }

  private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    var i = 0
    while(i < n) {
      res(i) = f(i)
      i += 1
    }
    res
  }

  private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      as.rep { a =>
        val k = f(a)
        map.getOrElseUpdate(k, ArrayBuffer()) += a
      }
      map
    }

    def rep[@specialized B](f: A => B): Unit = {
      var i = 0
      val N = as.length
      while(i < N) {
        f(as(i))
        i += 1
      }
    }
  }

  private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


Measured memory_bytes: 50840
a[9];main(z,n,m,i){for(;scanf("%d%d",&m,&n),*a=m;puts(a))for(;n--;)for(i=18;i;a[i]=n?a[i+1]+=z*m/1e4,z*m%10000:z&&!printf("%d%.3s",z,51-i*3+"MtsFksNytAsgGgsGokSaiSeiKanKo\0JouJo\0GaiKeiChoOkuMan"))z=a[--i];}

Measured memory_bytes: 616
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	string S;
	cin >> N >> S;
	int cnt = 0;
	for (int i = 1; i < N; i++) {
		if (S[i] == 'E') {
			cnt++;
		}
	}
	int ans = cnt;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'W') cnt++;
		if (S[i + 1] == 'E') cnt--;
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 900
from heapq import *
from collections import Counter
import itertools


n, x, y = map(int,input().split())
edges = [[] for _ in range(n)]

def dijkstra(s, edges):
    d = [float('inf')] * n
    d[s] = 0
    heap = [(0, s)]
    while heap:
        c, node = heappop(heap)
        for cost, v in edges[node]:
            if c + cost < d[v]:
                d[v] = c + cost
                heappush(heap, (d[v], v))
    return d

for i in range(n-1):
    u, v = i, i+1
    edges[u].append([1,v])
    edges[v].append([1,u])
edges[x-1].append([1, y-1])
edges[y-1].append([1, x-1])

ans = []

for s in range(n):
    ans.append(dijkstra(s, edges))

f_ans = []
for i in range(n):
    f_ans.append(ans[i][i+1:])
f_ans = Counter(list(itertools.chain.from_iterable(f_ans)))

for i in range(1, n):
    print(f_ans[i])

Measured memory_bytes: 222680
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//
//??????index??¨???????????????????????¨?????¢??????????¶??????????
//map????????£???[??????,?????°]?????¨???????????°????????¢????????????????????????
//

int main(void){
	ll ans[1000],cnt=0;
	rep(i,1000)ans[i]=0;
	while(true){
		int N,M;
		cin>>N>>M;
		if(N==0 && M==0)break;
		int h[1501],w[1501];
		reg(i,1,N)cin>>h[i];
		reg(i,1,M)cin>>w[i];
		ll DP[1501];
		map<ll,int> mapH;
		map<ll,int> mapW;
		DP[0]=0;
		rep(i,N)DP[i+1]=DP[i]+h[i+1];//h???i???????????§????´???????
		reg(i,1,N){//???????????§??????
			reg(j,0,N-i)mapH[DP[j+i]-DP[j]]++;//h?????????????????¨????????¨??????????±???????
		}
		rep(i,M)DP[i+1]=DP[i]+w[i+1];//w???i???????????§????´???????
		reg(i,1,M){//???????????§??????
			reg(j,0,M-i)mapW[DP[j+i]-DP[j]]++;//w?????????????????¨????????¨??????????±???????
		}

		for (map<ll,int>::iterator p=mapH.begin();p!=mapH.end();++p){
			ll key = p->first;
			ans[cnt] += mapW[key]*mapH[key];
		}
		cnt++;
	}
	rep(i,cnt)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 44636
#include <cstdio>
#include <cstring>

// 説明は省略しますが, 以下の行の 1 を 0 に変更することでデバッグ用の展開図などが出力されなくなり, 出力例に合う出力になります.
#define DEBUG 0

int main() {
	/* dice : サイコロの状態を保存
	 * dice[0] : 上の面
	 * dice[1] : West  の面
	 * dice[2] : South の面
	 *
	 *    ／‾‾／
	 *   ／_0__／|
	 *   |     |1|
	 *   |__2_ |／
	 *
	 **/

	int i;

	int dice[3] = {1, 3, 2};

	char input[10]; // 入力を保存する char 型の配列 (文字列はchar型の配列)
	int sum = 1;  // 合計
	int temp; // 一時保存用

	int n; // 指示回数
	
	while (1) {
	scanf("%d", &n);
	if (n == 0) break;
	sum = 1;
	dice[0] = 1;
	dice[1] = 3;
	dice[2] = 2;

	if (DEBUG) printf(" |%d|\n%d|%d|%d\n |%d|\n |%d|\n", 7 - dice[2], 7 - dice[1], dice[0], dice[1], dice[2], 7 - dice[0]);

	for (i=0; i<n; ++i) {
		if (DEBUG) printf("Sum: %d\n", sum);

		// n の回数だけ読み込み・処理を繰り返す
		scanf("%s", input);

		if (strcmp(input, "North") == 0) {
			// 北の場合の処理
			temp = 7 - dice[0]; // 処理後の dice[2] の値
			dice[0] = dice[2];
			dice[2] = temp;
		} else if (strcmp(input, "South") == 0) {
			// 南の場合の処理
			temp = 7 - dice[2]; // 処理後の dice[0] の値
			dice[2] = dice[0];
			dice[0] = temp;
		} else if (strcmp(input, "East") == 0) {
			// 東の場合の処理
			temp = 7 - dice[1]; // 処理後の dice[0] の値
			dice[1] = dice[0];
			dice[0] = temp;
		} else if (strcmp(input, "West") == 0) {
			// 西の場合の処理
			temp = 7 - dice[0]; // 処理後の dice[1] の値
			dice[0] = dice[1];
			dice[1] = temp;
		} else if (strcmp(input, "Right") == 0) {
			// 右の場合の処理
			temp = 7 - dice[2]; // 処理後の dice[1] の値
			dice[2] = dice[1];
			dice[1] = temp;
		} else if (strcmp(input, "Left") == 0) {
			// 左の場合の処理
			temp = 7 - dice[1]; // 処理後の dice[2] の値
			dice[1] = dice[2];
			dice[2] = temp;
		}


		if (DEBUG) printf(" |%d|\n%d|%d|%d\n |%d|\n |%d|\n", 7 - dice[2], 7 - dice[1], dice[0], dice[1], dice[2], 7 - dice[0]);

		sum += dice[0];
	}

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

	return 0;
}

Measured memory_bytes: 1032
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str;
  cin>>str;
  ll n=str.length();
  ll i,j=0,k=0;
  for(i=0;i<=n/2;i++)
  {
      if(str[i]!=str[n-i-1])
      {
          cout<<"No";
          return 0;
      }
  }
  string str3;
  for(i=0;i<(n-1)/2;i++)
  {
      str3[k]=str[i];
      k++;
  }
  for(i=0;i<k;i++)
  {
      if(str3[i]!=str3[k-i-1])
      {
          cout<<"No";
          return 0;
      }
  }
  string str2;
  for(i=(n+3)/2-1;i<n;i++)
  {
      str2[j]=str[i];
      j++;
  }
  for(i=0;i<j;i++)
  {
      if(str2[i]!=str2[j-i-1])
      {
          cout<<"No";
          return 0;
      }
  }
  cout<<"Yes"; 
  return 0;
}

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

// 
// なぜか一部通らない
int main() {
    int A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;

    for (int i = 0; i <= K; i++) {
        if (A < B && B < C) {
            cout << "Yes";
            return 0;
        }

        if (A >= B) {
            B *= 2;
            continue;
        }
        if (B >= C) {
            C *= 2;
            continue;
        }
    }

    cout << "No";
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int without(int V, int inx) {
    return (V % (1 << inx)) + ((V >> (inx + 1)) << inx);
}

int insert(int V, int inx, int val) {
    return (V % (1 << inx)) + ((V >> inx) << (inx + 1)) + (val << inx);
}

vi go(int N, int A, int B) {
    if (N == 1) {
        assert(A != B);
        return { A, B };
    }

    for (int i = 0; i < N; i++) {
        if ((A^B) & (1 << i)) {
            int AA = without(A, i),
                BB = without(B, i);

            vi left  = go(N - 1, AA, AA^1),
               right = go(N - 1, AA^1, BB);

            vi res;
            for (int v : left)
                res.push_back(insert(v, i, (A >> i)&1));
            for (int v : right)
                res.push_back(insert(v, i, (B >> i)&1));
            return res;
        }
    }

    assert(false);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N, A, B;
    cin >> N >> A >> B;

    if ((__builtin_popcount(A)&1) == (__builtin_popcount(B)&1)) {
        cout << "NO\n";
    } else {
        cout << "YES\n";
        vi res = go(N, A, B);
        for (int v : res)
            cout << v << " ";
        cout << "\n";
    }

    return 0;
}



Measured memory_bytes: 1756
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll gcd(ll p,ll q){for(ll t;q;)t=p%q,p=q,q=t;return p;}

int main(){
	ll x,y;
	scanf("%lld%lld",&x,&y);
	y/=gcd(x,y);
	ll ans=1;
	for(int i=2;i*i<=y;i++)if(y%i==0){
		ans*=i;
		while(y%i==0)y/=i;
	}
	printf("%lld\n",ans*y);
}


Measured memory_bytes: 2108
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>

//使い方がよくわからない
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    int n;
    cin >> n;
    cout << n*n*n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
long a,b,c,i,j[11],k;
while(cin>>a){
cin>>b>>c;
for(i=1;i<=10;i++)j[i]=1;
j[a]=j[b]=j[c]=0;
for(k=0,i=1;i<=10;i++){k+=j[i];if(k==4)break;}
if(a+b+i<=20)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}

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

int main() {
    int n,m;cin>>n>>m;;long long dp[n+1];vector<bool> s(n+1,true);
    for(int i=0;i<m;i++){
        int a;cin>>a;
        s[a]=false;
    }
    for(int i=0;i<n+1;i++) dp[i]=0;dp[0]=1;
    for(int i=0;i<n+1;i++){
        if(s[i+1]==true){
            dp[i+1]+=dp[i];
            if(i>0) dp[i+1]+=dp[i-1];
        }
        dp[i+1]%=1000000007LL;
    }
   cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();

        Console.WriteLine(N * 800 - (N / 15) * 200);
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

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

int main(){
  string s;
  cin >> s;
  int n=s.size();

  int cnt = 1;
//  char p = s[0];
  bool flg =false;
  for (int i = 1; i < n; i++)
  {
    if(s[i]==s[i-1] && !(flg)){
      if(i==n-1) break;
      i++;
      flg = true;
    }
    else{
      flg = false;
    }
    cnt++;
  }
  cout << cnt << endl;
  
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  string S;
  string T;
  cin >>N>>S>>T;
  string d;
  rep(i,N) {

    d +=S.at(i);
      d+=T.at(i);
  }
cout << d<< endl;
}
  

Measured memory_bytes: 256
import           Control.Monad
import           Data.Char
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed   as U
import qualified Data.IntSet           as S

main :: IO ()
main = do
  [n, d] <- map read . words <$> getLine
  xss <- replicateM n $ U.unfoldrN d (B.readInt . B.dropWhile isSpace) <$> B.getLine
  print $ solve xss

solve :: [U.Vector Int] -> Int
solve = length . filter p . pairs
  where
    p (xs, ys) = (`S.member` squares) $ U.sum $ U.zipWith sqareDist xs ys
    sqareDist x y = (x - y) ^ 2

squares :: S.IntSet
squares = S.fromList $ map (^ 2) [0 .. 400]

pairs :: [a] -> [(a, a)]
pairs []     = []
pairs [_]    = []
pairs (x:xs) = [(x, y) | y <- xs] ++ pairs xs

Measured memory_bytes: 636
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define INF 1 << 16
using namespace std;

int main(){
  int cost[20][20]; fill(&cost[0][0], &cost[0][0]+20*20, INF);
  int n, m, a, b, c, d;
  scanf("%d%d", &n, &m);
  rep(i, m){
    scanf("%d,%d,%d,%d", &a, &b, &c, &d);--a;--b;
    cost[a][b] = c;
    cost[b][a] = d;
  }

  rep(i, n) rep(j, n) rep(k, n)
    cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
  int s, g, weges, value;
  scanf("%d,%d,%d,%d", &s, &g, &weges, &value);--s;--g;
  printf("%d\n", weges - value - cost[s][g] - cost[g][s]);
  return 0;
}

Measured memory_bytes: 1028
n = int(input())
s = []
t = []
for i in range(n):
    ss, tt = map(str, input().split())
    s.append(ss)
    t.append(int(tt))
x =input()

song= s.index(x)
res = 0
for i in range(song+1, n):
    res += t[i]
    
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18 

using namespace std;
#define MAXN 1000001
// stores smallest prime factor for every number 
int spf[1000001]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
vector<int> getFactorization(int x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    string s;
    cin>>s;
    int n=s.length();
    if(s[n-1]=='s')
    {
        cout<<s;
        cout<<"es"<<endl;
    }
    else
    {
        cout<<s;
        cout<<"s"<<endl;
    }
}

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

int main() {
  double a,b,o1,o2,h,m;
  cin >> a >> b >> h >> m;
  o1 = (M_PI*(h+m/60))/6;
  o2 = M_PI*m/30;
  double lx,ly;
  lx = a*sin(o1)-b*sin(o2);
  ly = a*cos(o1)-b*cos(o2);
  double ans = sqrt(lx*lx+ly*ly);
  std::cout << std::fixed;
  std::cout << std::setprecision(12) << ans << endl;;
}

Measured memory_bytes: 4152
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <queue>
#include <cstring>
#include <iterator>
#include <list>
#include <set>
#include <map>
#include <bitset>
using namespace std;

int main()
{
  int r, g, b;
  cin >> r >> g >> b;

  if ((100 * r + 10 * g + b) % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}

		int max = 0;
		for (int i = 0; i < n; i++) {
			int sum = 0;
			for (int j = 0; j <= i; j++) {
				sum += a[j];
			}
			for (int j = i; j < n; j++) {
				sum += b[j];
			}
			max = Math.max(max, sum);
		}

		System.out.println(max);
		sc.close();
	}
}


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

int main() {
  string S, T;
  int A, B;
  string U;
  cin >> S >> T >> A >> B >> U;
  
  if(S==U) cout << A-1 << " " << B << endl;
    else cout << A << " " << B-1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long 
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define N ((ll)(2e6+100))
#define MAX ((ll)(1e16+100))
#define ARRS ((ll)(3e5+100))
#define MOD ((ll)(1e9+7))
#define M1 ((ll)(1001783))
#define M2 ((ll)(1001941))
#define M3 ((ll)(1002073))
#define pb push_back


ll w[200][200];
ll fi[200][200];
ll f[105][105][105];

struct va{
	ll a,b,c;
};
vector<va> v;
int main(){

	ll n,m;
	cin>>n>>m;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			cin>>w[i][j];

	for(int a=0; a<=100; a++){
		for(int b=0; b<=100; b++){
			for(int c=0; c<=100; c++){

				f[a][b][c]=1;
				for(int x=1; x<=n; x++)
					for(int y=1; y<=m; y++)
						if(w[x][y]>x*a+y*b+c)
							f[a][b][c]=0;

			}
		}
	}

	for(int a=0; a<=100; a++){
		for(int b=0; b<=100; b++){
			for(int c=0; c<=100; c++){

				for(int x=1; x<=n; x++)
					for(int y=1; y<=m; y++)
						if(f[a][b][c]&&w[x][y]==x*a+y*b+c)
							fi[x][y]=1;

			}
		}
	}


	bool e=1;
	for(int x=1; x<=n; x++)
		for(int y=1; y<=m; y++)
			e&=fi[x][y];


	if(e){
		for(int i=1; i<=100; i++)
			v.pb({i,i+1,-1});
		for(int j=1; j<=100; j++)
			v.pb({j+101,101+j+1,-2});

		for(int a=0; a<=100; a++)
			for(int b=0; b<=100; b++)
				for(int c=0; c<=100; c++)
					if(f[a][b][c])
						{v.pb({a+1,202-b,c});break;}

		cout<<"Possible\n";
		cout<<202<<" "<<v.size()<<endl;
		for(auto x:v)
			if(x.c==-1)
				cout<<x.a<<" "<<x.b<<" "<<"X"<<endl;
			else if(x.c==-2)
				cout<<x.a<<" "<<x.b<<" "<<"Y"<<endl;
			else
				cout<<x.a<<" "<<x.b<<" "<<x.c<<endl;
		cout<<1<<" "<<202;
	}
	else {
		cout<<"Impossible";
	}
}
 


Measured memory_bytes: 9536
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  ll a,b;
  cin>>a>>b;

  (a%3==0||b%3==0||(a+b)%3==0||(a==1&&b==2)||(a==2&&b==1))?cout<<"Possible"<<endl:cout<<"Impossible"<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int N;
	scanf("%d",&N);
	int A[N+1],B[N+1],C[N];
	int i;
	A[0] = 10000; B[0] = 100000;
	for(i=1;i<N+1;i++) scanf("%d",&A[i]);
	for(i=1;i<N+1;i++) scanf("%d",&B[i]);
	for(i=1;i<N;i++) scanf("%d",&C[i]);
	int ans = 0;
	/*
	for(i=1;i<N+1;i++){
		printf("i = %d, A[i] = %d, B[i] = %d",i,A[i],B[i]);
		if(i!=N) printf("C[i] = %d",C[i]);
		printf("\n");
	}
	*/
	int pre_A;
	pre_A = A[1];
	for(i=1;i<N+1;i++){
		ans += B[A[i]];
		if(A[i] == pre_A + 1)
		{
			//printf("C\n");
			ans += C[pre_A];
		}
		pre_A = A[i];
		//printf("ans = %d\n",ans);
	}
	printf("%d",ans);
	
	return 0;
}



Measured memory_bytes: 128
#include<stdio.h>

int main()
{
int a , b;
  scanf("%d %d\n",&a , &b);
  

  if (a < b)
    printf("a < b\n");

  if(a > b)
    printf("a > b\n");

  if(a == b)
    printf("a == b\n");


return 0;
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

struct P {
  int w, s, v;
  bool operator < (const P& p) {
    if (w+s != p.w+p.s) return w+s < p.w+p.s;
    return v > p.v;
  }
};

int N;
P ps[1010];
int dp[1010][20010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  REP(i, N) {
    cin >> ps[i].w >> ps[i].s >> ps[i].v;
  }
  sort(ps, ps+N);
  REP(i, N) REP(j, 20010) {
    chmax(dp[i+1][j], dp[i][j]);
    if (j <= ps[i].s && j+ps[i].w < 20010) {
      chmax(dp[i+1][j+ps[i].w], dp[i][j]+ps[i].v);
    }
  }
  int ans = 0;
  REP(i, 20010) chmax(ans, dp[N][i]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 156928
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
constexpr int64_t MOD = 998244353;

int p2m[9000];

int64_t p2(int64_t x) {
  return p2m[x];
}

int64_t frac[9000];
int64_t ifrac[9000];

int64_t inv(int64_t a,int64_t p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

void init() {
  frac[0] = ifrac[0] = 1;
  REP(i,8999) {
    frac[i+1] = ((i+1) * frac[i]) % MOD;
    ifrac[i+1] = inv(frac[i+1], MOD);
  }
  p2m[0] = 1;
  REP(i,8999) {
    p2m[i+1] = (2 * p2m[i]) % MOD;
  }
}

int64_t comb(int64_t n, int64_t k) {
  return (((frac[n] * ifrac[k]) % MOD) * ifrac[n-k]) % MOD;
}

int64_t solve(int64_t k, int64_t n, int64_t i) {
  int cnt = 0;
  FOR(j,1,k+1) {
    if (1 <= i - j && i - j <= k) ++cnt;
  }
  if ((i % 2) == 1) {
    cnt /= 2;
    int64_t res = 0;
    REP(j,cnt+1) {
      int64_t val = (((comb(cnt, j) * p2(cnt-j)) % MOD) * comb(n+(k-cnt-j)-1, n)) % MOD;
      res += (val * (((j % 2) == 0) ? 1 : (MOD-1))) % MOD;
      res %= MOD;
    }
    return res;
  } else {
    int64_t sub = (cnt+1)/2;
    cnt /= 2;
    int64_t res = 0;
    REP(j,sub) {
      int64_t val = (((comb(cnt, j) * p2(cnt-j)) % MOD) * (comb(n+(k-sub-j)-1, n) + comb((n-1)+(k-sub-j)-1, n-1))) % MOD;
      res += (val * (((j % 2) == 0) ? 1 : (MOD-1))) % MOD;
      res %= MOD;
    }
    return res;
  }
}

int main() {
  init();
  int64_t k, n;
  cin>>k>>n;
  FOR(i,2,2*k+1) {
    cout << solve(k,n,i) << endl;
  }
  return 0;
}


Measured memory_bytes: 512
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline                               
def I(): return list(map(int,inp().split()))
from collections import Counter
from numpy import prod

n=I()[0]
s=input() 
cut=0
for i in range(len(s)):
    for j in range(i+1,len(s)):
        if 2*j-i>=len(s): break
        if len({s[i],s[j],s[2*j-i]})==3:
            cut+=1
d=Counter(s)
if len(d)<3: print(0)
else: print(prod(list(d.values()))-cut)



Measured memory_bytes: 27240
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

vector<string> d;

void dfs(string s, int i){
  if (i == 10) d.push_back(s);
  else{
    dfs(s+'0', i+1);
    dfs(s+'1', i+1);
  }
}

int main(){
  string ss = "";
  dfs(ss, 0);
  sort(ALL(d));
  d.erase(d.begin());

  int n;
  cin >> n;
  vector<vector<char>> f(n, vector<char>(10));
  rep(i, n) rep(j, 10) cin >> f[i][j];
  vector<vector<int>> p(n, vector<int>(11));
  rep(i, n) rep(j, 11) cin >> p[i][j];

  int ans = -INF;
  rep(i, d.size()){
    int tmp = 0;
    rep(j, n){
      int c = 0;
      rep(k, 10){
        if (d[i][k] == '1' && d[i][k] == f[j][k]) c++;
      }
      tmp += p[j][c];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
N = int(input())
a = []

for i in range(N):
  N, k = input().split()
  k = int(k)
  #なぜsortメソッドで点数までsortできる？
  a.append([N, -k, i+1])
a.sort()

for a_ in a:
  print(a_[2])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{    
    int k, a, b;
    cin >> k >> a >> b;
    
    string ans = "NG";
    for(int i=a; i<b+1; ++i){
        if(i%k == 0){
            ans = "OK";
        }
    }

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  ll n;
  cin >> n;
  if(n<105){
    cout << 0 << endl;
  }else if(n<135){
    cout << 1 << endl;
  }else if(n<165){
    cout << 2 << endl;
  }else if(n<189){
    cout << 3 << endl;
  }else if(n<195){
    cout << 4 << endl;
  }else{
    cout << 5 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<" : "<<a<<endl;
#else
#define tr(a)    
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;
vi adj[100000+1];
int h[100000+1];
int parent[100000+1];
int subsize[100000+1];
void dfs(int u,int p){
	subsize[u]=1;
	parent[u]=p;
	h[u]=h[p]+1;
	for(auto i:adj[u])if(i!=p){
		dfs(i,u);
		subsize[u]+=subsize[i];
	}
}
void solve(){
	int N;
	cin>>N;
	rep(i,1,N){
		int a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	h[0]=-1;
	dfs(1,0);
	int move=(h[N]-1)/2;
	int cur=N;
	while(move--)cur=parent[cur];
	if((subsize[cur])*2>=N){
		cout<<"Snuke";
	}
	else{
		cout<<"Fennec";
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 13184
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define MOD 1000000007LL
using namespace std;
typedef vector<vector<int> > graph;
typedef pair<int,int> P;

void calc(int now, int pre_num, graph &g, vector<int> &cntr, vector<bool> &arrived) {
	cntr[now] += pre_num;
	for(int i = 0; i < g[now].size(); i++) {
		int next = g[now][i];
		if(!arrived[next]) {
			arrived[next] = true;
			calc(next,cntr[now],g,cntr,arrived);
		}
	}
}

int main() {
	int n,q;
	cin>>n>>q;
	graph g(n);
	for(int i = 0; i < n-1; i++) {
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> cntr(n);
	for(int i = 0; i < q; i++) {
		int p,x;
		cin>>p>>x;
		p--;
		cntr[p]+=x;
	}
	vector<bool> arrived(n);
	arrived[0] = true;
	calc(0,0,g,cntr,arrived);
	cout << cntr[0];
	for(int i = 1; i < n; i++) {
		cout << " " << cntr[i];
	}
	cout << endl;
}


Measured memory_bytes: 29824
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String InStr = scan.nextLine();

		String[] AryStr = InStr.split(" ");

		long cnt5 = 0;
		long cnt7 = 0;
		int i = 0;
      
		while(i <= 2) {
          if (AryStr[i].equals("5") ) {
				cnt5++;
			}
			if (AryStr[i].equals("7") ) {
				cnt7++;
			}
			i++;
		}

		if (cnt5 == 2 && cnt7 == 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		scan.close();
	}
}

Measured memory_bytes: 19796
#include<stdio.h>

int main (){
	int h_max,w_max,h,w;
	scanf("%d %d",&h_max,&w_max);
	scanf("%d %d",&h,&w);
	int cells[h_max][w_max];
	int i,j;
	for(i=0;i<h_max;i++){
		for(j=0;j<w_max;j++){
			cells[i][j] = 0;
		}
	}
	for(i=0;i<h;i++) {
		for(j=0;j<w_max;j++){
			cells[i][j] = 1;
		}
	}
	int count = 0;
	for(i=0;i<h_max;i++){
		for(j=0;j<w;j++){
			cells[i][j] = 1;
			count++;
			if(count == w) break;
		}
		count = 0;
	}
	int cell_count = 0;
	for(i=0;i<h_max;i++){
		for(j=0;j<w_max;j++){
			if(cells[i][j]==0) cell_count++;
		}
	}
	printf("%d\n",cell_count);	
	
	return 0; 
}
 

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
using namespace std;
long long x;
int ans=0,p;
int main()
{
	scanf("%lld",&x);
	while (x>=10)
	{
		if (x%10!=9) p=1;
		ans+=9;
		x/=10;
	}
	ans+=x-p;
	printf("%d",ans);
}

Measured memory_bytes: 256
use proconio::input;
fn main() {
    input!{
        n: usize,
        a: [usize; n],
    };
    let mut f: usize;
    let mut ans: u64 = 0;
    let mut prev = a[0];
    for i in 1..n {
        if prev > a[i] {
            f = prev - a[i];
        } else {
            f = 0;
        }
        prev = a[i] + f;
        ans = ans + f as u64;
    }
    println!("{}", ans);
}

Measured memory_bytes: 5652
n = int(input())
l_n = list(map(int, input().split()))
ans_count = 0

for i in range(n - 2):
    a = l_n[i]
    b = l_n[i + 1]
    c = l_n[i + 2]
    if a <= b <= c or c <= b <= a:
        ans_count += 1

print(ans_count)

Measured memory_bytes: 9084
//Bokann ga bokka--nn!!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main(){
	while(1)
	{
		int n;
		scanf("%d",&n);
		if(!n) return 0;
		map<char,pair<char,bool> >ch;
		for(int i=0;i<n;i++)
		{
			char x,y;
			cin >>x >> y;
			ch[x]=mp(y,1);
		}
		int m;
		scanf("%d",&m);
		string ret="";
		for(int i=0;i<m;i++)
		{
			char s;
			cin >> s;
			if(ch[s].second)
			{
				ret+=ch[s].first;
			}
			else
			{
				ret+=s;
			}
		}
		cout << ret << endl;
	}
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b){
    return (a/gcd(a,b)*b);
}


int main() {
    int K;
    cin >> K;
    string S;
    cin >> S;

    if(S.size() <= K) cout << S;
    else {
        rep(i,K) cout << S[i];
        cout << "...";
    }

    

    //string ans = ( flag ? "Yes" : "No" );
    //printf("%.8lf", ans);
    //cout << ans;
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define mod 1000000007
#define maxn 200000
using namespace std;
int h,w,a,b,ans;
int fac[200005],ifac[200005];

int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=1ll*res*x%mod;
		x=1ll*x*x%mod,y/=2;
	}
	return res;
}

int C(int x,int y){
	int res=1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;
	return res;
}

int main(){
	scanf("%d %d %d %d",&h,&w,&a,&b);
	fac[0]=1;for(int i=1;i<=maxn;i++) fac[i]=1ll*i*fac[i-1]%mod;
	ifac[maxn]=ksm(fac[maxn],mod-2);
	for(int i=maxn-1;i>=0;i--) ifac[i]=1ll*(i+1)*ifac[i+1]%mod;
	for(int i=1;i<=h-a;i++){
		ans+=1ll*C(i-1+b-1,i-1)*C(h-i+w-b-1,h-i)%mod;
		if(ans>=mod) ans-=mod;
	}
	printf("%d\n",ans);

	return 0;
}

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

using namespace std;

int w, h;
char mapl[52][52], mapr[52][52];

bool bfs(pair<int, int> sl, pair<int, int> sr, pair<int, int> gl, pair<int, int> gr) {
	vector<vector<vector<vector<int> > > > flag(52, vector<vector<vector<int> > >(52, vector<vector<int> >(52, vector<int>(52, 0))));
	queue<pair<int, int> > quel, quer; quel.push(sl); quer.push(sr);
	while (!quel.empty()) {
		pair<int, int>nowl, nowr; nowl = quel.front(); nowr = quer.front(); quel.pop(); quer.pop();
		if (nowl == gl && nowr == gr) {
			return true;
		}
		if ((mapl[nowl.first][nowl.second] == '%') || (mapr[nowr.first][nowr.second] == '%')) continue;
		if (flag[nowl.first][nowl.second][nowr.first][nowr.second]) continue;

		flag[nowl.first][nowl.second][nowr.first][nowr.second]++;

		int dlx[] = { -1,0,0,1 }; int dly[] = { 0,-1,1,0 };
		int drx[] = { -1,0,0,1 }; int dry[] = { 0,1,-1,0 };
		for (int i = 0; i < 4; ++i) {
			int xl = nowl.first + dlx[i], yl = nowl.second + dly[i], xr = nowr.first + drx[i], yr = nowr.second + dry[i];
			if (flag[xl][yl][xr][yr] == 0) {
				if (mapl[xl][yl] != '#' || mapr[xr][yr] != '#') {
					if (mapl[xl][yl] == '#') {
						quel.push(nowl); quer.push(make_pair(xr, yr));
					} else if (mapr[xr][yr] == '#') {
						quel.push(make_pair(xl, yl)); quer.push(nowr);
					} else {
						quel.push(make_pair(xl, yl)); quer.push(make_pair(xr, yr));
					}
				}
			}
		}
	}
	return false;
}

int main() {
	while (cin >> w >> h && (w || h)) {

		for (int i = 0; i < 52; ++i)
			for (int j = 0; j < 52; ++j) { mapl[i][j] = '#'; mapr[i][j] = '#'; }

		pair<int, int> sl, sr, gl, gr;
		for (int i = 1; i <= h; ++i) {
			for (int j = 1; j <= w; ++j) {
				cin >> mapl[i][j];
				if (mapl[i][j] == 'L') sl = make_pair(i, j);
				else if (mapl[i][j] == '%') gl = make_pair(i, j);
			}
			for (int j = 1; j <= w; ++j) {
				cin >> mapr[i][j];
				if (mapr[i][j] == 'R') sr = make_pair(i, j);
				else if (mapr[i][j] == '%') gr = make_pair(i, j);
			}
		}

		if (bfs(sl, sr, gl, gr)) cout << "Yes";
		else cout << "No";
		cout << endl;
	}
	return 0;
}


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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 100100;
int n;
int a[N];

int main () {
	//std::ios::sync_with_stdio(false);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	ll ans = 0;
	cin >> n;
	forn(i, n) {
		cin >> a[i];
	}
	ll l = 2, r = 2;
	ford(i, n) {
		ll nwl = (l + a[i] - 1) / a[i] * a[i];
		if (nwl > r) {
		 	puts("-1");
		 	return 0;
		}
		ll nwr = (r / a[i]) * a[i] + a[i] - 1;
		l = nwl, r = nwr;
	}
	cout << l << ' ' << r << endl;

	return 0;
}

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

int main()
{
    int N , ans = 0 ;
    cin >> N;
    vector<int>V(N);
    for (int j = 0; j < N; j++)
    {
        cin >> V[j];
    }
    sort(V.begin(), V.end());
    int low = 0, high = 0, mid = 0;
    for (int j = 0; j < N-2; j++)
    {
        
        for (int i = j + 1; i < N-1; i++)
        {

            low = i + 1;
            high = N-1;
            int temp = i;
            while (low <= high)
            {
                mid = (high + low) / 2;
                if (V[i] + V[j] > V[mid]) 
                {
                    temp = mid;
                    low = mid + 1;
                }
                else if (V[i] + V[j] <= V[mid]) { high = mid - 1; }
            }
            ans += (temp - i);
        }
    }

    cout << ans << endl;
}

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

int main()
{
  int N;
  cin >> N;
  string s;
  string t;
  cin >> s;
  cin >> t;

  rep(i,N){
    cout << s.at(i);
    cout << t.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
from sys import stdin
import bisect

n,t = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
li2 = []
for i in range(n):
    if li[i][1] <= t:
        li2.append(li[i][0])
if len(li2) == 0:
    print("TLE")
    exit()
li2.sort()
print(li2[0])

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int A =sc.nextInt();
        int B =sc.nextInt();
        int C =sc.nextInt();
        
        for(int i=1;i<=100;i++){
            if((A*i)%B ==C){
                System.out.println("YES");
                return;
            }
        }
        
        System.out.println("NO");
        
        
    }
    
    
}


Measured memory_bytes: 35600
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}

template<typename T>
vector<T> finddivisor(T x){//整数xの約数が入ったvectorを返すよ(xを含む)  
    vector<T> divisor;
    for(T i=1; (i*i)<=x ;i++)
    {
        if(x%i==0){
            divisor.push_back(i);
            if(i*i!=x){
                divisor.push_back(x/i);
            }//約数はペアを持つことを利用

        }
    }
    sort(divisor.begin(),divisor.end());
    return divisor;
}

signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  V<ll> v(n),u(0);
  rep(i,0,n)cin>>v[i];


  map<int,int> ma;
  rep(i,0,n)ma[v[i]]++;

  set<int> se;
  for(auto&& i:ma){
    if(i.sc<=1){
      u.pb(i.fs);
    }
  }


  ll ans=siz(u);
  rep(i,0,siz(u)){
    V<ll> div=finddivisor(u[i]);
    rep(j,0,siz(div)){
      if(div[j]==u[i])continue;

      if(ma.count(div[j])){
        ans--;
        break;
      }
    }
  }

  cout<<ans<<ENDL;


}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 16272
#include<bits/stdc++.h>
using namespace std;
int main(){
   int a=0,b=0;   
   string s;
   cin>>s;
  for(int i=s.size()-1;i>-1;i--){
    if(s[i]=='A')a=i;
  }
  for(int j=0;j<s.size();j++){
    if(s[j]=='Z')b=j;
  }
    cout<<b-a+1<<endl;
}

Measured memory_bytes: 640