akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        // なんか入力用の関数作ったけどまだテストしてないので使う前に確かめて
        static void Main(){
            long[] nm = ILongs();
            long n = nm[0];
            long m = nm[1];

            long[][] uv = ILongLongs(m);
            long[] st = ILongs();
            long s = st[0];
            long t = st[1];

            List<long>[] ikisaki = new List<long>[3*n];
            for(int i=0;i<3*n;i++){
                ikisaki[i] = new List<long>();
            }
            bool[] moumita = new bool[3*n];

            for(int i=0;i<m;i++){
                ikisaki[uv[i][0]-1].Add(uv[i][1]+n-1);
                ikisaki[uv[i][0]+n-1].Add(uv[i][1]+n+n-1);
                ikisaki[uv[i][0]+n+n-1].Add(uv[i][1]-1);
            }
            

            Queue<long[]> q = new Queue<long[]>();

            q.Enqueue(new long[2]{s-1,0});
            moumita[s-1] = true;

            while(q.Count>0){
                long[] ima = q.Dequeue();
                foreach(long saki in ikisaki[ima[0]]){
                    if(saki==t-1){
                        Console.WriteLine((ima[1]+1)/3);
                        return;
                    }else if(!moumita[saki]){
                        q.Enqueue(new long[2]{saki,ima[1]+1});
                        moumita[saki] = true;
                    }
                }
            }
            Console.WriteLine(-1);
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = Console.ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return Console.ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return Console.ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = Console.ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = Console.ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 61456
#include <iostream>
#include <sstream>
 
using namespace std;
 
int main(int argc, char *argv[]) {
	int h, w;
	cin >> h >> w;
	cout << string(w + 2, '#') << endl;
	for (int i = 0; i < h; ++i) {
		string s;
		cin >> s;
		cout << "#" << s << "#" << endl;
	}
	cout << string(w + 2, '#') << endl;
	return 0;
}

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

#define int long long 
signed main(){
    int n;cin >> n;
    vector<int> a(n);
    for(auto &i:a) cin >> i;
    for(int i=0;i<n;i++){
        int p = (i-1)/2;
        int l = 2*i+1;
        int r = 2*i+2;
        cout << "node " << i+1 << ": key = " << a[i] << ", ";
        if(i) cout << "parent key = " << a[p] << ", ";
        if(l<n) cout << "left key = " << a[l] << ", ";
        if(r<n) cout << "right key = " << a[r] << ", ";
        cout << endl;
    }
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <limits.h>
using namespace std;

int main()
{
	int K, A, B;
	cin >> K >> A >> B;
	for (int i = A; i <= B; i++)
	{
		if (i%K == 0)
		{
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
}

Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>
using namespace std;
const long long NR=210000;
long long n,he,s[NR];
struct Node
{
	long long a,m,b;
} a[NR];
bool cmp(Node a,Node b)
{
	return a.a<b.a;
}
bool cmq(Node a,Node b)
{
	return a.b<b.b;
}
int main()
{
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i].a);
		a[i].b=i;
	}
	sort(a+1,a+n+1,cmp);
	for(long long i=1;i<=n;i++)
	{
		if(a[i].a!=a[i-1].a)
		{
			a[i].m=i;
		}
		else
		{
			a[i].m=a[i-1].m;
		}
	}
	for(long long i=1;i<=n;i++)
	{
		s[a[i].m]++;
	}
	for(long long i=1;i<=n;i++)
	{
		he+=(s[i]*(s[i]-1))>>1;
	}
	sort(a+1,a+n+1,cmq);
	for(long long i=1;i<=n;i++)
	{
		printf("%lld\n",he-(s[a[i].m]-1)); 
	} 
	return 0;
}

Measured memory_bytes: 8704
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int main(){
    string str;
    cin >> str;
    int A[4];
    for(int i=0;i<4;i++){
        A[i] = str[i] - '0';
    }
    char p1,p2,p3;
    for(int bit = 0;bit<(1<<3);bit++){
        int ans = A[0];
        if(bit & 1){
            ans += A[1];
            p1 = '+';
        }
        else{
            ans -= A[1];
            p1 = '-';
        }
        if(bit & 2){
            ans += A[2];
            p2 = '+';
        }
        else{
            ans -= A[2];
            p2 = '-';
        }
        if(bit & 4){
            ans += A[3];
            p3 = '+';
        }
        else{
            ans -= A[3];
            p3 = '-';
        }
        if(ans == 7){
            cout << str[0] << p1 << str[1] << p2 << str[2] << p3 << str[3] << "=7" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
 int a, b, mennseki, nagasa;
 cin >> a >> b;

 if( 1 <= a && b <= 100 ){
  mennseki = a*b;
  nagasa = a+a+b+b;
  cout << mennseki << " " << nagasa << endl;
 }

 return 0;
}

Measured memory_bytes: 3016
#include "bits/stdc++.h"
#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, a, b) for(int i=(b)-1; i>=(a); --i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const LL MOD=1000000007ll;
const LL INF=2000000000ll;

long power(long a,long b){return b?power(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;}
long comb(int N,int K)
{
	long x=1,y=1;
	for(int i=1;i<=K;i++)
	{
		x=x*(N-i+1)%MOD;
		y=y*i%MOD;
	}
	return x*power(y,MOD-2)%MOD;
}

long hcomb(int N, int K){
    return comb(N+K-1, N-1);
}

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

    int N;
    cin >> N;
    VI A(N),B(N),C(N);
    REP(i,N) cin >> A[i];
    sort(ALL(A));
    REP(i,N) cin >> B[i];
    sort(ALL(B));
    REP(i,N) cin >> C[i];
    sort(ALL(C));

    LL ans = 0;
    REP(i,N){
        ans += (lower_bound(ALL(A),B[i])-A.begin()) * (C.end()-upper_bound(ALL(C),B[i]));
    }

    cout << ans << endl;
}

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

int main() {
	string s;
	cin >> s;
	bool E = false;
	bool N = false;
	bool S = false;
	bool W = false;
	for(int i = 0;i < s.size();i++){
		if(s.at(i) == 'E'){
			E = true;
			continue;
		}
		if(s.at(i) == 'N'){
			N = true;
			continue;
		}
		if(s.at(i) == 'S'){
			S = true;
			continue;
		}
		if(s.at(i) == 'W'){
			W = true;
			continue;
		}
	}
	if(E||W){
		if(E&&W){}
		else{
			cout << "No" << endl;
			return 0;
			}
		}
	if(S||N){
		if(S&&N){}
		else{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

#define ll long long
#define sz(x) (int)x.size();

using namespace std;

int main(){
	int x;
	cin>>x;
	if(360%x==0){
		cout<<360/x;
	}
	else{
		ll j=360;
		int cnt=0;
		while(j%x!=0){
			cnt++;
			j+=360;
		}
		cout<<(j/x);
	}
}

Measured memory_bytes: 3600
n,k=map(int,input().split())
p=list(map(int,input().split()))

lst=[0]
sum=0
for i in range(n):
    sum+=p[i]
    lst.append(sum)
    
ans=[]
for i in range(n-k+1):
    ans.append(lst[i+k]-lst[i])

print((max(ans)+k)/2)


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

typedef long long ll;

int main() {
    int N, P, minP = 1e9, ans = 0;
    cin >> N;
    rep(i, N) {
        cin >> P;
        if (P < minP) ans++;
        minP = min(minP, P);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = gets.to_i
As = gets.split.map(&:to_i)

bs, cs = As.each_slice(2).each_with_object([[], []]){|(a1, a2), (bs, cs)| bs << a1; cs << a2}.map(&:compact)
bs, cs = cs, bs if N.even?
puts (bs.reverse + cs).join(' ')

Measured memory_bytes: 29572
#include <bits/stdc++.h>
using namespace std;
typedef signed long long lint;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  for (int x=1; x<=50000; ++x) {
    if (x*108/100 == n) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,a=0,b=0,c=0,i,m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&m);
    if     (m%4==0)c++;
    else if(m%2==0)b++;
    else           a++;
  }
  if(c==0&&a==0){
    printf("%s\n",b-1?"Yes":"No");
    return 0;
  }
  a+=b?1:0;
  printf("%s\n",c+1>=a?"Yes":"No");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repbtw(i, a, b) for (int i = a; i <= (int)(b); i++)
#define all(v) v.begin(), v.end()
#define pr(x) cout << x << endl


int main()
{
    int r;
    cin >> r;
    pr(2*r*3.1415926535);

    return 0;
}



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

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

    string s[n];
    for (int i = 0; i < n; i++)
    {
        cin>>s[i];
    }
    int a=0,ans=0;
    for(int i=0;i<n;i++){
        if(s[i]=="A"){
            a++;
        }
        else {
            if(a){
                ans++;
                a--;
            }
        }
    }
    if(n%2==0 && n/2==ans){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    
    return 0;
    

}



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

scores = list(map(int, input().split()))

colors = [0] * 8
over = 0

for score in scores:
    if score < 3200:
        colors[score // 400] += 1
    else:
        over += 1

ans = sum(color > 0 for color in colors)

if ans:
    print(ans, ans + over)
else:
    print(1, over)


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c)
        cout<<"No"<<endl;
    else if(a!=b && b!=c && a!=c)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 10000000000000000
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<int,pii> pdii;
long long int MOD = 1000000007;
struct UnionFind {
	vector<int> data;
	void init(int n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if(x != y) {
			if(data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
};
UnionFind uf;
int main(){
	
	int n,m,k;
	vi data[114514];
	scanf("%d %d",&n,&m);
	uf.init(n);
	for(int i=0;i<n;i++){
		scanf("%d",&k);
		int l;
		for(int j=0;j<k;j++){
			scanf("%d",&l);l--;
			data[l].pb(i);
		}
	}
	
	for(int i=0;i<m;i++){
		if(data[i].size()!=0){
			int a=data[i][0];
			for(int j=1;j<data[i].size();j++){
				int x=data[i][j];
				uf.unionSet(a,x);
			}
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(uf.root(i)==i)cnt++;
	}
	if(cnt==1)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            var a = IO.RSInt;

            var cnt = 0;
            for (int i = 0; i < n; i++)
            {
                while (a[i] % 2 == 0)
                {
                    a[i] /= 2;
                    cnt++;
                }
            }
            WriteLine(cnt);
        }

        public class IO
        {
            #region Input
            public static int RInt => int.Parse(ReadLine());
            public static long RLong => long.Parse(ReadLine());
            public static double RDouble => double.Parse(ReadLine());

            public static string[] RSString => ReadLine().Split();
            public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
            public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
            public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static int GCD(int x, int y)
        {
            if (x < y) Swap(ref x, ref y);
            if (y == 0) return x;
            else return GCD(x % y, y);
        }

        public static void Swap(ref int x, ref int y)
        {
            int tmp = x;
            x = y;
            y = tmp;
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

Measured memory_bytes: 14176
s = input()

pre2 = s[0]
pre1 = s[1]
if pre2 == pre1:
    if len(s) == 2:
        print(1, 2)
    else:
        print(1, 3)
    exit()
for i in range(2, len(s)):
    if pre2 == s[i] or pre1 == s[i]:
        print(i-1, i+1)
        exit()
    pre2 = pre1
    pre1 = s[i]

print(-1, -1)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long

using namespace std;

signed main(){
    int n, k, sum=0;
    cin >> n >> k;
    for(int i=k;i<=n;i++){
        sum += i*n-i*(i-1)+1;
    }
    cout << 1+sum%1000000007 << endl;
    return 0;
}

Measured memory_bytes: 3624
import itertools
import bisect

N = int(input())
S = input()
R_set = set()
G_set = set()
B_set = set()
R = []
G = []
B = []
R_ids = [0] * N
G_ids = [0] * N
B_ids = [0] * N

for i, s in enumerate(S):
    if s == 'R':
        R_set.add(i)
        R.append(i)
        R_ids[i] = 1
    elif s == 'G':
        G_set.add(i)
        G.append(i)
        G_ids[i] = 1
    else:
        B_set.add(i)
        B.append(i)
        B_ids[i] = 1


R_ids = list(itertools.accumulate(reversed(R_ids)))[::-1]
G_ids = list(itertools.accumulate(reversed(G_ids)))[::-1]
B_ids = list(itertools.accumulate(reversed(B_ids)))[::-1]

ans = 0
for r_idx in R:
    start = bisect.bisect_left(G, r_idx)
    for g_idx in G[start:]:
        diff = g_idx - r_idx
        num = B_ids[g_idx]
        if g_idx+diff in B_set:
            num -= 1
        ans += num
    
    start = bisect.bisect_left(B, r_idx)
    for b_idx in B[start:]:
        diff = b_idx - r_idx
        num = G_ids[b_idx]
        if b_idx+diff in G_set:
            num -= 1
        ans += num

for g_idx in G:
    start = bisect.bisect_left(R, g_idx)
    for r_idx in R[start:]:
        diff = r_idx - g_idx
        num = B_ids[r_idx]
        if r_idx+diff in B_set:
            num -= 1
        ans += num
    
    start = bisect.bisect_left(B, g_idx)
    for b_idx in B[start:]:
        diff = b_idx - g_idx
        num = R_ids[b_idx]
        if b_idx+diff in R_set:
            num -= 1
        ans += num

for b_idx in B:
    start = bisect.bisect_left(G, b_idx)
    for g_idx in G[start:]:
        diff = g_idx - b_idx
        num = R_ids[g_idx]
        if g_idx+diff in R_set:
            num -= 1
        ans += num
    
    start = bisect.bisect_left(R, b_idx)
    for r_idx in R[start:]:
        diff = r_idx - b_idx
        num = G_ids[r_idx]
        if r_idx+diff in G_set:
            num -= 1
        ans += num


print(ans)

Measured memory_bytes: 70344
import scala.io.StdIn

object Main {
  def main(args: Array[String]){
    val input = StdIn.readLine().split(" ").map(_.toInt)
    val (a,b,c) = (input(0), input(1), input(2))
    println(if(a<b&&b<c)"Yes" else"No")
  }
}


Measured memory_bytes: 43828
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const ll mo = 23333333333333333;

ll mul(ll x, ll y) {
	x %= mo, y %= mo;
	ll z = (long double) x * y / mo;
	z = x * y - z * mo;
	if(z < 0) z += mo; else if(z >= mo) z -= mo;
	return z;
}

ll ksm(ll x, ll y) {
	ll s = 1;
	for(; y; y /= 2, x = mul(x, x))
		if(y & 1) s = mul(s, x);
	return s;
}

const ll w = 1e9 + 7;

const int N = 250005;

ll aw[N * 2], v[N * 2];
int n; char s[N];

map<ll, int> cnt;

ll ans;

int main() {
	scanf("%d", &n);
	scanf("%s", s + 1);
	aw[0] = 1; fo(i, 1, n * 2) aw[i] = mul(aw[i - 1], w);
	v[0] = ksm(ksm(w, mo - 2), n); fo(i, 1, n * 2) v[i] = mul(v[i - 1], w);
	ll p = n, sum = 0;
	fo(i, 1, n) {
		if(s[i] == '<') {
			p --;
		}
		if(s[i] == '>') {
			p ++;
		}
		if(s[i] == '+') {
			sum = (sum + aw[p]) % mo;
		}
		if(s[i] == '-') {
			sum = (sum - aw[p] + mo) % mo;
		}
	}
	ll eds = sum;
	p = n, sum = 0;
	cnt[(mul(eds, v[p]) + sum) % mo] ++;
	fo(i, 1, n) {
		if(s[i] == '<') {
			p --;
		}
		if(s[i] == '>') {
			p ++;
		}
		if(s[i] == '+') {
			sum = (sum + aw[p]) % mo;
		}
		if(s[i] == '-') {
			sum = (sum - aw[p] + mo) % mo;
		}
		ans += cnt[sum];
		cnt[(mul(eds, v[p]) + sum) % mo] ++;
	}
	pp("%lld\n", ans);

}

Measured memory_bytes: 39552
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();

    if (a+w <= b) {
      System.out.println(b-(a+w));
    } else if (a+w > b && a <= b) {
      System.out.println(0);
    } else if (b+w <= a) {
      System.out.println(a-(b+w));
    }

  }

}


Measured memory_bytes: 21076
#include <stdio.h>

int main(void){
	int i, j;
	int H, W;
	while(1){
		scanf("%d %d", &H, &W);
		if(H==0 && W==0) break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if(i==0 || j==0 || i==H-1 || j==W-1) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2532
#include <iostream>

int main(void) {
  int a, b, c, x, y;
  int cost=0, tmp;
  double ha, hb;
  std::cin >> a >> b >> c >> x >> y;
  ha = (double) a / (double) 2;
  hb = (double) b / (double) 2;
  if (ha + hb > c) {
    if (x > y) {
      tmp = y;
      x = x - y;
      y = 0;
    } else {
      tmp = x;
      y = y - x;
      x = 0;
    }

    cost = 2 * tmp * c;
    if (x*a+y*b < c * 2 * (x+y)) {
      cost += a * x + b * y;
    } else {
      cost += 2 * c * (x+y);
    }

  } else {
    cost = (x*a) + (y*b);
  }
  std::cout << cost << std::endl;
  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 a = sc.nextInt();
		int b = sc.nextInt();
	
		for(int i = 1 ; i < 13 ; i++) {
			if(a == i) {
				if(b >= i) {
					System.out.println(i);
					break;
				}else {
					System.out.println(i-1);
					break;
				}
			}
		}
	}
}

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

using namespace std;

int main()
{
   int n;cin>>n;
   long long int arr[n];
   
   for(int i=0;i<n;i++)
   {cin>>arr[i];}
   
   
   
   
   int ans=0;
   
   
   for(int i=0;i<n;i++)
   {
       for(int j=i+1;j<n;j++)
       {
           for(int k=j+1;k<n;k++)
           {
               if(arr[i]+arr[j]>arr[k] && arr[j]+arr[k]>arr[i] && arr[k]+arr[i]>arr[j] && arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k])
               ans++;
           }
       }
   }
   
   cout<<ans;
   
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int mod = 100007;
const double eps = 1e-8;
const ll inf = 1e18+9;
int a[maxn];
int road[maxn];
int vis[maxn];

int main(){
	memset(vis,0,sizeof(vis));
	int n;
	ll k;
	scanf("%d %lld",&n,&k);
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
	}
	int cnt = 1;
	int t = 1;
	vis[1] = 1;
	road[cnt++] = 1;
	int en = 0;
	while(1){
		int x = a[t];
		if(vis[x]){
			en = x;
			break;
		}else{
			vis[x] = 1;
			road[cnt++] = x;
			t = x;
		}
	}
//	for(int i = 1;i < cnt;i++){
//		printf("%d ",road[i]);
//	}
//	cout << endl;
	ll y = 0;
	for(ll i = 1;i < cnt;i++){
		if(road[i] == en){
			y = i;
			break;
		}
	}
	ll s = cnt - y;
	if(k <= y){
		printf("%d",a[road[k]]);
	}
	else{
		k -= y;
		k %= s;
		printf("%d",a[road[y+k]]);
	}
	return 0;
}

Measured memory_bytes: 6044
#include <stdio.h>

int main(){

  int a,b,c;

  scanf("%d%d%d",&a,&b,&c);

  if(a==b&&b!=c || a!=b&&b==c || a==c&&a!=b){
    printf("Yes");
    return 0;
  } else  printf("No");

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()) {
            int n = scan.nextInt();
            int a = 0;
            int b = a;
            int c = a;
            int d = a;
            int x = 0;

            while (d <= 9) {
                while (c <= 9) {
                    while (b <= 9) {
                        while (a <= 9) {
                            if (a + b + c + d == n) {
                                x++;
                            }
                            a++;
                        }
                        b++;
                        a = 0;
                    }
                    b = 0;
                    c++;
                }
                c = 0;
                d++;
            }
            System.out.println(x);

        }

    }
}



Measured memory_bytes: 26796
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

op = ["+","-"]

for i in op:
    for j in op:
        for k in op:
            if eval("A {} B {} C {} D".format(i, j, k)) == 7:
                print("{}{}{}{}{}{}{}=7".format(A, i, B, j, C, k, D))
                exit()




Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const int INF = INT_MAX;
const ll MOD = 1000000007;

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int N;
    cin >> N;
    string S[2];
    repeat(i, 2){
        cin >> S[i];
    }
    ll ans = 1;
    bool  prev_isone=0;
    repeat(i, N){
        bool cur_isone= S[0][i]==S[1][i];
        if(i==0){
            if(cur_isone) ans = 3;
            else ans = 6;
        }else if(prev_isone){
            ans = ans * 2 %MOD;
        }else{
            if(!cur_isone) ans = ans * 3 % MOD;
        }
        if(!cur_isone) i++;
        prev_isone = cur_isone;
    }
    cout << ans << endl;
    return 0;
}



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

#ifdef HOME
#define db(x) cerr << #x << " = " << x << endl
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define dbv(a) cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

using namespace std;
typedef long long ll;
typedef double dbl;

/*
const ll SZ = 2e9;
char buf[SZ];
ll csz;
void *operator new(size_t sz) {
    assert(csz + sz < SZ);
    void *res = buf + csz;
    csz += sz;
    return res;
}
void operator delete(void*) {}
void operator delete(void*, size_t) {}*/

const int MOD = (int)1e9 + 7;
void add(int &x, ll y) {
    x = (x + y) % MOD;
}
int mul(int x, int y) {
    return 1LL * x * y % MOD;
}


int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    int n, m;
    string a, b;
    while (cin >> n >> m) {
        cin >> a >> b;
        int g = __gcd(n, m);
        vector<pair<int, int>> v1, v2;
        for (int i = 0; i < n; i++) v1.push_back({i * (m / g), i});
        for (int i = 0; i < m; i++) v2.push_back({i * (n / g), i});

        bool ok = 1;
        for (int i = 0; i < n; i++) {
            int id = lower_bound(v2.begin(), v2.end(), make_pair(v1[i].first, -1)) - v2.begin();
            if (id < (int)v2.size() && v2[id].first == v1[i].first) {
                ok &= a[v1[i].second] == b[v2[id].second];
            }
        }
        ll res = 1LL * n / g * m;
        if (!ok) res =- 1;
        cout << res << endl;
    }

#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}


Measured memory_bytes: 2744
#include <stdio.h>

int main(void)
{
	int a = 0, b = 0;
	
	scanf("%d %d", &a,&b);
	
	if (a < b) {
		printf("a < b");
	} else if (a > b) {
		printf("a > b");
	} else {
		printf("a == b");
		
	}
	
	printf("\n");
		
	return 0;
}



Measured memory_bytes: 2100
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

n=int(input())
A=list(map(int,input().split()))

def main(c,temp):

    if temp>0:
        flag=1
    elif temp<0:
        flag=0
    for i in range(1,n):
        temp+=A[i]
        if flag:
            if temp>=0:
                c+=temp-(-1)
                temp=-1
            flag=0
        else:
            if temp<=0:
                c+=1-temp
                temp=1
            flag=1
    return(c)

temp=A[0]
if temp:
    a=main(0,temp)
    if temp>0:
        b=main(temp - (-1),-1)
    else:
        b=main(1-temp,1)
    print(min(a,b))
else:
    temp=1
    a=main(1,temp)
    temp=-1
    b=main(1,temp)
    print(min(a,b))


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

int main() {
  int K,A,B;
  cin >> K >> A >> B;
  for(int i=A; i<=B; i++){
    if(i%K == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3604
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val list = List.fill(n)(sc.nextInt)

  val range = 1 to n
  val ans = if ((range zip list).count(a => a._1 != a._2) == 2 || range.toList == list) YES else NO

  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 25920
import scala.io.StdIn.{readLine,readInt}

object Main {
  def getDigit(x:Int) = if (x>=10) (x-10,1) else (x,0)


  def getSum(s:String,t:String):String = {
    if(s.length > 80 || t.length > 80) "overflow"
    else {
      val (x,y) = if(s.length>t.length) (s,t) else (t,s)
      val f = (i:Int,j:Int) => if(j<0) x(i).asDigit else x(i).asDigit + y(j).asDigit
      def loop(i:Int,j:Int,sum:List[Int],carry:Int):List[Int] =  {
        if(i<0) { if(carry > 0) carry::sum else sum }
        else {
          val (d,c) = getDigit(f(i,j)+carry)
          loop(i-1, j-1, d::sum, c)
        }
      }
      val r = loop(x.length-1,y.length-1,Nil,0).mkString
      if(r.length > 80) "overflow" else r
    }
  }

  def main(args:Array[String]) = for(i<-1 to readInt) println(getSum(readLine,readLine))
}

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

typedef long long ll;

int main()
{
    int A[33] = {1,
                 1,
                 1,
                 2,
                 1,
                 2,
                 1,
                 5,
                 2,
                 2,
                 1,
                 5,
                 1,
                 2,
                 1,
                 14,
                 1,
                 5,
                 1,
                 5,
                 2,
                 2,
                 1,
                 15,
                 2,
                 2,
                 5,
                 4,
                 1,
                 4,
                 1,
                 51};
    int k;
    cin >> k;
    cout << A[k - 1] << endl;
}



Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int d, s;
    int i;

    for(;sc.hasNext();){
      d = sc.nextInt();
      s = 0;
      for(i = d;i < 600;i+=d)s += d * i * i;
      System.out.println(s);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17184
# Tsundoku
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if M > N:
    N,M = M,N
    A,B = B,A
a = [0]
b = [0]
for _ in range(max(N, M)):
    if _ < min(N,M):
        a.append(a[_] + A[_])
        b.append(b[_] + B[_])
    else:
        a.append(a[_] + A[_])
ans = 0
j = M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47612
h,w = map(int, input().split())
a = [input() for _ in range(h)]

r = [False] * h
c = [False] * w

for i in range(h):
  for j in range(w):
    if a[i][j] == "#":
      r[i] = True
      c[j] = True

for i in range(h):
  if r[i]:
    for j in range(w):
      if c[j]:
        print(a[i][j], end="")
    print()

Measured memory_bytes: 4468
fun main(args: Array<String>) {
    agc017a()
}

fun agc017a() {
    val (n, p) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toInt() % 2 == 0 }

    val (evens, odds) = aList.partition { it }.let { Pair(it.first.size, it.second.size) }

    if (n == evens) return println(if (p == 0) Math.pow(2.0, n.toDouble()).toLong() else 0)

    val answer = if (odds == 0) {
        Math.pow(2.0, n.toDouble()).toLong()
    } else {
        Math.pow(2.0, (n - 1).toDouble()).toLong()
    }

    println(answer)
}


Measured memory_bytes: 38316
import Control.Monad
import Data.List

main=do
    n<-readLn::IO Int
    as<-map read.words<$>getLine::IO [Int]
    print.sum $ unfoldr f as

f [] = Nothing
f aa@(a:as) = g $ span (==a) aa

g (x,y) = Just ((length x) `div` 2, y)

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

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

  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());

  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += p.at(i);
  }

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

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
long long f(int x)
{
  long long a=0;
  while(x%2==0)
  {
    a++;
    x/=2;
  }
  return a;
}
int main()
{
  int n;
  cin>>n;
  vector<int> v(n);
  for(int &i:v) cin>>i;
  long long ans = 0;
  for(int i:v) ans += f(i);
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int[] arr =  new int[] {
      scan.nextInt(),
      scan.nextInt(),
      scan.nextInt()
    };

    int maxIndex = -1;
    int maxKisu = -1;
    int kisuCount = 0;
    for(int i = 0; i < 3; i++) {
      if(arr[i]%2==1) {
        kisuCount++;
        if(arr[i] > maxKisu) {
          maxKisu = arr[i];
          maxIndex = i;
        }
      }
    }

    if(kisuCount < 3) {
      System.out.println(0);
    }
    else{
      long result = 1L;
      for(int i = 0; i < 3; i++) {
        if(i!=maxIndex) {
          result *= arr[i];
        }
      }
      System.out.println(result);
    }
  }
}


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

int main() {
	int N;
	cin >> N;
	vector<vector<vector<int> > > V(4, vector<vector<int> >(3, vector<int>(10, 0)));
	for (int i = 0; i < N; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		V.at(b - 1).at(f - 1).at(r - 1) += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << V.at(i).at(j).at(k);
				if (k == 9)
					cout << endl;
				if (k == 9 && j == 2 && i != 3)
					cout << "####################" << endl;
			}
		}
	}
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int cnt=0;
	while(a>=b){
		b*=2;
		cnt++;
	}
	while(b>=c){
		c*=2;
		cnt++;
	}
	if(cnt<=k) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3644
#include<cstdio>
int i,j,k,n;
int main()
{
	scanf("%d",&k),n=k+1>>1;
	if(k==1)return 0*puts("1\n1");
	for(printf("%d\n",n+=n&1),i=0;i<n;i++)for(j=0;j<n;j++)printf("%d%c",(i&1?(i+j)%n+n<k?(i+j)%n+n:(i+j)%n:(i+j)%n)+1,j==n-1?'\n':' ');
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define fore(i,a,b) for(int i = a; i < b; i++)
#define fst first
#define snd second
#define ll long long
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int>
#define piii pair<int, pii>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;

const int N_MAX = 3e3+15;
const ll P = 998244353LL;
ll D[N_MAX][N_MAX];
int A[N_MAX];

int main(){
    int N,S;
    cin>>N>>S;
    fore(i,0,N){
        cin>>A[i];
    }
    for(int i=N; i>=0; i--){
        for(int j=0; j<=S; j++){
            if(i==N){
                if(j==0) D[i][j]=1LL;
                else D[i][j]=0LL;
            }
            else{
                D[i][j]=D[i+1][j]*2;
                D[i][j]%=P;
                if(j>=A[i]) D[i][j]+=D[i+1][j-A[i]];
                D[i][j]%=P;
            }
        }
    }
    cout<<D[0][S]<<endl;
    return 0;
}

Measured memory_bytes: 74288
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE
const int N = 4;
using mat = vector<vector<int> >;

mat goal;
int calcCost(mat &pos){
  static int idxX[N * N], idxY[N * N], init = 1;
  if(init){
    init = 0;
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++) idxX[goal[i][j]] = j, idxY[goal[i][j]] = i;
  }

  int res = 0;  
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++){
      if(pos[i][j] == 0) continue;
      res += abs(i - idxY[pos[i][j]]) + abs(j - idxX[pos[i][j]]);
    }
  return res;
}


int dfs(mat &pos, int y, int x, int pre, int limit){
  if(calcCost(pos) == 0) return 1;
  if(limit - calcCost(pos) < 0) return 0;
  
  const int dx[] = {0, 1, 0, -1};
  const int dy[] = {-1, 0, 1, 0};
  for(int i=0;i<4;i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx < 0 || ny < 0 || nx >= N || ny >= N) continue;
    if((i + 2) % 4 == pre) continue;
    swap(pos[y][x], pos[ny][nx]);
    if(dfs(pos, ny, nx, i, limit - 1)) return 1;
    swap(pos[y][x], pos[ny][nx]);
  }
  return 0;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  goal = mat(N, vector<int>(N));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++) goal[i][j] = i * N + j + 1;
  goal[N-1][N-1] = 0;

  mat start(N, vector<int>(N));
  cin>>start;
  
  int y, x;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      if(start[i][j] == 0) y = i, x = j;
  
  int ans = 0;
  while(dfs(start, y, x, -1, ans) == 0) ans++;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3228
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void){
	char s[102]={0};
	char p[102]={0};
	int i,j,k,flag,slen,plen,count;
	count = -100;
	fgets(s,sizeof(s),stdin);
	fgets(p,sizeof(p),stdin);

	slen=strlen(s)-1;
	plen=strlen(p)-1;
	for(i=0;i<slen;i++){
		if(p[0] == s[i]){
			count = 0;
			for(j=1;j<plen;j++){
					if(p[j]==s[(i+j)%slen]) count++;
					else break;
			}
			if(count == plen-1){
				puts("Yes");
				break;}
		}
	}
	if(count != plen-1) puts("No");
	return 0;
}

Measured memory_bytes: 524
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
using namespace std;
typedef long long int ll; typedef pair <double, int> P; typedef vector <int> vecint;
const int INF = 2000000000;
const double EPS = 10e-9;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int res = 0;
	res += a / (b + c);
	a %= (b + c);
	if (a < c) res--;
	cout << res << endl;
	return 0;
}

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

using ll = long long;

int main() {

    int n;

    cin >> n;

    vector<ll> monsters(n + 1);

    for(int i = 0; i < n + 1; ++i)
        cin >> monsters[i];

    vector<ll> heros(n);

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


    ll sum = 0;
    for(int i = 0; i < n; ++i) {

        sum += min(heros[i], monsters[i]);

        heros[i] = heros[i] - monsters[i];
        
        if(heros[i] > 0) {
            ll nextM = max(monsters[i + 1] - heros[i], 0ll);
            sum += monsters[i + 1] - nextM;
            monsters[i + 1] = nextM;
        }


    }


    cout << sum << endl;

    return 0;


}

Measured memory_bytes: 1920
N, A, B = map(int, input().split())
X = list(map(int, input().split()))

X.sort()

group=[[X[0]]]
for i in range(N-1):
    if (X[i+1] - X[i]) * A > B:
        group.append([X[i+1]])
    else:
        group[-1].append(X[i+1])
#print(group)

ans = (len(group) - 1) * B
for g in group:
    ans += (max(g) - min(g)) * A
print(ans)

Measured memory_bytes: 71320
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		string S = Console.ReadLine();
		int N = int.Parse(S);

		int[] Pn = new int[N];
		for(int i=0; i<N; i++){
			//インデックスがややこしくならないように、最初から-1しておく
			int p = int.Parse(Console.ReadLine()) - 1;
			Pn[i] = p;
		}

		//数列Qnを作成
		/*
		各インデックスiについて、Pnでiが何番目に位置していたかを示す数列
		e.g. Qn[3] = 6のとき、
		Pnでは、3という数字は6番目に位置していた
		（即ち、Pn[6] = 3だった）
		*/
		int[] Qn = new int[N];
		for(int i=0; i<N; i++){
			Qn[Pn[i]] = i;
		}

		//Qnの中で、連続して単調増加しているうち最長の部分を求めれば良い
		/*
		cf. LSIとは違い、増加部分が連続（数列内で隣接）している必要あり
		*/
		int max = 1;
		int cnt = 1;
		for(int i=1; i<N; i++){
			//連続部分が単調増加の場合
			if(Qn[i] > Qn[i-1]){
				cnt ++;
			}
			//そうではない場合
			else{
				if(cnt > max){
					max = cnt;
				}
				//初期化
				cnt = 1;
			}
		}
		//最後まで増加した場合、改めてmaxの更新を確認する必要あり
		if(cnt > max){
			max = cnt;
		}

		int ans = N - max;

		Console.WriteLine(ans);
	}
}



Measured memory_bytes: 22560
mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    # comb init
    # mod = 1000000007
    nmax = 25 * 10 ** 5 + 10  # change here
    fac = [0] * nmax
    finv = [0] * nmax
    inv = [0] * nmax
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        if n < r:
            return 0
        else:
            return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod

    N, M = map(int, input().split())
    ans = comb(3 * M + N - 1, N-1)
    for i in range(2 * M + 1, 3 * M+1):
        ans = (ans - (N * comb(3*M - i + N-2, N-2))%mod)%mod
    for i in range(M+2, 3 * M + 1, 2):
        if i > N:
            break
        j = (3 * M - i) // 2
        ans = (ans - (comb(N, i) * comb(j + N-1, N-1))%mod)%mod
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}

Measured memory_bytes: 256