akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<pll> vll;
typedef vector<vl> vvl;

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

const ll mod = 1e9 + 7;
const ll INF = 1e18;

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr);

    int n;
    cin >> n;
    cout << (n >= 30 ? "Yes" : "No") << endl;

    time_taken();
    return 0;
}

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



int main() {

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
   	int n;
   	cin>>n;
   	vector<int> v(n);
   	for(int i = 0; i < n; i++) 
   		cin>>v[i];

   	vector<int> dp(n+1,0);
   	// dp[i] gives max value you can get

   	dp[n-1] = 0;
   	for(int i = n-2; i >= 0; i--) {
   		if(v[i] >= v[i+1]) 
   			dp[i] = 1 + dp[i+1];
   	}

   	int ans = 0;
   	for(int i : dp) {
   		ans = max(ans,i);
   	}

   	cout<<ans;
   	
	return 0;		
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s;
    int x,y=0;
    cin>>s;
    for(int i=0; i<s.size(); i++){
        if(s[i] == 'A'){
            x = i;
            break;
        }
    }
    for(int j=s.size()-1; j>=0; j--){
        if(s[j] == 'Z'){
            y = s.size() - j - 1;
            break;
        }
    }
    cout<< s.size() - x - y <<endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

string gcs(string x, string y){
	vi a(26,0), b(26,0);
  	rep(s,x.size()) {
   		rep(i,26) {
          	if(x[s] == 'a'+i) a[i]++;
        }
    }
  	rep(s,y.size()) {
    	rep(i,26) {
          	if(y[s] == 'a'+i) b[i]++;
        }
    }
    string ans = "";
    rep(i,26) {
      	rep(j,min(a[i],b[i])) {
        	ans += 'a'+i;
      	}
    }
    return ans;
}

void Main()
{
	int n;
  	cin >> n;
  	vector<string> s(n);
	string stemp;
  	//cout << gcs("ab", "aa");

  	rep(i,n) {
      cin >> s[i];
      if(i == 0) stemp = gcs(s[0],s[0]);
      else stemp = gcs(stemp, s[i]);
    }
  	cout << stemp << endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

int power(int n) {
  int p = 1;
  for (int i = 0; i < n; i++) {
    p *= 2;
  }
  return p;
}

signed main() {
  int n, m;
  cin >> n >> m;
  int time = 1900 * m + 100 * (n - m);
  cout << time * power(m) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int result = 0;

        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }

        for (int i = 0; i < n; i++) {
            result += factor2(a[i]);
        }


        System.out.println(result);


    }

    public static int factor2(int f) {
        int cnt = 0;
        while (true) {
            if (f % 2 == 0) {
                f = f/2;
                cnt++;
            } else {
                return cnt;
            }
        }
    }
}

Measured memory_bytes: 34108
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pque = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

#include <atcoder/all>
using namespace atcoder;

int main() {
	int n, m;
	cin >> n >> m;
	vector<string> a(n);
	cin >> a;
	mcf_graph<int, ll> g(n * m * (n + m) + 2);
	int s = n * m * (n + m);
	int t = s + 1;
	int cnt = 0;
	rep(i, n) {
		rep(j, m) {
			if (a[i][j] == 'o') cnt++;
			if (a[i][j] == '#') continue;
			int idx = i * m + j;
			idx *= n + m;
			if (a[i][j] == 'o') {
				g.add_edge(s, idx, 1, inf);
				rep(k, i + j) {
					g.add_edge(idx + k, idx + k + 1, 1, inf);
				}
			}
			for (int k = i + j; k < n + m - 1; k++) {
				g.add_edge(idx + k, idx + k + 1, 1, inf);
			}
			g.add_edge(idx + n + m - 1, t, 1, inf);
		}
	}
	rep(i, n) {
		rep(j, m) {
			if (j != m - 1 && a[i][j] != '#' && a[i][j + 1] != '#') {
				int f1 = i * m + j; int f2 = f1 + 1;
				g.add_edge(f1 * (n + m) + i + j, f2 * (n + m) + i + j + 1, cnt, inf - 1);
			}
			if (i != n - 1 && a[i][j] != '#' && a[i + 1][j] != '#') {
				int f1 = i * m + j; int f2 = f1 + m;
				g.add_edge(f1 * (n + m) + i + j, f2 * (n + m) + i + j + 1, cnt, inf - 1);
			}
		}
	}
	auto res = g.flow(s, t, cnt);
	cout << ((ll)inf * (ll)inf - res.second) % inf << '\n';
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

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

    if(a>=13){
        cout<<b<<endl;
    }
    else if(a<=5){
        cout<<0<<endl;
    }
    else {
        cout<<b/2<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;
  transform(S.begin() + K - 1, S.begin() + K, S.begin() + K - 1, ::tolower);
  cout << S << "\n";
}


Measured memory_bytes: 256
"""
J氏は、メッセージのすべての文字を左に1つ回転させます。
たとえば、「aB23d」を「B23da」に変換します。

ミスCは、メッセージのすべての文字を1つ右に回転します。
たとえば、彼女は「aB23d」を「daB23」に変換します。

E氏はメッセージの左半分を右半分と入れ替えます。メッセージの文字数が奇数の場合、中央の文字は移動しません。
たとえば、「e3ac」を「ace3」に、「aB23d」を「3d2aB」に変換します。

A氏はメッセージを逆にします。たとえば、「aB23d」を「d32Ba」に変換します。

Dr. Pは、メッセージ内のすべての数字を1つ増やします。数字が「9」の場合、「0」になります。アルファベットは変更されません。
たとえば、彼は「aB23d」を「aB34d」に、「e9ac」を「e0ac」に変換します。

M氏は、メッセージのすべての桁を1つ減らします。数字が「0」の場合、「9」になります。アルファベットは変更されません。
たとえば、彼は「aB23d」を「aB12d」に、「e0ac」を「e9ac」に変換します。
"""

def func_by_J(t):
    return t[len(t)-1] + t[:len(t)-1]

def func_by_C(t):
    return t[1:len(t)] + t[0]

def func_by_E(t):
    if len(t)%2 == 0:
        t = t[len(t)//2:] + t[:len(t)//2]
    else:
        t = t[len(t)//2+1:] + t[len(t)//2] + t[:len(t)//2]
    return t

def func_by_A(t):
    return t[::-1]

def func_by_P(t):
    s = []
    for c in t:
        try:
            integer = int(c)
            s.append(str((integer - 1)%10))
        except:
            s.append(c)

    return "".join(s)

def func_by_M(t):
    s = []
    for c in t:
        try:
            integer = int(c)
            s.append(str((integer + 1)%10))
        except:
            s.append(c)

    return "".join(s)


def solve(s, t):
    for c in reversed(s):
        if c == "J":
            t = func_by_J(t)
        elif c == "C":
            t = func_by_C(t)
        elif c == "E":
            t = func_by_E(t)
        elif c == "A":
            t = func_by_A(t)
        elif c == "P":
            t = func_by_P(t)
        elif c == "M":
            t = func_by_M(t)
    return t


if __name__ == '__main__':
    #"""
    n = int(input())
    ans = []
    for i in range(n):
        s = input()
        t = input()
        ans.append(solve(s, t))
    print(*ans, sep="\n")

    """
    t = "abcd019"
    print(t)
    print(func_by_J(t))
    print(func_by_C(t))
    print(func_by_E(t))
    print(func_by_A(t))
    print(func_by_P(t))
    print(func_by_M(t))
    """



Measured memory_bytes: 5628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n,k,ans;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    //minを探す
    int minx=0;
    int min=a[0];
    for(int i=0;i<n;i++){
        if(a[i]<min){
            min=a[i];
            minx=i;
    }
    }
    ans=(n+k-3)/(k-1);
    //cout<<(minx+k-3)/(k-1)<<endl;
    //cout<<minx<<endl;
    if(n==k)cout<<1<<endl;

    else cout<<ans<<endl;
   

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int ans;
  if(a==b && b==c)
    ans=1;
  else if(a==b || b==c || c==a)
    ans=2;
  else
    ans=3;
  cout << ans << endl;
  return 0;
}

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

int main(){
  char a[110];
  int n;
  cin>>n>>a;
  int x=0,maxn=0;
  for(int i=0;i<n;i++){
    if(a[i]=='I')
      x++;
    else x--;
    if(x>maxn)
      maxn=x;
  }
  cout<<maxn<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 1000005
#define M 500005
#define P 998244353
int nn, n, m, ha[N + M], hb, pw, nx[N], d[N];
char a[N + M], b[M];
bool vis[N];
int hash(int l){
	return (ha[l + m - 1] - 1ll * ha[l - 1] * pw % P + P) % P;
}
int main(){
	scanf("%s", a + 1), nn = n = strlen(a + 1);
	scanf("%s", b + 1), m = strlen(b + 1);
	while (n < m){
		for (register int i = 1; i <= nn; ++i) a[n + i] = a[i];
		n += nn;
	}
	for (register int i = 1; i <= m; ++i) a[n + i] = a[i];
	nn = n + m;
	ha[0] = 0;
	for (register int i = 1; i <= nn; ++i)
		ha[i] = (1ll * ha[i - 1] * 31 + a[i] - 'a') % P;
	hb = 0, pw = 1;
	for (register int i = 1; i <= m; ++i)
		hb = (1ll * hb * 31 + b[i] - 'a') % P, pw = 1ll * pw * 31 % P;
	memset(nx, -1, sizeof nx);
	for (register int i = 1; i <= n; ++i)
		if (nx[i] == -1){
			if (hash(i) != hb) continue;
			int j = (i + m - 1) % n + 1, pre = i;
			for (; hash(j) == hb; pre = j, j = (j + m - 1) % n + 1){
				nx[pre] = j;
				if (~nx[j]) break;
			}
			if (nx[j] == -1) nx[pre] = 0;
		}
	int s = 0;
	for (register int i = 1; i <= n; ++i)
		if (~nx[i]){
			++s;
			if (nx[i] > 0) ++d[nx[i]];
		}
	int ans = 0;
	for (register int i = 1; i <= n; ++i)
		if (!d[i] && ~nx[i]){
			int len = 0;
			for (register int j = i; j; j = nx[j]) --s, ++len;
			ans = std :: max(ans, len);
		}
	if (s) printf("-1\n");
	else printf("%d\n", ans);
}

Measured memory_bytes: 15744
input_str_list = input().split(" ")
n = int(input_str_list[0])
y = int(input_str_list[1])

answer_pattern = ["-1", "-1", "-1"]

# n枚で実現できる全パターンをまず求める
for i in range(0, n+1):
  for j in range(0, (n-i)+1):
    cash_pattern = [i*10000, j*5000, (n-(i+j))*1000]
    if sum(cash_pattern) == y:
      answer_pattern = list(map(str,[i,j,n-i-j]))

print(" ".join(answer_pattern))

Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      
      int handred = N/100;
      int ten = (N/10)%10;
      int one = N%10;
      
    if(handred==7){
        System.out.println("Yes");
      }
       else if(ten==7){
        System.out.println("Yes");
      }
      else if(one==7){
        System.out.println("Yes");
      }
      else{
         System.out.println("No");
      }
    }
  }


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

int main(){

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

  long long count = 0;
  
  bool check = false;
  long long cnt = 0;
  for(int i=0; i<N; i++){
    if(i==N-1)
      break;

    if(s.at(i)==s.at(i+1)){
      check = true;
      cnt++;
      count += cnt;
    }else{
      check = false;
      cnt = 0;    
    }
    
  }

  cout << count << endl;
}

Measured memory_bytes: 7296
import sys
s = int(input())
flg=0
A = []
A.append(s)

index = 0
if s==4 or s==2 or s==1:
    print(index+4)
    sys.exit()
while flg!=1:
    if A[index]%2==0:
        f = (A[index]//2)
    else:
        f = 3*A[index]+1

    A.append(f)
    index = index + 1

    if f==4 or f==2 or f==1:
        flg=1
        break

#1,4,2,1,4

print(index+4)

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

using namespace std;

#define int long long

void solve() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    int a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) sum += a[i];
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] * 4 * m >= sum) ++cnt;
        if (cnt >= m) {
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

using namespace std;

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define FORD(i, n) for (int (i) = (int)(n) - 1; i>= 0; i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1 << 30;
const int N = 1005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

inline ll read()
{
	ll x = 0; int f = 1, c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
	return x * f;
}

int n; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	n = read(); 
	REP(i, n)
	{
		int a = read(); 
		if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0)
		{
			puts("DENIED"); 
			return 0; 
		}
	}
	puts("APPROVED"); 
	
	return 0;
}


Measured memory_bytes: 256
let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readIntArray() = readStringArray() |> Array.map (fun x -> int x)

let a, b = readIntArray() |> fun x -> (x.[0], x.[1])

(a + b) % 24
|> printfn "%d"

Measured memory_bytes: 14032
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int h, w, a, b; cin >> h >> w >> a >> b;
    vector<vector<int>> grid(h, vector<int>(w));
    rep(i, b){
        rep(j, a)grid[i][j] = 0;
        rept(j, a, w)grid[i][j] = 1;
    }
    rept(i, b, h){
        rep(j, a)grid[i][j] = 1;
        rept(j, a, w)grid[i][j] = 0;
    }
    rep(i, h){
        rep(j, w){
            cout << grid[i][j];
        }cout << ln;
    }
}
    

 


Measured memory_bytes: 7552
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1e9 + 7;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N, X, T;
    cin >> N >> X >> T;
    ll tmp = (N + X - 1) / X;
    cout << tmp * T;
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N), S(N + 1, 0);
    map<ll,ll> dic;
    dic[0]=1;
    rep(i, N)
    {
        cin >> A[i];
        S[i + 1] = A[i] + S[i];
        if(dic.count(S[i+1])){
            dic[S[i+1]]++;
        }
        else{
            dic[S[i+1]]=1;
        }
    }
    ll cnt = 0;
    for(auto x:dic)
    {
        ll num=x.second;
        cnt+=num*(num-1)/2;
    } 
    cout << cnt << endl;

 //   system("pause");
    return 0;
}

Measured memory_bytes: 15872
let () = Scanf.scanf "%d %d\n" @@ fun n t ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let maximum = Array.make n (as_.(n - 1), n - 1) in
  for i = n - 2 downto 0 do
    maximum.(i) <-
      if as_.(i) < fst maximum.(i + 1) then maximum.(i + 1)
      else (as_.(i), i)
  done;
  Array.to_list as_
  |> List.mapi (fun i a -> (fst maximum.(i) - a, snd maximum.(i)))
  |> List.fold_left (fun (maximum, is) (d, i) ->
      match compare d maximum with
      | -1 -> (maximum, is)
      | 0 ->  (d, i :: is)
      | 1 ->  (d, [i])) (min_int, [])
  |> snd
  |> List.length
  |> Printf.printf "%d\n"


Measured memory_bytes: 17152
#include<iostream>
using namespace std;
#include<map>
#include<unordered_map>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#define int long long int
#define mod 1000000007
int power(int a,int b)
{
	int x=pow(a,b);
	return x;
}
int function2(int arr[],int initial,int final,int mat[][13],int value,int total,int n,int memo[][4101])
{
	if(initial>final)
	{
		if(value==total)
		   return 0;
		else
		   return 1000000000;
	}
	if(memo[initial][value]!=-1)
	    return memo[initial][value];
	else
	{
		int newval=value;
		int j;
		for(j=0;j<n;j++)
		{
			if(mat[initial][j]==1)
			{
				newval|=power(2,j);
			}
		}
		int x=arr[initial]+function2(arr,initial+1,final,mat,newval,total,n,memo);
		int y=function2(arr,initial+1,final,mat,value,total,n,memo);
		memo[initial][value]=min(x,y);
		return memo[initial][value];
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int k;
	cin>>k;
	int arr[n],j;
	int answer=0;
	for(j=0;j<n;j++)
	{
		cin>>arr[j];
	}
	for(j=0;j<n;j++)
	{
		if(arr[j]>=k)
		  answer++;
	}
	cout<<answer<<endl;
}


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

int main()
{
  ll a, b, c, x, y; cin>>a>>b>>c>>x>>y;

  int tan = a*x + b*y;
  int half = max(x,y) * c * 2;

  int tan_half = 0;
  if (min(x, y) == x) {
    tan_half = x*c*2 + (y-x)*b;
  } else {
    tan_half = y*c*2 + (x-y)*a;
  }

  cout << min(min(tan,half),tan_half) << endl;

  return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)cin>>a[i];
	int dp[n+1][k+1];
	for(int i=1;i<=k;i++){ dp[0][i]=0; }
	dp[0][0]=1;
	int pref[k+1]={};
	for(int i=1;i<=n;i++)
	{
	 pref[0]=dp[i-1][0];	
	 for(int j=1;j<=k;j++)
	 {
	 	pref[j]=(pref[j-1]+dp[i-1][j] )%mod;
	 }
	 for(int j=0;j<=k;j++)
	 {
	 	int tr=pref[j];  
            int unreachable=j-a[i]-1;
            if(unreachable>=0)
            {
                tr=(tr-pref[unreachable]+mod)%mod; 
            }
            dp[i][j]=tr;
	 }
	}
	cout<<dp[n][k];
}

Measured memory_bytes: 40064
#include <stdio.h>

int main(void) {
	
	for(;;) {
		int cSweet;							/*お菓子の個数*/
		int infSw[1000][5] = {0};			/*お菓子の情報ipqrC*/
		int conSw[4] = {0};					/*ipqrCの制限値*/
		int clrSw[1000] = {0};				/*許可されたお菓子のフラグ*/
		int i, j, f;						/*for文制御用*/
		
		scanf("%d", &cSweet);			/*0が入力されたら終了する*/
		if(cSweet == 0)			break;
		
										/*お菓子の情報infSwを入力する*/
		for(i = 0; i < cSweet; i++) {
			for(j = 0; j < 4; j++) {
				scanf("%d", &infSw[i][j]);
				if(j == 1 || j == 3)	infSw[i][4] += 4 * infSw[i][j];
				else if(j == 2)			infSw[i][4] += 9 * infSw[i][j];
			}
		}
		
		scanf("%d %d %d %d", &conSw[0], &conSw[1], &conSw[2], &conSw[3]);
										/*制限値を入力する*/
		
										/*フラグを立てる*/
		for(i = 0; i < cSweet; i++) {
			f = 0;
			if(infSw[i][1] > conSw[0]) f = 1;		/*pの比較*/
			if(infSw[i][2] > conSw[1]) f = 1;		/*qの比較*/
			if(infSw[i][3] > conSw[2]) f = 1;		/*rの比較*/
			if(infSw[i][4] > conSw[3]) f = 1;		/*Cの比較*/
			if(f == 0)		clrSw[i] = 1;
		}
		
		f = 0;
		for(i = 0; i < cSweet; i++) {
			if(clrSw[i] == 1){
				printf("%d\n", infSw[i][0]);
				f = 1;
			}
		}
		
		if(f == 0)		puts("NA");
	}
	
	return 0;
}

Measured memory_bytes: 644
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a, b;
	cin >> a >> b;
	if (16 - a - b >= abs(a - b)) cout << "Yay!\n";
	else cout << ":(\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N);
    for(int i = 0;i < N;i++){
        scanf("%d",&A[i]);
        B[i] = A[i];
    }
    sort(A.begin(),A.end());
    int l = A[N/2-1],r = A[N/2];
    for(int i = 0;i < N;i++){
        printf("%d\n",B[i] > l ? l : r);
    }
}

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

int main(){
  int N,T;
  cin>>N>>T;
  long long ans=0;
  int logt; cin>>logt;
  for(int i=0;i<N-1;i++){
    int t; cin>>t;
    if(t-logt>T) ans+=T;
    else ans+=t-logt;
    logt=t;
  }
  cout<<T+ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define CL clear()



int main()
{

   string a, b;
   cin >> a >> b;
   for(ul i = 0; i < b.length(); i++) cout <<a[i]<<b[i];
   if(a.length()-b.length()) cout << a[a.length()-1];


}




Measured memory_bytes: 256
#include <cstdio>


int W, H;
char Maps[120][120];
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
void dfs(int x, int y);
int ans;

int main(void) {
    while (scanf("%d %d\n", &H, &W)!=EOF) {
        if (H*W==0) break;
        
        for (int i = 0; i<H; i++)
            scanf("%s", Maps[i]);
        
        for (int i = 0; i<H; i++)
            for (int j = 0; j<W; j++)
                if (Maps[i][j]!=' ') {
                    dfs(i, j);
                    ans++;
                }
        
        printf("%d\n", ans);
        ans = 0;
    }
    return 0;
}

void dfs(int x, int y) {
    char tmp = Maps[x][y];
    Maps[x][y] = ' ';
    for (int i = 0; i<4; i++) {
        int nx = x+dx[i], ny = y+dy[i];
        if (nx>=0 && nx<H && ny>=0 && ny<W && Maps[nx][ny]==tmp) dfs(nx, ny);
    }
}

Measured memory_bytes: 1516
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main()
{
	int a = 0, b = 0, ab = 0, o = 0, n;
	char bld[3];

	while(scanf("%d,%s", &n, bld) != EOF){
		if(bld[1] == 'B')    ab++;
		else if(bld[0] == 'A')    a++;
		else if(bld[0] == 'B')    b++;
		else if(bld[0] == 'O')    o++;
	}

	cout << a << endl << b << endl << ab << endl << o << endl;
	
	return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	string s1, s2, s3; cin >> s1 >> s2 >> s3;

	cout << (char)(s1[0] - 'a' + 'A');
	cout << (char)(s2[0] - 'a' + 'A');
	cout << (char)(s3[0] - 'a' + 'A');
	cout << endl;


	return 0;

}


Measured memory_bytes: 256
// AOJ 0234: Aizu Buried Treasure
// 2018.1.19 bal4u

#include <stdio.h>
#include <string.h>

#define QMAX 10000
typedef struct { int y, x, o, c, s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].c < que[i].c) min = l; else min = i;
	if (r < qsize && que[r].c < que[min].c) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int y, int x, int o, int c, int s)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].y = y, que[i].x = x, que[i].o = o, que[i].c = c, que[i].s = s;
	while (i > 0 && que[min = PARENT(i)].c > que[i].c) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x30303030
int w, h, f, m;
int air[10][10], cost[10][10];
int mv[3][2] = {{0,-1},{1,0},{0,1}};
int dist[10][10][50][1024];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();

	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}

	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int dijkstra(int o)
{
	int i, x, y, c, s, x2, y2, o2, c2, s2;

	memset(dist, INF, sizeof(dist));
	qsize = 0;
	for (x = 0; x < w; x++) enq(-1, x, o, 0, 1 << x);
	while (qsize) {
		x = que[0].x, y = que[0].y, o = que[0].o, c = que[0].c, s = que[0].s, deq();
		if (y == h-1) return c;

		for (i = 0; i < 3; i++) {
			y2 = y + mv[i][0], x2 = x + mv[i][1];
			if (y2 < 0 || x2 < 0 || x2 >= w || o <= 1) continue;
			c2 = c, o2 = o-1;
			if (i == 1) s2 = 1 << x2;
			else        s2 = s | (1 << x2);
			if (i == 1 || s2 != s) {
				c2 += cost[y2][x2];
				o2 += air[y2][x2]; if (o2 > m) o2 = m;
			}
			if (c2 > f) continue;
			if (dist[y2][x2][o2][s2] <= c2) continue;
			dist[y2][x2][o2][s2] = c2;
			enq(y2, x2, o2, c2, s2);
		}
	}
	return -1;
}

int main()
{
	int o, x, y, t, ans;

	while (w = in()) {
		h = in();
		f = in(), m = in(), o = in();
		for (y = 0; y < h; y++) for (x = 0; x < w; x++) {
			t = in();
			if (t >= 0) air[y][x] = t, cost[y][x] = 0;
			else        air[y][x] = 0, cost[y][x] = -t;
		}
		ans = dijkstra(o);
		if (ans < 0) puts("NA");
		else printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 21684
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;

ll gcd(ll a, ll b){
  if(a%b == 0) return b;
  else return gcd(b,a%b);
}

int main(){
  ll A,B;
  cin >>A>>B;
  ll AB = gcd(A,B);
  ll stop = sqrt(AB);
  vector<int> fact(1,1);
  ll i = 2;
  while(AB>1){
    if(i > stop){
      fact.push_back(i);
      break;
    }
    if(AB%i == 0){
      fact.push_back(i);
      while(AB%i == 0){
        AB /= i;
      }
    }else i += (i == 2) ? 1 : 2;
  }
  cout << fact.size() << endl;
}

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

tmp=0
for i in p[:k]:
    tmp+=(1+i)/2
li=[tmp]

for i in range(0,n-k):

    tmp=li[i]
    tmp-=(1+p[i])/2
    tmp+=(1+p[k+i])/2
    
    li.append(tmp)


print(max(li))
    

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

int main(){
  string n;
  cin >> n;
  for(int i = 0;i < n.size();i++){
    if(n.substr(i,1)== "1"){
      cout << 9;
    }
    else cout << 1;
  }
  cout << endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s;
int l;

int main() {
	cin >> s;
	l = (int)s.length();
	
	// どちらかのプレイヤーが操作を行えなくなったときの最終的なsはababab...のように異なる2文字が交互に並んでいるはず
	// (abcのように異なる3文字が連続する箇所があればまだ真ん中の文字を取り除ける)
	// 最終的なsの長さの偶奇は一意に決まる sの先頭と末尾が同じならababaのように奇数になり、異なればababのように偶数になる
	// 最初のsの長さの偶奇と最後の偶奇からターン数がわかる
	if ((l%2==0 && s[0]==s[l-1]) || (l%2==1 && s[0]!=s[l-1])) cout << "First" << ln;
	else cout << "Second" << ln;
}

Measured memory_bytes: 512
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    long long K;
    cin >> n;
    cin >> K;

    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
        --A[i];
    }

    int h = 0;
    while (h < 63 && 1LL << (h + 1) <= K) {
        ++h;
    }
    vector<vector<int>> nexts(n, vector<int>(h + 1, -1));

    for (int i = 0; i < n; ++i) {
        nexts[i][0] = A[i];
    }

    for (int i = 1; i <= h; ++i) {
        for (int j = 0; j < n; ++j) {
            nexts[j][i] = nexts[nexts[j][i - 1]][i - 1];
        }
    }

    int res = 0;
    for (int i = h; i >= 0; --i) {
        if (K & (1LL << i)) {
            res = nexts[res][i];
        }
    }

    cout << (res + 1) << '\n';

    return 0;
}

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

int f (int x) {
    int sum = 0;
    while (x != 0) {
        sum += x%10;
        x /= 10;
    }
    return sum;
}

int main() {
    int N;
    cin >> N;
    int mini = 99999;
    for (int i=1; i<N; i++) {
        int sum = f(i) + f(N-i);
        mini = min(mini, sum);
    }
    cout << mini << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int k;
    scanf("%d",&k);
    if(k % 2 == 0 || k % 5 == 0){
        puts("-1");
        return 0;
    }
    if(k == 1){
        puts("1");
        return 0;
    }
    if(k % 7 == 0)
        k /= 7;
    int l = 9 * k;
    int ans = 0;
    int p = 1;
    do{
        p *= 10;
        p %= l;
        ans++;
    }while(p != 1);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

int main(){

  vector<int> a(4, 0);
  REP(i, 6){
    a[in()-1]++;
  }
  sort(a.begin(), a.end());

  if(a.back() == 2){
    puts("YES");
  } else {
    puts("NO");
  }
  
  return 0;
}


Measured memory_bytes: 256
def max2(x,y):
    return x if x > y else y

def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c

N = int(input())
data = [[] for _ in range(N)]
res = 0
for i in range(N):
    for _ in range(int(input())):
        data[i].append(tuple(map(int, input().split())))
for n in range(1 << N):
    flg = False
    for i in range(N):
        for x, y in data[i]:
            x -= 1
            if (n>>i)&1 == 1:
                if (n>>x)&1 != y:
                    flg = True
                    break
        if flg:
            break
        if i == N-1:
            res = max2(res, popcnt(n))
print(res)


Measured memory_bytes: 73284
#include <cstdio>
#include <cstring>

using namespace std;

// 線路の情報の構造体

typedef struct _lnInfo{
	int cost;
	int time;
}lnInfo;

// 問い合わせの構造体

typedef struct _Req{
	int p;
	int q;
	int r;
}Req;


int main(void){
	int n, m, k, i, j, a, b, cost, time, ans;
	lnInfo st[100][100];
	Req rq;
	while(1){
		scanf("%d%d",&n,&m);
		if(n == 0 && m == 0){
			break;
		}
		memset(st,-1,sizeof(st));
		for(i = 0;i < n;i++){
			scanf("%d%d%d%d",&a,&b,&cost,&time);
			st[a - 1][b - 1].cost = st[b - 1][a - 1].cost = cost;
			st[a - 1][b - 1].time = st[b - 1][a - 1].time = time;
			
		}
		for(i = 0;i < m;i++){
			for(j = 0;j < m;j++){
				for(k = 0;k < m;k++){
					if(st[j][i].cost != -1 && st[i][k].cost != -1 && (st[j][k].cost == -1 || st[j][k].cost > st[j][i].cost + st[i][k].cost)){
						st[j][k].cost = st[j][i].cost + st[i][k].cost;
					}
					if(st[j][i].time != -1 && st[i][k].time != -1 && (st[j][k].time == -1 || st[j][k].time > st[j][i].time + st[i][k].time)){
						st[j][k].time = st[j][i].time + st[i][k].time;
					}
				}
			}
		}
		scanf("%d",&k);
		for(i = 0;i < k;i++){
			scanf("%d%d%d",&rq.p,&rq.q,&rq.r);
			if(rq.r == 0){
				ans = st[rq.p - 1][rq.q - 1].cost;
			}else{
				ans = st[rq.p - 1][rq.q - 1].time;
			}
			printf("%d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 1112
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<ll,ll> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]

int main(){
    int n,m; cin >> n >> m;
    vector<vector<int>> to(n+m);
    rep(i,n){
        int k; cin >> k;
        rep(j,k){
            int l; cin >> l;
            l--;
            to[i].pb(n+l);
            to[n+l].pb(i);
        }
    }
    vector<bool> visit(n+m,0);
    queue<int> q;
    visit[0]=1;
    q.push(0);
    while(!q.empty()){
        int v=q.front(); q.pop();
        for(auto u:to[v]){
            if(!visit[u]){
                visit[u]=1;
                q.push(u);
            }
        }
    }
    bool ans=1;
    rep(i,n){
        if(!visit[i]) ans=0;
    }
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 8952
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
#define endl '\n'
using namespace std;
set<int> adj[200001];
bool vis[200001];
int cnt = 0;
void dfs(int x){
    cnt++;
    for(auto i : adj[x]){
        if(!vis[i]){
            vis[i] = 1; dfs(i);
        }
    }
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        adj[a].insert(b); adj[b].insert(a);
    }
    int res = 0;
    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            vis[i] = 1; cnt = 0; dfs(i); res = max(res, cnt);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 38120
sa = list(input())
sb = list(input())
sc = list(input())
turn = "a"
while 1:
  if turn == "a":
    if len(sa) == 0:
      break
    turn = sa.pop(0)
  elif turn == "b":
    if len(sb) == 0:
      break
    turn = sb.pop(0)
  elif turn == "c":
    if len(sc) == 0:
      break
    turn = sc.pop(0)
print(turn.upper())

Measured memory_bytes: 3064
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readInt()
  val points :Seq[(Int,Int)] = for(i <- 1 to n) yield {
    val Array(a,b,_*) = StdIn.readLine().split(' ').map(_.toInt)
    (a,b)
  }
  val sin45 = math.sin(Math.PI/4)
  val cos45 = math.cos(Math.PI/4)
  def rotate(point:(Int,Int)):(Double,Double)={
    val (x,y) = point
    (x*cos45-y*sin45,x*sin45+y*cos45)
  }

  def dist(point1:(Int,Int),point2:(Int,Int)):Int={
    val (x1,y1) = point1
    val (x2,y2) = point2
    math.abs(x1-x2) + math.abs(y1-y2)
  }
  val pointRot = points.map(rotate)

  val maxX = pointRot.map(_._1).zipWithIndex.maxBy(_._1)._2
  val minX = pointRot.map(_._1).zipWithIndex.minBy(_._1)._2
  val maxY = pointRot.map(_._2).zipWithIndex.maxBy(_._1)._2
  val minY = pointRot.map(_._2).zipWithIndex.minBy(_._1)._2
  val ans = math.max(dist(points(maxX),points(minX)),dist(points(maxY),points(minY)))
  println(ans)
}







Measured memory_bytes: 127216
/*

_/\_


*/


#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,r,n) for(int i=r; i<=n; i++)
#define sz(v) (int)(v).size()
#define vec(x) vector < x >
using vi = vector < int >;
using mii = map <int , int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
using int64 = long long;
const int inf = 2e9 + 7;
const char nwl = '\n';
const int mxx = 1e6 + 3;
int64 sumV(vi &v) {
	int64 s = 0;
	for (int x : v) {
		s += (int64)x;
	}
	return s;
}
int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a % b);
}
//const int64 biGinf = 9e+18;
//const string yo = "YES\n", no = "NO\n";


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	int n;
	cin >> n;
	if (n >= 1800) n = 1;
	else if (n >= 1600) n = 2;
	else if (n >= 1400) n = 3;
	else if (n >= 1200) n = 4;
	else if (n >= 1000) n = 5;
	else if (n >= 800) n = 6;
	else if (n >= 600) n = 7;
	else if (n >= 400) n = 8;
	cout << n;

	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    int x, y;
    while (scanf("%d %d\n", &x, &y)){
        if (x == 0 && y == 0) break;
        if (x > y) {
            int tmp = x;
            x = y;
            y = tmp;
        }
        printf("%d %d\n", x, y);
    }
    return 0;
}



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N, M;
    cin >> N >> M;
    if(abs(N - M) > 1) {
        cout << 0 << endl;
        return 0;
    }

    LL res = 1;
    for(int i = 2; i <= N; ++i) {
        res = res * i % MOD;
    }
    for(int i = 2; i <= M; ++i) {
        res = res * i % MOD;
    }
    if(N == M) res = res * 2 % MOD;
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 384