akhauriyash/Code-Regression huggingface dataset:
var
	ch:ansistring;
	n,s,i:longint;
	t:int64;
begin
	readln(ch);
	n:=length(ch);
	s:=1; t:=0;
	for i:=1 to n do 
		if ch[i]='W' then
		begin
			t:=t+i-s;
			inc(s);
		end;
	writeln(t);
end.

Measured memory_bytes: 256
var
  n,st:string;
  ch:char;
  p:boolean;
begin
  readln(n);
  for ch:='0' to '9' do
 begin
   st:=ch+ch+ch;
   if pos(st,n)>0 then begin p:=true;writeln('Yes');break; end;
 end;
  if p=false then writeln('No');//最后判断p
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 101;
 
int N;
vector<vector<int> > q;
 
int lcm(int a, int b) {
  return a * b / __gcd(a, b);
}
 
int main() {
  while(cin >> N && N) {
    q.clear();
    vector<int> a(13), b(17), c(19), d(23);
    for(int i = 0; i < N; ++i) {
      int s, t; cin >> s >> t;
      vector<int> v(s);
      for(int j = 0; j < s; ++j) cin >> v[(j-t+s)%s];
      if(s == 13) for(int j = 0; j < 13; ++j) a[j] += v[j];
      else if(s == 17) for(int j = 0; j < 17; ++j) b[j] += v[j];
      else if(s == 19) for(int j = 0; j < 19; ++j) c[j] += v[j];
      else if(s == 23) for(int j = 0; j < 23; ++j) d[j] += v[j];
      else q.push_back(v);
    }
    int T = 1;
    for(int i = 0; i < q.size(); ++i) {
      T = lcm(T, q[i].size());
    }
    int res = 0;
    for(int t = 0; t < T; ++t) {
      int sum = 0;
      for(int i = 0; i < q.size(); ++i) {
        sum += q[i][t%q[i].size()];
      }
      res = max(res, sum);
    }
    res += *max_element(a.begin(), a.end());
    res += *max_element(b.begin(), b.end());
    res += *max_element(c.begin(), c.end());
    res += *max_element(d.begin(), d.end());
    cout << res << endl;
  }
  return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, m;
    cin >> n >> m;

    vector<vector<int64_t>> adjs(n);
    for (auto _ : irange(0L, m)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;
        adjs[a].push_back(b);
        adjs[b].push_back(a);
    }

    int64_t q;
    cin >> q;
    vector<vector<int64_t>> k(n, vector<int64_t>(11, 0L));
    vector<int64_t> c(q + 1);
    for (auto i : irange(0L, q)) {
        int64_t v, d;
        cin >> v >> d >> c[i + 1];
        --v;
        k[v][d] = max(k[v][d], i + 1);
    }

    for (auto i : irange(1L, 11L) | reversed) {
        for (auto v : irange(0L, n)) {
            k[v][0] = max(k[v][0], k[v][i]);
            for (auto u : adjs[v]) {
                k[u][i - 1] = max(k[u][i - 1], k[v][i]);
            }
        }
    }

    for (auto i : irange(0L, n)) {
        cout << c[k[i][0]] << "\n";
    }
}

Measured memory_bytes: 19444
n, m = map(int, input().split())		# 5 7

L=[]

a=[]
b=[]
c=[]
d=[]
e=[]
f=[]
g=[]
h=[]

for i in range(n):
	x,y,z = map(int, input().split())		# 5 7
	
	#l=[]
	#for a in range(-1,2,2):
	#	for b in range(-1,2,2):
	#		for c in range(-1,2,2):
	#			d = (x*a)+(y*b)+(z*c)
	#			l.append(d)
	#L.append(l)
	
	a.append( x+y+z)
	b.append( x+y-z)
	c.append( x-y+z)
	d.append( x-y-z)
	e.append(-x+y+z)
	f.append(-x+y-z)
	g.append(-x-y+z)
	h.append(-x-y-z)

#print("a", a)
#print("b", b)
#print("c", c)
#print("d", d)
#print("e", e)
#print("f", f)
#print("g", g)
#print("h", h)



a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
d.sort(reverse=True)
e.sort(reverse=True)
f.sort(reverse=True)
g.sort(reverse=True)
h.sort(reverse=True)


#print("a", a)
#print("b", b)
#print("c", c)
#print("d", d)
#print("e", e)
#print("f", f)
#print("g", g)
#print("h", h)

ans=float("-inf")

ans = max(ans, sum(a[:m]))
ans = max(ans, sum(b[:m]))
ans = max(ans, sum(c[:m]))
ans = max(ans, sum(d[:m]))
ans = max(ans, sum(e[:m]))
ans = max(ans, sum(f[:m]))
ans = max(ans, sum(g[:m]))
ans = max(ans, sum(h[:m]))

print(ans)


Measured memory_bytes: 3444
#include <iostream>
using namespace std;
int main(){
    int N=0;
    int x=0;
    int a[101];
    int temp=0;
    int ans=0;
    int i=0;
    int c=0;
    int check=0;
    
    cin>>N>>x;
    
    for(i=0;i<N;i++){
        cin>>a[i];
    }
    for(c=0;c<N;c++){
    for(i=0;i<N-1;i++){
        if(a[i]>a[i+1]){
            temp=a[i];
            a[i]=a[i+1];
            a[i+1]=temp;
        }    
    }
    }
    
    for(i=0;i<N;i++){
        //cout<<a[i];
        if(a[i]<=x){
            ans++;
            x=x-a[i];
            check=1;
        }
        //cout<<x<<endl;
    }
    
    if(x==0 && check==1){
        cout<<ans<<endl;
    }
    if(x==0 && check==0){
        cout<<0<<endl;
    }
    if(x>0){
        if(check==0){
            cout<<0<<endl;
        }
        if(check==1 && N==ans){
            cout<<ans-1<<endl;
        }
        if(check==1 && N>ans){
            cout<<ans<<endl;
        }
    }
    
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math

#入力
x, y = map(int, input().split())

g2 = [4,6,9,11]

#g3
if x == 2 or y == 2 :
  print ("No")
  exit()
  
if x in g2 and y in g2 :
  print ("Yes")
elif x not in g2 and y not in g2 :
  print ("Yes")
else :
  print ("No")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String data[] = reader.readLine().split(" ");
		int a= Integer.parseInt(data[0]);
		int b= Integer.parseInt(data[1]);
		System.out.printf("%d %d %6f", a/b,a%b,(double)a/b);
	}
}

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

int main(){
while(1){
	int n,c,a,b[100000+2],k=0,ans=0;
	scanf("%d",&n);
	if(n==0)break;
	scanf("%d",&a);
	b[0]=1;
	for(int i=2;i<=n;i++){
		scanf("%d",&c);
		if(c==(a+k)%2)b[k]++;
		else {
			if(i%2!=0){
				b[k+1]=1; k++;
			}
			else {
				if(k==0){a=c; b[0]+=1;}
				else {b[k-1]+=b[k]+1; k--;}
			}
		}
	}
	for(int i=a;i<=k;i+=2){
		ans+=b[i];
	}
	printf("%d\n",ans);
}
}

Measured memory_bytes: 1192
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Map<Character, char[]> cardMap = new HashMap<Character, char[]>();
        cardMap.put('a', scanner.nextLine().toCharArray());
        cardMap.put('b', scanner.nextLine().toCharArray());
        cardMap.put('c', scanner.nextLine().toCharArray());
        Map<Character, Integer> indexMap = new HashMap<Character, Integer>();
        indexMap.put('a', 0);
        indexMap.put('b', 0);
        indexMap.put('c', 0);

        System.out.print(play('a', cardMap, indexMap));


    }

    private static char play(char now, Map<Character, char[]> cardMap, Map<Character, Integer> indexMap) {
        char card[] = cardMap.get(now);
        int index = indexMap.get(now);

        if (index >= card.length )
            return Character.toUpperCase(now);

        char next = card[index];
        indexMap.put(now, index+1);
        return play(next, cardMap, indexMap);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define write(x) printf("%d\n", x)
using namespace std;
typedef long long ll;
template <typename T>
void read(T &x)
{
	x = 0;
	char c;
	while (!isdigit(c = getchar()));
	do
	{
		x = (x << 1) + (x << 3) + (c ^ 48);
	}while (isdigit(c = getchar()));
}
ll H;
ll f(ll x)
{
	if (x == 1) return 1;
	return 1 + (f(x >> 1) << 1);
}
int main()
{
	read(H);
	printf("%lld\n", f(H));
	return 0;
}

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

int n,r,x,par[10000],l,v[10000];
vector<int> e[10000];
string s;

int B(int z){
	if(v[z]!=0)return v[z]/2+1;
	int ret = 0;
	vector<int> tmp;
	rep(i,e[z].size()) tmp.push_back(B(e[z][i]));
	sort(tmp.begin(),tmp.end());
	rep(i,tmp.size()/2+1) ret+=tmp[i];
	return ret;
}

int A(){
	r=0;x=0;l=0;
	rep(i,10000)e[i].clear();
	memset(par,0,sizeof(par));
	memset(v,0,sizeof(v));
	cin>>s;
	rep(i,s.size()){
		if(s[i]=='['){
			if(i)l++;
			if(r!=l){
				par[l]=r;
				e[r].push_back(l);
			}
			r = l;
		}
		else if(s[i]==']'){
			r = par[r];
			if(s[i-1]!=']'){
				v[l]=x;x=0;
			}
		} else{
			x*=10;x+=s[i]-'0';
		}
	}
	return B(0);
}

main(){
	cin>>n;
	rep(i,n)cout<<A()<<endl;
}

Measured memory_bytes: 1676
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,i,j;
  cin>>n>>m;
  
  int k[n],kind[m]={},ans=0;
  
  for(i=0;i<n;i++){
    cin>>k[i];
    int a[k[i]];
    for(j=0;j<k[i];j++){
      cin>>a[j];
      kind[a[j]-1]++;
    }
  }
  
  for(i=0;i<m;i++){
    if(kind[i]==n)
      ans++;
   
    
  }
  cout<<ans;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define endl '\n'
#define int long long


int32_t  main()
{
    IOS; 
    int k;
    cin>>k;
    string s;
    cin>>s;
    
    if(s.length()<=k)
    {
        cout<<s;
        return 0;
    }
    cout<<s.substr(0,k)+"...";
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  vector<int> n;
  for(int i=0;i<s.size();i++){
    n.push_back(1);
  }
  for(int i=0;i<s.size();i++){
    if(i==s.size()||(s[i]=='L'&&s[i+1]==s[i])){
      int m=0;
      while(i<s.size()&&s[i]!='R'){
        n[i]--;
        m++;
        i++;
      }
      n[i-m-1]+=(m/2);
      n[i-m]+=(m-m/2);
      i--;
    }
    else if(s[i]=='R'&&s[i]==s[i+1]){
      int m=0;
      while(s[i]!='L'){
        n[i]--;
        m++;
        i++;
      }
      n[i]+=(m/2);
      n[i-1]+=(m-m/2);
      i--;
    }
  }
  for(int i=0;i<s.size();i++){
    cout<<n[i]<<" ";
    }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1144
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int n, m;
  cin.scan(n, m);
  int[] a = cin.nextArray!int(n);

  auto s = sum(a);
  a.sort;
  a.reverse;

  foreach (i; 0 .. m) {
    auto e = a[i];
    if (e < cast(double)(s) / (4 * m)) {
      writeln("No");
      return;
    }
  }
  writeln("Yes");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<int,int> pii;

bool visit[1 << 20];
int prev[1 << 20];

void output(int n, int x){
	printf("You can go home in %d steps.\n", x);

	vector<int> v;
	v.push_back(n << 16 | 1 << n);
	while(prev[v.back()] != -1){
		v.push_back(prev[v.back()]);
	}

	for(int i = v.size() - 1; i > 0; --i){
		int now = v[i], next = v[i-1];
		if((now >> 16) != (next >> 16)){
			printf("Move to room %d.\n", next >> 16);
		}
		else{
			for(int j = 1; j <= n; ++j){
				if((now ^ next) >> j & 1){
					if(now >> j & 1){
						printf("Switch off room %d.\n", j);
					}
					else{
						printf("Switch on room %d.\n", j);
					}
				}
			}
		}
	}
}

int solve(int n, int m){
	memset(visit, 0, sizeof visit);
	memset(prev, -1, sizeof prev);

	vector<vector<int> > G(n + 1), sw(n + 1);
	int s, t;
	for(int i = 0; i < m; ++i){
		scanf("%d%d", &s, &t);
		G[s].push_back(t);
		G[t].push_back(s);
	}

	int state = 1 << 16;
	for(int i = 1; i <= n; ++i){
		scanf("%d", &s);
		state |= s << i;
	}
	
	for(int i = 1; i <= n; ++i){
		scanf("%d", &s);
		sw[i].resize(s);
		for(int j = 0; j < s; ++j){
			scanf("%d", &sw[i][j]);
		}
		sort(sw[i].begin(), sw[i].end());
	}

	if(!(state & 2)){ return 2; }

	int goal = n << 16 | 1 << n;

	queue<int> q;
	q.push(state);
	q.push(-1);
	
	visit[state] = true;
	int result = 2;
	int x = 0;
	while(q.size() > 1){
		state = q.front();
		q.pop();
		
		if(state == -1){
			q.push(-1);
			++x;
		}
		else{
			if(state == goal){
				output(n, x);
				return 0;
			}

			int room = state >> 16;
			if(room == n){
				result = 1;
			}

			for(int i = 0; i < G[room].size(); ++i){
				int to = G[room][i];
				int next = state & 0xffff | to << 16;
				if(state >> to & 1 && !visit[next]){
					visit[next] = true;
					prev[next] = state;
					q.push(next);
				}
			}

			for(int i = 0; i < sw[room].size(); ++i){
				int next = state ^ (1 << sw[room][i]);
				if(sw[room][i] != room && !visit[next]){
					visit[next] = true;
					prev[next] = state;
					q.push(next);
				}
			}
		}
	}
	
	return result;
}

int main(){
	int n, m;
	while(scanf("%d%d", &n, &m), n){
		int res = solve(n, m);
		if(res == 1){
			puts("You can not switch off all lights.");
		}
		else if(res == 2){
			puts("Help me!");
		}
	}
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

int main(){
	int n; scanf("%d",&n);
	tuple<int,int,int> a[1000];
	rep(i,n){
		int w,s,v; scanf("%d%d%d",&w,&s,&v);
		a[i]=make_tuple(w,s,v);
	}

	sort(a,a+n,[](const auto& x,const auto& y){
		return get<0>(x)+get<1>(x)<get<0>(y)+get<1>(y);
	});

	lint dp[20001];
	rep(x,20001) dp[x]=-INF;
	dp[0]=0;
	rep(i,n){
		int w,s,v; tie(w,s,v)=a[i];
		for(int x=s;x>=0;x--) if(dp[x]>-INF) {
			dp[x+w]=max(dp[x+w],dp[x]+v);
		}
	}
	printf("%lld\n",*max_element(dp,dp+20001));

	return 0;
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    vector<pair<ll,ll>>a(n+1);
    rep2(i,1,n)cin>>a[i].second>>a[i].first;

    sort(a.begin(),a.end());

    rep2(i,1,n){
        a[i].second=a[i].second+a[i-1].second;
        if(a[i].second>a[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
}


Measured memory_bytes: 6436
open System



[<EntryPoint>]
let main argv =
    let cube = stdin.ReadLine()
    let L = String.length cube
    cube
    |>Seq.sumBy(fun c -> (if c='0' then 1 else -1))
    |>fun c -> (L-(c|>abs))
    |>printfn "%d"
    0

Measured memory_bytes: 14428
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    A, B, C, K = map(int, readline().split())
    if K<=A:
        print(K)
    elif A<K<=A+B:
        print(A)
    else:
        print(A-K+A+B)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9244
#include <bits/stdc++.h>
#define maxn 100005
#define MOD 1000000007
#define INF 1000000000000000000
#define lim 20

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

void solve(){
    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes\n";
    else cout << "No\n";
}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


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

typedef pair<ll, ll> p;

int main(){
    map<p, int> mp;
    int n; cin >> n;
    vector<ll> x(n), y(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
    }
    for(int i = 0; i < n; i++){
        for(int l = 0; l < n; l++){
            if(i == l)  continue;
            p z = {x[i] - x[l], y[i] - y[l]};
            mp[z]++;
        }
    }
    int max = 0;
    for(auto x:mp) {
        if(max < x.second){
            max = x.second;
        }
    }
    cout << n - max << endl;
}

Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class FXORMatching {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int M, K;
        in>>M>>K;
        if((1<<M)<=K){
            out<<"-1\n";
            return;
        }
        if(M==1){
            if(K==0) out<<"0 0 1 1\n";
            else out<<"-1\n";
            return;
        }
        REP(i, (1<<M)){
            if(i!=K) out<<i<<' ';
        }
        out<<K<<' ';
        for(int i=(1<<M)-1;0<=i;--i){
            if(i!=K) out<<i<<' ';
        }
        out<<K<<'\n';
    }
};


int main() {
	FXORMatching solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3656
import numpy as np 
n = int(input())
a = [int(input()) for i in range(n)]
aa = np.array(a)
maxa = max(aa)
argmax = np.argmax(aa)

for i in range(n):
    if i == argmax:
        tmp = np.delete(aa,i)
        print(max(tmp))
    else:
        print(maxa)

Measured memory_bytes: 24788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX =510000;
// 最大公約数を求める
long long GCD(long long x, long long y) {
    return y ? GCD(y, x%y) : x;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
	ll A,B;	
  	cin >>A>>B;
  	ll g=GCD(A,B);
  	auto t=prime_factorize(g);
  	cout<<t.size()+1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define mod(d) d%1000000007
#define loop(i,s,e) for(ll i=s;i<e;i++)
#define vll vector<ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e5+5;
vector<int> V[MAX];
bool cnt[3];
int dp[100000][3];

int MaxHappiness(vector<int> V[MAX],ll n){	
		dp[0][0]=V[0][0];	
		dp[0][1]=V[0][1];	
		dp[0][2]=V[0][2];	
		loop(i,1,n){
			dp[i][0]=V[i][0]+max(dp[i-1][1],dp[i-1][2]);
			dp[i][1]=V[i][1]+max(dp[i-1][0],dp[i-1][2]);
			dp[i][2]=V[i][2]+max(dp[i-1][1],dp[i-1][0]);
		}

		return max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

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

    loop(i,0,3)cnt[i]=false;
    memset(dp,-1,sizeof(dp));
    ll n;
    cin>>n;
    loop(i,0,n){
    	int x,y,z;
    	cin>>x>>y>>z;

    	V[i].push_back(x);
    	V[i].push_back(y);
    	V[i].push_back(z);
    }

    cout<<MaxHappiness(V,n)<<'\n';

    // loop(i,0,n){
    // 	loop(j,0,3){
    // 		cout<<dp[i][j]<<" ";
    // 	}
    // 	cout<<'\n';
    // }

   
}


Measured memory_bytes: 6912
#include<stdio.h>
int main(){
  int a,A[100],n,i,count=0,arr;
  scanf("%d",&a);
  for(n=0;n<a;n++){
    scanf("%d",&A[n]);
  }
  for(i=0;i<a;i++){
    for(n=0;n<a-1;n++){
      if(A[n]>A[n+1]){
	arr=A[n+1];
	A[n+1]=A[n];
	A[n]=arr;
	count++;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n]);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <algorithm> 
using namespace std;
int main(){
  int a,b,c,q[3];
  scanf("%d%d%d",&q[0],&q[1],&q[2]);
   sort(q,q+3);
   if(q[0]==q[2]){printf("0");return 0;
   } 
   if(q[1]==q[2]){
   	a=q[1]-q[0];
   	b=a/2;
   	c=a%2;
   	if(c){
   	b+=2;
	   }
	printf("%d",b);
	return 0;
   }
    a=q[2]-q[1];
	if(q[0]+a==q[2]){
		printf("%d",a);
		return 0;
	} 
  b=q[1]-q[0];
  c=b/2;
  if(b%2){
  	c+=2;
  }
  printf("%d",c+a);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <set>
using namespace std;

set<long long> s;

int main()
{
    int n;
    
    scanf("%d",&n);
    
    for (int i = 0;i < n;i++)
    {
        long long t;
        
        scanf("%lld",&t);
        
        set<long long>::iterator it;
        
        it = s.find(t);
        
        if (it == s.end()) s.insert(t);
        else s.erase(it);
    }
    
    printf("%d",s.size());
}


Measured memory_bytes: 4864
#include <iostream>
#include <string>
using namespace std;
int main() {
	int N, A, ans = 1, n = 1;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A;
		if (A % 2 == 0) { n*=2; }
		ans *= 3;
	}
	cout << ans - n;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int d; cin >> d;
  if (d == 25) cout << "Christmas" << endl;
  if (d == 24) cout << "Christmas Eve" << endl;
  if (d == 23) cout << "Christmas Eve Eve" << endl;
  if (d == 22) cout << "Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 888
import collections

n=int(input())
a=[int(x) for x in input().split()]
evn=[]
odd=[]

def ct(lrg,sml):
    for lst in [lrg,sml]:
        if len(lst)==1:
            lst.append((0,0))
    if lrg[0][0]==sml[0][0]:
        return min(n-lrg[1][1]-sml[0][1],n-lrg[0][1]-sml[1][1])
    else:
        return n-lrg[0][1]-sml[0][1]

for i in range(len(a)):
    if i%2:
        evn.append(a[i])
    else:
        odd.append(a[i])
        
cevn=collections.Counter(evn).most_common()
codd=collections.Counter(odd).most_common()

if cevn[0][1]>codd[0][1]:
    ans = ct(cevn,codd)
else:
    ans = ct(codd,cevn)
    
print(ans)

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

int main() {
    int k;
    string s, r;
    cin >> k;
    cin >> s;

    if(s.length() <= k) {
      cout << s;
    } else {
      r = s.substr(0,k).append("...");
      cout << r;
    }
    return 0;
}

Measured memory_bytes: 3528
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
constexpr long MOD = 1e9 + 7;
using namespace std;

#include <map>

map<pair<int,int>, int> m;
long h, w, n;
long counter[10];
long nonzero = 0;

void hoge(int a, int b) {
    for (int i = -1; i < 2; i++) {
        for (int j = -1; j < 2; j++) {
            if (0 <= a + i && a + i < h && 0 <= b + j && b + j < w) {
                m[make_pair(a + i, b + j)]++;
            }
        }
    }
}

int main() {
    cin >> h >> w >> n;
    
    int a, b;
    
    REP(i,n) {
        cin >> a >> b;
        hoge(a-1,b-1);
    }
    
    for (auto itr = m.begin(); itr != m.end(); itr++) {
        if (itr->first.first > 0 && itr->first.first < h - 1 && itr->first.second > 0 && itr->first.second < w - 1) counter[itr->second]++;
    }
    
    for (int i = 1; i < 10; i++) nonzero += counter[i];
    
    cout << (h-2) * (w-2) - nonzero << endl;
    
    for (int i = 1; i < 10; i++) cout << counter[i] << endl;
}


Measured memory_bytes: 56448
import heapq
n,k = (int(x) for x in input().split())
arr = []
discard = []
type = set()
score = 0

for i in range(n):
  a,b = (int(x) for x in input().split())
  heapq.heappush(arr, (-b, a))
  
# 初期状態
for i in range(k):
  d, t = heapq.heappop(arr)
  score -= d
  if t not in type:
    type.add(t)
  else:
    heapq.heappush(discard, (-d, t))

bonus = len(type)
ans = score + bonus**2

while arr and discard:
  pd, pt = heapq.heappop(arr)  #追加候補
  if pt not in type:
    _pd, _pt = heapq.heappop(discard) #被っているものの中で美味しさが最も小さいものを取り出す
    type.add(pt)
    score = score - _pd - pd
    bonus += 1
    tmp = score + bonus**2
    ans = max(ans, tmp)
    
print(ans)
    



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

int main(){
    string k; cin >> k;
    if( k[0] != k[1] && k[2] != k[1] && k[2] != k[3]){
        cout << "Good" << endl;
    } else {
        cout << "Bad" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;
int N;
vector<int> a(3010);
ll dp[3010][3010];

ll dfs(int x, int y){
    int turn = (N - y + x) % 2;
    if(dp[x][y] != INF){
        return dp[x][y];
    }else{
        if(x == y){
            if(turn){
                return dp[x][y] = a.at(x);
            }
            else return dp[x][y] = -a.at(x);
        }
        else{
            if(turn){
                return dp[x][y] = max(dfs(x+1, y) + a.at(x), dfs(x, y-1) + a.at(y));
            }
            else{
                return dp[x][y] = min(dfs(x+1, y) - a.at(x), dfs(x, y-1) - a.at(y));
            }
        }
    }
}


int main(void){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    
    for(int i = 0; i < 3010; i++){
        for(int j = 0; j < 3010; j++){
            dp[i][j] = INF;
        }
    }
    
    cout << dfs(0, N-1) << endl;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int max = 0;
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
        if(max < a.at(i)){
            max = a.at(i);
        }
    }
    int min = 1000000000, min_number;
    for(int i = 0; i < n; i++){
        if(max == a.at(i)) continue;
        if(min > abs(max / 2 - a.at(i))){
            
            min  = abs(max / 2 - a.at(i));
            min_number = a.at(i);
        }
    }
    cout << max << " " << min_number << endl;

}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b; cin >> a >> b;
    out((a+b+1)/2);

    return 0;
}

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

#define SIZE 100000

typedef struct {
	int n, c;
	int *arr;
} list;

void ladd(list *l, int x) {
	if (l->n+1 > l->c) {
		l->c = l->c*2 + !l->c;
		l->arr = realloc(l->arr, l->c * sizeof *l->arr);
	}
	l->arr[l->n++] = x;
}

int seen[3][SIZE];
list vert[SIZE];
int q[2][SIZE], qi[2][2];

void qpush(int p, int x) {
	q[p%2][qi[p%2][1]++] = x;
}

int qpop(int p) {
	return q[p%2][qi[p%2][0]++];
}

void qreset(int p) {
	qi[p%2][0] = qi[p%2][1] = 0;
}

int qempty(int p) {
	return qi[p%2][0] == qi[p%2][1];
}

int main(void) {
	int n, m;
	scanf("%d%d", &n, &m);

	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		ladd(&vert[u-1], v-1);
	}

	int s, t;
	scanf("%d%d", &s, &t);
	s--; t--;

	int p = 0;
	qpush(0, s);
	while (!seen[0][t]) {
		if (qempty(p)) {
			qreset(p++);
			if (qempty(p)) {
				break;
			}
		}

		int cur = qpop(p);
		for (int i = 0; i < vert[cur].n; i++) {
			if (!seen[(p+1)%3][vert[cur].arr[i]]) {
				seen[(p+1)%3][vert[cur].arr[i]] = 1;
				qpush(p+1, vert[cur].arr[i]);
			}
		}
	}

	for (int i = 0; i < n; i++) {
		free(vert[i].arr);
	}

	if (seen[0][t]) printf("%d\n", (p+1)/3);
	else puts("-1");
}


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

int main(){
  int sp=0,cec=1,maxce=0;;
  string s;
  string ce[2]={"chicken","egg"};
  cin>>s;
  int len = s.size();
  bool f,ans=0;
  if(s.substr(sp,ce[0].size())==ce[0]) sp+=ce[0].size(),f=0;
  else sp+=ce[1].size(),f=1;
  while(sp!=len){
    if(s.substr(sp,ce[0].size())==ce[0]){
      if(f==1)cec++;
      else{
	if(maxce<cec) maxce=cec,ans=f;
	cec=1;
      }
      sp+=ce[0].size();
      f=0;
    }
    else if(s.substr(sp,ce[1].size())==ce[1]){
      if(f==0)cec++;
      else{
	if(maxce<cec) maxce=cec,ans=f; 
	cec=1;
      }
      sp+=ce[1].size();
      f=1;
    }
    if(maxce<cec) maxce=cec,ans=f;
  }
  cout<<ce[ans]<<endl;
  return 0;
}

Measured memory_bytes: 1212
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var answer = (N - 1) / 2;


            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int a = 0;
	int i;
	for (i = 0; i < m; i++) {
		int sc;
		scanf("%d", &sc);
		a += sc;
	}
	if (a > n)
		printf("-1\n");
	else
		printf("%d\n", n - a);
	
	return 0;
}

Measured memory_bytes: 1724
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll X[17],Y[17];
	ll P[17];
	scan(N);
	rep(i,N){
		scan(X[i]>>Y[i]>>P[i]);
	}
	ll tate[1<<N][N],yoko[1<<N][N];
	int bitall=(1<<N);
	rep(bit,bitall){
		bool line[N]={};
		rep(i,N){
			if(bit&(1<<i)) line[i]=1;
		}
		rep(i,N){
			ll absxmin=P[i]*abs(X[i]),absymin=P[i]*abs(Y[i]);
			rep(j,N){
				if(line[j]){
					absxmin=min(absxmin,P[i]*abs(X[i]-X[j]));
					absymin=min(absymin,P[i]*abs(Y[i]-Y[j]));
				}
			}
			tate[bit][i]=absxmin,yoko[bit][i]=absymin;
		}
	}
	int pow3=(int)(pow(3,N)+0.5);
	ll ans[N+1];
	fill(ans,ans+N+1,INFl);
	rep(bit,pow3){
		ll sum=0;
		int retu[N];
		int tmp=bit;
		int linenum=0;
		rep(i,N){
			retu[i]=tmp%3;
			linenum+=(tmp%3>0);
			tmp/=3;
		}
		int tatebit=0,yokobit=0;
		rep(i,N){
			if(retu[i]==1) tatebit+=(1<<i);
			if(retu[i]==2) yokobit+=(1<<i);
		}
		rep(i,N){
			sum+=min(tate[tatebit][i],yoko[yokobit][i]);
		}
		ans[linenum]=min(ans[linenum],sum);
	}
	rep(i,N+1){
		prin(ans[i]);
	}
	return 0;
}


Measured memory_bytes: 11692
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] list = scanner.nextLine().toCharArray();
        for(char a:list)
            if(Character.isLowerCase(a))
                System.out.print(Character.toUpperCase(a));
            else
                System.out.print(Character.toLowerCase(a));
        System.out.println();
    }
}


Measured memory_bytes: 26972
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
     int n,a,b,sum=0;
     cin>>n>>a>>b;
     for(int i=1;i<=n;i++){
        int cur=i;
        int ds=0;
        while(cur>0){
            ds+=cur%10;
            cur/=10;
        }
        if(ds>=a && ds<=b)
            sum+=i;
     }
     cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3620
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		int ans = 0;
		if(A >= K)
			ans = K;
		else {
			ans = A;
			K -= A;
			ans -= Math.max(K-B, 0);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main(){
    int i=0;
    while(true){
        int x;cin>>x;
        if(x==0)break;
        i++;
        cout<<"Case "<<i<<": "<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if(a==b||a<b)cout << a << endl;
  else cout << a-1 << endl;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def dfs(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのstackを作成
    dist[start] = 0
    stack = [(0,start)]
    
    while stack:
        cost, cur_node = stack.pop()

        # 未探索のノードをstackに入れる
        for nex_cost, nex_node in graph[cur_node]:
            if dist[nex_node] != INF:
                continue
            else:
                dist[nex_node] = dist[cur_node] + nex_cost
                stack.append((dist[nex_node],nex_node))
                
    return dist

def isnibu(graph:list, dist:list) -> bool:
    for i,edges in enumerate(graph):
        for _, j in edges:
            if dist[i]%2 == dist[j]%2:
                return False
    
    return True
    
    

n,m = li()

adj_lst = [set() for _ in range(n)]

for _ in range(m):
    a,b = li_()
    
    adj_lst[a].add((1,b))
    adj_lst[b].add((1,a))
    
dist = dfs(adj_lst, n, 0)

nibu = isnibu(adj_lst, dist)

ans = 0
if isnibu(adj_lst, dist):
    ans = sum([dist[i]%2 == 1 for i in range(n)]) * sum([dist[i]%2 == 0 for i in range(n)]) - m
    
else:
    ans = n*(n-1)//2 - m
    
print(ans)

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

typedef long long ll;
typedef vector < int > vi;
typedef pair <int , int > pi;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fr(i,a,b) for(int i=a;i<b;i++)




int isprime(ll n)
{
    int flag=0;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            flag=1;;
            break;
        }
    }
    return flag;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   int t;
   cin>>t;
   int f = 360;
   int ans=0;
   if(f%t==0)
   {
       ans+=f/t;
       cout<<ans<<"\n";
   }
   else
   {
       while(f%t!=0)
       {
           ans+=f/t;
           f= 360+(f%t);

       }
       ans+=f/t;
       cout<<ans;

   }
   
  
    return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
long long x[100010],y[100010];
#define int long long 
signed main(){
    int n,a,b;
    string s;
    cin>>s;
    if(s=="Sunny"){
    cout<<"Cloudy"<<'\n';  
    }else if(s=="Rainy"){
        cout<<"Sunny"<<'\n';
    }else if(s=="Cloudy"){
        cout<<"Rainy"<<'\n';
    }
}

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

int main(){
    ll a,b,c,k;
    cin >>a >> b >> c >> k;
    if(k<=a)
    cout << k << endl;
    else if(k<=(a+b)){
        cout << a << endl;
    }
    else{
        k=k-a-b;
        
        cout << a-k << endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
	vector<int> v,v2;
	int n,a;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i){
		scanf("%d",&a);
		v2.push_back(a);
		if(i == 0){
			v.push_back(a);
		}else{
			v.push_back(v[i-1]+a);
		}
	}
	
	for (int i = v2.size()-2; i >= 0; i--){
		v2[i]=v2[i]+v2[i+1];
	}
	int minimo = INT_MAX;

	for (int i = 0; i < v.size(); ++i){
		minimo = min(minimo,abs(v[i]-v2[i+1]));
	}
	cout<<minimo<<'\n';
	return 0;
}

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

int main()
{
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(r > x || r > y)
    {
        cout << "No" << endl;
    }
    else if (x + r > W || y + r > H)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3092
using namespace std;
#include 		<bits/stdc++.h>
#define	fi 		first
#define se 		second
#define pb 		push_back
#define mp 		make_pair
#define maxn	500005
#define inf		int(21e8)
#define mod		int(1e9+7)
#define db		double
#define ll		long long
#define si 		stack<int>
#define qi 		queue<int>
#define vi 		vector<int>
#define pi 		pair<int, int>
#define pq  	priority_queue< int, vector<int>, greater<int> >
ll powmod(ll a, ll b) {
	ll res = 1; a %= mod;
	for (; b; b >>= 1)
		res = (res * ((b & 1) ? a : 1)) % mod,
		a = a * a % mod;
	return res;
}
ll gcd(ll a, ll b) {return b ? gcd(a, b) : a;}
int n, m, k, ans;
string s[10];
int co[10], rw[10];
int main() {
	cin >> n >> m >> k;
	for(int i = 0; i < n; i ++)
		cin >> s[i];
	for(int i = 0; i < (1 << n); i ++) {
		for(int j = 0; j < (1 << m); j ++) {
			int cnt = 0;
			for(int tt = 0; tt < 6; tt ++) co[tt] = rw[tt] = 0;
			for(int x = 0; x < n; x ++) if(i & (1 << x)) co[x] = 1;
			for(int y = 0; y < m; y ++) if(j & (1 << y)) rw[y] = 1;
			// cout << i << endl;
			// for(int x = 0; x < n; x ++) cout << co[x];
			// cout << endl;
			// for(int x = 0; x < m; x ++) cout << rw[x];
			// cout << endl;


			for(int x = 0; x < n; x ++)
				for(int y = 0; y < m; y ++)
					cnt += (s[x][y] == '#' && !co[x] && !rw[y]);
			ans += (cnt == k);
		}
	}
	cout << ans << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 3696
def resolve():
    n, k = list(map(int, input().split()))
    xxx = list(map(int, input().split()))
    ans = float("inf")
    for i in range(n-k+1):
        max_l = xxx[i+k-1]
        min_l = xxx[i]
        if not min_l <= 0 <= max_l:
            ans = min(ans, max(abs(min_l), abs(max_l)))
        else:
            ans = min(ans, min(abs(min_l), abs(max_l))+abs(max_l-min_l))
    print(ans)
resolve()

Measured memory_bytes: 62576
#include <bits/stdc++.h>
using namespace std;
int girl[10010];
struct node
{
    int x,y;
}arr1[200],arr2[200];
int mapp[200][200];
int vis[200];
int n;
void solve()
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(arr1[i].x<arr2[j].x && arr1[i].y<arr2[j].y) mapp[i][j]=1;
        }
    }
}
bool findd(int x)
{
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0 && mapp[x][i])
        {
            vis[i]=1;
             if(girl[i]==0 || findd(girl[i]))
             {
                 girl[i]=x;
                 return true;

             }

        }
    }
    return false;
}
int main()
{
    while(cin>>n)
    {
        int ans=0;
        memset(mapp,0,sizeof(mapp));
        memset(girl,0,sizeof(girl));
        for(int i=1;i<=n;i++)
        {
            cin>>arr1[i].x>>arr1[i].y;
        }
        for(int i=1;i<=n;i++)
        {
            cin>>arr2[i].x>>arr2[i].y;
        }
        solve();
        for(int i=1;i<=n;i++)
        {
            memset(vis,0,sizeof(vis));
            if(findd(i)) ans++;
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 384
#include <iostream>  
#include <map>  
#include <set>  
#include <string>  
#include<string.h>  
#include <cstring>  
#include <cstdio>  
#include <algorithm>  
#include <cmath>  
#include <queue>  
#include <vector>  
using namespace std;  
typedef long long ll;  
const int maxn=55;  
char mp[maxn][maxn];  
int f[maxn][maxn];  
int main(){  
    int h,w;  
    scanf("%d%d",&h,&w);  
    memset(f,0,sizeof(f));  
    for(int i=0;i<h;i++){  
        scanf("%s",mp[i]);  
    }  
    for(int i=0;i<h;i++){  
        for(int j=0;j<w;j++){  
            if(mp[i][j]=='#'){  
                if(i-1>=0){  
                    f[i-1][j]++;  
                }  
                if(j-1>=0){  
                    f[i][j-1]++;  
                }  
                if(i+1<h){  
                    f[i+1][j]++;  
                }  
                if(j+1<w){  
                    f[i][j+1]++;  
                }  
                if(i-1>=0&&j-1>=0){  
                    f[i-1][j-1]++;  
                }  
                if(i+1<h&&j-1>=0){  
                    f[i+1][j-1]++;  
                }  
                if(i-1>=0&&j+1<w){  
                    f[i-1][j+1]++;  
                }  
                if(i+1<h&&j+1<w){  
                    f[i+1][j+1]++;  
                }  
            }  
        }  
    }  
    for(int i=0;i<h;i++){  
        for(int j=0;j<w;j++){  
            if(mp[i][j]=='#') printf("#");  
            else printf("%d",f[i][j]);  
        }printf("\n");  
    }  
    return 0;  
}  


Measured memory_bytes: 256
//23:24
#include <stdio.h>

int x[50];
int y[50];
int min(int x, int y){ return (x < y)?x : y;}
int max(int x, int y){ return (x > y)?x : y;}
int main(){
	int N, K;
	scanf("%d %d",&N,&K);
	for(int i = 0; i < N; i++) scanf("%d %d",x+i,y+i);

	long long space = 4*1000000000LL*1000000000LL;
	for(int x1 = 0; x1 < N-1; x1++){
		for(int x2 = x1; x2 < N; x2++){
			for(int y1 = 0; y1 < N-1; y1++){
				for(int y2 = y1; y2 < N; y2++){
					long long  xs = min(x[x1],x[x2]);
					long long  xl = max(x[x1],x[x2]);
					long long  ys = min(y[y1],y[y2]);
					long long  yl = max(y[y1],y[y2]);
					int cnt=0;
					for(int n = 0; n < N; n++){
						if(xs <= x[n] && x[n] <= xl 
						&& ys <= y[n] && y[n] <= yl){ cnt++; }
					}				
					if(cnt >= K){
						if(space > (xl-xs)*(yl-ys)) space = (xl-xs)*(yl-ys);
					}
				}
			}
		}
	}
	printf("%lld\n",space);
}


Measured memory_bytes: 128
import math

X = int(input())

check = X
while check <= 200000:

  is_prime = True

  i = 2
  while i <= math.sqrt(check):
    if (check % i == 0):
      is_prime = False
      break
    i += 1

  if (is_prime):
    break

  check += 1

print(check)


Measured memory_bytes: 38768