akhauriyash/Code-Regression huggingface dataset:
/**
あなたの課題は、あるクラスの数学の成績を付けるプログラムを作成することです。

プログラムは複数の学生のテストの点数を読み込みます。

テストの点数は、中間試験の点数 m、期末試験の点数 f、再試験の点数 r で構成されています。

中間試験と期末試験は 50 点満点（m, f ? 50）、再試験は 100 点満点 （r ? 100）です。

試験を受けていない場合は点数を -1 とします。

以下の手順で成績が付けられます：
?中間試験、期末試験のいずれかを欠席した場合成績は F。
?中間試験と期末試験の合計点数が 80 以上ならば成績は A 。
?中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。
?中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
?中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。 ただし、再試験の点数が 50 以上ならば成績は C。
?中間試験と期末試験の合計点数が 30 未満ならば成績は F。

 */

/*sucannerクラス使うためにインポート*/
import java.util.Scanner;

class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		// 点数を受け取る変数を宣言
		int intM = 0;
		int intF = 0;
		int intR = 0;
		int intSum = 0;

		while (true) {
			intM = sc.nextInt();
			intF = sc.nextInt();
			intR = sc.nextInt();

			if (intM == -1 && intF == -1 && intR == -1) {
				break;
			}
			if (intM == -1 || intF == -1) {
				System.out.println("F");
			} else if (intM + intF >= 80) {
				System.out.println("A");
			} else if (intM + intF >= 65) {
				System.out.println("B");
			} else if (intM + intF >= 50 || intR >= 50) {
				System.out.println("C");
			} else if (intM + intF >= 30) {
				System.out.println("D");
			} else {
				System.out.println("F");
			}
		}
	}
}

Measured memory_bytes: 17404
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int A, B, C, D;
    cin >> A >> B >> C;

    cout << C << " " << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int m = cin.Int();
			long[] xs = cin.ArrayLong(n);
			long[] ys = cin.ArrayLong(m);

			long x = 0;
			for (int i = 1; i < n; i++) {
				long tempX = (xs[i] - xs[i - 1]) % MOD;
				long r = n - i - 1;
				long l = i - 1;

				long temp = tempX;
				temp = (temp + ((tempX * r) % MOD)) % MOD;
				temp = (temp + ((tempX * l) % MOD)) % MOD;
				long rl = (r * l) % MOD;
				temp = (temp + ((tempX * rl) % MOD)) % MOD;

				x = (x + temp) % MOD;
			}

			long y = 0;
			for (int i = 1; i < m; i++) {
				long tempY = (ys[i] - ys[i - 1]) % MOD;
				long t = m - i - 1;
				long b = i - 1;

				long temp = tempY;
				temp = (temp + ((tempY * t) % MOD)) % MOD;
				temp = (temp + ((tempY * b) % MOD)) % MOD;
				long tb = (t * b) % MOD;
				temp = (temp + ((tempY * tb) % MOD)) % MOD;

				y = (y + temp) % MOD;
			}

			long ans = (x * y) % MOD;

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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

int main() {
  int64_t a, b, c, d;
  cin >> a >> b >> c;
  d = c - a - b;
  if (d <= 0) {
    cout << "No" << endl;
  } else if ((4 * a * b) < d * d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split())) + [10**10]
res = 0
s = 0
while s < N:
    interim = 0
    if H[s] < H[s + 1]:
        s += 1
        continue
    while s < N and H[s] >= H[s + 1]:
        interim += 1
        s += 1   
    res = max(res, interim)
print(res)

Measured memory_bytes: 14228
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)

#define mp make_pair
#define P pair<int,int>
#define ll __int64
string x;
int main(){
	cin>>x;
	int ts=x.size();

	for(int i=0;i<ts;i++){
		int now=x[i]-'A';
		now-=3;
		if(now<0)now=26+now;
		x[i]='A'+now;
	}
	cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>
int main(){
    int n,m,s[99999],a[100000],ans=0,p=0,i,j;
    scanf("%d%d",&n,&m);
    for (i=0; i<n-1; i++) {
        scanf("%d",&s[i]);
    }
    for (i=0; i<m; i++) {
        scanf("%d",&a[i]);
        if (a[i]>0) {
            for (j=0; j<a[i]; j++) {
                ans+=s[p];
                p++;
                if (ans>100000) {
                    ans%=100000;
                }
            }
        }else{
            for (j=0; j>a[i]; j--) {
                ans+=s[p-1];
                p--;
                if (ans>100000) {
                    ans%=100000;
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1376
a, b = input().split()
a, b = [int(a), int(b)]

if b < 0:
    if (b - a + 1) % 2 == 0:
        result = 'Positive'
    else:
        result = 'Negative'
elif 0 < a:
    result = 'Positive'
else:
    result = 'Zero'

print(result)

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

using namespace std;

int main() {
    int n, k;
    int res = 1;

    cin >> n >> k;

    for (int i=0; i<n; i++) {
        if (res*2 < res+k) {
            res *= 2;
        }
        else {
            res += k;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string S;
  std::cin >> S;

  std::map<char, ll> mc;
  for (char c = 'a'; c <= 'z'; c++) {
    mc[c] = 0;
  }

  bool judge = true;
  for (auto c : S) {
    mc[c]++;
    if (mc[c] > 1) judge = false;
  }

  if (judge) print("yes");
  else print("no");

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def calc_divisors(n):
    divisors_a = []
    divisors_b = []
    for d in range(1, int(n**0.5) + 1):
        if n % d == 0:
            divisors_a.append(d)
            if n // d != d:
                divisors_b.append(n // d)
    divisors = divisors_a + divisors_b[::-1]
    return divisors


def main():
    N = int(input())

    divisors = calc_divisors(N)

    # N = qm + r
    #   q = r
    # --> N = rm + r = r(m+1) (r < m)

    m_set = set()
    for d in divisors:
        m = N // d - 1
        if d < m and m != 1:
            m_set.add(m)
    ans = sum(m_set)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3676
// ACM-ICPCà\I2010 B. jyjfö

#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;

int main(){
	vector<int> msp; msp.push_back(6);
	int cur = 8, plus = 5;
	while(cur < 300000){
		bool flag = true;
		for(int i=0;flag && msp[i]*msp[i]<=cur;i++)
			if(cur%msp[i] == 0) flag = false;
		if(flag) msp.push_back(cur);
		cur += plus;
		plus = 7-plus;
	}
	int n;
	while(cin >> n, n-1){
		printf("%d:", n);
		for(int i=0;i<msp.size();i++)
			if(n%msp[i]==0) printf(" %d", msp[i]);
		puts("");
	}
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

int n,m;
vector<string> ans,ans2;

void solve(int a,int b,string s){
  if(a==0 && b==0){
    ans.push_back(s);
    return;
  }
  if(a!=0){
    solve(a-1,b,s+'A');
  }
  if(b!=0){
    solve(a,b-1,s+'B');
  }
}

void solve2(int a,int b,string s){
   if(a==0 && b==0){
    ans2.push_back(s);
    return;
  }
  if(a!=0){
    solve2(a-1,b,s+'A');
  }
  if(b!=0){
    solve2(a,b-1,s+'B');
  }
}

signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  cin>>n>>m;
  solve(min((int)4,n),min((int)4,m),"");
  if(n>4 || m>4){
    solve2(max((int)0,n-4),max((int)0,m-4),"");
    rep(i,ans.size() ){
      rep(j,ans2.size() ){
	cout<<ans[i]+ans2[j]<<endl;
      }
    }
  }
  else{
    rep(i,ans.size() ){
      cout<<ans[i]<<endl;
    }
  }
	
    

  return 0;
}



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

int main() {
	int N, T;
	cin >> N >> T;
	int ans = 1e9;
	for (int n = 0;n<N;++n) {
		int c, t;
		cin >> c >> t;
		if (t<=T) {
			ans = min(ans, c);
		}
	}
	if (1e9 == ans) {
		cout << "TLE" << endl;
	}
	else {
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3540
// finish date: 2019/11/24

#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)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1000000007;
const long long INFll = 100000000000000000;


vvi G;
map<pii, int> edge_i, edge_color;
vb isPass;

void dfs(int node) {
    if (isPass[node]) return;
    isPass[node] = true;
    int skip = -1;
    rep(i, G[node].size()) {
        if (edge_color[pii(node, G[node][i])] != 0) {
            skip = edge_color[pii(node, G[node][i])];
        }
    }

    int c = 1;
    rep(i, G[node].size()) {
        if (c == skip) c += 1;
        if (edge_color[pii(node, G[node][i])] == 0) {
            edge_color[pii(node, G[node][i])] = c;
            edge_color[pii(G[node][i], node)] = c;
            dfs(G[node][i]);
            c++;
        }
    }
}


int main() {
    int N;
    cin >> N;
    vvi ab(N - 1, vi(2));
    G = vvi(N);
    isPass = vb(N, false);

    rep(i, N - 1) {
        cin >> ab[i][0] >> ab[i][1];
        ab[i][0]--;
        ab[i][1]--;
        G[ab[i][0]].push_back(ab[i][1]);
        G[ab[i][1]].push_back(ab[i][0]);
        edge_i[pii(ab[i][0], ab[i][1])] = i;
        edge_i[pii(ab[i][1], ab[i][0])] = i;
        edge_color[pii(ab[i][1], ab[i][0])] = -1;
        edge_color[pii(ab[i][1], ab[i][0])] = -1;
    }
    int color = 0;
    rep(i, N) {
        color = max(color, (int) G[i].size());
    }
    dfs(0);
    cout << color << endl;
    rep(i, N - 1) {
        cout << edge_color[pii(ab[i][1], ab[i][0])] << endl;
    }


    return 0;
}


Measured memory_bytes: 36480
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		std::vector<int> num;
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (; x; x /= 10) {
			num.push_back(x % 10);
		}
		while (!num.empty()) {
			putchar(num.back() ^ '0');
			num.pop_back();
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

long long n;
int ans;

bool check(int x) {
	long long t = n;
	while (t % x == 0) t /= x;
	return (t - 1) % x == 0;
}

int main() {
	read(n);
	for (int i = 2; 1ll * i * i <= n - 1; ++i) {
		if ((n - 1) % i == 0) {
			++ans;
			if (1ll * i * i < n - 1) {
				++ans;
			}
		}
	}
	if (n > 2) {
		++ans;
	}
	for (int i = 2; 1ll * i * i <= n; ++i) {
		if (n % i == 0) {
			if (check(i)) {
				++ans;
			}
			if (1ll * i * i < n && check(n / i)) {
				++ans;
			}
		}
	}
	print(ans + 1);
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <stdlib.h>
int main(int argv, char *argc[]){
    int hex, wide, x, y;
     
    while(1){
        scanf("%d %d", &hex ,&wide);
         
        if(hex == 0 || wide == 0)break;
         
        for(y=0;y<hex;y++){
            for(x=0;x<wide;x++){
                printf("#");        
            }
            printf("\n");
        }
        printf("\n");
         
    }
    return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define F first
#define S second
 
signed main()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	/************************************/
	
	int s, b; cin>>s>>b;
	
	vector<int> bulb[b];
	for(int i=0; i<b; i++)
	{
		int k; cin>>k;
		while(k--)
		{
			int x; cin>>x; x--;
			bulb[i].push_back(x);
		}
	}
	vector<int> p(b);
	for(int &i : p) cin>>i;
	
	int nos = 1<<s;
	int ans = 0;
	for(int i=0; i<nos; i++)
	{
		vector<int> state(s, 0), bulb_ON(b, 0);
		int temp = i, j = 0;
		for(int j=0; j<s; j++)
		{
			if( 1<<j & i)
				state[j] = 1;
		}
		int cnt = 0;
		for(int j=0; j<b; j++)
		{
			int on = 0;
			for(int swich: bulb[j])
				on += state[swich];
			cnt += (on%2 == p[j]);
		}
		ans += (cnt == b);
	}
	
	cout<<ans<<"\n";
	
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    int count;
    int maxCount = 0;
    string subString;
    for(int i = 0; i <= S.size() - T.size(); ++i){
        count = 0;
        for(int j = 0; j < T.size(); ++j) {
            if(S[i + j] == T[j]) {
                count++;
            }
        }
        maxCount = max(count, maxCount);
    }
    cout << T.size() - maxCount << endl;
    return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] c = new int[3][3];
		for(int i = 0 ; i < 3 ; i++) {
			for(int j = 0 ; j < 3 ; j++) {
				c[i][j] = sc.nextInt();
			}
		}
		for(int i = -100 ; i <= 100 ; i++) {
			for(int j = -100 ; j <= 100 ; j++) {
				for(int k = -100 ; k <= 100 ; k++) {
					int[] b = new int[3];
					b[0] = c[0][0] - i;
					b[1] = c[1][1] - j;
					b[2] = c[2][2] - k;
					if(i + b[0] == c[0][0] && i + b[1] == c[0][1] && i + b[2] == c[0][2] && j + b[0] == c[1][0] && j + b[1] == c[1][1] && j + b[2] == c[1][2] && k + b[0] == c[2][0] && k + b[1] == c[2][1] && k + b[2] == c[2][2]) {
						System.out.println("Yes");
						return;
					}
				}
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 39632
fun main(args: Array<String>) {
    val n = Integer.parseInt(readInputLine())
    
    val workList = mutableListOf<Pair<Long, Long>>()
    
    for (i in 0 until n) {
        val inputs = readInputLine().split(" ").map { it.toLong() }
        workList.add(Pair(inputs[0], inputs[1]))
    }
    
    workList.sortBy { it.second }

    var nowTime = 0L

    for (elem in workList) {
        nowTime += elem.first
        if (nowTime > elem.second) {
            println("No")
            return
        }
    }

    println("Yes")
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 134552
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
LL vis[200001]={0},lvl[200001]={-1};
V<LL>v[200001];
Q<LL>u;
int main()
{
    FAST;
    long long int n,m,i,j,k,p,q,a;
    cin >> n>>m;
    for(i=0; i<m; i++)
    {
        cin >>p>>q;
        v[p].push_back(q);
        v[q].push_back(p);
    }
    u.push(1);
    lvl[1]=0;
    vis[1]=1;
    while(!u.empty())
    {
        k=u.front();
        u.pop();
        for(i=0; i<v[k].size(); i++)
        {
            if(vis[v[k][i]]==0)
            {
                u.push(v[k][i]);
                vis[v[k][i]]=1;
                lvl[v[k][i]]=lvl[k]+1;
            }

        }

    }
    if(vis[n]==1 && lvl[n]==2 || lvl[n]==1)
    {
        cout<<"POSSIBLE"<<endl;
    }
    else
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
        return 0;
}


Measured memory_bytes: 16744
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>
#include <atcoder/all>
 
using namespace std;
using namespace atcoder;
 
/* template */
 
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};
 
struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};
 
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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 ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
 
constexpr ll LNF = 1LL<<50;
 
constexpr int INF = 1e9+7;
 
const long double PI=acos(-1);

vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    dsu uf(n);
    rep(i,0,m){
        int a,b; cin >> a >> b;
        a--; b--;
        uf.merge(a,b);
    }
    auto x = uf.groups();
    int y = x.size();
    cout << y-1 << endl;
}


Measured memory_bytes: 8888
# include<stdio.h>

int main(){
  long n = 0;
  long a[500000] = {};
  long b[500000] = {};
  long i = 0;
  long c = 0;
  long cnt = 0;
  long total = 0;
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
    a[i] -= 1;
  }
  cnt = 0;
  for(i=0;i<n;i++){
    if(a[i] == i ){
      b[cnt]++;
      //printf("#");
    }else{
      if(b[cnt] != 0){
        cnt++;
      }
    }  
  }
  //printf("%ld",cnt);
  for(i=0;i<n;i++){
    if(b[i] != 0){
      total += (b[i]+1)/2;
    }
  }
  printf("%ld",total);
  return 0;
}
      
    
    

Measured memory_bytes: 7936
N, Y = map(int, input().split())
for i in range(N+1):
    for j in range(0, N-i+1):
        k = N - i - j
        total_momey = 10000 * i + 5000 * j + 1000 * k
        if total_momey == Y:
            print("{} {} {}".format(i, j, k))
            exit()
print("-1 -1 -1")

Measured memory_bytes: 40300
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a>>b;
    int res1=a+b;
    int res2=a-b;
    int res3=a*b;
    int x=max(res1,res2);
    int y=max(x,res3);
    cout<<y <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll n,a=0,count=0;
    cin>>n;
    for(int i=0; i<n; i++)
    {  a+=7;
        a%=n;
        a*=10;
        count++;
        if(a==0)
        {
            break;
        }
    }
    if(a==0)
        cout<<count;
    else
        cout<<-1;
}

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

using namespace std;

int main(){
    long long n;
    cin >> n;
    long long ans = 0, arr[n];
    for(long long i = 0; i < n; ++i){
        cin >> arr[i];
        ans += arr[i];
    }
    long long last = 0, rans = INT_MAX;
    for(long long i = 0; i < n - 1; ++i){
        last += arr[i];
        rans = min(rans, abs(last - (ans - last)));
    }
    cout << rans;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX + 1];

void maxHeapify(int i) {
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;

	if (l <= H && A[l] > A[i]) largest = l;
	else largest = i;
	if (r <= H &&A[r] > A[largest]) largest = r;

	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}
}

int main() {
	cin >> H;

	for (int i = 1; i <= H; i++) cin >> A[i];

	for (int i = H / 2; i >= 1; i--) maxHeapify(i);

	for (int i = 1; i <= H; i++) {
		cout << " " << A[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 4952
#include<iostream>
using namespace std;
int main(){
    int x;
    int y;
    
    
    while (1){ cin >> x >> y ;
        if (x == 0 && y == 0)break;
        else if ( x <= y ){
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
        
            
        }return 0;
}


Measured memory_bytes: 2984
import sys
S = input()
alp = list(set(S))
cnts = [0] * len(alp)
for i in range(len(S)):
    cnts[alp.index(S[i])] += 1
    
for a in cnts:
    if a%2 == 1:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] livePoint = new int[n];
		for (int i = 0; i < n; i++) {
			livePoint[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(livePoint);
		int min = -1;
		for (int i = livePoint[0]; i <= livePoint[n - 1]; i++) {
			int total = 0;
			for (int j = 0; j < n; j++) {
				total += (int) Math.pow(i - livePoint[j], 2);
			}
			if (min == -1 || total < min) {
				min = total;
			}
		}
		System.out.println(min);
	}

}


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

const double PI = acos(-1.0);

int main()
{
	//printf("%lf\n", PI);
	double r, area, circumference;
	scanf("%lf", &r);
	area = r * r * PI;
	circumference = 2 * r * PI;
	printf("%lf %lf", area, circumference);
	return 0;
}


Measured memory_bytes: 2088
M, K = map(int, input().split())

if K >= 2**M or (M == 1 and K == 1):
    ans = -1
elif K == 0:
    a = []
    for i in range(2**M):
        a.append(i)
        a.append(i)
    ans = ' '.join(map(str, a))
else:
    a = [0, K, 0]
    for i in range(1, 2**M):
        if i != K:
            a.append(i)
    a.append(K)
    for i in range(2**M - 1, 0, -1):
        if i != K:
            a.append(i)
    ans = ' '.join(map(str, a))

print(ans)


Measured memory_bytes: 31652
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << 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; }

using namespace std;
typedef pair<ll, ll> pint;

const ll mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }
}

int main() {
    combination c(200005);
    ll n, m, k;
    cin >> n >> m >> k;
    mint ans = 0;
    mint col = m;
    for (int x = n - 1; x >= 0; --x) {
        mint now = col;
        now *= c(n-1, x);
        if (x <= k) ans += now;
        col *= m - 1;
    }
    cout << ans.x << endl;


}

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


int main() {
    int H,W;
    cin >> H >> W;
    vector<vector<string>> data(H, vector<string>(W));
    for(int i = 0;i<H;i++){
        for(int j = 0;j<W;j++){
            cin >> data[i][j];
        }
    }
    for(int i = 0;i<H;i++){
        for(int j = 0;j<W;j++){
            if(data[i][j] == "snuke"){
                cout << char(65+j) << i+1 <<endl;
            }
        }
    }
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;


    vector<int> v(10000,0);
    v[a]++;
    v[b]--;

    v[c]++;
    v[d]--;

    rep(i,101){
        v[i+1] += v[i];
    }

    int cnt = 0;
    rep(i,1002){
        if(v[i] == 2) cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
void solve(){
    string s;cin>>s;
    for(auto i:s){
        if(i=='?'){
            cout<<'D';
        }else{
            cout<<i;
        }
    }
    cout<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 3788
#include <stdio.h>
#include <string.h>
#define LEN 100000

typedef struct t{
  char name[10];
  int t;
} Process;

void enqueue(Process);
Process dequeue(void);
int min(int,int);

Process Q[LEN];
int head, tail, n;

int main(){
  int i;
  Process p;
  int n,q,time,Ktime = 0;
  scanf("%d%d",&n,&q);
  for(i = 1;i <= n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1;
  tail = n+1;
  while(head != tail){
    p = dequeue();
    time = min(q,p.t);
    p.t -= time;
    Ktime += time;
    if (p.t > 0)enqueue(p);
    else{
      printf("%s %d\n",p.name, Ktime);
    }
  }
  return 0;
}

void enqueue(Process x){
  Q[tail] = x;
  if (tail + 1 == LEN){
    tail = 0;
  }else{
    tail++;
  }
}


Process dequeue(){
  Process x = Q[head];
  if (head + 1 == LEN){
    head = 0;
  }else{
    head++;
  }
  return x;
}

//最小の値を返す
int min(int x,int y){
  if(x > y){
    return y;
  }else{
    return x;
  }
}



Measured memory_bytes: 3292
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    Q, *BC = map(int, read().split())

    total = sum(A)
    d = [0] * (10 ** 5 + 1)
    for a in A:
        d[a] += 1

    for b, c in zip(*[iter(BC)] * 2):
        total += (c - b) * d[b]
        d[c] += d[b]
        d[b] = 0
        print(total)

    return


if __name__ == '__main__':
    main()


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


int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	int n;
	
	cin >> n;
	
	int a[n+5];
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	sort(a+1, a+n+1);
	
	n /= 2;
	
	int d = a[n+1] - a[n];
	
	cout << d << "\n";
	
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007


using namespace std;

int main(void){
    int N,M;
    cin>>N;
    V<pair<int,int>> t(N);
    rep(i,N)cin>>t[i].first>>t[i].second;
    cin>>M;
    V<pair<int,int>> t1(M);
    rep(i,M)cin>>t1[i].first>>t1[i].second;
    t.insert(t.end(),t1.begin(),t1.end());
    sort(t.begin(),t.end());
    rep(i,t.size()){
        if(i!=0&&t[i-1]==t[i])continue;
        if(i)cout<<' ';
        cout<<t[i].first<<':';
        if(t[i].second<10)cout<<0<<t[i].second;
        else cout<<t[i].second;
        
    }
    cout<<endl;
}




Measured memory_bytes: 3124
S=int(input())
sqr=int(S**0.5)
if sqr==10**9:
    print(0,0,sqr,1,10**18-S,sqr)
    exit(0)
x1,y2=sqr+1,sqr+1
sub=(sqr+1)**2-S
print(0,0,x1,1,sub,y2)

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

int main(){
int W, H, N;
int i, j,k,sum;
int x, y, a;
cin >> W >> H>> N;
int array[100][100];

for(i = 0; i < W;i++){
     for( j = 0; j< H; j++){
        array[i][j]= 1;
        }
}
for ( k = 0; k<N ; k++){
    cin >>x >>y >>a ;
        if( a == 1){
        for(i = 0; i < x;i++){
             for( j = 0; j< H; j++){
                array[i][j]= 0;
            }
        }
    }  
    if( a == 2){
    for(i = x; i < W;i++){
         for( j = 0; j< H; j++){
            array[i][j]= 0;
            }
        }
    }   if( a == 3){
    for(i = 0; i < W;i++){
         for( j = 0; j< y; j++){
            array[i][j]= 0;
            }
        }
    }  
    if( a == 4){
    for(i = 0; i < W;i++){
         for( j = y; j< H; j++){
            array[i][j]= 0;
            }
        }
    }
}
sum = 0;
for(i = 0; i < W;i++){
     for( j = 0; j< H; j++){
        sum +=array[i][j];
        }
    }
cout << sum;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int head[100010],Next[200010],tot,to[200010],No[200010];
int ans[100010],ansnum=0;
void dfs(int now,int faco,int fa){
	int tmp=1;
	for(int i=head[now];i;i=Next[i]){
		if(to[i]==fa) continue;
		if(tmp==faco) tmp++;
		ans[No[i]]=tmp;
		ansnum=max(ansnum,tmp);
		dfs(to[i],tmp,now);
		tmp++;
	}
}
void ADD(int a,int b,int num){
	tot++;
	Next[tot]=head[a];
	head[a]=tot;
	No[tot]=num;
	to[tot]=b;
}
int main(){
	int n;
	cin>>n;
	int a,b;
	for(int i=1;i<=n-1;i++){
		scanf("%d%d",&a,&b);
		ADD(a,b,i);
		ADD(b,a,i);
	}
	dfs(1,-1,-1);
	cout<<ansnum;
	for(int i=1;i<=n-1;i++){
		printf("\n%d",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 5888
N = int(input())
A = list(map(int,input().split()))

mod = 10**9 + 7

S = 0
T = 0

for i in range(len(A)):
    S += A[i]
    T += A[i]**2
    S %= mod
    T %= mod

print(((S**2-T)*pow(2,mod-2,mod))%mod)

Measured memory_bytes: 94056
#include<stdio.h>

int main() {
	bool x[500][500]{};
	bool y[500]{};
	y[0] = true;
	int n, m, a, b, cnt = 0;
	scanf("%d%d", &n, &m);
	if (!(n | m))return 0;
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &a, &b);
		a--; b--; x[a][b] = true; x[b][a] = true;
		if (!a){ cnt++; y[b] = true;}
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (x[0][i] && x[i][j] && !y[j]){ cnt++; y[j] = true; }
	printf("%d\n", cnt);
	main();
}

Measured memory_bytes: 4052
A,B,C,X,Y=map(int,input().split())

ans1=max(X,Y)*C*2
ans2=X*A+Y*B
if X>Y:
  ans3=C*Y*2+(X-Y)*A
else:
  ans3=C*X*2+(Y-X)*B

print(min(ans1,ans2,ans3))

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

int main()
{
	int N;
	cin >> N;
	
	vector<int> index(N);
	for (int i = 0; i < N; ++i)
	{
		index[i] = i + 1;
	}

	vector<int> P(N);
	vector<int> Q(N);

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

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

	int a = 0;
	int b = 0;
	int count = 0;
	do {
		++count;

		if (a == 0)
		{
			bool isMatch = true;
			for (int i = 0; i < N; ++i)
			{
				if (P[i] != index[i])
				{
					isMatch = false;
					break;
				}
			}

			if (isMatch)
			{
				a = count;
			}
		}

		if (b == 0)
		{
			bool isMatch = true;
			for (int i = 0; i < N; ++i)
			{
				if (Q[i] != index[i])
				{
					isMatch = false;
					break;
				}
			}

			if (isMatch)
			{
				b = count;
			}
		}

		if (a != 0 && b != 0)
		{
			break;
		}
	} while (next_permutation(index.begin(), index.end()));

	cout << abs(a - b) << endl;
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var in = NewScanner(os.Stdin, 0)

/* this is port of top c++ answer to test go performance */
func main() {
	h, w, k := in.Int(), in.Int(), in.Int()
	f := make([]int, h+w+1)
	f[0] = 1
	for i := 1; i <= h+w; i++ {
		f[i] = f[i-1] * i % M7
	}
	r := 0
	x := f[h+w-2]
	x = x * Pow7(f[h+w-k], M7-2) % M7
	for i := 2; i <= k; i++ {
		y := x * i % M7
		y = y * (i - 1) % M7
		r += y
		if r >= M7 {
			r -= M7
		}
	}
	r = r * h % M7
	r = r * w % M7
	z := (k + 3) * k
	z = z / 2 % M7
	z = z * f[h+w] % M7
	z = z * Pow7(f[h+w-k], M7-2) % M7
	Pln((r + z) % M7)
}

const M7 = 1000000007

type Scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader, max int) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if max <= 0 {
		max = 1048576
	}
	s.Buffer([]byte{}, max)
	return &Scanner{s}
}
func (s *Scanner) Int() int {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for start < len(data) && isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i + 1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func Pow7(x, k int) int {
	if k == 0 {
		return 1
	}
	r := Pow7(x, k/2)
	r = r * r % M7
	if k%2 == 1 {
		r = r * x % M7
	}
	return r
}
func Pln(s ...interface{}) {
	fmt.Println(s...)
}

type ByteSlice []byte
type IntSlice []byte


Measured memory_bytes: 161792
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = 1e18;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 111;
     
using namespace std;

int q, a, b, c, d[maxn];

void solve(){
	cin >> a >> b >> c;
	d[a]++;
	d[b]++;
	d[c]++;
	if (d[5] == 2 && d[7] == 1)
		cout << "YES";
	else
		cout << "NO";
}

main(){
    boost;
	    
	q = 1;

	while (q--){
		solve();
	}
}

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

int main(){
  int K;
  cin >> K;
  int count = 0;
  string S;    
  cin >> S;
  count = S.size();
  //cout << count << endl;
  for(int i = 0; i < K; i++){
    cout << S.at(i);
    if(i == count - 1){
      break;
    }
  }
  if(K < count)
    cout << "..." << endl;
}

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

    public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
  //  Scanner sc = new Scanner(System.in);
    double d = sc.nextDouble();
    double s = sc.nextDouble();
    double t = sc.nextDouble();
    if(d/t<=s)
    System.out.println("Yes");
    else
    System.out.println("No");
       // System.out.println("Hello World");
    }
}

     //   System.out.println("Hello World");
 

Measured memory_bytes: 37312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K;
string S;
ll t;
ll ret = 0;

void input() {
  IN(N);
  IN(K);
  IN(S);
}

void solve() {
  ll c = S[0];
  ll change = 0;
  ll acc = 1;
  FOR(i, 1, N) {
    if (S[i] == c) {
      acc += 1;
    } else {
      c = S[i];
      ret += acc - 1;
      acc = 1;
      change += 1;
    }
  }
  ret += acc - 1;
  ll man = min(2*K, change);
  ret += man;
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
    int N, x;
    bool incremental;
    int first = 0;
    int ans = 1;
    int prev;
    vector<int> A;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x;
        if (i != 0) {
            if (prev > x) {
                if (first == 0) {
                    incremental = false;
                    first++;
                }
                if (incremental) {
                    incremental = false;
                    first = 0;
                    ans++; 
                }
            } else if (prev < x){
                if (first == 0) {
                    incremental = true;
                    first++;
                }
                if (!incremental) {
                    incremental = true;
                    first = 0;
                    ans++;
                }
            } 
        }
        prev = x;
        A.push_back(x);
    }
    cout << ans << endl;
}


Measured memory_bytes: 892
N=int(input())
tmp_max=0

alpha_list=[]
for i in range(97,97+26):
    alpha_list.append(chr(i))    

for i in range(11):
    tmp_max=tmp_max+26**(i+1)
    if N <= tmp_max:
        keta=i+1
        mx=tmp_max
        mn=tmp_max-26**(i+1)+1
        break

ans=['a']*keta

ans[keta-1]=alpha_list[(N-mn)%26]

tmp=(N-mn)
for _ in range(keta-1):
    tmp=tmp//26
ans[0]=alpha_list[tmp]

tmp_keta=keta-2
count=1
while tmp_keta>0:
    tmp=(N-mn)
    for _ in range(count):
        tmp=tmp//26
    tmp=tmp%26
    ans[tmp_keta]=alpha_list[tmp]
    count=count+1
    tmp_keta=tmp_keta-1

ans=''.join(ans)
print(ans)

Measured memory_bytes: 9252