akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						(int)2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	string S, T;
	cin >> N >> S >> T;

	REP(i, N) {
		cout << S[i] << T[i];
	}
	cout << endl;

	return 0;
}


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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int ans = k;
  for (int i = 0; i + 1 < n; i++) {
    ans *= (k - 1);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <cmath>

using namespace std;

int main(void){
  int n, l;
  cin >> n >> l;
  int apples[n] = {}, eaten, eaten_taste = INT_MAX, taste = 0;
  for(int i = 0; i < n; i++){
    apples[i] = l+i;
    if(abs(l+i) < eaten_taste){
      eaten = i;
      eaten_taste = abs(l+i);
    }
  }
  for(int i = 0; i < n; i++){
    if(i == eaten) continue;
    taste += apples[i];
  }
  cout << taste << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    A = in_nl()

    def sad(x):
        s = 0
        for i in range(N):
            s += abs(A[i] - (x + i + 1))
        return s

    def binary_search(min_n, max_n):

        while max_n - min_n != 1:
            tn = (min_n + max_n) // 2
            if sad(tn) < sad(tn + 1):
                max_n = tn
            else:
                min_n = tn

        return max_n

    b = binary_search(min(A) - 10**9, max(A) + 10**9)
    print(sad(b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 29192
#include <stdio.h>
int main(void)
{
  int a,b,d,r;
  double f;

  scanf("%d%d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/b;
  printf("%d %d %f\n",d,r,f);
  return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include <string>
using namespace std;
int main(){
   int a,b,c,d,e,A,B,C,D,E;
    cin>>a>>b>>c>>d>>e;

   int abc,arc,agc,apc,atc;
    abc = a-(a/10)*10;
    arc = b-(b/10)*10;
    agc = c-(c/10)*10;
    apc = d-(d/10)*10;
    atc = e-(e/10)*10;
   
    int result = abc;
    if(result > arc && arc != 0) result = arc;
    if(result > agc && agc != 0) result = agc;
    if(result > apc && apc != 0) result = apc;
    if(result > atc && atc != 0) result = atc;

    if(abc!=0) A=a+10-abc;
    else A = a;

    if(arc!=0) B=b+10-arc;
    else B = b;

    if(agc!=0) C=c+10-agc;
    else C = c;

    if(apc!=0) D=d+10-apc;
    else D = d;

    if(atc!=0) E=e+10-atc;
    else E = e;

    if(result == abc) cout << a+B+C+D+E<<endl;
    else if(result == arc) cout << b+A+C+D+E<<endl;
    else if(result == agc) cout << c+B+A+D+E<<endl;
    else if(result == apc) cout <<  d+B+C+A+E<<endl;
    else if(result == atc) cout <<  e+B+C+D+A<<endl;
    
return 0;


}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,wan;
	while(cin>>n>>wan,n||wan){
		vector<int>have(n);
		int i=0;
		int co=wan;
		while(1){
			if(wan){
				have[i]++;
				wan--;
				if(have[i]==co)break;
			}else{
				wan=have[i];
				have[i]=0;
			}
			i=(i+1)%n;
		}
		cout<<i<<endl;
	}
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  vector<int> ans(N);
  int one = 0;
  for(int i=N-1; i>=0; i--){
    int cnt = 0;
    int x = i;
    while(x < N){
      if(ans.at(x) == 1){
        cnt++;
      }
        x += i+1;
    }
    if(vec.at(i) == 0 && cnt %2 == 1){
      ans.at(i) = 1;
      one++;
    }
    else if(vec.at(i) == 1 && cnt %2 == 0){
      ans.at(i) = 1;
      one++;
    }
  }
  cout << one << endl;
  for(int i=0; i<N; i++){
    if(ans.at(i) == 1){
      cout << i+1;
      if(i == N-1){
        cout << endl;
        break;
      }
    cout << " ";
    }
  }
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,k; cin>>n>>k;
  vll a(n);
  bool zero=0;
  ll pos=0, neg=0;
  rep(i,n){
    cin>>a[i];
    if(a[i]==0) zero=1;
    if(a[i]>0) pos++;
    if(a[i]<0) neg++;
  }
  vsort(a);
  
  ll ans=1;
  
  // 正数なし
  if(pos==0){
    if(k%2==0){
      rep(i,k){
        (ans*=(a[i]+MOD)%MOD)%=MOD;
      }
      cout<<ans<<endl;
    }else{
      if(zero) cout<<0<<endl;
      else{
        rep(i,k){
          (ans*=(a[n-1-i]+MOD)%MOD)%=MOD;
        }
        cout<<ans<<endl;
      }
    }
    return 0;
  }
  
  // 正数が1つはある
  ll l=0, r=n-1;
  if(k%2) r--; // 正数がありkが奇数ならば最大値は必ず使われる
  
  ll cnt=0;
  while(k-cnt>=2){
    if(a[l]*a[l+1]>=a[r]*a[r-1]){
      ll mul=a[l]*a[l+1];
      while(mul<0) mul+=MOD;
      (ans*=mul%MOD)%=MOD;
      l+=2;
    }else{
      ll mul=a[r]*a[r-1];
      while(mul<0) mul+=MOD;
      (ans*=mul%MOD)%=MOD;
      r-=2;
    }
    cnt+=2;
  }
  
  if(k%2){
    (ans*=a[n-1])%=MOD;
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 4760
#include<stdio.h>
#define H 2000000

int P[H+1],n;
int parent(int);
int Left(int);
int Right(int);
void maxHeapify(int i){
  int left,right,large,temp;
  left = Left(i);
  right = Right(i);
  if(left <= n && P[left] > P[i]) large = left;
  else large = i;
  if(right <= n && P[right] > P[large])large = right;

  if(large != i){
    temp = P[i];
    P[i] = P[large];
    P[large] = temp;
    maxHeapify(large);
  }
}
    
int main(){
  int i,p;
  
  scanf("%d", &n);
  for(i = 1;i<=n;i++){
    scanf("%d" , &P[i]);
  }
  for(i = n/2;i>=1;i--){
    maxHeapify(i);
  }
  for(i = 1; i <= n;i++){
    printf(" %d", P[i]);
  }
  printf("\n");

  
  return 0;
  
}
int parent(int i){
  return i/2;
}
int Left(int i){
  return 2*i;
}
int Right(int i){
  return 2*i+1;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN=200000;
char a[MAXN+5],b[MAXN+5];
int cnt1[30],cnt2[30],num1[MAXN+5],num2[MAXN+5];
int alen,blen,Max;
int main()
{
	scanf("%s%s",a,b);
	alen=strlen(a);
	blen=strlen(b);
	for(int i=0;i<alen;i++)
	{
		cnt1[a[i]-'a']++;
		if(cnt1[a[i]-'a']>Max)
			Max=cnt1[a[i]-'a'];
	}
	for(int i=0;i<blen;i++)
	{
		cnt2[b[i]-'a']++;
		if(cnt2[b[i]-'a']>Max)
			Max=cnt2[b[i]-'a'];
	}
	for(int i=0;i<=25;i++)
		num1[cnt1[i]]++;
	for(int i=0;i<=25;i++)
		num2[cnt2[i]]++;
	for(int i=0;i<=Max;i++)
		if(num1[i]!=num2[i])
		{
			printf("No\n");
			return 0;
		}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>　　　 //STL 通用算法
#include <bitset>　　　　　//STL 位集容器
#include <cctype>         //字符处理
#include <cerrno> 　　　　 //定义错误码
#include <cfloat>　　　　 //浮点数处理
#include <ciso646>         //对应各种运算符的宏
#include <climits> 　　　　//定义各种数据类型最值的常量
#include <clocale> 　　　　//定义本地化函数
#include <cmath> 　　　　　//定义数学函数
#include <complex>　　　　 //复数类
#include <csignal>         //信号机制支持
#include <csetjmp>         //异常处理支持
#include <cstdarg>         //不定参数列表支持
#include <cstddef>         //常用常量
#include <cstdio> 　　　　 //定义输入／输出函数
#include <cstdlib> 　　　　//定义杂项函数及内存分配函数
#include <cstring> 　　　　//字符串处理
#include <ctime> 　　　　　//定义关于时间的函数
#include <cwchar> 　　　　 //宽字符处理及输入／输出
#include <cwctype> 　　　　//宽字符分类
#include <deque>　　　　　 //STL 双端队列容器
#include <exception>　　　 //异常处理类
#include <fstream> 　　　 //文件输入／输出
#include <functional>　　　//STL 定义运算函数（代替运算符）
#include <limits> 　　　　 //定义各种数据类型最值常量
#include <list>　　　　　　//STL 线性列表容器
#include <locale>         //本地化特定信息
#include <map>　　　　　　 //STL 映射容器
#include <memory>         //STL通过分配器进行的内存分配
#include<new>            //动态内存分配
#include <numeric>         //STL常用的数字操作
#include <iomanip> 　　　 //参数化输入／输出
#include <ios>　　　　　　 //基本输入／输出支持
#include <iosfwd>　　　　　//输入／输出系统使用的前置声明
#include <iostream> 　　　//数据流输入／输出
#include <istream>　　　　 //基本输入流
#include <iterator>        //STL迭代器
#include <ostream>　　　　 //基本输出流
#include <queue>　　　　　 //STL 队列容器
#include <set>　　　　　　 //STL 集合容器
#include <sstream>　　　　 //基于字符串的流
#include <stack>　　　　　 //STL 堆栈容器
#include <stdexcept>　　　 //标准异常类
#include <streambuf>　　　 //底层输入／输出支持
#include <string>　　　　　//字符串类
#include <typeinfo>        //运行期间类型信息
#include <utility>　　　　 //STL 通用模板类
#include <valarray>        //对包含值的数组的操作
#include <vector>　　　　　//STL 动态数组容器
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

const int MAXN=1e5+10;
const int MOD=998244353;

inline int read(){
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*f;
}
inline ll readll(){
	ll x=0;int f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-') f=-1;c=getchar();}
	while(isdigit(c)) x=(x<<3ll)+(x<<1ll)+1ll*(c-'0'),c=getchar();
	return x*f;
}
int gcd(int x,int y){
	return y?gcd(y,x%y):x;
}
ll gcd(ll x,ll y){
	return y?gcd(y,x%y):x;
}

int n,cnt[4];
char s[10];

int main(){
	n=read();
	for(int i=1;i<=n;i++){
		scanf("%s",s);
		if(s[0]=='A') ++cnt[0];
		if(s[0]=='W') ++cnt[1];
		if(s[0]=='T') ++cnt[2];
		if(s[0]=='R') ++cnt[3];
	}
	cout<<"AC x "<<cnt[0]<<'\n';
	cout<<"WA x "<<cnt[1]<<'\n';
	cout<<"TLE x "<<cnt[2]<<'\n';
	cout<<"RE x "<<cnt[3]<<'\n';
	return 0;
}

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt() + sc.nextInt() - sc.nextInt() - sc.nextInt();
		System.out.println(n == 0 ? "Balanced" : (n > 0 ? "Left" : "Right"));
	}
}

Measured memory_bytes: 21716
import Control.Monad

main :: IO ()
main = do
  ls <- replicateM 9 getLine
  let ls' = map words ls
      ansl = map (format . solve) ls'
  mapM_ putStrLn ansl

solve :: [String] -> (String,Int,Int)
solve [name,x,y] = (name,num,pro)
  where x' = read x
        y' = read y
        num = x' + y'
        pro = 200 * x' + 300 * y'
format :: (String,Int,Int) -> String
format (name,num,pro) = name ++ " " ++ (show num) ++ " " ++ (show pro)

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  map<double,int> score;
  for(int i = 0;i<a;i++){
    double d;
    cin >> d;
    score[b - d*0.006] = i+1;
  }
  double MIN = 10000000;
  double minkey = 0;
  for (auto p : score) {
    auto key = p.first;
    auto value = p.second;
    double lon = abs(key-c);
    if(lon < MIN){
      MIN = lon;
      minkey = key;
    }
  }
  cout << score.at(minkey) << endl;
}


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

typedef long long lli;

const lli MAXN = 100005;
const lli MAXM = 100005;
lli N, M;
lli s[MAXN], t[MAXN];
lli p[MAXM];
lli sum1[MAXM], sum2[MAXM];

int main() {
  while(cin >> N >> M) {
    for(lli i = 0; i < N; ++i) {
      cin >> s[i] >> t[i];
    }
    for(lli i = 0; i < M; ++i) {
      cin >> p[i];
    }
    sort(p, p+M);
    for(lli i = 2; i <= M; ++i) {
      sum1[i] = sum1[i-1];
      sum2[i] = sum2[i-1];
      if(i & 1) sum1[i] += p[i-1] - p[i-2];
      else      sum2[i] += p[i-1] - p[i-2];
    }
    lli res = 0;
    for(lli i = 0; i < N; ++i) {
      lli S = s[i], T = t[i];
      lli a = lower_bound(p, p+M, S) - p;
      lli b = lower_bound(p, p+M, T) - p;
      bool rev = false;
      if(S > T) {
        swap(S, T);
        swap(a, b);
        rev = ((b - a) % 2 != 0);
      }
      if(a == b) {
        res += T - S;
        continue;
      }
      lli add = p[a] - S;
      if(a & 1) add += sum2[b] - sum2[a+1];
      else      add += sum1[b] - sum1[a+1];
      if((b - a) % 2 == 0) add += T - p[b-1];
      if(rev) add = (T - S) - add;
      res += add;
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 5080
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static double d(double x, double y, double x2, double y2) {
		double dx = x - x2;
		double dy = y - y2;
		return Math.sqrt(dx*dx + dy*dy);
	}

	static double[][][] undirectedGraph(int n, int[] v1, int[] v2, double[] cost) {
		int[] cnt = new int[n];
		for (int i : v1) cnt[i]++;
		for (int i : v2) cnt[i]++;

		double[][][] g = new double[n][][];
		for (int i=0; i<n; i++) g[i] = new double[cnt[i]][2];
		for (int i=0; i<v1.length; i++) {
			int s = v1[i];
			int t = v2[i];

			g[s][--cnt[s]][0] = t;
			g[s][cnt[s]][1] = cost[i];

			g[t][--cnt[t]][0] = s;
			g[t][cnt[t]][1] = cost[i];
		}

		return g;
	}

	static double[] dijkstra(double[][][] g, int source) {
		int n = g.length;

		final double[] d = new double[n];
		Arrays.fill(d, 1L<<60);
		d[source] = 0;

		TreeSet<Integer> pQ = new TreeSet<Integer>(new Comparator<Integer>(){
			public int compare(Integer a, Integer b) {
				if (d[a] != d[b]) return Double.compare(d[a], d[b]);
				return a - b;
			}
		});
		pQ.add(source);

		while (!pQ.isEmpty()) {
			int cur = pQ.pollFirst();

			for (int i=0; i<g[cur].length; i++) {
				int next = (int)g[cur][i][0];
				double dist = d[cur] + g[cur][i][1];
				if (dist < d[next]) {
					pQ.remove(next);
					d[next] = dist;
					pQ.add(next);
				}
			}
		}

		return d;
	}

	static void solve() {
		int sx = in.nextInt();
		int sy = in.nextInt();
		int gx = in.nextInt();
		int gy = in.nextInt();
		int n = in.nextInt();
		double[][] p = new double[n+2][3];
		for (int i=0; i<n; i++) {
			for (int j=0; j<3; j++) {
				p[i][j] = in.nextDouble();
			}
		}

		p[n][0] = sx; p[n][1] = sy;
		p[n+1][0] = gx; p[n+1][1] = gy;

		ArrayList<Integer> s = new ArrayList<>();
		ArrayList<Integer> t = new ArrayList<>();
		ArrayList<Double> c = new ArrayList<>();
		for (int i=0; i<n+2; i++) {
			for (int j=i+1; j<n+2; j++) {
				s.add(i); t.add(j);
				double d = d(p[i][0], p[i][1], p[j][0], p[j][1]);
				c.add(Math.max(0, d - p[i][2] - p[j][2]));
			}
		}

		int m = s.size();
		int[] ss = new int[m];
		int[] tt = new int[m];
		double[] cc = new double[m];
		for (int i=0; i<m; i++) {
			ss[i] = s.get(i);
			tt[i] = t.get(i);
			cc[i] = c.get(i);
		}

		double[][][] g = undirectedGraph(n+2, ss, tt, cc);

		double[] d = dijkstra(g, n);
		dump(d);
		out.printf("%.12f\n",d[n+1]);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 132288
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>

using namespace std;

int main() {
  
  int N;
  while(cin >> N && N) {
    int x; cin >> x;
    stack<pair<int, int> > st; st.push(make_pair(1, x));
    for(int i=0; i<N-1; i++) {
      cin >> x;
      if(i % 2 == 0) {
	// even
	pair<int, int> p = st.top();
	if(p.second == x) {
	  st.pop();
	  st.push(make_pair(p.first + 1, x));
	}
	else {
	  st.pop();
	  pair<int, int> q;
	  if(!st.empty()) {
	    q = st.top(); st.pop();
	  }
	  st.push(make_pair(p.first+q.first+1, x));
	}
      }
      else {
	// odd
	pair<int, int> p = st.top();
	if(p.second == x) {
	  st.pop();
	  st.push(make_pair(p.first + 1, x));
	}
	else {
	  st.push(make_pair(1, x));
	}
      }
    }
    
    int cnt = 0;
    for(;!st.empty();) {
      cnt += (st.top().second == 0)*st.top().first;
      st.pop();
    }
    cout << cnt << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1204
n=int(input())

import random
def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)

        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

while True:
     if is_prime3(n):
         break
     n+=1
print(n)

Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,time=0,t=0;
	cin>>a>>b>>c>>d;
	if((a==b && c==d) || (a==c && b==d) || (a==d && b==c))
		cout<<"yes"<<endl;
	else
		cout<<"no"<<endl;	
	
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define eps 1e-7
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i = a; i <= b; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
mt19937_64 mrand(random_device{}()); 
const int mod = 1e9 + 7;
const int N = 110;
const int M = 1e5 + 10;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline ll Pow(ll a, ll b) { ll ans = 1; for( ; b; b >>= 1) { if(b&1) ans = ans * a % mod; a = a * a % mod;} return ans;}
inline ll Mul ( ll a, ll b)  { ll lf = a * ( b >> 25ll ) % mod * ( 1LL << 25 ) % mod; ll rg = a * ( b & ( ( 1ll << 25 ) - 1 ) ) % mod; return ( lf + rg ) % mod;}
inline ll C(ll y, ll x) { ll ans = 1; if(y < 0 || x < 0 || y < x) return 0; y %= mod; if(!y || !x) return 1; rep(i, 0, x-1) ans = ans * (y-i) % mod; rep(i, 1, x) ans = ans * Pow(i, mod-2) % mod; return ans; }
/*==================================================*/

int n, k, a[N];
ll dp[M], sum[M];

int main() {
   ms(dp, 0);
   // 利用滚动数组优化掉了第i个人这一维度
   dp[0] = 1;
   scanf("%d %d", &n, &k);
   rep(i, 1, n) scanf("%d", &a[i]);
   rep(i, 1, n) {
      ms(sum, 0);
      rep(j, 0, k) {
         int l = j+1, r = j + min(k - j, a[i]);
         if(l > r) continue;
         sum[l] = (sum[l] + dp[j]) % mod;
         sum[r+1] -= dp[j];
         if(sum[r+1] < 0) sum[r+1] += mod;
         // debug1 printf("%d %d %lld %lld\n", l, r, dp[j], sum[l]);
      }
      rep(j, 1, k) {
         sum[j] = (sum[j] + sum[j-1]) % mod;
         dp[j] = (dp[j] + sum[j]) % mod;
      }
   }
   printf("%lld\n", dp[k]);
   return 0;
}

Measured memory_bytes: 5280
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a;
  cin >> a;
  cout << a * a * a << "\n";
}

Measured memory_bytes: 3564
import bisect

A, B, Q = map(int, input().split())
INF = 10**18
s = [-INF] + [int(input()) for y in range(A)] + [INF]
t = [-INF] + [int(input()) for z in range(B)] + [INF]


for i in range(Q):
    x = int(input())
    a = bisect.bisect_right(s, x)
    b = bisect.bisect_right(t, x)
    cost = INF
    for j in [s[a-1], s[a]]:
        for k in [t[b-1], t[b]]:
            d1, d2 = abs(j-x)+abs(j-k), abs(k-x)+abs(j-k)
            cost = min(cost, d1, d2)
    print(cost)

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((int)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

void print(Vl v){
    rep(i, 0, sz(v)){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}

////////////////////////////////////////////////////////

ll dp[105][105];

int main() {
	ll H, W; cin >> H >> W;
	Vs s(H);
	rep(i, 0, H) cin >> s[i];

	rep(i, 0, 101) rep(j, 0, 101) dp[i][j] = INF;

	if(s[0][0] == '#') dp[0][0] = 1;
	else dp[0][0] = 0;

	rep(h, 0, H) rep(w, 0, W) {
		if(w-1>=0){
			if(s[h][w] == s[h][w-1]) chmin(dp[h][w], dp[h][w-1]);
			if(s[h][w] == '#' && s[h][w-1] == '.') chmin(dp[h][w], dp[h][w-1]+1);
		}
		if(h-1>=0){	
			if(s[h][w] == s[h-1][w]) chmin(dp[h][w], dp[h-1][w]);
			if(s[h][w] == '#' && s[h-1][w] == '.') chmin(dp[h][w], dp[h-1][w]+1);
		}
		if(s[h][w] == '.'){
			if(w-1>=0) chmin(dp[h][w], dp[h][w-1]);
			if(h-1>=0) chmin(dp[h][w], dp[h-1][w]);
		}
	}

	// rep(h, 0, H){
	// 	rep(w, 0, W){
	// 		cout << dp[h][w] << " ";
	// 	}
	// 	cout << endl;
	// }

	co(dp[H-1][W-1]);

    return 0;
}


Measured memory_bytes: 384
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define MOD 100000
#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

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

int main(){
  
  int n, m, sum = 0;
  int ssum[111111], s[111111], a[111111];;
  
  cin >> n >> m;
  ssum[0] = ssum[1] = 0;
  for(int i = 0; i < n-1; i++){
    cin >> s[i];
    ssum[i + 2] = ssum[i + 1] + s[i];
  }
  for(int i = 0; i < m; i++) cin >> a[i];
 
  int now = 1;
  for(int i = 0; i < m; i++){
    (sum += abs(ssum[now] - ssum[now + a[i]])) %= MOD;
    now += a[i];
  }

  cout << sum << endl;
  
}

Measured memory_bytes: 2344
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;


int main(){
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        int flag=0;
        while(n>0){
            int k=n%10;
            if(k==7){
                cout<<"Yes";
                flag=1;
                break;
            }
            n/=10;
        }
        if(!flag){
            cout<<"No";
        }
    }
    return 0;
}
    

Measured memory_bytes: 3604
from math import degrees, atan

a, b, x = map(int, input().split())

vol = a * a * b

def A(a, b, x):
    return degrees(atan((a * b * b) / (2 * x)))

if vol == x:
    result = 0
elif 2 * x > vol:
    x -= vol / 2
    tmp = A(a, a, vol / 2 - x)
    result = 90 - tmp
else:
    result = A(a, b, x)

print(result)


Measured memory_bytes: 3060
use std::io::Read;
fn read<T: std::str::FromStr>() -> T {
    let stdin1 = std::io::stdin();
    let stdin2 = stdin1.lock();
    let input: String = stdin2
        .bytes()
        .map(|c| c.ok().unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    input.parse().ok().unwrap()
}

fn main() {
    let t1 = read::<i64>();
    let t2 = read::<i64>();
    let a1 = read::<i64>();
    let a2 = read::<i64>();
    let b1 = read::<i64>();
    let b2 = read::<i64>();

    let mut d1: i64 = (a1 - b1) * t1;
    let mut d2: i64 = (a2 - b2) * t2;
    // d1 ha always positive ni suru
    if d1 < 0 {
        d1 *= -1;
        d2 *= -1;
    }

    // sa ha hirogaru bakari
    if d1 + d2 > 0 {
        println!("0");
    }
    // every set deau
    else if d1 + d2 == 0 {
        println!("infinity");
    } else {
        let zure: i64 = d1 / (-d2 - d1);
        let pittari: bool = d1 % (-d2 - d1) == 0;

        let mut ans: i64 = zure * 2 + 1;
        if pittari {
            ans -= 1;
        }
        println!("{}", ans);
    }
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

	int n, c;
	cin >> n >> c;
	vector<pair<pii, int> > v(n);
 
	rep(i, n){
		cin >> v[i].first.first >> v[i].first.second >> v[i].second;
		v[i].second--;
	}

	sort(all(v));
	vector<pii> cap;

	rep(i, n){
		int p = -1;
		rep(j, cap.size()){
			if(v[i].second == cap[j].second){
				if(cap[j].first <= v[i].first.first){
					p = j;
					break;
				}
			}else{
				if(cap[j].first < v[i].first.first){
					p = j;
					break;
				}
			}
		}
		if(p == -1){
            cap.push_back(make_pair(v[i].first.second, v[i].second));
        }else{
			cap[p] = make_pair(v[i].first.second,v[i].second);
		}
		sort(all(cap));
	}
    
    cout << cap.size() << '\n';
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define MN 18
#define mod 998244353
#define pa pair<int,int>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,tot,a[1<<MN],b[1<<MN];pa f[1<<MN];
inline int Div2(int x){return (x&1)?(x+mod>>1):(x>>1);}
inline pa Div2(pa y){return make_pair(Div2(y.first),Div2(y.second));}
pa operator + (const pa&x,const pa&y){return make_pair((x.first+y.first)%mod,(x.second+y.second)%mod);}
pa operator - (const pa&x,const pa&y){return make_pair((x.first-y.first+mod)%mod,(x.second-y.second+mod)%mod);}
pa operator * (const pa&x,int y){return make_pair(1LL*x.first*y%mod,1LL*x.second*y%mod);}
inline int pw(int x,int k)
{
    int res=1;
    for(;k;k>>=1,x=1LL*x*x%mod) if(k&1) res=1LL*res*x%mod;
    return res;
}
void FWT(int*x)
{
    for(int i=2;i<=1<<n;i<<=1) for(int j=0;j<1<<n;j+=i) for(int k=0;k<(i>>1);++k)
    {
        int l=j+k,r=j+k+(i>>1),A=x[l],B=x[r];
        x[l]=(A+B)%mod;x[r]=(A-B+mod)%mod;
    }
}
void IFWT(pa*x)
{
    for(int i=2;i<=1<<n;i<<=1) for(int j=0;j<1<<n;j+=i) for(int k=0;k<(i>>1);++k)
    {
        int l=j+k,r=j+k+(i>>1);pa A=x[l],B=x[r];
        x[l]=A+B;x[r]=A-B;
        x[l]=Div2(x[l]),x[r]=Div2(x[r]);
    }
}
int main()
{
    n=read();
    for(int i=0;i<1<<n;++i) a[i]=read(),tot+=a[i];
    tot=pw(tot,mod-2); 
    for(int i=0;i<1<<n;++i) b[i]=a[i]=1LL*a[i]*tot%mod;
    FWT(a);f[0].first=1;b[0]=0;
    for(int i=1;i<1<<n;++i) f[i].second=(1LL<<n)*pw(a[i]-1,mod-2)%mod;
    IFWT(f);pa F(0,1);
    for(int i=0;i<1<<n;++i) F=F+f[i]*b[i];
    assert(F.first!=0);
    int num=1LL*((1<<n)+mod-F.second)*pw(F.first,mod-2)%mod;
    puts("0");
    for(int i=1;i<1<<n;++i) printf("%d\n",(1LL*num*f[i].first+f[i].second)%mod);
	return 0;
}
/*
f1+1 f2+1 ... fn+1
p1 p2 ... pn     FWT(^)->
f1+y f2 ... fn   (y=sigma fipi)
F:对f数组FWT
F1+(2^n) F2 ... Fn
P1 P2 ... Pn
F1+y F2+y ... Fn+y
可发现y=2^n
知道Fn之后，P1是1没法求F1,用F1表示F2...Fn，带着变量做fwt，解出F1
*/

Measured memory_bytes: 6912
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let n: usize = util::get();
    let a: Vec<usize> = (0..n).map(|_| util::get::<usize>() - 1).collect();

    let mut visited = vec!(false; n);

    let mut i = 0;
    let mut count = 0;

    while !visited[i] {
        visited[i] = true;
        if i == 1 {
            break;
        }
        count += 1;
        i = a[i];
    }

    if visited[1] {
        println!("{}", count);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 4352
N = input()
K = int(input())

if len(N) < K:
  print(0)
  exit()

ans = [1, int(N[-1]), 0, 0];

def combination(N,K):
  if N < K:
    return 0
  else:
    p = 1
    for k in range(K):
      p *= N
      N -= 1
    for k in range(1, K+1):
      p //= k
    return p

for k in range(1, len(N)):
  if int(N[-k-1]) > 0:
    a = [1, 0, 0, 0]
    for j in range(1, K+1):
      a[j] += (9**(j))*combination(k, j)
      a[j] += (int(N[-k-1])-1)*combination(k, j-1)*(9**(j-1)) + ans[j-1]
    ans = a
print(ans[K])

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
 
# define INF 0x3f3f3f3f
#define MOD 1000000007
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d%d",&x,&y)
#define siii(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d%d",x,y)
#define piii(x,y,z) printf("%d%d%d",x,y,z) 
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld%lld",x,y)
#define plll(x,y,z) printf("%lld%lld%lld",x,y,z) 
 
#define ll long long
#define mp make_pair
#define pb push_back
#define pp pop_back
#define nl printf("\n");
#define sf scanf
#define pf printf
#define rep(i,n) for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int>
#define tci int t;scanf("%d",&t);while(t--)
const int maxn=10e6+4;

int prime[100008];
void seive()
{
    for(int i=2;i<=100000;i++)
    {
        if(!prime[i])
        {
            for(int j=i*2;j<=100000;j+=i)
            {
                prime[j]=1;
            }
        }
    }
    /*repi(i,1,100)
    {
        if(!prime[i])
            cout<<i<<" ";
    }
    nl*/
}

int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }
    
    seive();
    int res[100008]={0};
    //res[1]=1;
    repi(i,3,100001)
    {
        if(!prime[i] && !prime[(i+1)/2])
        {
            res[i]=1;
        }
    }
    repi(i,1,100001)
    {
        res[i]=res[i-1]+res[i];
    }
    int q;
    si(q);
    while(q--)
    {
        int a,b;
        sii(a,b);
        cout<<res[b]-res[a-1];nl
    }

    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main() {
    string N;
    cin >> N;
    int m = 0;
    for (int i = 0; i < N.size(); i++)m += N[i] - '0';
    if (m % 9 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

bool MAP[12][12];
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

void sink_one_island(int x, int y) {
  if (x < 0 or 11 < x or y < 0 or 11 < y or !MAP[x][y])
    return;

  MAP[x][y] = false;
  for (int i = 0; i < 4; i++)
    sink_one_island(x + dx[i], y + dy[i]);
}

int sink_all_islands() {
  int islands = 0;

  for (int x = 0; x < 12; x++) {
    for (int y = 0; y < 12; y++) {
      if (MAP[x][y]) {
        sink_one_island(x, y);
        islands++;
      }
    }
  }

  return islands;
}

int main() {
  string s;
  while (cin >> s) {
    if (s.empty()) continue;

    for (int x = 0; x < 12; x++)
      MAP[x][0] = (s[x] == '1')? true:false;

    for (int y = 1; y < 12; y++) {
      cin >> s;
      for (int x = 0; x < 12; x++)
        MAP[x][y] = (s[x] == '1')? true:false;
    }

    int ids = sink_all_islands();

    cout << ids << endl;
  }
}

Measured memory_bytes: 1184
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void input(vector<int>&line){
int num;
cin>>num;
line.resize(num);
for(int i=0;i<num;++i){
cin>>line[i];
}
sort(line.begin(),line.end());
}

bool func(vector<int> nline,vector<int> mline){
int place=0;
for(int i=0;i<mline.size();++i){
while(nline[place]!=mline[i]){
if(++place==nline.size())return false;
}
++place;
}
return true;
}

int main(){
vector<int> nline,mline;
input(nline);
input(mline);
cout<<(func(nline,mline)?"YES":"NO")<<endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

char s[4000][40001];
int c[4000][4000][4];

int
main(int argc, char *argv[])
{
  int h, w;
  scanf("%d %d", &h, &w);
  for (int i = 0; i < h; i++) scanf("%s", s[i]);

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
	for (int k = 0; k < 4; k++) c[i][j][k] = -1;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 1; j < w; j++) {
      if (s[i][j] != '#') {
	c[i][j][0] = c[i][j - 1][0] + 1;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 1; j < w; j++) {
      if (s[i][w - 1 - j] != '#') {
	c[i][w - 1 - j][1] = c[i][w - j][1] + 1;
      }
    }
  }
  for (int i = 0; i < w; i++) {
    for (int j = 1; j < h; j++) {
      if (s[j][i] != '#') {
	c[j][i][2] = c[j - 1][i][2] + 1;
      }
    }
  }
  for (int i = 0; i < w; i++) {
    for (int j = 1; j < h; j++) {
      if (s[h - 1 - j][i] != '#') {
	c[h - 1 - j][i][3] = c[h - j][i][3] + 1;
      }
    }
  }

  /* rep(i, h) {
    rep(j, w) printf("%2d ", c[i][j][2]);
    endl;
    }*/
  
  
  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int x = 1 + c[i][j][0] + c[i][j][1] + c[i][j][2] + c[i][j][3];
      //printf("%d ", x);
      if (c[i][j][0] != -1) {
	ans = Max(ans, x);
      }
    }//endl;
  }

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

  return 0;
}
  


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

using namespace std;

int main() {
	int n;
	cin >> n;
	int a[n], b[n];
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}
	int cnt = 0;
	bool ok = false;
	for (int i = 0; i < n; ++i) {
		if (a[i] == b[i]) {
			cnt++;
		} else {
			cnt = 0;
		}
		if (cnt == 3) {
			ok = true;
		}
	}
	if (ok) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<ll>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

ll popHeap(vector<ll>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  ll i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

vector<int> ver;
void dfs(const graph &g,int v){
  ver[v]=1;
  for(auto i:g[v]){
    if(ver[i]!=0)continue;
    dfs(g,i);
  }
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,cnt=0;
  ll n,x;
  cin>>n>>x;
  ll a[n];
  for(i=0;i<n;i++)cin>>a[i];
  ll q[n];
  for(i=0;i<n;i++)q[i]=LLONG_MAX;
  ll ans=LLONG_MAX;
  for(j=0;j<n;j++){
    for(i=0;i<n;i++){
      int m=i-j;
      if(m<0)m+=n;
      q[i]=min(q[i],a[m]);
    }
    ll sum=0;
    for(i=0;i<n;i++){
      sum+=q[i];
    }
    ans=min(sum+x*j,ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String x = "CODEFESTIVAL2016";
		int ans = 0;
		for(int i = 0 ; i < 16 ; i++) {
			if(s.charAt(i) != x.charAt(i)) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
import java.util.Scanner;

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

    public void run() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        // 100000
        System.out.println(getNextPrimeNumber(X));

    }

    public int getNextPrimeNumber(int num) {
        for (int i = num; i <= 200000; i++) {
            boolean isPrime = true;
            for (int j = 2; j < i; j++) {
                if (i % j == 0) {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime) {
                return i;
            }
        }
        return 0;
    }
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

/*vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
//vll a;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>s;
	sort(all(s));
	if(s=="abc") cout<<"Yes\n";
	else cout<<"No\n";
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 3672
package main
import (
  "fmt"
)

func validXs(h, w int, as []string) []int {
  result := make([]int, 0)
  for i := 0; i < w; i++ {
    isValid := false
    for j := 0; j < h; j++ {
      str := as[j][i]
      if str != '.' {
        isValid = true
        break
      }
    }
    if isValid {
      result = append(result, i)
    }
  }
  return result
}
func validYs(h, w int, as []string) []int {
  result := make([]int, 0)
  for i := 0; i < h; i++ {
    isValid := false
    for j := 0; j < w; j++ {
      if as[i][j] != '.' {
        isValid = true
        break
      }
    }
    if isValid {
      result = append(result, i)
    }
  }
  return result
}

func main() {
  var h, w int
  fmt.Scan(&h, &w)
  as := make([]string, h)
  for i := 0; i < h; i++ {
    fmt.Scan(&as[i])
  }
  
  xs := validXs(h, w, as)
  ys := validYs(h, w, as)

  for _, y := range ys {
    for _, x := range xs {
      fmt.Printf("%c", as[y][x])
    }
    fmt.Print("\n")
  }
}

Measured memory_bytes: 512
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def gcd_list(A):
    res = A[0]
    for a in A:
        res = gcd(a, res)
    return res

def check(N,A):
    if 1 in A:
        if((sum(A)-N) & 1):
            return 0 #先手
        else:
            return 1 #後手
    odd_cnt, even_cnt = 0, 0
    for a in A:
        if(a&1):
            odd_cnt += 1
        else:
            even_cnt += 1
    if(even_cnt & 1):
        return 0
    else:
        if(odd_cnt >= 2):
            return 1
        else: ##奇数のを選ぶしかないのでその後どうなるかを調べる
            odd_idx = [i for i in range(N) if A[i]&1 ][0]
            A[odd_idx] -= 1
            G = gcd_list(A)
            return check(N, [a//G for a in A]) ^ 1
def main():
    N=I()
    A=LI()
    print(["First","Second"][check(N,A)])



if __name__ == '__main__':
    main()

Measured memory_bytes: 90920
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, K, d, count=0;
    cin >> N >> K;
    vector<int> sunuke(N);
    for (int i=0; i<K; i++){
        cin >> d;
        vector<int> have(d);
        for (int j=0; j<d; j++){
            cin >> have.at(j);
        }
        for (int x : have){
            sunuke.at(x-1) = 1;
        }
    }
    for (int x : sunuke){
        if (x == 0) count += 1;
    }
    cout << count << endl;
    return 0;

}

Measured memory_bytes: 3612
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		int len = s.length();
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		StringBuilder sub1 = new StringBuilder();
		sub1.append(sb.substring(0,len/2));
		StringBuilder sub2 = new StringBuilder();
		sub2.append(sb.substring(len/2+1));
		if(sb.toString().contentEquals(sb.reverse()) && 
		   sub1.toString().contentEquals(sub1.reverse()) &&
		   sub2.toString().contentEquals(sub2.reverse())){
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21716