akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int n, m;
	int p;
	char s[2];

	scanf("%d%d", &n, &m);
	int ac[100000] = { 0 }, wa[100000] = { 0 };
	for (int i = 0; i < m; i++) {
		scanf("%d%s", &p, s);
		if (!strcmp(s, "AC"))
			ac[p]++;
		else if (ac[p] <= 0)
			wa[p]++;
	}

	int correct = 0, failed = 0;
	for (int i = 1; i <= n; i++) {
		if (ac[i] > 0) {
			correct++;
			if (wa[i] > 0)
				failed += wa[i];
		}
	}

	printf("%d %d", correct, failed);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>

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

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;

int add(int a, int b){
	return (a + b) % mod;
}

int mul(int a, int b){
	return ll(a) * b % mod;
}

int pow(int a, int k){
	int p = a;
	int q = 1;
	while(k){
		if(k & 1){
			q = mul(q, p);
		}
		p = mul(p, p);
		k >>= 1;
	}
	return q;
}

int n, m;
int p[5001][5001];

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

	p[0][0] = 1;
	for(int i = 1; i <= n; ++i){
		p[i][0] = add(p[i - 1][1], p[i - 1][0]);
		for(int j = 1; j <= n; ++j){
			p[i][j] = mul(2, p[i - 1][j - 1]);
			if(j < n){
				p[i][j] = add(p[i][j], p[i - 1][j + 1]);
			}
		}
	}

	cout << mul(p[n][m], pow(pow(2, mod - 2), m)) << endl;
	return 0;
}

Measured memory_bytes: 97920
n = input()
#a,b = map(str,raw_input().split())
a = [raw_input() for i in range(n)]
j=0
for i in range(1,14):
  for j in range(n):
    if a[j] == 'S %s' % i:
      break
    elif j==n-1:
      print 'S %s' % i
for i in range(1,14):
  for j in range(n):
    if a[j] == 'H %s' % i:
      break
    elif j==n-1:
      print 'H %s' % i
for i in range(1,14):
  for j in range(n):
    if a[j] == 'C %s' % i:
      break
    elif j==n-1:
      print 'C %s' % i
for i in range(1,14):
  for j in range(n):
    if a[j] == 'D %s' % i:
      break
    elif j==n-1:
      print 'D %s' % i

Measured memory_bytes: 6480
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 12220, M = 240030, inf = 0x3f3f3f3f;
int S,T,head[N],cur[N],nxt[M],cap[M],to[M],edgenum=1; //1.WA£¨ÆäËüµØ·½Ó¦¸Ã¶¼²»ÈÝÒ×Ð´¹Ò£©--edgenum=1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
void addedge(int u, int v, int c){
	to[++edgenum]=v;cap[edgenum]=c;nxt[edgenum]=head[u];head[u]=edgenum;
}
void add(int u, int v, int c){
	addedge(u,v,c);addedge(v,u,0);
}
void init(){
	edgenum=1;rep(i,0,T)head[i]=0;
}
int dis[N],q[N];
inline bool bfs() {
	memset(dis,inf,4*(T+2));//2.memset²»ÓÃsizeof()
	int f=0,r=1; q[f]=T; dis[T]=0;
	while (f!=r) {
		int u=q[f++];
		L(i,u) if (cap[i^1]&&dis[to[i]]==inf){
			q[r++]=to[i];dis[to[i]]=dis[u]+1;if(to[i]==S)return 1;//3.¼ôÖ¦
		}
	}
	return dis[S]<inf;
}
inline int dfs(int u, int flow) {
	if (u==T||!flow)return flow;int res=0;
	for(register int &i=cur[u];i;i=nxt[i])if(cap[i]&&dis[u]==dis[to[i]]+1){//4.µ±Ç°»¡ 
		int tmp=dfs(to[i],min(flow,cap[i]));
		res+=tmp;flow-=tmp;cap[i]-=tmp;cap[i^1]+=tmp;if(!flow)break;
	}
	return res;
}
inline int dinic() {
	int res=0;
	while (bfs()) {
		memcpy(cur,head,4*(T+2)); res+=dfs(S,inf);
	}
	return res;
}
int n,m,a[122][122],b[122][122],rec[122][122];
Vi buc[122][122];
int gettp(int x){return (x-1)/m+1;}
int main() {
	read(n);read(m);
	rep(i,1,n)rep(j,1,m)read(a[i][j]),buc[i][gettp(a[i][j])].pb(a[i][j]);
	rep(j,1,m){
		S=2*n+1;T=S+1;init();
		rep(i,1,n)add(S,i,1),add(n+i,T,1);
		rep(i,1,n)rep(x,1,n)if(SZ(buc[x][i]))
			rec[x][i]=edgenum+1,add(i,n+x,1);
		dinic();
		rep(i,1,n)rep(x,1,n)if(SZ(buc[x][i])&&!cap[rec[x][i]])
			b[x][j]=buc[x][i].back(),buc[x][i].pop_back();
	}
	rep(i,1,n){rep(j,1,m)printf("%d ",b[i][j]);puts("");}
	rep(j,1,m){
		static int s[N];rep(i,1,n)s[i]=b[i][j];
		sort(s+1,s+n+1);
		rep(i,1,n)b[i][j]=s[i];
	}
	rep(i,1,n){rep(j,1,m)printf("%d ",b[i][j]);puts("");}
	
	rep(i,1,n){
		static int s[N];rep(j,1,m)s[j]=b[i][j];
		sort(s+1,s+m+1);
		rep(j,1,m)b[i][j]=s[j];
	}
	rep(i,1,n)rep(j,1,m)assert(b[i][j]==(i-1)*m+j);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define vv(type)		vector<vector<type>>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define db(x) 			cout<<x<<" "
#define db1(x) 			cout<<x<<'\n'
#define db2(x,y) 		cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) 		cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define repA(i,a,n) 	for(int i=a;i<=(n);++i)
#define repD(i,a,n) 	for(int i=a;i>=(n);--i)
#define so(a) 			sort(a.begin(),a.end())
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// to find all local maximaa and minima in O(n)
//	 for (int i=1;i<=n;i++)
//        {
//            if (i==1 || i==n || (p[i-1]<p[i])!=(p[i]<p[i+1]))
//           ans.push_back(p[i]);
//        }
int dx[] = { -1, 1, -1, 0, 0, -1, 1, 1 };
int dy[] = { -1, -1, 1, -1, 1, 0, 0, 1 };
int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}
int modular_expo(int x, int y, int m)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans % m * x % m) % m;
		x = (x % m * x % m) % m;
		y /= 2;
	}
	return ans % m ;
}
int power(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x);
		x *= x;
		y /= 2;
	}
	return ans;
}

void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m, x, y;
	cin >> n >> m;
	std::vector<std::vector<int>> a(n, vector<int>(m)), dp(n, vector<int>(m));
	char ch;
	rep(i, n)
	{
		rep(j, m)
		{
			cin >> ch;
			if (ch == '.')
				a[i][j] = 1;
			else
				a[i][j] = 0;
		}
	}
	rep(i, m)
	if (a[0][i])
		dp[0][i] = 1;
	else break;
	rep(i, n)
	if (a[i][0])
		dp[i][0] = 1;
	else break;
	repA(i, 1, n - 1)
	repA(j, 1, m - 1)
	{
		if (a[i][j])
			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		else
			dp[i][j] = 0;
	}
	db(dp[n - 1][m - 1] % mod);
}

int32_t main()
{
	solve();
	return 0;
}


Measured memory_bytes: 19020
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n; cin >> n;
    ll ans = 1;
    rep1(i, n) {
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

#define LL long long

int power(int a,int b){
	int res=1;
	while(b>0){
		res *=a;
		b--;
	}
	return res;
}

int get(int k,int a){
	int l=0,r=20,res=0;
	while(l<=r){
		int m = (l+r)/2;
		if(power(2,m)*a >= k){
			res = m;
			r=m-1;
		}else{
			l=m+1;
		}
	}
	return res;
}

int main(){
	

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n,k;
	cin>>n>>k;

	double ans=0;

	for(int i=1;i<=n;i++){
		int x = get(k,i);
		//cout<<i<<" "<<x<<endl;
		ans+=(1.0/(1.0 * n * power(2,x)));
	}
	cout<<fixed<<setprecision(12);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)

{
    string s, t;
    int i, a, counter = 0;
    cin>>s>>t;
    a = s.size();
    for(i = 0; i < a; i++){
        if(s[i] != t[i])counter++;
    }
    cout<<counter<<endl;
    return 0;
}


Measured memory_bytes: 3468
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int result = -1;
        if (a > 0 && a < 10 && b > 0 && b < 10) result = a * b;
        System.out.println(result);
        
    }
}


Measured memory_bytes: 35944
n=input()
if len(n)==1:
    print(n)
elif len(n)==2:
    print('9')
elif len(n)==3:
    print(int(n)-90)
elif len(n)==4:
    print('909')
elif len(n)==5:
    print(int(n)-9090)
else:
    print('90909')

Measured memory_bytes: 9056
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		char[][] a = new char[h + 2][w + 2];
		for(int i = 0 ; i < h + 2 ; i++) Arrays.fill(a[i] , '#');
		for(int i = 1 ; i < h + 1 ; i++){
			String s = sc.next();
			for(int j = 1 ; j < w + 1 ; j++){
				a[i][j] = s.charAt(j - 1);
			}
		}
		for(int i = 0 ; i < h + 2 ; i++){
			for(int j = 0 ; j < w + 2 ; j++){
				ou.print(a[i][j]);
			}
			ou.println();
		}
		ou.flush();
	}
}

Measured memory_bytes: 36460
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int n,h,w,h2,w2,t;
	scanf("%d%d%d%d%d",&h,&w,&h2,&w2,&t);
	printf("%d\n",(h2-h)*60+w2-w-t);
}


Measured memory_bytes: 1708
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	rd := bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscan(rd, &n)

	max := 1 - int(10e9)
	min := int(10e9) + 1

	var x int
	// fmt.Println("x\tmin\tmax")
	for i := 0; i < n; i++ {
		fmt.Fscan(rd, &x)
		if max < x-min {
			max = x - min
		}
		if min > x {
			min = x
		}
		// fmt.Printf("%d\t%d\t%d\n", x, min, max)
	}
	fmt.Println(max)
}



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

int main(){
  string s;
  cin >> s;
  if(s=="AAA" || s=="BBB"){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl; 
  }
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
const ll inf = 10000000000;
#define MXN 101
#define MXV 100010
ll dp[MXN][MXV];
int v[MXN], w[MXN];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N; cin>>N;
	ll W; cin>>W;
	for(int i=1; i<=N;i++) cin>>w[i]>>v[i];

	for(int i=0; i<MXV; i++) dp[0][i] = inf;
	dp[0][0] = 0;

	for(int i=1; i<=N; i++)
		for(int j=0; j<MXV; j++)
			if(j<v[i]) dp[i][j] = dp[i-1][j];
			else dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]]+w[i]);
	int ret = 0;
	for(int i=MXV-1; i>=0; i--)
		if(dp[N][i]<=W)
		{
			ret = i; break;
		}
	cout << ret << '\n';

	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool takahashi = false;
  bool aoki = false;
 while(1){
   c -= b;
   if(a <= 0){
     cout << "No" << endl;
     return 0;
   }
   
   a -= d;
   if(c <= 0){
     cout << "Yes" << endl;
     return 0;
   }
 }
}


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

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll A[300001];
int main()
{
    ll n,k;
    cin>>n>>k;

    for(int i=0; i<n; i++)
        cin>>A[i];
    sort(A,A+n);
    ll ans=1,sign=0;
    int l=0,r=n-1;
    if(k%2)
    {
        ans=A[r];
        r--;
        --k;
        if(ans<0)
            sign=1;
    }
    while(k)
    {
        ll x=A[l]*A[l+1],y=A[r]*A[r-1];
        if(sign)
        {
            if(x>=y)
            {
                ans=y%mod*ans%mod;
                r-=2;
            }
            else
            {
                ans=x%mod*ans%mod;
                l+=2;
            }
        }
        else
        {
            if(x<=y)
            {
                ans=y%mod*ans%mod;
                r-=2;
            }
            else
            {
                ans=x%mod*ans%mod;
                l+=2;
            }
        }
        k-=2;
    }
    cout<<(ans+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 5112
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const int MAX_C = 2010;
long long Com[MAX_C][MAX_C] = {0};

int main(){
  int N;
  cin >> N;
  ll ans = 1;
  for(int i=2; i<=N; i++){
   ans *= i;
   ans %= mod;
 }
 cout << ans << endl;}

Measured memory_bytes: 256
i,z=256,t[65536];main(j,k,l,x){for(;i<z;i++)for(j=i;j<z;j++)for(k=j;k<z;k++)for(l=k;l<z;l++)if((x=i*i+j*j+k*k+l*l)<z*z)t[x]++;while(scanf("%d",&x),x)printf("%d\n",t[x]);return 0;}

Measured memory_bytes: 536
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	V b = a;
	sort(all(b));
	int valid = 0;
	rep(i, n) {
		if (a[i] == b[i]) valid++;
	}
	if (valid == n) {
		cout << 0 << endl;
		return 0;
	}
	int q;
	cin >> q;
	rep(qi, q) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		bool prevx = a[x] == b[x];
		bool prevy = a[y] == b[y];
		swap(a[x], a[y]);
		bool nowx = a[x] == b[x];
		bool nowy = a[y] == b[y];
		valid += nowx - prevx;
		valid += nowy - prevy;
		if (valid == n) {
			cout << qi + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 5228
import sys
a = []
for l in sys.stdin:
    a.append(l)


word_num = int(a[0])
word = a[1].split()[0]
char_num = int(a[2])

target_char = word[char_num - 1]

result = []
for each_char in word:
    if each_char != target_char:
        result.append('*')
    else:
        result.append(each_char)
result = ''.join(result)
print(result)


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

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> x(M);
	vector<int> y(M);
	for(int i=0;i<M;i++){
		cin >> x[i] >> y[i];
		x[i]--;
		y[i]--;
	}
	
	vector<int> ball(N,1);
	vector<int> red(N,0);
	red[0]=1;
	
	for(int i=0;i<M;i++){
		ball[x[i]]--;
		ball[y[i]]++;
		if(red[x[i]]==1){
			red[y[i]]=1;
			if(ball[x[i]]==0)red[x[i]]=0;
		}
	}
	int ans=accumulate(red.begin(),red.end(),0);
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

int main(){

    int K;
    int A,B;
    cin>>K>>A>>B;

    bool ans = false;

    for(int i=A; i<=B; i++){
        if(i % K == 0) ans = true;
    }

    cout<<(ans ? "OK" : "NG")<<endl;
      

    return 0;
}

Measured memory_bytes: 3592
from operator import itemgetter
N, M = map(int, input().split())
PY = sorted(((i, tuple(map(int, input().split()))) for i in range(M)), key=itemgetter(1))
L = []
prev, x = 0, 1
for i, (p, _y) in PY:
    if p == prev:
        x += 1
    else:
        prev = p
        x = 1
    L.append((i, "{:06d}{:06d}".format(p, x)))
L.sort()
print(*[l for _, l in L], sep="\n")

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  int a,b;
  cin >> a >> b;
  cout << (a-1)*(b-1) << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std ;
int main(int argc, const char * argv[]) {
    int n,c=0,a,b;
    cin>>n;
    for (int i =0 ; i< n ; i++)
    {
        cin>>a>>b;
        if(a==b)
            c++;
        else
            c=0;
        if(c==3){
             cout<<"Yes"<<endl;
             return 0;
        }
           
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll mod=1e9+7,dp[101][6][6][6];
int n;
ll solve(int i,int p3,int p2,int p1)
{
    if(i==n)
        return 1;
    ll &ret=dp[i][p3][p2][p1];
    if(ret+1)
        return ret;
    ret=0;
    // 1 A , 2 G , 3 C , 4 T
    for(int j=1; j<=4; j++)
    {
        bool ok=1;
        int x[]= {p3,p2,p1,j},y[]= {p3,p2,p1,j};
        for(int k=0; k<3; k++)
        {
            for(int l=0; l<4; l++)
                y[l]=x[l];
            if(y[0]==1&&y[1]==2&&y[2]==3)
                ok=0;
            else if(y[1]==1&&y[2]==2&&y[3]==3)
                ok=0;
            swap(y[k],y[k+1]);
            if(y[0]==1&&y[1]==2&&y[2]==3)
                ok=0;
            else if(y[1]==1&&y[2]==2&&y[3]==3)
                ok=0;
        }
        if(ok)
            ret+=solve(i+1,p2,p1,j)%mod;
        ret%=mod;
    }
    return ret;
}
int main()
{
    go;
    cin>>n;
    memset(dp,-1,sizeof dp);
    cout<<solve(0,0,0,0)%mod;
    return 0;
}


Measured memory_bytes: 384
use std::io;

fn main() {
    let vs: Vec<usize> = parse_values(3);
    let n: usize = vs[0];
    let m: usize = vs[1];
    let q: usize = vs[2];
    let mut q_vecs: Vec<Vec<usize>> = Vec::with_capacity(q);
    for _i in 0..q {
        let vecs: Vec<usize> = parse_values(4);
        q_vecs.push(vecs);
    }
    let mut max_score: usize = 0;
    for i in 1..=m {
        let score = solve(m, n, &mut vec![i], &q_vecs);
        max_score = max_score.max(score);
    }
    println!("{}", max_score);
}

fn solve(m: usize, n: usize, current: &Vec<usize>, q_vecs: &Vec<Vec<usize>>) -> usize {
    if current.len() == n {
        let a = current;
        let mut score: usize = 0;
        for q_vec in q_vecs {
            if a[q_vec[1]-1] - a[q_vec[0]-1] == q_vec[2] {
                score += q_vec[3];
            }
        }
        return score
    }
    let last = *current.last().unwrap();
    let mut max_score = 0;
    for i in 0..=m-last {
        let mut current_increased: Vec<usize> = current.iter().cloned().collect();
        current_increased.push(last+i);
        let score = solve(m, n, &current_increased, q_vecs);
        max_score = max_score.max(score);
    }
    max_score
}


#[allow(dead_code)]
fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn parse_values<T: std::str::FromStr>(n: usize) -> Vec<T> {
    let line = parse_line::<String>();
    let mut split = line.split_whitespace();
    let mut values = Vec::with_capacity(n);
    for _ in 0..n {
        let v = split.next().unwrap().parse::<T>().ok().unwrap();
        values.push(v);
    }
    values
}





Measured memory_bytes: 2132
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	int A, B, C, K;
    scanf("%d %d %d", &A, &B, &C);
    scanf("%d", &K);
    K = pow(2,K);
    if(A >= B && A >= C){
        printf("%d\n", (K*A) + B + C);
    }
    else if(B >= C && B >= A){
        printf("%d\n", (K*B) + A + C);
    }
    else{
        printf("%d\n", (K*C) + B + A);
    }
}
   

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

const int N=1e5+20,C=3;

int n,k,c[C],dp[N][C];
char a[N];
map <char,int> m={{'r',0},{'s',1},{'p',2}};

int main()
{
	scanf("%d%d%d%d%d %s",&n,&k,&c[0],&c[1],&c[2],a+1);

	for(int i=1;i<=k;i++)
	{
		int move=m[a[i]];
		for(int cur=0;cur<C;cur++)
		{
			if(move!=(cur+1)%C) dp[i][cur]=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]});
			else
			{
				for(int pv=0;pv<C;pv++)
					dp[i][cur]=max(dp[i][cur],dp[i-1][pv]+c[cur]);
			}
		}
	}

	for(int i=k+1;i<=n;i++)
	{
		int move=m[a[i]];
		if(a[i-k]=='$' or move!=m[a[i-k]])
		{
			for(int cur=0;cur<C;cur++)
			{
				if(move!=(cur+1)%C) dp[i][cur]=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]});
				else
				{
					for(int pv=0;pv<C;pv++)
						dp[i][cur]=max(dp[i][cur],dp[i-1][pv]+c[cur]);
				}
			}
		}
		else
		{
			for(int cur=0;cur<C;cur++)
				dp[i][cur]=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]});
			a[i]='$';
		}
	}

	printf("%d",max({dp[n][0],dp[n][1],dp[n][2]}));
}

Measured memory_bytes: 1536
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-11-16 08:46:19
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  char X, Y;
  cin >> X >> Y;
  if (X < Y)
  {
    cout << "<" << endl;
  }
  else if (X == Y)
  {
    cout << "=" << endl;
  }
  else
  {
    cout << ">" << endl;
  }
}

Measured memory_bytes: 256
n, a=$<.map{|m|m.split.map(&:to_i)}
if a.select{|s| s<=0 }.count.even?
  puts a.map{|m| m.abs}.inject(&:+)
else
  puts a.map{|m| m.abs}.inject(&:+) - (a.map{|s| s.abs }.min * 2)
end


Measured memory_bytes: 10884
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));
        StringBuilder builder = new StringBuilder();
        String line;
        String[] columns;
        int x, y;
        line = reader.readLine();
        columns = line.split(" ");
        y = Integer.parseInt(columns[0]);
        x = Integer.parseInt(columns[1]);
        int[] total = new int[x+1];

        for (int i = 0; i < y; i++) {
            int sum = 0;
            line = reader.readLine();
            columns = line.split(" ");
            for (int j = 0; j < x; j++) {
                sum += Integer.parseInt(columns[j]);
                builder.append(columns[j])
                        .append(" ");
                total[j] += Integer.parseInt(columns[j]);
            }
            builder.append(sum)
                    .append("\n");
            total[x] += sum;
        }
        for (int i = 0; i < x + 1; i++) {
            if ( i != 0 ) {
                builder.append(" ");
            }
            builder.append(total[i]);
        }
//        builder.append("\n");
//        System.out.print("\n");
        System.out.println(builder);
    }
}

Measured memory_bytes: 27424
#include<bits/stdc++.h>
#define For(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define vi vector<int>
#define vll vector<long long>  
#define vf vector<float>
#define pi (int,int)
#define vpi vector<pair<int,int>>
#define vs vector<string>
#define mp make_pair
#define ll long long
#define vc vector<char>
#define rng(x) x.begin(),x.end()
#define b(x) x.begin()
#define e(x) x.end()
#define F first
#define S second
#define me max_element
#define ne min_element
using namespace std;
int main() 
{
  int i,ctr=0;
  string s,t;
  cin>>s>>t;
  For(i,0,s.length())
  {
    if(s[i]!=t[i])
    {
      ctr++;
    }
  }
  cout<<ctr;
  return 0;
}

Measured memory_bytes: 3856
#094a
A,B,X = map(int, input().split())
    
#猫と犬が合わせて A+B 匹います． このうち A 匹は猫であることがわかっていますが，残りの B匹は猫と犬のどちらであるかわかっていません．
#この A+B匹の中に，猫がちょうど X 匹いるということはありうるかどうか判定してください．

if A > X or X - A > B:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define mp make_pair
#define p(x) cout<< x << " ";
#define pe(x) cout<< x << endl ;
#define int long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROR(i,a,b) for(int i=a;i>=b;i--)
const int N = 1e5 + 5;
#define M 1000000007
int32_t main()
{
    FAST
    int n,cnt=0;
    cin>>n;
    int a[n];
    FOR(i,0,n)
    cin>>a[i];
    for(int i=1;i<n-1;i++)
    {
        if(( a[i]>a[i+1] && a[i]<a[i-1]) || ( a[i]<a[i+1] && a[i]>a[i-1]))
        cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	cout<<s;
	if(s[s.size()-1]=='s')cout<<"es";
	else cout<<'s';
	return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<cstring>
#include<iomanip>
#include<stdio.h>
using namespace std;
const int maxn  = 2e5 + 5;
int a[maxn];
int n;
int main()
{
    cin>>n;
    for(int i = 1;i<=n;i++){
        int x;
        scanf("%d",&x);
        a[x] = i;
    }
    int max_inc = 1;
    int ans = -1;
    for(int i =1;i<n;i++){
        if(a[i] < a[i+1]){
            max_inc++;
        }else{
            ans = max(ans,max_inc);
            max_inc = 1;
        }
    }
    ans = max(ans,max_inc);
    cout<<n-ans<<endl;



    return 0;
}


Measured memory_bytes: 1024
n, a, b = map(int,input().split())
h = [ int(input()) for i in range(n)]
maxim_h =  max(h)

ok = (maxim_h + a - 1) // a * n
ng = 0
while abs(ok - ng) > 1:

    X = (ok + ng) // 2
    #X回爆発を起こす必要があると仮定する

    cnt = 0
    flag = 1
    for val in h:
        if val <= b * X:continue
        temp = (val - b * X + a - b - 1) // (a - b)
        cnt += temp

        if cnt > X:
            flag = 0
            break

    #print(X, cnt, ok)
    if flag:ok = X
    else:ng = X
print(ok)


Measured memory_bytes: 7072
#include<cstdio>
using namespace std;
int main()
{
	long long n,t;
	scanf("%lld%lld",&n,&t);
	if(n-t<=0)
	{
		printf("0\n");
		return 0;
	}
	printf("%lld\n",n-t);
	return 0;
} 

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int N;
vl A;

ll memo[3001][3001];
ll seen[3001][3001];
ll ans(int l,int r){
    if(seen[l][r]){
        return memo[l][r];
    }
    seen[l][r]=true;
    if(l==r){
        return memo[l][r]=A[l];
    }
    return memo[l][r]=max(A[l]-ans(l+1,r),A[r]-ans(l,r-1));
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    A.resize(N);
    rep(i,N){
        cin >> A[i];
    }
    rep(i,3001){
        rep(j,3001){
            seen[i][j]=false;
        }
    }
    cout << ans(0,N-1) << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 120264
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        while(sc.hasNext()){
          list.add(sc.nextInt());
        }
      
        Collections.sort(list);

        String ans = "No";
        if (list.get(2) == list.get(0) + list.get(1)) ans = "Yes";
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    ll x;
    cin >> x;
    ll ans1 = (11 + x -1)/11;
    if(ans1 * 11 - 5 >= x) cout << ans1*2 -1 << endl;
    else cout << ans1*2 << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n,k,ans=0;
  cin>>n>>k;
  rep(i,n){
  int x;
  cin>>x;
  int d1=abs(x),d2=abs(x-k);    
  ans += (d1<d2 ? d1 : d2);
  }
  cout<<ans*2<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#define LOOP 1000000
using namespace std;

int main()
{
	double N, M;
	cin >> N >> M;
	double L = N - M;
	double ans = 0;
	double t = 0;
	double temp = 1;
	while (true)
	{
		t+=1;
		ans += (100.0*L*t + 1900.0*M*t)*temp*pow(1.0/2.0,M);
		temp *= 1 - pow(1.0 / 2.0, M);
		if (t >= LOOP)
		{
			ans = static_cast<int>(ans + 0.5f);
			break;
		}
	}
	cout << int(ans) << endl;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main() {
    int A, B;
    scanf("%d %d", &A, &B);
    int flag = 0;
    int num1, num2;
    int tmp;
    int i;

    for(i = 1; i < 1250; i++) {
        num1 = i * 0.08;
        if(num1 == A) {
            num2 = i * 0.1;
            if(num2 == B) {
                tmp = i;
                flag = 1;
                break;
            }
        }
    }

    if(flag == 1) {
        printf("%d", tmp);
    } else {
        printf("-1");
    }

    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
mcount = 0
for i in range(len(s)-len(t)+1):
    count = 0
    for j in range(len(t)):
        if t[j] == s[i:i+len(t)][j]:
            count += 1
    mcount = max(mcount, count)
print(len(t) - mcount)

Measured memory_bytes: 9116
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;

typedef long int l;

l ary[100005];

int main()
{
    l n,k;
    cin >> n >> k;

    memset(ary, 0, sizeof(ary));
    for(int i=0; i<n; i++){
        int a, b;
        cin >> a >> b;
        ary[a]+=b;
    }

    int cnt;
    for(int i=0; i<100005; i++){
        k-=ary[i];
        if(k<=0){
            cnt=i;
            break;
        }
    }
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n, c, k;
	cin >> n >> c >> k;

	vector<int> t(n);

	for (int i = 0; i < n; i++) {
		cin >> t[i];

	}

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


	int bus = 0;
	int n_guest = 0;
	int t_end = 0;
	for (auto tt : t) {
		if (tt > t_end) {
			bus++;
			t_end = tt + k;
			n_guest = 1;
		} else if (n_guest == c) {
			bus++;
			t_end = tt + k;
			n_guest = 1;
		} else {
			n_guest++;
		}
	}


	cout << bus << endl;
	return 0;
}


Measured memory_bytes: 640
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Control.Monad.Primitive
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Bits
import Data.Int
import Debug.Trace

main = do
  [n,q] <- map read . words <$> getLine :: IO [Int]
  queries <- replicateM q $ map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine :: IO [[Int]]


  let inf = 2147483647

  seg <- newSegmentTree n inf min :: IO (IOUSegmentTree Int)

  forM_ queries $ \[com,x,y] -> do
    when (com == 0) $ do
      modifySegmentTree seg x (const y)
    when (com == 1) $ do
      print =<< findSegmentTree seg x (y+1)



{-- 点更新・範囲取得のセグメント木 --}
type MSegmentTree v s a = (v s a, a, (a -> a -> a)) -- (セグメント木, 単位元, 二項演算)
type STSegmentTree s a = MSegmentTree VM.MVector s a
type IOSegmentTree a = STSegmentTree RealWorld a
type STUSegmentTree s a = MSegmentTree VUM.MVector s a
type IOUSegmentTree a = STUSegmentTree RealWorld a

newSegmentTree :: (Applicative m, PrimMonad m, VGM.MVector v a) => Int -> a -> (a -> a -> a) -> m (MSegmentTree v (PrimState m) a)
newSegmentTree n e f = (,e,f) <$> (VGM.replicate m e)
  where m = 2 * (2 ^ (ceiling $ logBase 2 (fromIntegral n))) - 1

modifySegmentTree :: (Applicative m, PrimMonad m, VGM.MVector v a) => MSegmentTree v (PrimState m) a -> Int -> (a -> a) -> m ()
modifySegmentTree (tree,e,f) i g = do
  VGM.write tree j =<< return . g =<< VGM.read tree j
  aux ((j-1)`div`2)
  where
    n = (VGM.length tree) `div` 2 + 1
    j = i + n - 1
    aux i = do
      when (i >= 0) $ do
        VGM.write tree i =<< f <$> VGM.read tree (i*2+1) <*> VGM.read tree (i*2+2)
        aux ((i-1)`div`2)
        
findSegmentTree :: (Applicative m, PrimMonad m, VGM.MVector v a) => MSegmentTree v (PrimState m) a -> Int -> Int -> m a
findSegmentTree (tree,e,f) x y = do
  aux 0 0 n
  where
    n = (VGM.length tree) `div` 2 + 1
    aux i l r
      | r <= x || y <= l = return e
      | x <= l && r <= y = VGM.read tree i
      | otherwise = f <$> aux (i*2+1) l ((l+r)`div`2) <*> aux (i*2+2) ((l+r)`div`2) r



Measured memory_bytes: 38800
n = gets.to_i
f = Array.new(n+1, 0)

1.upto(100) do |x|
    sx = x * x
    break if sx > n
    1.upto(100) do |y|
        sy = sx + y * y + x * y
        break if sy > n
        1.upto(100) do |z|
            sz = sy + z * z + y * z + z * x
            break if sz > n
            f[sz] += 1
        end
    end
end

puts f[1..-1]

Measured memory_bytes: 14380
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
const int maxN = 107;
 
template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}
 
int n, m;
int a[maxN];
int cnt, c[2];
 
int main() {
 
	n = ri(), m = ri();
 
	if (m == 1) {
		int x = ri();
		if (x != 1) printf("%d\n2\n1 %d\n", x, x - 1);
		else printf("%d\n1\n%d\n", x, x);
		return 0;
	}
 
	rep (i, 1, m) {
		a[i] = ri();
		if (a[i] & 1) {
			if (cnt == 2) {
				puts("Impossible");
				return 0;
			}
			c[cnt++] = i;
		}
	}
 
	if (cnt >= 1) swap(a[1], a[c[0]]);
	if (cnt == 2) swap(a[m], a[c[1]]);
 
	rep (i, 1, m) printf("%d%c", a[i], " \n"[i == m]);
	printf("%d\n", m - (a[1] == 1));
	rep (i, 1, m) {
		if (i == 1) {if (a[i] != 1) printf("%d ", a[i] - 1);}
		else if (i == m) printf("%d\n", a[i] + 1);
		else printf("%d ", a[i]);
	}
 
	return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
  
  int h, w, n;
  cin >> h >> w >> n;
  rep(i, max(h, w) + 1) {
    if(max(h, w) * i >= n) {
      cout << i << endl;
      break;
    }
  }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  if (N > K) {
  	cout << X * K + Y * (N - K) << endl;
  }else {
  	cout << X * N << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    int n, x[1000], i;
    
    while(1){
        scanf("%d\n", &n);
        
        if(n == 0){
            break;
        }
        
        for(i=0; i<n; i++){
            scanf("%d", &x[i]);
        }
        
        double m=0, a=0;
        
        for(i=0; i<n; i++){
            m += x[i];
        }
        
        m = m/n;
        
        for(i=0; i<n; i++){
            a += pow(x[i]-m, 2.0);
        }
        
        a = a/n;
        
        printf("%.8f\n", sqrt(a));
        }
    
    return 0;
}



Measured memory_bytes: 2040
program main
        implicit none
        character(99) :: s
        integer(4) :: i, l, j
        logical :: check = .true.
        read(*,*) s

        l = len(trim(s))
        j = 0
        do i = 1, l/2
          if (s(i:i) /= s((l+1-i):(l+1-i))) check = .false.
        end do
        do i = 1, (l/2)/2
          if (s(i:i) /= s(((l/2)+1-i):((l/2)+1-i))) check = .false.
        end do

        if ( check )  print *, "Yes"
        if ( .not. check ) print *, "No"
end program main


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  
  rep(i,n){
    cin >> A[i];
  }
  
  double ans=0.00;
  rep(i,n){
    ans+=1.00/A[i];
  }
  ans=1.00/ans;
  cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        ArrayList<Integer> A = new ArrayList<Integer>();
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
 
        for(int i=0;i<N;i++){
            A.add(scanner.nextInt());
        }
        printList(A,N);
        insertionSort(A,N);
    }
     
    static void insertionSort(ArrayList<Integer> A,int N){
        for(int i=1;i<N;i++){
            int v = A.get(i);
            int j=i-1;
            while(j>=0 && (v < A.get(j))){
                A.set(j+1,A.get(j));
                j--;
            }
            A.set(j+1, v);
            printList(A,N);
        }
    }
    static void printList(ArrayList<Integer> A,int N){
        StringBuilder builder = new StringBuilder();
        for(int i=0;i<N;i++){
            if(i>0){
                builder.append(" ");
            }
            builder.append(A.get(i));
        }
        System.out.println(builder);
    }
}

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

int main(){
    int N,count=0;
    cin>>N;
    int A[N];

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

    for(int i=1;i<N;i++){
        for(int j=1;j<N;j++){
            if(A[j]<A[j-1]){
                int k=A[j];
                A[j]=A[j-1];
                A[j-1]=k;
                count+=1;
            }
        }
    }
    for(int i=0;i<N;i++){
        if(i!=N-1){
            cout<<A[i]<<" ";
        }else{
            cout<<A[i]<<endl;
        }
    }
    cout<<count<<endl;
}


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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
  int x;
  cin >> x;
  int p, q;
  p = x/100;
  q = x%100;
  if(5*p>=q)cout << 1 << endl;
  else cout << 0 << endl;
}

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

int main()
{
	int a, b, c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c); 
	if (a+b==c)
	{
		printf("Yes\n");
	}
	else 
	{
		if (b+c==a)
		{
			printf("Yes\n");
		}
		else 
		{
			if (c+a==b)
			{
				printf("Yes\n");
			}
			else 
			{ 
				printf("No\n");
			}
		}
	}
	system("pause");
	return 0;
}


Measured memory_bytes: 504
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)cin >> a[i];
	int q;
	cin >> q;
	int ans = 0;
	for(int i = 0; i < q; i++){
		int t;
		cin >> t;
		bool ok = false;
		for(int j = 0; j < n; j++){
			if(a[j] == t){
				ok = true;
				break;
			}
		}
		if(ok)ans++;
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const ll mod = 1e9+7;

ll memo[1001][1001];

ll counta(int reach[][1001],int i,int j){
	if(i<0 || j<0) return 0;
	if(i==0 && j==0) return memo[i][j] = 1;
	if(!reach[i][j]) return memo[i][j] = 0;
	ll res=0;
	if(memo[i][j]!= -1) return memo[i][j]%mod;
	res+= (counta(reach,i-1,j)%mod+counta(reach,i,j-1)%mod)%mod;
	return memo[i][j] = res%mod;
}

main(){
	int h,w;cin>>h>>w;
	char a[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++) cin>>a[i][j];
	}
	int reachable[h][1001];
	memset(reachable,0,sizeof(reachable));
	memset(memo,-1,sizeof(memo));
	reachable[0][0]=1;reachable[h-1][w-1]=1;
	for(int j=1;j<w;j++) {
		if(a[0][j] == '#') reachable[0][j]=0;
		else reachable[0][j] = reachable[0][j-1];
	}
	for(int j=1;j<h;j++) {
		if(a[j][0] == '#') reachable[j][0]=0;
		else reachable[j][0] = reachable[j-1][0];
	}
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(a[i][j] == '#') reachable[i][j] = 0;	
			else reachable[i][j] = (reachable[i-1][j] | reachable[i][j-1]);
		}
	}
	ll ans=0;
	ans = counta(reachable,h-1,w-1);
	cout<<ans;
}

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

int main() {

  long long int n;
  cin >> n;

  vector< long long int > c;
  for ( long long int i = 1; i <= 2 * n; i++ ) {
    c.push_back( i );
  }

  long long int m;
  cin >> m;

  for ( long long int i = 0; i < m; i++ ) {

    long long int k;
    cin >> k;

    vector< long long int > v;
    if ( k == 0 ) {
      for ( long long int i = 0; i < n; i++ ) {
	v.push_back( c[i] );
	v.push_back( c[i+n] );
      }
    }else {
      for ( long long int i = k; i < 2 * n; i++ ) {
	v.push_back( c[i] );
      }
      for ( long long int i = 0; i < k; i++ ) {
	v.push_back( c[i] );
      }
    }
    swap( c, v );

  }

  for ( long long int i = 0; i < 2 * n; i++ ) {
    cout << c[i] << endl;
  }

  return 0;

}

Measured memory_bytes: 1216
import java.awt.geom.Point2D;
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new AOJ0118().doIt();
	}
	
	class AOJ0118{
		int w,h;
		char[][] map;
		boolean sw[][];
		int sx[],sy[];
		void dfs(int x,int y,char f){
			LinkedList<Point2D> q = new LinkedList<Point2D>();
			q.add(new Point2D.Double(x,y));
			while(q.size()>0){
				Point2D p = q.remove();
				for(int i=0;i<4;i++){
					int nx = (int)p.getX()+sx[i];
					int ny = (int)p.getY()+sy[i];
					if(nx<0||nx>=w||ny<0||ny>=h)continue;
					if(sw[ny][nx]||map[ny][nx]!=f)continue;
					sw[ny][nx]=true;
					q.add(new Point2D.Double(nx,ny));
				}
			}
		}
		
		int solve(){
			int result = 0;
			for(int i=0;i<h;i++)for(int s=0;s<w;s++)if(!sw[i][s]){
				result++;
				sw[i][s] = true;
				dfs(s,i,map[i][s]);
			}
			return result;
		}
		
		void doIt(){
			sx = new int[4];
			sy = new int[4];
			sx[0]=1;sx[1]=0;sx[2]=-1;sx[3]=0;
			sy[0]=0;sy[1]=1;sy[2]=0;sy[3]=-1;
			while(true){
				h = in.nextInt();
				w = in.nextInt();
				if(h==0&&w==0)break;
				map = new char[h][w];
				sw = new boolean[h][w];
				for(int i=0;i<h;i++)map[i] = in.next().toCharArray();
				System.out.println(solve());
			}
		}
	}
	
}

Measured memory_bytes: 24844
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int n,m;
    cin >> n >> m;
    int prohi=1;
    for(int i=0; i<m; i++)prohi*=2;
    cout << (1900*m+100*(n-m))*prohi << endl;
    return 0;
}

Measured memory_bytes: 256
public class Main {
	public static void main (String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int n = scan.nextInt();
		int[] arr = new int[n];

		for(int i = 0;i < n; i++){
			arr[i] = scan.nextInt();
		}
		for(int j = (n-1);j >= 0;j--){
			System.out.print(arr[j]);
			if(j == 0){
				break;
			}
			System.out.print(" ");
		}
		System.out.println();
	}

}

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

list_A = list(map(int, input().split()))
list_B = list(map(int, input().split()))

score = 0
for i in range(len(list_B)):
    #全滅
    if list_A[i] < list_B[i]:
        score = score + list_A[i]

        #次の街
        #次の街も全滅
        if list_A[i+1] < list_B[i]-list_A[i]:
            score = score + list_A[i+1]
            list_A[i+1] = 0
        #次の街を全滅させられない場合
        else:
            score = score + list_B[i]-list_A[i]
            list_A[i+1] = list_A[i+1] - (list_B[i]-list_A[i])

    else:
        score = score + list_B[i]

print(score)

Measured memory_bytes: 18624