akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    int max_num = 0;
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
//    vector<int> a_diff(n);
    rep(i, n) {
        int tmp_diff = 0;
        if ( i == n -1 ) {
            tmp_diff = k - a[n-1] + a[0];
        }
        else {
            tmp_diff = a[i+1] - a[i];
        }
        max_num = max(max_num, tmp_diff);
    }
    cout << k - max_num << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
struct point{double x;double y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n;
    cin>>n;
    int x,odd=0;
    for(i=0;i<n;i++){
        cin>>x;
        if(x%2==1)odd++;
    }
    cout<<((odd%2==0)?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


from itertools import product
h, w, k = inpl()
data = [list(input()[:-1]) for _ in range(h)]
ans = 0
for t in product([0, 1], repeat=h):
    for s in product([0, 1], repeat=w):
        tmp = 0
        for i in range(h):
            for j in range(w):
                if data[i][j] == "#" and t[i] and s[j]:
                    tmp += 1
        if tmp == k:
            ans += 1
print(ans)


Measured memory_bytes: 69928
#include <stdio.h>
#include <string>

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

  int count = 0;
  for (int i = 1; i <= n; i++) {
    if (std::to_string(i).length() % 2 == 1) {
      count++;
    }
  }

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


Measured memory_bytes: 256
#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);
  }
  
  int a = 0;
  int A = 0;
  int B = 0;

  for (int i=0; i < N; i++){
    for (int j=i+1; j < N; j++){
      if (vec.at(i) > vec.at(j)){
      a = vec.at(i);
        vec.at(i) = vec.at(j);
          vec.at(j) = a;
      }
    }
  }
    
    int b;
    b = N / 2;
  if (2*b == N){
    for (int i=0; i < b; i++){
    B = B + vec.at (2 * i);
    }
  }else{
    for (int i=0; i < b;i++){
    B = B + vec.at (2 * i + 1);
    }
  }
    
    
    for (int i=0; i < N; i++){
    A = A + vec.at (i);
    }
  cout << A - 2*B << endl;
  
}
 

Measured memory_bytes: 3532
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(H: int, W: int, s: "List[str]"):
    s = ["."*(W+2)]+["."+ss+"." for ss in s]+["."*(W+2)]
    
    direction = ((0,1),(1,0),(0,-1),(-1,0))

    # 全ての黒マスの上下左右に一つでも黒マスがあればおk
    for i in range(H+2):
        for j in range(W+2):
            if s[i][j] == ".":
                continue
            
            for x,y in direction:
                if s[i+x][j+y] == "#":
                    break
            else:
                print(NO)
                return 
    
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(H)]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif
struct UF {
public:
  int N,G/* # of disjoint sets */;
  UF(int N): N(N) { init(N); }
  void init(int N) {
    par=vector<int>(N),sz=vector<int>(N,1);
    for(int i=0; i<N; ++i) par[i]=i,sz[i]=1;
    G=N;
  }
  int find(int x) { return par[x]==x?x:par[x]=find(par[x]); }
  int size(int x) { return sz[find(x)]; }
  bool sameset(int x, int y) { return find(x)==find(y); }
  int unite(int x, int y) {
    x=find(x),y=find(y);
    if(x==y) return x;
    int p=x,c=y;
    if(sz[p]<sz[c]) swap(p,c);
    G--,sz[p]=sz[c]=sz[p]+sz[c];
    par[c]=p;
    return p;
  }
private:
  vector<int> par,sz;
};
// $ cp-batch ConnectCities | diff ConnectCities.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address ConnectCities.cpp && ./a.out

/*

 9/26/2020

 5:04-

 */

int N,M;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>M;
  UF uf(N);
  REP(i,M) {
    int u,v; cin>>u>>v;
    --u,--v;
    uf.unite(u,v);
  }

  cout<<uf.G-1<<endl;

  return 0;
}


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

int main(){
  int n;
  n=0;
  string s;
  cin >> s;
  for(int i=0;i < s.size();i++){
    if(s.at(i) == '1'){
      n++;
    }
  }
  cout << n << endl;  
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <cassert>

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;

using namespace std;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s;
	cin >> s;
	cout << s.substr(0, s.length() - 8);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;
public class Main {
	int INF = 1 << 24;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			int [][] data = new int[n][n];
			int count = 0;
			int mid = n / 2;
			data[mid+1][mid] = 1;
			count++;
			int num = 2;
			int xpos = (mid + 1) % n, ypos = (mid + 2) % n;
			while(count != n * n){
				if(data[ypos][xpos] == 0){
					count++;
					data[ypos][xpos] = num++;
					xpos = (xpos + 1) % n;
					ypos = (ypos + 1) % n;
				}
				else{
					xpos = (xpos - 1 + n) % n;
					ypos = (ypos + 1) % n;
				}
			}
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n-1; j++){
					System.out.printf("%4d",data[i][j]);
				}
				System.out.printf("%4d\n",data[i][n-1]);
			}
		}
	}

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

Measured memory_bytes: 12000
import copy
keta_lunlun = [1,2,3,4,5,6,7,8,9]
nexketa_lunlun = []
K = 0
keta = 1
def lunlun_gen(lunlun):
    global K
    global keta_lunlun
    global nexketa_lunlun
    global keta
    if(keta>=10):
        return lunlun
    nexketa_lunlun.clear()
    for i in range(len(keta_lunlun)):
        if(0<keta_lunlun[i]%10<9):
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10)-1)
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10)  )
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10)+1)
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10-1))
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10  ))
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10+1))
          
        elif(keta_lunlun[i]%10 == 9):
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10)-1)
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10)  )
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10-1))
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10))
        else:
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10))
            lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10)+1)
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10))
            nexketa_lunlun.append(keta_lunlun[i]*10+(keta_lunlun[i]%10+1))
    keta_lunlun.clear()
    keta_lunlun.extend(nexketa_lunlun)
    keta +=1
    return lunlun_gen(lunlun)

def main():
    global K
    K = int(input())
    lunlun = [1,2,3,4,5,6,7,8,9]
    ans = lunlun_gen(lunlun)
    print(ans[K-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 21488
from itertools import permutations

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

ls = [i for i in range(1, N+1)]

a = 0
b = 0

for i, name in enumerate(list(permutations(ls, N))):
    name = list(name)
    if name == P:
        a = i
    if name == Q:
        b = i

print(abs(a-b))


Measured memory_bytes: 79964
#include <iostream>
#include <map>
#include <string>
#include <cmath>

using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	map<string, int> mp1;
	for(int i = 0; i < n; i++){
			string s;
			cin >> s;
			if(mp1.find(s) == mp1.end())mp1[s] = 0;
			mp1[s]++;
	}
	int m;
	cin >> m;
	map<string, int> mp2;
	for(int i = 0; i < m; i++){
			string s;
			cin >> s;
			if(mp2.find(s) == mp2.end())mp2[s] = 0;
			mp2[s]++;
	}
	int res = 0;
	for(map<string, int>::iterator itr = mp1.begin(); itr != mp1.end(); ++itr){
			if(mp2.find((*itr).first) == mp2.end())res = max(res, (*itr).second);
			else res = max(res, (*itr).second - mp2[(*itr).first]);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

class TEST{
	static void Main(){
		while(true){
			var d=int.Parse(Console.ReadLine());
			if(d==0)break;
			Sol mySol=new Sol(d);
			mySol.WriteAns();
		}
	}
}


class Sol{
	int n;
	PannelTag TOP;
	public void WriteAns(){
		for(int i=0;i<n;i++){
			//var s=Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));
			var ss=Console.ReadLine().Split(' ');
			int[] s=new int[2];
			s[0]=int.Parse(ss[0]);
			s[1]=int.Parse(ss[1]);
			
			SearchAndWrite(TOP,s[0],s[1]);
		}
	}
	
	void SearchAndWrite(PannelTag P,int x,int y){
		bool chk=true;
		for(int i=0;i<P.Children.Count;i++){
			if(x>=P.Children[i].Xmin && x<=P.Children[i].Xmax && y>=P.Children[i].Ymin && y<=P.Children[i].Ymax){
				chk=false;
				SearchAndWrite(P.Children[i],x,y);
				break;
			}
		}
		if(chk){
			Console.Write(P.Body);
			Console.WriteLine(" {0}",P.Children.Count);
		}
	}
	
	public Sol(int n_){
		n=n_;
		String tag_main=Console.ReadLine();
		
		PannelTag Content=new PannelTag(tag_main);
		
		// 外枠を追加する（万一、mainの中に"OUT OF MAIN PANEL"があった時のために、個別に生成）
		TOP=new PannelTag("<OUT OF MAIN PANEL>0,0,10001,10001</OUT OF MAIN PANEL>");
		Content.Parent=TOP;
		TOP.Children.Add(Content);
	}
}


class PannelTag{
	PannelTag parent;
	String body;
	String expr;
	int xmin;
	int xmax;
	int ymax;
	int ymin;
	
	public PannelTag Parent{
		get{return parent;}
		set{this.parent=value;}
	}
	public List<PannelTag> Children;
	public int Xmin{get{return xmin;}}
	public int Xmax{get{return xmax;}}
	public int Ymin{get{return ymin;}}
	public int Ymax{get{return ymax;}}
	public String Body{get{return body;}}


	//constructor
	//exprを与えて再帰的にparseしながらツリーを生成。
	public PannelTag(String expr_){
		expr=expr_;
		
		int cursol=0;
		int cursol_bak=0;
		
		while(expr[cursol]!='>')cursol++;
		body=expr.Substring(1,cursol-1);
//Console.WriteLine("dbg body={0}",body);
		cursol++;
		cursol_bak=cursol;//＠サイズの先頭文字
		while(expr[cursol]!='<')cursol++;
		var Csv=expr.Substring(cursol_bak,cursol-cursol_bak).Split(',');
//Console.WriteLine("dbg CSV={0}",expr.Substring(cursol_bak,cursol-cursol_bak));
		xmin=int.Parse(Csv[0]);
		ymin=int.Parse(Csv[1]);
		xmax=int.Parse(Csv[2]);
		ymax=int.Parse(Csv[3]);
//Console.WriteLine("dbg xmin={0},ymin={1},xmax={2},ymax={3}",xmin,ymin,xmax,ymax);
		//子ノードを追加する
		//cursol:'<'の上にいる
		Children=new List<PannelTag>();
		while(cursol<expr.IndexOf("</"+body+">",0)){
			cursol_bak=cursol;
			while(expr[cursol]!='>')cursol++;
			String body_child=expr.Substring(cursol_bak+1,cursol-(cursol_bak+1));
//Console.WriteLine("dbg body_child={0}",body_child);
			cursol=expr.IndexOf("</"+body_child+">",cursol_bak);
			while(expr[cursol]!='>')cursol++;
			String expr_child=expr.Substring(cursol_bak,cursol-cursol_bak+1);
//Console.WriteLine("dbg expr_child={0}",expr_child);
			Children.Add(new PannelTag(expr_child));
			cursol++;//'<'の上に置く
		}
	}
}

Measured memory_bytes: 6340
#include<bits/stdc++.h>
using namespace std;
const int N=1e7;
int f[N+5];
int cnt[N+5];
int prime[N+5];
void init() 
{
    for (int i=2;i<=N;i++) 
	{
        if (!prime[i]) 
		{
            prime[++prime[0]]=i;
            f[i]=2;
            cnt[i]=1;
        }
        for (int j=1;j<=prime[0];j++) 
		{ 
            if (i*prime[j]>N) break;
            prime[i*prime[j]]=1;
            if (i%prime[j]==0) 
			{
                f[i*prime[j]]=f[i]/(cnt[i]+1)*(cnt[i]+2);
                cnt[i*prime[j]]=cnt[i]+1;
                break;
            } else 
			{
                f[i*prime[j]]=f[i]*f[prime[j]]; 
                cnt[i*prime[j]]=1;
            }
        }
    }
    return ;
}
int main()
{
	init();
	f[1]++;
	int n;cin>>n;
	long long ans=0;
	for (int i=1;i<=n;i++) 
	{
		long long x=i;long long y=f[i];long long z=x*y;ans+=z;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 120800
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct DADA{
	int val;
	int idx;
	bool operator>(const DADA &d) const{
		return val > d.val;
	}
	bool operator<(const DADA &d) const{
		return val < d.val;
	}
};
int main(){
	int N; cin >> N;
	vector<DADA> A(N);
	for(int i = 0; i < N; i++){
		cin >> A[i].val;
		A[i].idx = i;
	}
	sort(A.begin(), A.end());
	int res[N];
	for(int i = 0; i < N; i++){
		for(int j = N - 1; j >= 0; j--){
			if(A[j].idx != i){
				res[i] = A[j].val;
				break;
			}
		}
	}
	for(int i = 0; i < N; i++) cout << res[i] << endl;


}


Measured memory_bytes: 3968
//by xxj
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define fi first
#define se second
#define ll long long 
#define mpa make_pair
#define pb push_back
#define pii pair<int,int>
using namespace std;
const int inf=1e9+7;
const ll linf=1e18+7;
const ll hh=523;
const int mod=1e9+7;
int la[100007],lq[100007],rc[100007],rq[100007];
int pow(int x,int k){
	if (k<0){
		return 0;
	}
	int res=1;
	while (k!=0){
		if (k%2==1){
			res=1ll*res*x%mod;
		}
		x=1ll*x*x%mod;
		k/=2;
	}
	return res;
}
int le(int k){
	return (1ll*la[k-1]*pow(3,lq[k-1])%mod+1ll*lq[k-1]*pow(3,lq[k-1]-1)%mod)%mod;
}
int ri(int k){
	return (1ll*rc[k+1]*pow(3,rq[k+1])%mod+1ll*rq[k+1]*pow(3,rq[k+1]-1))%mod;
}
int main(){
	string s;
	cin>>s;
	int lens=s.size();
	if (s[0]=='A'){
		la[0]=1;
	}
	else if(s[0]=='?'){
		lq[0]=1;
	}
	for (int i=1;i<lens;i++){
		la[i]=la[i-1];
		lq[i]=lq[i-1];
		if (s[i]=='A'){
			la[i]++;
		}
		else if(s[i]=='?'){
			lq[i]++;
		}
	}
	for (int i=lens-1;i>=0;i--){
		rc[i]=rc[i+1];
		rq[i]=rq[i+1];
		if (s[i]=='C'){
			rc[i]++;
		}
		else if(s[i]=='?'){
			rq[i]++;
		}
	}
	int ans=0;
	for (int i=1;i<lens-1;i++){
		if (s[i]=='B' || s[i]=='?'){
			ans=(ans+1ll*le(i)*ri(i)%mod)%mod;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2048
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{


long long a,b,c,d,e,f,g,h;
cin>>a;

int x=111;

while(x<a){
	x=x+111;
}

cout<<x<<endl;
return 0;
}

Measured memory_bytes: 3556
// ABC165C - Many Requirements

#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main() 
{
	double   count=100000000;
	double sum=0;
	int N;
	cin >> N;
	vector<int> vec(N);
	for (int& a : vec)
	{
		cin >> a;
		//cout << a << endl;
	}
	//cout << count << endl;

	sort(vec.begin(), vec.end());
	//cout << count << endl;

	for (double i = vec[0]; i <= vec[N-1]; i++)
	{
		sum = 0;
		//cout << count << endl;
		for (int j = 0; j < N; j++)
		{
			//cout << count << endl;
			 sum += pow((i - vec[j]), 2);
			//cout << count << endl;
		}
		count = min(count, sum);
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main ()
{
    int X,A ,B , rslt1 , rslt2;

    scanf("%d%d%d" , &X,&A,&B);

    rslt1 = X - A ;
    rslt2 = rslt1%B ;

    printf("%d" , rslt2) ;

    return 0 ;





}


Measured memory_bytes: 128
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    A = []
    for _ in range(n):
        A.append(input_int())
    A = sorted(A)
    A[-1] = A[-1] // 2
    print(sum(A))
    return


if __name__ == "__main__":
    main()


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

int main(){

    string s;
    cin >> s;

    map<char,int> mp;

    rep(i,s.size()){
        mp[s[i]]++;
    }

    for(auto i:mp){
        if(i.second%2!=0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<long> a(n),b(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  
  if(n%2){
    for(int i=0; i<n; i++){
      if(i<(n+1)/2){cout << a.at(n-1-2*i) << ' ';}
      else if(i!=n-1){cout << a.at(2*i-n) << ' ';}
      else{cout << a.at(n-2) << endl;}
    }
  }
  else{
    for(int i=0; i<n; i++){
      if(i<n/2){cout << a.at(n-1-2*i) << ' ';}
      else if(i!=n-1){cout << a.at(2*i-n) << ' ';}
      else{cout << a.at(n-2) << endl;}
    }
  }
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int a,b;
	cin >> a >> b;
	if(((a*b)%2) ==0){
	cout << "Even" << endl;
}	
	if(((a*b)%2) !=0){
	cout << "Odd" << endl;
}
}


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

using namespace std;

vector < int > v;

int main( ) {

        int n; cin >> n;

        for( int i = 0; i < 3 * n; i ++ ) {
                int x; cin >> x;
                v.push_back( x );
        }

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

        int64_t ans = 0;

        for( int i = 2, cnt = 0; cnt < n; i += 2, cnt ++ ) {
                ans += v[ v.size( ) - i ];
        }

        cout << ans << "\n";

        return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<int>> c(3,vector<int>(3));
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      cin>>c[i][j];
  for(int j=0;j<2;j++){
    int k=c[0][j+1]-c[0][j];
    for(int i=0;i<3;i++)
      if(c[i][j+1]-c[i][j]!=k){
        cout<<"No"<<endl;
        return 0;
      }
  }
  for(int j=0;j<2;j++){
    int k=c[j+1][0]-c[j][0];
    for(int i=0;i<3;i++)
      if(c[j+1][i]-c[j][i]!=k){
        cout<<"No"<<endl;
        return 0;
      }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    int n , k;
    cin >> n >> k;
    int a[n];
    rep(i,n){
        cin >> a[i];
    }
    sort (a,a+n);
    int sum = 0;
    rep(i,k){
        sum += a[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3592
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		StringBuilder sb = new StringBuilder(scan.next());
		int q = scan.nextInt();

		for(int i = 0; i < q; i++){

			String cmd = scan.next();
			int a = scan.nextInt();
			int b = scan.nextInt() + 1;

			if(cmd.equals("print")){

				System.out.println(sb.substring(a, b));

			}else if(cmd.equals("reverse")){

				StringBuilder tmp = new StringBuilder(sb.substring(a, b));
				String tmp2 = tmp.reverse().toString();
				sb = sb.replace(a, b, tmp2);

			}else if(cmd.equals("replace")){

				String p = scan.next();
				sb = sb.replace(a, b, p);

			}
		}
	}

}

Measured memory_bytes: 22036
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  int wa = 0, tmp = N;
  
  while(tmp>0){
    wa += tmp % 10;	// N = 123 なら wa に 3 を足す
    tmp = tmp / 10;	// 次にN = 12 として ↑ の操作を繰り返す
  }
  
  cout << (N % wa == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
# include "algorithm"
# include "iostream"
# include "cstdio"
# include "set"

using namespace std;

const int maxm=2e5+10;
const int maxn=31;
int N,A[maxm];
multiset<int> LH;

int main(){
	register int i,j,k,Ans=0;
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		scanf("%d",A+i);
		LH.insert(A[i]);
	}
	while(LH.size()){
		int i=*LH.rbegin();
		LH.erase(--LH.end());
		for(j=30;j;j--){
			k=(1<<j)-i;
			if(LH.find(k)!=LH.end()){
				multiset<int>:: iterator it=LH.lower_bound(k);
				LH.erase(it);
				Ans++;
				break;
			}
		}
	}
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

#define N 11

char A[N];
int cnt = 0;
vector<vector<int>>klist(100);
int n, m;
vector<int>plist;
vector<vector<bool>>flag2(100, vector<bool>(100, 0));
int ans = 0;

void binary(int nn) {
	if (nn < 1) {
	
		A[N - 1] = '\0';
		//cout << A << " cnt->" << cnt << endl;
		int cnt3 = 0;

		for (int i = 0; i < m; i++) {
			//for (int j = 0; j < klist[i].size(); j++) {
				int cnt2 = 0;
				for (int t = 0; t < n; t++) {
					//if (A[t] == '1' && klist[i][t] == true) {
					if (A[t] == '1' && flag2[i][t] == true) {
						cnt2++;
					}
				}

				if (cnt2 % 2 == plist[i])cnt3++;
			//}

			if (cnt3 == m)ans++;
		}

	}
	else {
		A[nn - 1] = '0';
		binary(nn - 1);
		A[nn - 1] = '1';
		binary(nn - 1);
	}
}


signed main() {
	

	cin >> n >> m; //n=スイッチ、m=電球

	#define N n

	for (int i = 0; i < m; i++) {
		int num;
		cin >> num;

		for (int j = 0; j < num; j++) {
			int num2;
			cin >> num2;
			klist[i].push_back(num2);
			flag2[i][num2 - 1] = true;
		}
	}



	for (int i = 0; i < m; i++) {
		int num;
		cin >> num;
		plist.push_back(num);
	}

	binary(N );

	cout << ans << endl;


	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = Integer.parseInt(sc.next());
    int A = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());

    System.out.println((X - A) % b);

  }
}


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

int main(){

    int y,m,d;
    char c1,c2;
    cin>>y>>c1>>m>>c2>>d;

    if(m>=5) cout<<"TBD"<<endl;
    else cout<<"Heisei"<<endl;

    return 0;
}

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

typedef long long llong;
// -2.1e-9 <= int <= 2.1e9

int main()
{
    size_t N, K;
    cin >> N >> K;

    vector<int> p(N, 0);
    vector<double> Evalue(N, 0);
    //vector<double> psum(N, 0);
    for (size_t i=0; i<N; i++) {
        cin >> p[i];
        double pinv = 1.0 / p[i];
        double sum = p[i] * (p[i] + 1) / 2;
        Evalue[i] = pinv * sum;
    }

    double Ecur = 0.0;
    for(size_t i=0; i<K; i++) {
        Ecur += Evalue[i];
    }

    double Emax = Ecur;
    for (size_t i=1; i<=(N-K); i++) {
        Ecur = Ecur - Evalue[i-1] + Evalue[i+K-1];
        if (Ecur > Emax) {
            Emax = Ecur;
        }
    }
    cout << fixed << setprecision(12);
    cout << Emax << endl;
}


Measured memory_bytes: 2560
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);

	return x * y / tmp;
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


    int n;
    cin >> n;
    vector<int> p(n),q(n),b(n);
    for (int i = 0; i < n; i++)
    {
        b[i]=i+1;
        cin >> p[i];
        /* code */
    }

     for (int i = 0; i < n; i++)
    {
        cin >> q[i];
        /* code */
    }
    
    int pa=0,qa=0;
    int cnt = 1;
    do
    {
        bool bp = true;
        for (int i = 0; i < n; i++)
        {
            /* code */
            bp &= (p[i]==b[i]);
        }
        
        if(bp){
            pa=cnt;
        }

         bool bq = true;
        for (int i = 0; i < n; i++)
        {
            /* code */
            bq &= (q[i]==b[i]);
        }
        
        if(bq){
            qa=cnt;
        }

        cnt++;
    } while (next_permutation(b.begin(),b.end()));
    


    cout << abs(qa-pa)<<endl;
	

	return 0;
}



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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    ll vmax = 0;
    ll vmin = n+20;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        vmax = max(vmax,a[i]);
        vmin = min(vmin,a[i]);
    }
    
    if(vmax-vmin>1){
        std::cout << "No" << std::endl;
        return 0;
    }
    
    ll num = 0;
    for (int i = 0; i < n; i++) {
        if(a[i]==vmin)num++;
    }
    
    if(num==n){
        if(vmin*2 <= n || vmin==n-1){
            std::cout << "Yes" << std::endl;
        }else{
            std::cout << "No" << std::endl;
        }
        return 0;
    }
    
    if(vmax-num<0){
        std::cout << "No" << std::endl;
        return 0;
    }
    
    if((vmax-num) == 0 || (vmax-num)*2 > n-num){
        std::cout << "No" << std::endl;
        return 0;
    }
    std::cout << "Yes" << std::endl;
    // 全部でk種類だとして、ありうる答えはkかk-1。つまりmax-minが1いない
    
    // 問題は何匹までk-1という答えが許されるか
    
    // k-1が矛盾しないためには、そいつだけが独自の帽子を被る必要がある。
    
    // 一方で、全体ではk種類だけしかない。
    

    
}

Measured memory_bytes: 1024
#include <cstdio>
#include <utility>

static const size_t n_max = 1000000;
static int cs[n_max];
static size_t heap[n_max], paeh[n_max];

static bool lt(size_t k, size_t l) {
  auto i = heap[k], j = heap[l];
  return cs[i] > cs[j] || (cs[i] == cs[j] && i < j);
}

static void swap(size_t i, size_t j) {
  std::swap(heap[i], heap[j]);
  std::swap(paeh[heap[i]], paeh[heap[j]]);
}

int main() {
  size_t n, q;
  scanf("%zu%zu", &n, &q);
  for (size_t i = 0; i < n; i++)
    heap[i] = paeh[i] = i;
  for (size_t i = 0; i < q; i++) {
    size_t a;
    int v;
    scanf("%zu%d", &a, &v);
    a--;
    cs[a] += v;
    if (v > 0)
      for (auto j = paeh[a]; j;) {
        auto k = (j-1)/2;
        if (lt(j, k)) {
          swap(j, k);
          j = k;
        } else
          break;
      }
    else {
      size_t i = paeh[a];
      for (;;) {
        size_t j = i * 2 + 1, k = i * 2 + 2, l = i;
        if (j < n && lt(j, l))
          l = j;
        if (k < n && lt(k, l))
          l = k;
        if (i == l)
          break;
        swap(i, l);
        i = l;
      }
    }
    printf("%zu %d\n", heap[0] + 1, cs[heap[0]]);
  }
}

Measured memory_bytes: 22212
#include<iostream>

int main() {
	int a=0,b=1,c,n;

	std::cin >> n;



	for (int i = 0; i < 3; i++) {

		if (n % 10 == 9) {
			c = 1;
		}

		if (n % 10 == 1) {
			c = 9;
		}

		a = a+c * b;

		b = 10 * b;

		n = n / 10;
	}



	std::cout << a << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define MOD 1000000007

#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)

using namespace std;

int a,b,c,d;

int main()
{
	cin>>a>>b>>c>>d;
	if((c-1)/b<=(a-1)/d)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  string s;
  cin>>s;
  rever(s);
  while(true) {
    if(s.empty()) {
      cout<<"YES"<<endl;
      return 0;
    }
    else if(s.size()<5) {
      cout<<"NO"<<endl;
      return 0;
    }
    if(s.substr(0,5)=="maerd"||s.substr(0,5)=="esare") {
      s.erase(0,5);
    }
    else if(s.substr(0,7)=="remaerd") {
      s.erase(0,7);
    }
    else if(s.substr(0,6)=="resare") {
      s.erase(0,6);
    }
    else {
      cout<<"NO"<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<queue>
#include<deque>
using namespace std;
const int INF=100005;
int vis[INF];
vector<int> c[INF],a1,a2;
deque<int> dq;
int n,m;
int get1,get2,res,k;
void work(){
	do{
		res=0;
		k=dq.front();
		vis[k]=1;
		a1.push_back(k);
		for(int i=0;i<c[k].size();i++){
			if(!vis[c[k][i]]){
				res=1;
				dq.push_front(c[k][i]);
				break;
			}
		}
	}while(res);
}
void checkleft(){
	do{
		res=0;
		k=dq.back();
		vis[k]=1;
		a2.push_back(k);
		for(int i=0;i<c[k].size();i++){
			if(!vis[c[k][i]]){
				dq.push_back(c[k][i]);
				res=1;
				break;
			}
		}
	}while(res);
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>get1>>get2;
		c[get1].push_back(get2);
		c[get2].push_back(get1);
	}
	vis[1]=1;
	dq.push_back(1);
	work();
	checkleft();
	printf("%d\n",a1.size()+a2.size()-1);
	for(int i=a1.size()-1;i>=0;i--){
		printf("%d ",a1[i]);
	}
	for(int i=1;i<a2.size();i++){
		printf("%d ",a2[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 7544
#include <bits/stdc++.h>
using namespace std;
int a[26];

int main(){
    iota(a,a+26,1);
    srand(time(NULL));
    random_shuffle(a,a+26);
    for (int i = 0; i < 365; i++){
        printf("%d\n",a[i%26]);
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  rep(i, n) cin >> a[i];
  for(auto x: a){
    mp[x]++;
    mp[x - 1]++;
    mp[x + 1]++;
  }
  int ans = 0;
  for(auto x :mp){
    ans = max(ans, x.second);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5120
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;

int main() {
	int n;
	int a;
	cin >> n;
        int flag[101] = {};
	for (int i=0;i<n;i++) {
	cin >> a;
	flag[a] = 1;
	}

	int cnt = 0;
	for (int i=0;i<101;i++) {
	if (flag[i]) {
	cnt++;
	}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
def resolve():
    n = int(input())
    def divisor(n):
        ass = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                ass.append(i)
                if i ** 2 == n:
                    continue
                ass.append(n // i)
        return ass  # sortされていない
    g = sorted(divisor(n))

    q = []
    for i in range(1, len(g)):
        m=n
        while m >= g[i]:
            if m %g[i] == 0:
                m = m//g[i]
            else:
                m = m%g[i]
        if m == 1:
            q.append(g[i])
    print(len(set(divisor(n-1)+q))-1)

resolve()

Measured memory_bytes: 39152
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

constexpr int N_LIM = 100010;

int N, L;
int a[N_LIM];

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

    cin >> N >> L;
    for (int j = 0; j < N; ++j) {
        cin >> a[j];
    }

    stack<int> pending;
    vector<int> ans;

    bool possible = false;
    for (int j = 0; j < N-1; ++j) {
        if (possible) {
            pending.push(j);
        } else if (a[j]+a[j+1] >= L) {
            pending.push(j);
            possible = true;
        } else {
            ans.push_back(j);
        }
    }

    if (!possible) {
        cout << "Impossible" << endl;
        return 0;
    }

    while (!pending.empty()) {
        ans.push_back(pending.top());
        pending.pop();
    }

    cout << "Possible" << endl;
    for (const int e : ans) {
        cout << e+1 << endl;
    }
    return 0;
}


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

#define Debug(x) x
typedef int regular_int;
 #define int ll
typedef long long ll;


int n;

pair<int, int > pos[200000];
int  P[200000];
set <int > s;

regular_int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(12) << fixed;

	cin >> n;
	s.insert(- 1);
	s.insert(- 2);
	s.insert(n);
	s.insert(n + 1);

	for(int i = 0; i < n; ++i) {
		cin >> pos[i].first;
		P[i] = pos[i].first;
		pos[i].second = i;
	}

	sort(pos, pos + n);
	ll res = 0;
	for(int i = n - 1; i >= 0; --i) {
		int y = pos[i].second;
	//	cout << "y: " << y << ", res: " << res << endl;
//            cout << cnt << ", size(): " << s[pos[i].second] << ", y: " << y << endl;
		s.insert(y);
		auto x = s.find(y);
		--x;
		int a = *x;
		--x;
		int aa = *x;
		x = s.find(y);
		++x;
		int b = *x;
		++x;
		int bb = *x;
	//	cout << aa << " " << a << "  " << b << " " << bb << endl;
		if(a >= 0)
			res += (i + 1) * (a - aa) * (b - y);
		if(b <= n - 1)
			res += (i + 1) * (bb - b) * (y - a);

	}
	cout << res << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  for (int i = 0; i < M; ++i) cin >> a[i];
  vector<int> dp(N + 1, 0);
  dp[0] = 1;
  dp[1] = 1;
  for (int i = 0; i < M; ++i) dp[a[i]] = -1;
  for (int i = 2; i < N + 1; ++i) {
    if (dp[i] == -1) continue;
    dp[i] = (max(dp[i - 1], 0) + max(dp[i - 2], 0)) % mod;
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s;

int main(){
	cin>>s;
	int p=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='p'){
			p++;
		}
	}
	cout<<s.size()/2-p<<endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;


public class Main {
	static class State implements Comparable<State>{
		int x;
		int y;
		int cost;
		public State(int a , int b , int c) {
			x = a;
			y = b;
			cost = c;
		}
		@Override
		public int compareTo(State o) {
			return cost - o.cost;
		}
	}

	static int solve(int map[][], int vis[][], int SX , int SY, int EX, int EY){
		State sp = new State(SX, SY, 0);
		vis[SY][SX] = 0;
		PriorityQueue<State> q = new PriorityQueue<State>();
		q.add(sp);
		while(!q.isEmpty()){
			State cp = q.poll();
			if(cp.x == EX && cp.y == EY){
				return vis[cp.y][cp.x];
			}
			for(int dx = -2 ; dx <= 2 ; ++dx){
				int nx = cp.x + dx;
				if(nx < 0 || nx >= vis[0].length){
					continue;
				}
				for(int dy = -2 ; dy <= 2 ; ++dy){
					int ny = cp.y + dy;
					if(ny < 0 || ny >= vis.length){
						continue;
					}
					if(map[ny][nx] == 1){
						continue;
					}
					int D = Math.abs(dx) + Math.abs(dy);
					if(D == 0){
						continue;
					}
					int c = D == 1 ? 0 : 1;
					if(vis[ny][nx] == -1 || cp.cost + c < vis[ny][nx]){
						vis[ny][nx] = cp.cost + c;
						q.add(new State(nx , ny , cp.cost + c));
					}
				}
			}
		}
		return -1;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int SY = sc.nextInt() - 1;
		int SX = sc.nextInt() - 1;
		int EY = sc.nextInt() - 1;
		int EX = sc.nextInt() - 1;
		int vis[][] = new int[H][W];
		int map[][] = new int[H][W];
		for(int i = 0 ; i < H ; ++i){
			Arrays.fill(vis[i], -1);
			String S = sc.next();
			for(int j = 0 ; j < W ; ++j){
				char c = S.charAt(j);
				if(c == '#'){
					map[i][j] = 1;
				}
			}
		}
		System.out.println(solve(map, vis, SX, SY, EX, EY));
	}
}


Measured memory_bytes: 63456
n, k = map(int, input().split())
a = map(int, input().split())
ball_count = {}
for num in a:
    if num in ball_count:
        ball_count[num] += 1
    else:
        ball_count[num] = 1
ball_kinds = len(ball_count.keys())
ball_count_list = sorted(ball_count.values(), reverse=True)
ans = 0
for _ in range(ball_kinds - k):
    ans += ball_count_list.pop()

print(ans)


Measured memory_bytes: 41116
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod) { a %= _mod; b %= _mod; ll res = 1; switch(op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break; } if (res < 0) res += _mod; return res; }


int main()
{
        ll N;
        cin >> N;
        vll A(N);
        vll acc(N+1);
        rep(i, 0, N) cin >> A[i];
        rep(i, 1, N+1) acc[i] = acc[i-1] + A[i-1];


        ll ans = inf;
        rep(i, 0, N-1) {
                ll l = acc[i+1] - acc[0];
                ll r = acc[N] - acc[i+1];

                chmin(ans, abs(l - r));
        }

        cout << ans << endl;
}


Measured memory_bytes: 6404
import math

N,K = map(int,input().split())

prod = 0

if K <= N:
    prod = (N-K+1)/N
    case = K
else:
    case = N+1

for i in range(1,case):
    exp = math.ceil(math.log2(K/i))
    prod  = prod + 1/N * 0.5**exp

print(prod)

Measured memory_bytes: 3060
a, b = map(int, input().split())
# a, bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
# a, bの最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)

print(lcm(a, b))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
  ll n ;
  cin >> n ;
  cout << 180*n - 360 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_tatenaga(void) {
	int h, w;
	char c[110][110];
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> c[i][j];
		}
	}
	int h_pos = 0;
	int w_pos = 0;

	for (int i = 1; i <= h * 2; i++) {
		for (int j = 1; j <= w; j++) {
			h_pos = (i + 1) >> 1;
			w_pos = j;
			cout<<c[h_pos][w_pos];
		}
		cout << endl;
	}



}

int main()
{
	b_tatenaga();
    return 0;
}

Measured memory_bytes: 3556