akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void)
{
  int aa, bb, m;
  scanf("%d %d %d", &aa, &bb, &m);
  int a[aa], b[bb], i;
  int min_a = 100000, min_b = 100000;
  for (i = 0; i < aa; i++)
  {
    scanf("%d", &a[i]);
    if (min_a > a[i])
      min_a = a[i];
  }
  for (i = 0; i < bb; i++)
  {
    scanf("%d", &b[i]);
    if (min_b > b[i])
      min_b = b[i];
  }
  int x[m], y[m], c[m];
  for (i = 0; i < m; i++)
    scanf("%d %d %d", &x[i], &y[i], &c[i]);
  
  int ans = min_a + min_b;
  int sum;
  for (i = 0; i < m; i++)
  {
    sum = a[x[i] - 1] + b[y[i] - 1] - c[i];
    if (ans > sum)
    {
      ans = sum;
    }
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 2176
S = input()
N = len(S)
odds = []
even = []

if N == 1:
    print(0)
#奇数番目と偶数番目で別にリスト化する
else:
    for i in range(N):
        if i % 2 == 1:
            odds.append(int(S[i]))
        else:
            even.append(int(S[i]))
    #print(odds)
    #print(even)
    n1 = len(odds)
    n2 = len(even)
    ans1 = 0
    ans2 = 0
    for j in range(n1):
        if odds[j] == 1:
            ans1 += 1
    for k in range(n2):
        if even[k] == 0:
            ans1 += 1

    for n in range(n1):
        if odds[n] == 0:
            ans2 += 1
    for m in range(n2):
        if even[m] == 1:
            ans2 +=1

    print(min(ans1, ans2))


Measured memory_bytes: 4220
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int a[][] = new int[M][2];
		for(int i = 0; i < M; i++) {
			a[i][0] = sc.nextInt() - 1;
			a[i][1] = sc.nextInt() - 1;
		}

		int ans = 0;
		for(int k = 0; k < M; k++) {
			UnionFind.init(N);
			for(int i = 0; i < M; i++) {
				if(i == k) continue;
				UnionFind.unite(a[i][0], a[i][1]);
			}
			if(!UnionFind.same(a[k][0], a[k][1])) ans++;
		}
		
		System.out.println(ans);
	}
}

class UnionFind {
	static int N;
	static int par[];
	static int rank[];
	public static void init(int n) {
		N = n;
		par = new int[N];
		rank = new int[N];
		for(int i = 0; i < N; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	public static int find(int x) {
		if(par[x] == x) {
			return x;
		} else {
			return par[x] = find(par[x]);
		}
	}

	public static void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	public static boolean same(int x, int y) {
		return find(x) == find(y);
	}
}

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

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    ll a[n+1], b[m+1];
    a[0] = 0;
    b[0] = 0;
    rep(i, n){
        int t;
        cin >> t;
       a[i+1] = a[i] + t;
    }
    rep(i, m){
        int t;
        cin >> t;
        b[i+1] = b[i] + t;
    }
    int ans = 0;
    int j = m;
    rep(i, n+1){
        if(a[i] > k){
            break;
        }
        while(b[j] + a[i] > k){
            j--;
        }
        ans = max(ans, i + j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6716
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;

/*----------macros----------*/

//input, output================
#define fastio                          \
std::ios::sync_with_stdio(false);       \
std::cin.tie(nullptr);                  \
std::cout.tie(nullptr)

#define endl '\n'
#define fcout(a)                        \
cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF    = (ll)1e9 + 1;
constexpr ll INFll  = (ll)1e18 + 1;
constexpr ll MOD1   = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define snd second

//others================
#define sz(x)                           \
(int) x.size()

#define all(x)                          \
(x).begin(), (x).end()

#define rall(x)                         \
(x).rbegin(), (x).rend()

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

#define reps(i, n)                      \
for(int i = 1; (i) <= (n); ++(i))

#define rrep(i, n)                      \
for(int i = n - 1; (i) >= 0 ; --(i))

#define repbit(bit, n)                  \
for(int bit = 0; (bit) < (1 << (n)); ++(bit))

#define ifbit(bit, i)                   \
if((bit) & (1 << (i)))

#define CtoI(c)                         \
int((c)) - int('0')

#define ItoC(c)                         \
char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b)
{ return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b)
{ return a > b && (a = b, true); }

// Vi  dx = {1, 0, -1, 0},
//     dy = {0, 1, 0, -1};

// Vi  dx2 = { 1,1,0,-1,-1,-1,0,1 },
//     dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
fastio;

    int a, b, t; cin >> a >> b >> t;

    int cnt = 0;
    reps(i, t){
        if(i%a == 0) ++cnt;
    }

    cout << b * cnt << endl;

return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double n = sc.nextDouble();
		double count = b-1;
		if(n < b-1) {
			count = n;
		}

		System.out.println((int)(Math.floor(a * count/b) -(a * Math.floor(count/b))));
	}
}

Measured memory_bytes: 28760
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

#define MOD 1000000007
using namespace std;
int main() {
    IOS
    int t;
    cin >> t;
    if(t >= 30 ) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }   
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

int main(){
    int h,w; cin>>h>>w;
    vector<string> a(h);
    rep(i,0,h) cin>>a[i];

    vector<bool> hcheck(h,1);
    vector<bool> wcheck(w,1);
    rep(i,0,h){
        bool ok=true;
        rep(j,0,w){
            if(a[i][j]=='#') ok=false;
        }
        if(ok) hcheck[i]=0;
    }

    rep(j,0,w){
        bool ok=true;
        rep(i,0,h){
            if(a[i][j]=='#') ok=false;
        }
        if(ok) wcheck[j]=0;
    }

    int H=0;
    int hsize=0;
    rep(i,0,h){
        if(hcheck[i]==1) hsize++;
    }
    vector<vector<char>> ans(hsize);
    rep(i,0,h){
        if(hcheck[i]==0) continue;
        rep(j,0,w){
            if(wcheck[j]==0) continue;
            ans[H].push_back(a[i][j]);
        }
        H++;
    }
    rep(i,0,ans.size()){
        rep(j,0,ans[i].size()){
            cout<<ans[i][j];
        }
        cout<<endl;
    }

}

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

int main() {

    int X, Y;
    cin >> X >> Y;

    if (Y - 2*X >= 0 && (Y-2*X)%2 == 0 && 4*X-Y >= 0 && (4*X-Y)%2 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


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

S1, S2 = 0, sum(A)
L = []
for i in range(N):
  L.append(abs(S1 - S2))
  S1, S2 = S1 + A[i], S2 - A[i]
print(min(L))

Measured memory_bytes: 26764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 200005

using namespace std;

int main()
{
    ll n,x=1;

    scanf("%lld",&n);

    ll mx=0;

    for(ll i=1; i<=n; i++)
    {
        ll m=i,cnt=0;

        while(1)
        {
            if(m%2==0)
                cnt++;

            else
                break;

            m=m/2;
        }

        if(cnt>mx)
        {
            mx=cnt;
            x=i;
        }
    }

    printf("%lld\n",x);

    return (0);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
int main() {
    int n , k;
    cin >> n >> k;
    int p[n];
    for (int i = 0; i < n; i++)
    {
        cin>>p[i];
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n-1; j++)
        {
            if(p[j]>p[j+1]){
                swap(p[j],p[j+1]);
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i < k; i++)
    {
        ans+=p[i];
    }
    

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

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

int sum(int a){
  int b = a,sum = 0;
  while(b > 0){
    a =  b % 10;
    sum += a;
    b /= 10;
  }
  return sum;
}
  
int main(){
  int N,c = 46;
  cin >> N;
  for(int i=1;i<N;i++){
  	c = min(c,sum(i)+sum(N-i));
  }
  cout << c << endl;
}

Measured memory_bytes: 256
/*
				" اللهم صلي و سلم علي سيدنا محمد و علي اله وصحبه اجمعين "
*/


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define f for
#define ll long long
#define ull unsigned long long
#define endl "\n"
using namespace std;
#define BI  acos(-1)
#define all(a) a.begin(), a.end()
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a % b);
}
void madesetprobblem()
{
	//$ $
	//less than or equal => $ 1 \leq 100 $
	//  $(1 \le A,B \le 10^5 )$
	// a[i] => $a_i$
	// a[i][j] => $a_{i,j}$
	// double qoutes ''yext''
	/*
		image
		\begine{center}
		\includegraphics{image.jpg}
		\end{center}
	*/
	/*
		list
		\begin{itemize}
			\item first one
			\item second one
		\end{itemize}
	*/
}
int n;
vector<int>a(1e5 + 2),dp(1e5+2,-1);
ll ans(int c = 0)
{
	if (c == n-1)
		return 0;
	int ans1 = INT_MAX, ans2 = INT_MAX;
	if (dp[c] != -1)
		ans1 = dp[c];
	else
	{
		if (c + 1 < n)
			ans1 = (abs(a[c] - a[c + 1]) + ans(c + 1));
		if (c + 2 < n)
			ans2 = (abs(a[c] - a[c + 2]) + ans(c + 2));
		dp[c] = min(ans1, ans2);
	}
	//cout <<c<<" "<< ans1 << " " << ans2 << endl;
	return min(ans1,ans2);
}
int main()
{
	// توكلت علي الله 
//Open();
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	f(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	cout << ans();
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 5;
const int inf = 1e18 + 9;
int a[N], pre[N], suf[N], sum[N];

signed main()
{
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];

		if(a[i] > 0)
			pre[i] = pre[i - 1] + a[i];
		else
			pre[i] = pre[i - 1];
	}

	for(int i = n; i >= 1; i--)
	{
		if(a[i] > 0)
			suf[i] = suf[i + 1] + a[i];
		else
			suf[i] = suf[i + 1];
	}

	int ans = -inf;
	for(int l = 1; l + k - 1 <= n; l++)
	{
		int r = l + k - 1;

		int res = max(sum[r] - sum[l - 1], 0LL) + pre[l - 1] + suf[r + 1];
		ans = max(ans, res);
	}

	cout << ans;
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim(){
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for(int i=0; i<n; i++){
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while(1){
        minv = INFTY;
        u = -1;
        for(int i=0; i<n; i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) break;
        color[u] = BLACK;
        for(int v=0; v<n; v++){
            if(color[v] != BLACK && M[u][v] != INFTY){
                if(d[v] > M[u][v]){
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for(int i=0; i<n; i++){
        if(p[i] != -1) sum += M[i][p[i]]; //辺の重みの総和を計算
    }

    return sum;
}

int main(){
    cin >> n;

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            int e; cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }

    cout << prim() << endl;

    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define ll long long 
#define MM(arr,x) memset(arr,x,sizeof(arr))
#define INF 0x3f3f3f3f
#define Maxn 1e5+10;
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	ll n,d;
	cin>>n>>d;
	int ans = 0;
	while(n--)
	{
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d) ans++;
	} 
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 3640
// https://atcoder.jp/contests/abc169/tasks/abc169_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

// 素因数分解
map<int, int> factorize(int n) {
    map<int, int> V;

    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            V[i]++;
            n /= i;
        }
    }
    if (n > 1)
        V[n]++;
    return V;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    auto mp = factorize(N);
    int ans = 0;

    for (auto &x : mp) {
        int a = x.second;
        int b = 1;
        while (a > 0) {
            a -= (b++);
            if (a >= 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int n,a=0,b=0,c=0,d=0;
    string s;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        if(s=="AC")
        {
            a++;
        }
        else if(s=="WA")
        {
            b++;
        }
        else if(s=="TLE")
        {
            c++;
        }
        else if(s=="RE")
        {
            d++;
        }
    }
    cout<<"AC x "<<a<<endl<<"WA x "<<b<<"\nTLE x "<<c<<"\nRE x "<<d<<endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N; cin>>N;
    vector<int> place(N);
    int a;
    for (int i = 1; i <=N; ++i) {
        cin>>a; --a;
        place[a]=i;
    }

    set<int> used={-1,0,place[N-1],N+1,N+2};
    int r1,r2,l1,l2;
    ll ans=0ll;
    for (int i = N-2; i >= 0; --i) {
        auto itr = used.lower_bound(place[i]);
        r1=*itr;
        ++itr;
        r2=*itr;
        --itr; --itr;
        l1=*itr;
        --itr;
        l2=*itr;

        ll cnt=0ll;
        if(r2!=N+2)cnt+=(ll)(place[i]-l1)*(r2-r1);
        if(l2!=-1)cnt+=(ll)(l1-l2)*(r1-place[i]);

        ans+=cnt*(i+1);
        //cout<<i+1<<" "<<cnt<<endl;
        used.insert(place[i]);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
#include <tuple>
#include <queue>
#include <stack>
#define inf 100100100
using namespace std;
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
#define pb push_back
#define INF (1<<31)
#include<iostream>
#include<string>
using namespace std;
int dp[1010][1010] = {};
int main(){
    int h,w,n;
    int sy,sx;
    cin >> h >> w >> n;
    cin >> sy >> sx;
    string s;
    string t;
    cin >> s;
    cin >> t;
    int u=0;
    int d=0;
    int l=0;
    int r=0;
    int mu=0;
    int md=0;
    int ml=0;
    int mr=0;
    rep(i,n){
        switch(s[i]){
            case 'U':
                u++;
            break;
            case 'R':
                r++;
            break;
            case 'D':
                d++;
            break;
            case 'L':
                l++;
            break;
        }
        // cout << "r : " << r << endl;
        // cout << "ml : " << ml << endl;
        // cout << endl;
        if( sy-u+md<=0 ||
            sy+d-mu>h ||
            sx-l+mr<=0 ||
            sx+r-ml>w){
            cout << "NO" << endl;
            return 0;
        }
        switch(t[i]){
            case 'U':
                mu++;
            break;
            case 'R':
                mr++;
            break;
            case 'D':
                md++;
            break;
            case 'L':
                ml++;
            break;
        }
        if(r>0 && ml>0){
            if(r>ml){
                r = r-ml;
                ml = 0;
            }else{
                ml = ml - r;
                r = 0;
            }
        }
        if(sx-ml<=0){
            ml--;
        }
        if(d>0){
            if(d>mu){
                d = d-mu;
                mu = 0;
            }else{
                mu = mu - d;
                d = 0;
            }
        }
        if(sy-mu<=0){
            mu--;
        }
        if(l>0){
            if(l>mr){
                l = l-mr;
                mr = 0;
            }else{
                mr = mr - l;
                l = 0;
            }
        }
        if(sx+mr>w){
            mr--;
        }
        if(u>0){
            if(u>md){
                u = u-md;
                md = 0;
            }else{
                md = md - u;
                u = 0;
            }
        }
        if(sy+md>h){
            md--;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

int main(){
	char s[1200];
	int c = 0;
	while(1){
		scanf("%c", &s[c]);
		if(s[c] == '\n') break;
		if(isalpha(s[c])){
			if(islower(s[c])){
				s[c] = toupper(s[c]);
			}
			else{
				s[c] = tolower(s[c]);
			}
		}
		cout << s[c];
		c++;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  string S;
  cin >> S;
  
  vector<bool> flag(3, false);
  rep(i,S.size()) {
    if (S.at(i) == 'a') flag.at(0) = true;
    if (S.at(i) == 'b') flag.at(1) = true;
    if (S.at(i) == 'c') flag.at(2) = true;
  }
  
  if (count(all(flag), false) == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
  int K,S;
  int num=0;
  cin >> K >> S;
  for(int x=0;x<=K;x++){
    for(int y=0;y<=K;y++){
      if(S-x-y>=0&&K>=S-x-y) num++;
    }
  }
  cout << num;
}


Measured memory_bytes: 3640
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int MAX = 10000;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int x = sc.nextInt();
			if( (n|a|b|c|x) == 0 ) break;
			
			int y[] = new int[n];
			for(int i=0;i<n;i++) y[i] = sc.nextInt();
			
			int i, j = 0;
			for(i=0;i<=MAX;i++) {
				if( x == y[j] ) j++;
				if( j == n ) break;
				x = (a * x + b) % c;
			}
			
			System.out.println( (i>MAX? -1:i) );
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

char	grade(int m, int f, int r)
{
	if (m == -1 || f == -1)
		return 'F';
	if (m + f >= 80)
		return 'A';
	if (m + f >= 65)
		return 'B';
	if (m + f >= 50 || (m + f >= 30 && r >= 50))
		return 'C';
	if (m + f >= 30) 
		return 'D';
	return 'F';
}

int	main()
{
	int	m, f, r;
	while (cin >> m >> f >> r) {
		if (m == -1 && f == -1 && r == -1) break;
		cout << grade(m, f, r) << endl;
	}
}


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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

ll addmod(ll a,ll b)
{
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a %=mod;
    b%=mod;
    return (a*b)%mod;
}
ll submod(ll a,ll b)
{
    ll x  = a-b;
    if(x<0)x+=mod;
    x%=mod;
    return x;
}
bool comp(pair<pi,ll>a,pair<pi,ll>b)
{
    if(a.fi.fi==b.fi.fi)return a.fi.se<b.fi.se;
    return a.fi.fi<b.fi.fi;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
string s; cin>>s;
ll n =s.size();
string ans = s;
rep(i,0,n)
{
    if(s[i]=='?')s[i]='D';
}
cout<<s<<endl;
return 0;
}
/*
5 10 10
22 23
17 19
13 17
8 12
2 6
*/


Measured memory_bytes: 3756
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAXN = 1000002;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
#define fill(x,y) memset(x,y,sizeof(x))
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll mul(ll x, ll y)
{
    return (x * 1ll * y) % MOD;
}

ll fastpow(ll x, ll y)
{
    ll z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}
/*struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.ff.ff == b.ff.ff) {
      return a.ff.ss < b.ff.ss;
    }
    return a.ff.ff <b.ff.ff;
  }
};*/
inline int ask(int x, int y){
	cout<<"?"<<" "<<x<<" "<<y<<"\n"<<flush; 
	int ret; cin>>ret; 
	if(ret == -1)exit(0); 
	return ret; 
}

int main(int argc, char** argv)
{
  sws ;  
  cout<<setprecision(20); 
 // tcase
  {
  ll s=0 ;
  ll n ;
  cin>>n ;
  ll a[n] ;
  map<ll,ll>mp ;
  forn(i,n)
  {
  cin>>a[i] ;
  mp[a[i]]++ ;
  s+=a[i];
  }
  ll q ;
  cin>>q ;
  while(q--)
  {
  	ll b,c ;
  	cin>>b>>c ;
  	ll temp=mp[b] ;
  	s+=temp*(c-b) ;
  	mp[b]=0 ;
  	mp[c]+=temp ;
  //	cout<<mp[c]<<" "<<c<<"\n";
  	cout<<s<<"\n";
  }
  
  
  }
  
  return 0 ;
}

Measured memory_bytes: 10244
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int a, b, c, d, p;
	cin >> a >> b >> c >> d >> p;
	int x, y;
	x = a * p;
	y = b;
	if (p > c) {
		y += d * (p-c);
	}
	cout << min(x, y) << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
long long int PredictTheWinner(long long int A[], int n){
        
       long long int dp[n][n];
       long long int sum[n][n];
        sum[0][0] = A[0];
        dp[0][0] = A[0];

        for (int i = 1; i < n; ++i) {
            sum[0][i] = sum[0][i - 1] + A[i];
            sum[i][i] = A[i];
            dp[i][i] = A[i];
            for (int j = i - 1; j >= 0; --j) {
                sum[j][i] = sum[0][i] - (j == 0 ? 0 : sum[0][j - 1]);
                dp[j][i] = max(sum[j][i] - dp[j + 1][i],  sum[j][i] - dp[j][i - 1]);
            }
        }
        return dp[0][n-1]-(sum[0][n - 1]-dp[0][n - 1]);
    }
int main() {
	// your code goes here
	int n;
	cin>>n;
	long long int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	cout<<PredictTheWinner(a,n);
	return 0;
}

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

ans = 0
for i in range(1, n-1):
    if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
        ans += 1
    else:
        continue

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  int n,j,knum;
  string s;
  string c[10] = {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  cin >> n;
  while(n){
    cin >> s;
    for(int i = 0;i<s.size();i++){
      if(s[i] == '0')continue;
      for(j=0;j<s.size();j++)
	if(s[i+j+1] == '0')break;
      knum = j%c[s[i]-'0'].size();
      cout << c[s[i]-'0'][knum];
      i += j;
    }
    cout << "\n";
    n--;
  }

  return 0;
}

Measured memory_bytes: 2948
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Card[] card = new Card[n];
		for (int i = 0; i < n; i++) {
			String str = scan.next();
			char ch = str.charAt(0);
			char num = str.charAt(1);
			card[i] = new Card(num,ch);
		}
		// bubble sort
		Card[] bCard = Arrays.copyOf(card, card.length);
		boolean flag = true;
		while (flag) {
			flag = false;
			for (int i = 1; i < n; i++) {
				if (bCard[i].value < bCard[i-1].value) {
					Card tmp = bCard[i];
					bCard[i] = bCard[i-1];
					bCard[i-1] = tmp;
					flag = true;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.print((i==0?"":" ") + bCard[i]);
		}
		System.out.println();
		System.out.println("Stable");
		
		// Selection sort
		Card[] sCard = Arrays.copyOf(card, card.length);
		for (int i = 0; i < n; i++) {
			int minj = i;
			for (int j = i; j < n; j++) {
				if (sCard[minj].value > sCard[j].value)
					minj = j;
			}
			if (i != minj) {
				Card tmp = sCard[i];
				sCard[i] = sCard[minj];
				sCard[minj] = tmp;
			}
		}
		boolean stable = true;
		for (int i = 0; i < n; i++) {
			System.out.print((i==0?"":" ") + sCard[i]);
			if (bCard[i] != sCard[i]) stable = false;
		}
		System.out.println();
		System.out.println(stable?"Stable":"Not stable");

	}
}

class Card {
	char value;
	char suit;
	Card(char value, char suit) {
		this.value = value;
		this.suit = suit;
	}
	public String toString() {
		return new String(suit + "" + value);
	}
}


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

struct Sieve{
  int n;
  vector<int> f,primes;
  Sieve(int n=1):n(n),f(n+1){
    f[0] = f[1] = -1;
    for(ll i = 2; i<=n;++i){
      if(f[i]) continue; //素数でない場合continue
      primes.push_back(i);
      f[i] = i;
      for(ll j=i*i;j<=n;j+=i){
        if(!f[j]) f[j]=i;
      }
    }
  }
  bool isPrime(int x){
    return f[x]==x;
  }
  vector<int> factorList(int x){
    vector<int> res;
    while(x != 1){
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x){
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1,P(fl[0],0));
    for (int p:fl){
      if(res.back().first == p){
        res.back().second++;
      }else{
        res.emplace_back(p,1);
      }
    }
    return res;
  }
};

int main(){
    int x;
    cin >> x;
    Sieve si(1e6);
    for (auto p:si.primes) if(p>=x){
        cout << p << endl;
        break;
    }
}

Measured memory_bytes: 4732
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let c = read::<char>();
    let b = "aiueo".chars().collect::<Vec<_>>();
    if b.contains(&c) {
        println!("vowel");
    } else {
        println!("consonant");
    }
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

using namespace std;
using ll = long long;

/**
 * Radix conversion of a certain decimal integer.
 *
 * You can choose any integer, including negative integers, as a decimal integer and a radix.
 * (NOTE) It do not support too big or too small integers.
 *
 * @param N, B : N to be converted to radix, B is a radix.
 * @return A vector containing the value of each digit of the converted integer.
 **/

// CUT begin
template<typename T>
vector<T> radixConvertion(T N, T B) {
    vector<T> convertedNum;
    T n = 1, b = abs(B);
    while (N) {
        convertedNum.emplace_back((N * n) % b);
        if (convertedNum.back() < 0) convertedNum.back() += b;
        N -= convertedNum.back() * n;
        N /= b;
        n *= (B / b);
    }
    if (convertedNum.empty()) convertedNum.emplace_back(0);
    reverse(convertedNum.begin(), convertedNum.end());
    return convertedNum;
}
//CUT end


int main() {
    // As an example, convert 4 in decimal notation to -2 base number.

    ll N, B = -2;
    cin >> N;
    auto res = radixConvertion(N, B);
    for (auto d : res)cout << d;
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64_t h, w;
  cin >> h >> w;
  if(h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  if(h * w % 2 == 0) cout << h * w / 2 << endl;
  else cout << h * w / 2 + 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int k, a, b;
    scanf("%d", &k);
    scanf("%d %d", &a, &b);

    int tmp = k;
    while (tmp <= b)
    {
        if (a <= tmp)
        {
            printf("OK\n");
            return 0;
        }
        tmp += k;
    }
    printf("NG\n");
}


Measured memory_bytes: 1664
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int N, M;

	cin >> N >> M;

	int no = 0;
	int A[30] = {};

	for (int i = 0; i < N; i++) {
		cin >> no;
		for (int n = 0; n < no; n++) {
			int input;
			cin >> input;
			A[input-1]++;
		}
	}

	int count = 0;
	for (int i = 0; i < M; i++) {
		if (A[i] == N)count++;
	}

	cout << dec << count;
	return 0;

}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

//library----------------------------------------------



int main() {
    CIN(N,M);
    vector<int> s(M),c(M);
    rep(i,M)cin>>s[i]>>c[i];
    bool flag;
    int ans = -1;

    rep(i,1000){
        flag=true;
        string sr=to_string(i);

        if(sr.size()!=N)continue;
        rep(j,M){
            if(sr[s[j]-1]-'0'!=c[j])flag=false;    
        }
        if(flag){
            ans=i;
            break;
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

int main() {
    char c;
    cin >> c;

    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
        return 0;
    }else{
        cout << "consonant" << endl;
        return 0;
    }
}

Measured memory_bytes: 3528
#include<stdio.h>
#include<string.h>
int main(){
	char moji[200],moji2[100], ao[100];

	int a,b,c;
	scanf("%s",&moji);
	scanf("%s",&ao);
	strcpy(moji2, moji);
	strcat(moji,moji2);

	if(strstr(moji,ao) != NULL)
	{printf("Yes\n");
	}else{
		printf("No\n");
	}

	//scanf("%d",&a);
 return 0;
} 



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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=2003,INF=10000;

int main(){
    
    ll I,O,T,J,L,S,Z;cin>>I>>O>>T>>J>>L>>S>>Z;
    ll ans=0;
    int cnt=0;
    ans+=O;
    if(I%2==1) cnt++;
    if(J%2==1) cnt++;
    if(L%2==1) cnt++;
    if(I==0||J==0||L==0) cnt=-1;
    if(cnt==3){
        ans+=(I/2)*2+(J/2)*2+(L/2)*2;
        ans+=3;
    }else if(cnt==-1||cnt==1||cnt==0){
        ans+=(I/2)*2+(J/2)*2+(L/2)*2;
    }else if(cnt==2){
        ans+=(I/2)*2+(J/2)*2+(L/2)*2;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case,unused_imports,dead_code)]
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::Ordering;

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        N:usize,
        ABC:[(Usize1,Usize1,isize);N-1],
        Q:usize,
        K:Usize1,
        XY:[(Usize1,Usize1);Q]
    }

    let mut E = vec![HashMap::new();N];
    for &(a,b,c) in &ABC{
        E[a].insert(b,c);
        E[b].insert(a,c);
    }

    let d = bfs_dist_weighted_tree(N, &E, K);

    for &(x,y) in &XY{
        println!("{}",d[x]+d[y]);
    }

}

fn bfs_dist_weighted_tree(N:usize,E:&Vec<HashMap<usize,isize>>,start:usize) -> Vec<isize>{
    //BFSで重み付き木グラフのstartからの距離を測る。
    let mut d = vec![-1;N];
    let mut q = VecDeque::new();
    q.push_back(start);
    d[start] = 0;
    while let Some(i) = q.pop_front(){
        for (&j,&c) in E[i].iter(){
            if d[j]!= -1{continue;}
            d[j] = d[i]+c;
            q.push_back(j);
        }
    }
    d
}

Measured memory_bytes: 24740
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define ull unsigned long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) (int)(x).size()
using namespace std;

const int N = 307;

int n;

int a[N][N];	
bitset<N> skip[N];																																												

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n;

	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			cin >> a[i][j];
		}
	}

	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			for(int k = 1; k <= n; ++k)
			{
				if(a[i][j]>a[i][k]+a[k][j])
				{
					cout << -1;
					return 0;
				}
			}
		}
	}

	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			for(int k = 1; k <= n; ++k)
			{
				if(i!=k && j!=k && a[i][j]==a[i][k]+a[k][j])
					skip[i][j] = 1;
			}
		}
	}

	ll res = 0;

	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			if(!skip[i][j])
				res += a[i][j];
		}
	}

	cout << res/2;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int x[200];
int y[200];

int n;

int ni;
int di;

int main()
{
	int left=0;
	int right=0;
	int up=0;
	int down=0;
	
	cin >> n;
	while(n)
	{
		x[0] = 0;
		y[0] = 0;
		
		left = 0;
		right = 0;
		up = 0;
		down = 0;
		
		for (int i=1;i<n;++i)
		{
			cin >> ni >> di;
			
			if (di == 0)
			{
				x[i] = x[ni] -1;
				y[i] = y[ni];
			}
			
			if (di == 1)
			{	
				x[i] = x[ni];
				y[i] = y[ni] -1;
			}
			
			if (di == 2)
			{
				x[i] = x[ni] +1;
				y[i] = y[ni];
			}
			
			if (di == 3)
			{
				x[i] = x[ni];
				y[i] = y[ni]+1;
			}
			
			if (x[i] > right) right = x[i];
			if (x[i] < left) left = x[i];
			
			if (y[i] > up) up = y[i];
			if (y[i] < down) down = y[i];
			
		}
		
		cout << (right - left + 1) <<" "<< (up - down +1) <<endl;
		
		cin >>n;
	}
}

Measured memory_bytes: 0
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
set<ll> factrize(ll n)
{
    set<ll> res;
    for (ll i = 2; i <= sqrtl(n); i++)
    {
        ll k = i;
        ll cnt = 0;
        while (n % k == 0)
        {
            n /= k;
            res.insert(k);
        }
        
    }
    if (n != 1)
    {
        res.insert(n);
    }
    return res;
}

ll GCD(ll x, ll y)
{
    if (x < y)
    {
        const ll a = x;
        x = y;
        y = a;
    }
    ll b = 100000;
    while (b)
    {
        b = x % y;
        x = y;
        y = b;
    }
    return x;
}

ll LCM(ll x,ll y)
{
    ll g = GCD(x, y);
    return x / g * y;
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll A,B;
cin >> A >> B;
ll g = GCD(A,B);
set<ll> st = factrize(g);
st.insert(1);
cout << st.size() << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]

from itertools import accumulate

upper = list(accumulate(a[0]))
lower = list(accumulate(a[1][:][::-1]))

ans = 0

for i in range(n):
    sm = upper[i] + lower[n - 1 - i]
    ans = max(ans, sm)

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FastIO ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
void solve();int main() {FastIO;solve();return 0;}
// ====================================================================================
void solve()
{
	int n,x,k,y;
    cin>>n>>k>>x>>y;
    if(n>=k){cout<<k*x+((n-k)*y);}
else{cout<<n*x;};
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n;
 	cin >> n;
 	int x[n];
 	for (int i = 0; i < n; i++){
 		int y;
 		cin >> y;
 		x[y-1]=i+1;
 	}
 	for (int i = 0; i < n; i++){
 		cout << x[i] << " ";
 	}
 	cout << endl;
 }

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int H,N;
int mp[10000][4] = {};

int dp[10000][1<<4];
int solve(int now, int state){
	if(now == H && state == 0) return 0;
	if(now == H) return -10000;
	if(dp[now][state] != -1) return dp[now][state];
	int ans = solve(now+1, 0);
	//l
	if((state>>0)%2 == 0 && (state>>1)%2 == 0){
		if(mp[now][0] == 0 && mp[now][1] == 0 && mp[now+1][0] == 0 && mp[now+1][1] == 0){
			ans = max(ans, solve(now+1, 3)+1);
		}
	}
	//m
	if((state>>1)%2 == 0 && (state>>2)%2 == 0){
		if(mp[now][1] == 0 && mp[now][2] == 0 && mp[now+1][1] == 0 && mp[now+1][2] == 0){
			ans = max(ans, solve(now+1, 6)+1);
		}
	}
	//r
	if((state>>2)%2 == 0 && (state>>3)%2 == 0){
		if(mp[now][2] == 0 && mp[now][3] == 0 && mp[now+1][2] == 0 && mp[now+1][3] == 0){
			ans = max(ans, solve(now+1, 12)+1);
		}
	}
	//lr
	if((state>>0)%2 == 0 && (state>>1)%2 == 0){
		if(mp[now][0] == 0 && mp[now][1] == 0 && mp[now+1][0] == 0 && mp[now+1][1] == 0){
			if((state>>2)%2 == 0 && (state>>3)%2 == 0){
				if(mp[now][2] == 0 && mp[now][3] == 0 && mp[now+1][2] == 0 && mp[now+1][3] == 0){
					ans = max(ans, solve(now+1, 15)+2);
				}
			}
		}
	}
	return dp[now][state] = ans;
}
int main(){
	cin >> H >> N;
	for(int i=0; i<N; i++){
		int x,y;
		cin >> x >> y;
		mp[y][x] = 1;
	}
	for(int i=0; i<H; i++){
		for(int j=0; j<(1<<4); j++) dp[i][j] = -1;
	}
	cout << solve(0, 0) << endl;
}



Measured memory_bytes: 4648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<int,ll> Pil;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<ll,ll> Pl;
typedef pair<Pil,ll> P2;
const ll INF=1000000000000000001;
const int inf=1000000000;
//struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main(){

	string s;

	cin>>s;

	if(s[0]!='A'){
		cout<<"WA"<<endl;
		return 0;
	}
	if(isupper(s[s.size()-1])||isupper(s[1])){
		cout<<"WA"<<endl;
		return 0;
	}
	int f=0;
	for(int i=2; i<s.size(); i++){
		if(isupper(s[i])&&s[i]!='C'){
			cout<<"YES"<<endl;
			cout<<"WA"<<endl;
			return 0;
		}
		if(s[i]=='C'&&f==0)f=1;
		else if(s[i]=='C'&&f==1){
			cout<<"WA"<<endl;
			return 0;
		}
	}
	if(f==1)cout<<"AC"<<endl;
	if(f==0)cout<<"WA"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
//const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    double A,B,H,M;
    cin>>A>>B>>H>>M;
    double Ax=A*cos((H*30+M*0.5)*PI/180);
    double Ay=A*sin((H*30+M*0.5)*PI/180);
    double Bx=B*cos((M*6)*PI/180);
    double By=B*sin((M*6)*PI/180);
    //cout<<Ax<<" "<<Ay<<" "<<Bx<<" "<<By<<endl;
    cout<<setprecision(15)<<sqrt((Ax-Bx)*(Ax-Bx)+(Ay-By)*(Ay-By))<<endl;
}


Measured memory_bytes: 4116
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

int gcd(int a,int b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b, a%b);
}

int main(){
    int k;
    cin >> k;
    int memo[205][205][205];
    for(int a=1;a<=k;a++){
        for(int b=a;b<=k;b++){
            for(int c=b;c<=k;c++){
                memo[a][b][c] = gcd(gcd(a,b),c);
                memo[a][c][b] = gcd(gcd(a,b),c);
                memo[c][b][a] = gcd(gcd(a,b),c);
                memo[c][a][b] = gcd(gcd(a,b),c);
                memo[b][a][c] = gcd(gcd(a,b),c);
                memo[b][c][a] = gcd(gcd(a,b),c);
            }
        }
    }
    ll ans=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                ans += memo[a][b][c];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 36472
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long
using namespace std;
 
int main() {
  int x, y;
  cin >> x >> y;
  if (x < y) cout << 0 << endl;
  else cout << 10 << endl;
}

Measured memory_bytes: 256
#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 ret = 0;
string s;

int main(void){
  
  IN(N);
  string S, T;
  IN(S);
  IN(T);
  REP(i, N) {
    cout << S[i] << T[i];
  }
  cout << endl;
}


Measured memory_bytes: 256