akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

typedef long long int ll;

const ll MAXN = 8020;

int main()
{
  string s;
  cin >> s;
  int x,y;
  cin >> x >> y;

  vector<int> t;
  int cnt = 0;
//文字列を変形する
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'T'){
      if(cnt != 0) t.push_back(cnt);
      t.push_back(0);
      cnt = 0;
    }else{
      cnt++;
      if(i == s.size()-1) t.push_back(cnt);
    }
  }

  bool dp_x[MAXN][MAXN*2] = {false}, dp_y[MAXN][MAXN*2] = {false};
  dp_x[0][8000] = true;
  dp_y[0][8000] = true;

  bool flag = false;
  bool xy = true; // trueならx軸について見ている
  int cnt_x = 0,cnt_y = 0;

  for(int i = 0; i < t.size(); i++){
    if(t[i] == 0){
      xy  = !xy;
    }else if(xy){
      cnt_x++;
      for(int j = 0; j < MAXN*2; j++){
        if(dp_x[cnt_x-1][j]){
          if(j+t[i] < MAXN*2) dp_x[cnt_x][j+t[i]] = true;
          if(j-t[i] >= 0 && flag) dp_x[cnt_x][j-t[i]] = true;
        }
      }
    }else if(!xy){
      cnt_y++;
      for(int j = 0; j < MAXN*2; j++){
        if(dp_y[cnt_y-1][j]){
          if(j+t[i] < MAXN*2) dp_y[cnt_y][j+t[i]] = true;
          if(j-t[i] >= 0) dp_y[cnt_y][j-t[i]] = true;
        }
      }
    }

    if(!flag) flag = true;
  }

  cout << ((dp_x[cnt_x][x+8000] && dp_y[cnt_y][y+8000]) ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 251648
#include <iostream>
using namespace std;
int main() {
    int n, i, a[100000];
    cin >> n;
    for ( i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for ( i = n-1; i > 0; i--)
    {
        cout << a[i] << " ";
    }
    cout << a[0] << endl;
    
    
    
    

return 0;

}


Measured memory_bytes: 3056
S = input()
if S[0] == 'A':
  s =S[2:-1]
  if s.find('C') == -1:
    print('WA')
  else:
    if s[(s.find('C')+1):].find('C') > -1:	
      print('WA')
    else:
      if S[1:(s.find('C')+2)].islower():
        if S[s.find('C')+3:].islower():
          print('AC')
        else:
          print('WA')
      else:
        print('WA')
else:
	print('WA')

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("speech.in", "r", stdin);
	freopen ("speech.out", "w", stdout);
#endif
}

const int N = 2e3 + 1e2;

char str[N][N];

int n, m, t[N][N], s[N][N], ans, stk[N], top;

inline int Sqr(int a, int b) {
	return (a + 1) * (b + 1);
}

int l[N];
inline void Solve(int *h) {
	int len;
	stk[top = 0] = len = 0;
	For (i, 1, m) {
		if (h[i] >= stk[top])
			stk[++ top] = h[i], l[top] = 1;
		else {
			for (len = 0; top && stk[top] > h[i]; -- top)
				len += l[top], chkmax(ans, Sqr(len, stk[top]));
			stk[++ top] = h[i], l[top] = len + 1;
		}
	} 
	for (len = 0; top; -- top)
		len += l[top], chkmax(ans, Sqr(len, stk[top]));
}

int main () {

	File();

	n = read(); m = read();

	For (i, 1, n)
		scanf ("%s", str[i] + 1);

	For (i, 1, n) For (j, 1, m)
		t[i][j] = (str[i][j] == '#');

	-- n, -- m;
	For (i, 1, n) For (j, 1, m)
		s[i][j] = !((t[i][j] + t[i + 1][j] + t[i][j + 1] + t[i + 1][j + 1]) & 1);

	Set(t, 0);
	For (i, 1, n) For (j, 1, m) if (s[i][j]) t[i][j] = t[i - 1][j] + 1;
	For (i, 1, n) Solve(t[i]);

	chkmax(ans, max(n + 1, m + 1));
	printf ("%d\n", ans);

    return 0;

}


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

int main() {
    int n, tmp;
    cin >> n;
    
    vector<int> input(n, 0);
    vector<int> score(n, 0);

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

    score[0] = 0;
    score[1] = abs(input[1] - input[0]);

    for (int i = 2; i <n; i++) {
        score[i] = min( abs(input[i] - input[i-1] ) + score[i-1] , abs( input[i] - input[i-2] ) + score[i-2]);
    }

    cout << score[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int a[3];

int main() {
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  int t1 = a[2] - a[0];
  int t2 = a[2] - a[1];
  int tmp = (t1 + t2);
  if(tmp % 2){
    cout << tmp/2 +2 << endl;
  }else{
    cout << tmp/2 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = int(1e5 + 5);
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    int n, a[MAX_N]{}, sum = 0;
    cin >> n;
    REP(i,n) cin >> a[i+1];
    REP(i,n+1) sum += abs(a[i]-a[i+1]);
    for(int i=1;i<=n;i++){
        cout << sum - abs(a[i-1]-a[i]) - abs(a[i]-a[i+1]) + abs(a[i-1]-a[i+1]) << endl;
    }
    return 0;
}


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

int main() {
	
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	
	if(c < d) swap(c, d);
	
	ll x = c, y = d;
	ll r = x % y;
	while(r!=0){
		x = y;
		y = r;
		r = x % y;
	}

	ll lcm = c * d / y;
	ll ans = b - b / c - b / d + b / lcm;
	ans -= (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / lcm;
	
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// 200219.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;

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

    int i = 1;
    int digit =0;
    while (1) {
        if (pow(K, i) > N) {
            digit = i;
            break;
        }
        i++;
    }
    cout << digit << endl;
    return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	int main()
	{
		long long n ,m;
		cin>>n>>m;
		if(n == 0)
		{
			if(m < 0)
			{
				cout<<abs(m) + 1;
			}else
			{
				cout<<abs(m);
			}return 0;
		}
		if(m == 0)
		{
			if(n > 0)
			{
				cout<<1 + n;
			}else
			{
				cout<<abs(n);
			}return 0;
		}
		if(abs(n) == abs(m))
		{
			if(n == m)
			{
				cout<<0;
			}else
			{
				cout<<1;
			}return 0;
		}
		if(n > 0 &&m > 0 )
		{
			if(n >m)
			{
				cout<<2 + (n - m);
			}else
			{
				cout<<m - n;
			}
		}if(n > 0 &&m < 0)
		{
			if(n > abs(m))
			{
				cout<<1 + (n - abs(m));
			}else
			{
				cout<<1 + (abs(m) - n);
			}
		}if(n < 0 &&m > 0)
		{
			if(abs(n) > m)
			{
				cout<<1 + (abs(n) - m);
			}else
			{
				cout<<1 + (m - abs(n));
			}
		}if(n < 0 && m< 0)
		{
			if(n > m)
			{
				cout<<2 + (abs(abs(n) - abs(m)));
			}else
			{
				cout<<m - n;
			}
		}
	}

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

int main() {
long long n,m;
  cin >> n >> m;
  if(m==1)cout << '0' << endl;
  else if(m<=2*n)cout << m/2 << endl;
  else{
  m=m-2*n;//この時点でn個のSccが作れる。残ったのはm個のc
  long long a=m/4;
    cout << a+n << endl;
  }
}


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

int main(void) {

  string A, B, C;
  cin >> A >> B >> C;

  if(A[A.length()-1] == B[0] && B[B.length()-1] == C[0]) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum=0;
    if(a>=k) cout<<k;
    else if(k<=a+b) cout<<a;
    else cout<<a-(k-a-b);
    return 0;
}


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

int main(){
	int N;
	cin>>N;
	int A[N];
	int left[N];
	int right[N];
	int max_e = std::numeric_limits<int>::min();
	for(int i=0; i< N ; i++){
		cin>>A[i];
		max_e = std::max(A[i], max_e);
		left[i] = max_e;
	}
	if(N==1){//edge case
		cout<<A[0]<<"\n";
		return 0;
	}
	max_e = std::numeric_limits<int>::min();
	for(int i=N-1; i>=0; i--){
		max_e = std::max(A[i], max_e);
		right[i] = max_e;
	}
	for(int i=0; i<N; i++){
		if(i==0){
			cout<<right[i+1]<<"\n";
		}
		else if(i==N-1){
			cout<<left[i-1]<<"\n";
		}
		else{
			cout<<std::max(left[i-1], right[i+1])<<"\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 a;
    std::cin >> a;
    std::set<i64> s;
    int ret = 1;
    while (s.find(a) == s.end()) {
        s.insert(a);
        a = a % 2 ? 3 * a + 1 : a / 2;
        ret++;
    }
    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    byte x = sc.nextByte();
    byte n = sc.nextByte();
    if(n > 0) {
      boolean[] num = new boolean[102];
      byte li = 101;
      byte ui = 0;
      for(byte i = 0; i < n; i++) {
        byte val = sc.nextByte();
        if(li > val) li = val;
        if(ui < val) ui = val;
        num[val] = true;
      }
      sc.close();
      if(li >= 1) li--;
      if(ui <= 100) ui++;
      byte cl = 0;
      byte cld = 101;
      for(byte i = li; i <= ui; i++) {
        if(!num[i]) {
          byte nd = (byte)Math.abs((int)(x - i));
          if(cld > nd) {
            cld = nd;
            cl = i;
          }
        }
      }
      System.out.println(cl); 
    } else {
      System.out.println(x);
    }
  }
}

Measured memory_bytes: 35812
#include <bits/stdc++.h>
using namespace std;
const long M=1e9;
int main(){
long N, D, A, i, j, t, ans=0; cin >> N >> D >> A; vector<long> X(N), H(N), G(N);
for(i=0; i<N; i++){ cin >> X[i] >> H[i]; }
for(i=0; i<N; i++){ G[i]=(H[i]+A-1)/A; }
vector< pair<long, long> > V;
for(i=0; i<N; i++){ V.push_back(make_pair(X[i], G[i])); }
sort(V.begin(), V.end()); V.push_back(make_pair(M+1, M));
vector<long> W(N+1);
for(i=0; i<N; i++){
  if(i>0){ W[i]+=W[i-1]; }
  V[i].second-=W[i];
  if(V[i].second<=0){ continue; }
  t=min(V[i].first+2*D, M);
  long j=upper_bound(V.begin(), V.end(), make_pair(t, M))-V.begin();
  W[i]+=V[i].second; W[j]-=V[i].second; ans+=V[i].second;
}
cout << ans << "\n";
}

Measured memory_bytes: 10608
#include <bits/stdc++.h>
using namespace std;
set <string> A;
int main(){
    int n, i, j;
    string S;
    cin >>n;
    for(i=0;i<n;i++){
        cin >> S;
        if(A.end() == A.find(S)){
            A.insert(S);
        }
    }
    cout << A.size();
}
//strcmp();


Measured memory_bytes: 19224
import scipy.sparse as z;H,W,*S=open(0).read().split();W=int(W);m=int(H)*W;A=[]
for i in range(m):
 h,w=divmod(i,W)
 if S[h][w]=='S':A=[m*2,h,m*2,w+m]+A
 elif S[h][w]=='T':A=[h,m*3,w+m,m*3]+A
 elif S[h][w]=='o':A+=[h,w+m,w+m,h]
f=z.csgraph.maximum_flow(z.csr_matrix(([999]*4+[1]*(len(A)//2-4),(A[::2], A[1::2])),[m*4]*2),m*2,m*3).flow_value;print(f if f<999 else -1)

Measured memory_bytes: 40736
import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def score(A):
    res = 0
    for a, b, c, d in abcd:
        if A[b - 1] - A[a - 1] == c:
            res += d
    return res

  
def main(n, m, abcd):
    p = itertools.combinations_with_replacement(range(1, m+1), n)
    L = list(p)
    ans = 0
    for A in L:
        ans = max(ans, score(list(A)))
    return ans


n, m, q = map(int, readline().split())
abcd = [list(map(int, readline().split())) for _ in range(q)]

print(main(n, m, abcd))

Measured memory_bytes: 21396
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    cout<<max(a-k,(ll)0)<<' '<<max(min(b,a+b-k),(ll)0)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

public class Main {
	static class S {
		int pos;
		int height;

		S(int pos, int height) {
			this.pos = pos;
			this.height = height;
		}
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		Stack<S> stack = new Stack<S>();
		int a[][];
		int h, w;
		int max;

		while (true) {
			h = sc.nextInt();
			w = sc.nextInt();
			if ((w | h) == 0) {
				break;
			}

			a = new int[h][w];
			max = 0;
			for (int i = 0; i < h; i++) {
				String s = sc.next();
				for (int j = 0; j < w; j++) {
					if (s.charAt(j) == '*') {
						a[i][j] = 0;
					} else if (s.charAt(j) == '.') {
						if (i == 0) {
							a[i][j] = 1;
						} else {
							a[i][j] = a[i - 1][j] + 1;
						}
					}
				}
			}

			stack.clear();
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					S s = new S(j, a[i][j]);
					if (stack.isEmpty()) {
						stack.push(s);
					} else if (stack.peek().height < s.height) {
						stack.push(s);
					} else if (s.height < stack.peek().height) {
						while (!stack.isEmpty() && s.height <= stack.peek().height) {
							S s2 = stack.pop();
							int sum = s2.height * (j - s2.pos);
							s.pos = s2.pos;
							max = (max < sum) ? sum : max;
						}
						stack.push(s);
					}
				}
				int fPos = w;
				while (!stack.isEmpty()) {
					S s = stack.pop();
					int sum = s.height * (fPos - s.pos);
					max = (max < sum) ? sum : max;
				}
			}

			System.out.println(max);
		}
	}
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    ll N, M; cin >> N >> M;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    vector<pair<ll, ll>> CB(M);
    REP(i, M) {
        ll b, c;
        cin >> b >> c;
        CB[i] = make_pair(c, b);
    }

    sort(CB.rbegin(), CB.rend());

    priority_queue<ll> Q;
    REP(i, M) {
        REP(k, CB[i].second) {
            if(Q.size() < N) {
                Q.push(CB[i].first);
            } else {
                break;
            }
        }
    }

    for(int i = 0; i < N; ++i) Q.push(A[i]);

    ll res = 0;
    for(int i = 0; i < N; ++i) {
        ll d = Q.top();
        res += d;
        Q.pop();
    }

    cout << res << endl;
}

Measured memory_bytes: 4724
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  ll x;
  cin>>x;

  x %= 1000;
  if (x > 0)
    x = 1000 - x;
  cout<<x<<endl;
}

int 
main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    deque<int> d;
    rep(i, n)
    {
        int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
        if (p == 0)
            d.push_front(a[i]);
        else
            d[p - 1] = a[i];
    }
    int ans = d.size();
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int GCD(int a,int b)
{
  int r, tmp;
   /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
    /*文字列を種類ごと区切って配列にする*/
  string s;
  cin>>s;
  vector<string> v;
  int cnt=0,start;
  bool flag=true;
  for(long long int i=0;i<s.size();i++){
    if(flag){
      start=i;
      flag=false;
    }
    if(s[i]==s[i+1]){
      cnt++;
    }else{
      v.push_back(s.substr(start,cnt+1));
      cnt=0;
      flag=true;
    }
  }
  cout<<v.size()-1<<endl;
 
}
///////////////////////////

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

int main(){
	string str ; cin >> str ;
	set<int> s ;
	s.insert('A') ; s.insert('C') ; s.insert('T') ; s.insert('G') ;
	int cnt = 0 ;
	int sub = 0 ;
	for(int i=0;i<str.size();i++){
		for(int j=0;j<str.size()-i;j++){
			if(s.count(str.at(i+j))) sub++ ;
			else break ;
		}
		if(cnt<sub) cnt = sub ;
		sub = 0 ;
	}
	cout << cnt << endl ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>

static void A_Buttons();

int main()
{

	A_Buttons();

	fflush(stdout);
	return 0;
}

static void A_Buttons()
{
	int A, B;
	scanf(" %d %d", &A, &B);

	int sum = 0;
	for (int i = 0; i < 2; i++) {
		if (A > B) {
			sum += A;
			A--;
		}
		else {
			sum += B;
			B--;
		}
	}
	printf("%d\n", sum);
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    string s;
    cin >> s;
    int l = s.size();
    int maxv = 0;
    REP(i, l) {
        int v = 0;
        FOR(j, i, l-1) {
            if(s[j]=='A' || s[j]=='C' || s[j]=='G' || s[j]=='T') v++;
            else break;
        }
        maxv = max(maxv, v);
    }
    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>

int area(int a, int b) {
	return a * b;
}
int surface(int a, int b) {
	return 2 * a + 2 * b;
}

int main() {
	int a, b;
	std::cin >> a >> b;
	std::cout << area(a, b) << " " << surface(a, b) << std::endl;
	return 0;
}

Measured memory_bytes: 3080
s=input()
abc='abcdefghijklmnopqrstuvwxyz'
a=s[0]
b=s[2:-1]

check=0
for i in range(len(s)):
    if s[i] in abc:
        check +=1
        
print('AC' if a=='A' and 'C' in b and check+2==len(s) else 'WA')

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#define INF 1000000000

int compcount;

void merge(int *A, int l, int m, int r){
  int n1,n2,i,j,k;
  int *L, *R;

  n1 = m-l;
  n2 = r-m;
  L = (int *)malloc(sizeof(int) * (n1+1));
  R = (int *)malloc(sizeof(int) * (n2+1));

  // divide
  for(i=0; i<n1; i++) L[i] = A[l+i];
  for(i=0; i<n2; i++) R[i] = A[m+i];
  L[n1] = INF;
  R[n2] = INF;

  // merge
  i=0;
  j=0;
  for(k=l; k<r; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
      compcount++;
    }
    else {
      A[k] = R[j];
      j++;
      compcount++;
    }
  }

  free(L);
  free(R);

}

void mergeSort(int *A, int l, int r){
  int m;
  if(l+1 < r){
    m = (l+r) / 2;
    mergeSort(A,l,m);
    mergeSort(A,m,r);
    merge(A,l,m,r);
  }
}

int main(){
  int n,i;
  int *arr;

  // input and alloc
  scanf("%d",&n);
  arr = (int *)malloc(sizeof(int) * n);
  for(i=0; i<n; i++) scanf("%d",&arr[i]);

  // sort
  mergeSort(arr,0,n);

  // output
  for(i=0; i<n; i++){
    if(i == n-1) printf("%d",arr[i]);
    else printf("%d ",arr[i]);
  }
  printf("\n%d\n",compcount);

  free(arr);

  return 0;
}

Measured memory_bytes: 4484
#!/usr/bin/env python3
import sys


def solve(K: int, X: int):
    res = [X]

    # right
    for i in range(X + 1, X + K):
        res.append(i)

    # left
    for i in range(X - 1, X - K, -1):
        res.append(i)

    for i, x in enumerate(sorted(res)):
        print(x, end='')
        if not res.__len__() == i + 1:
            print(end=' ')

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}

int main() {
  double l; cin >> l;

  double v;
  v = (l * l * l)/27;
  printf("%.12f\n", v);
}


Measured memory_bytes: 3716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line1 = br.readLine();
		String line2 = br.readLine();
		System.out.println(line1.equals(line2.substring(0, line2.length() - 1)) ? "Yes" : "No");
	}
}


Measured memory_bytes: 32760
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){
    
    int table[9];
    vector<bool> t(10,false);

    rep(i,9) cin >> table[i];
    map<int,int> mp;
    rep(i,9){
            mp[table[i]] = i+1;
    }

    int k;
    cin >> k;
    int tmp;
    rep(i,k){
        cin >> tmp;
        if(mp[tmp] != 0){
            t[mp[tmp]] = true;
        } 
    }

    if(t[1] == true && t[2] == true && t[3] == true ){
        cout<< "Yes" << endl;
        return 0;
    }
    if(t[4] == true && t[5] == true && t[6] == true ){
        cout<< "Yes" << endl;
        return 0;
    }
    if(t[7] == true && t[8] == true && t[9] == true ){
        cout<< "Yes" << endl;
        return 0;
    }
    if(t[1] == true && t[4] == true && t[7] == true ){
        cout<< "Yes" << endl;
        return 0;
    }
    if(t[2] == true && t[5] == true && t[8] == true ){
        cout<< "Yes" << endl;
        return 0;
    }
    if(t[3] == true && t[6] == true && t[9] == true ){
        cout<< "Yes" << endl;
        return 0;
    }
    if(t[1] == true && t[5] == true && t[9] == true ){
        cout<< "Yes" << endl;
        return 0;
    }
    if(t[3] == true && t[5] == true && t[7] == true ){
        cout<< "Yes" << endl;
        return 0;
    }
    
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <list>
#include <map>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b + c - max(a, max(b, c))) << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s;
    int ans = INF;
    cin >> s;
    for(int i = 0; i < s.size() - 2; i++){
        ans = min(ans, abs(753 - ((s[i]-'0')*100 + (s[i+1] - '0') * 10 + s[i+2]-'0')));
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#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)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> A, std::vector<long long> B){
    vector<pair<LL, LL>  >pairs;
    REP(i, N)pairs.PB(make_pair(A[i],B[i]));
    sort(ALL(pairs), compare_by_b);
    LL time=pairs[0].first;
    REP(i, N){
        if(time>pairs[i].second){cout<<NO<<endl;return;}
        if(i!=N-1)time+=pairs[i+1].first;
    }
    cout<<YES<<endl;return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 9328
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
A = LI()

from math import gcd

g = 0
for i in range(N):
    g = gcd(g,A[i])

if g != 1:
    print('not coprime')
    exit()

B = []
for i in range(N):
    if A[i] != 1:
        B.append(A[i])
N = len(B)

if N == 0:
    print('pairwise coprime')
    exit()

primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

if N > 78498:
    print('setwise coprime')
    exit()


C = [0]*(10**6+1)

for i in range(N):
    b = B[i]
    for p in primes:
        if b % p == 0:
            if C[p] == 1:
                print('setwise coprime')
                exit()
            else:
                C[p] = 1
            while b % p == 0:
                b //= p
    if b != 1:
        if C[b] == 1:
            print('setwise coprime')
            exit()
        else:
            C[b] = 1

print('pairwise coprime')


Measured memory_bytes: 207836
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <deque>

using namespace std;

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

    vector<int> a(N);
    for (auto& ai: a) {
        cin >> ai;
    }

    vector<int> B(N);
    for (int i=N;i>0;--i) {
        int s=0;
        for (int j=i; j <=N; j += i) {
            s += B[j-1];
        }
        if (s % 2 != a[i-1]) {
            B[i-1]=1;
        }
    }

    vector<int> b;
    for (int i=0;i<N;++i) {
        if (B[i]) b.push_back(i+1);
    }

    cout << b.size() << endl;
    if (!b.empty()) {
        for (auto bi:b) {
            cout << bi << " ";
        }
        
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
using namespace std;
int main() {
	int n, a[201],b[201];
	int temp;
	while (1) {
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		cin >> n;
		if (n == 0)return 0;
		for (int i = 0; i < n; i++) {
			cin >> temp;
			a[temp]++;
		}
		for (int i = 1; i <= n * 2; i++) {
			if (a[i] == 0) {
				b[i]++;
			}
		}
		int ba = 0;
		int masatoy, hideo;//????????????????¨???¶
		int amai, bmai;
		amai = bmai = n;//????????????????????£??????????????????????????°
		masatoy = hideo = 0;
		int bal = 0;//0??????????????????????????±???
		while (amai > 0 && bmai > 0) {
			if (bal == 0) {
				//cout << "o" << endl;
				if (masatoy == ba&&ba > 0) {
					ba = 0;
					masatoy = -1;
				}
				for (int i = 1; i <= n * 2; i++) {
					if (a[i] == 1 && i > ba) {
						ba = i;
						masatoy = i;
						a[i] = -1;
						bal = 1;
						amai--;
						//cout << "tarou" << bmai << endl;
						break;
					}
				}
				bal = 1;
			}
			else if (bal == 1) {
				//	cout << "owannnele" << endl;
				if (hideo == ba&&ba > 0) {
					ba = 0;
					hideo = -1;
				}
				for (int i = 1; i <= n * 2; i++) {
					if (b[i] == 1 && i > ba) {
						ba = i;
						hideo = i;
						b[i] = -1;
						bal = 0;
						bmai--;
						//cout << "hanako" << bmai << endl;
						break;
					}
				}
				bal = 0;
			}
		}
		cout << bmai << endl << amai << endl;
	}
}

Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
long long dfs(int cnt,int sum);
int n,x[100];
long long memo[59][50009];

int main(){
  int a;
  memset(memo,-1,sizeof(memo));
  cin>>n>>a;
  for(int i=0;i<n;i++){
    cin>>x[i];
    x[i]-=a;
  }
  cout<<dfs(0,2500)-1<<endl;
  return(0);
}

long long dfs(int cnt,int sum){
  long long rec=0;
  if(memo[cnt][sum]!=-1)return memo[cnt][sum];
  if(cnt==n){
    if(sum==2500)return 1;
    else return 0;
  }
  rec+=dfs(cnt+1,sum);
  rec+=dfs(cnt+1,sum+x[cnt]);
  return memo[cnt][sum]=rec;
}


Measured memory_bytes: 23296
use std::io::Write;
use std::ops::{Add, Mul, Sub};

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };


    let arr: Vec<usize> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.split_whitespace().map(|x| x.parse().unwrap()).collect()
    };

    let mut ans = Modulo(0);
    for i in 0..60 {
        let bit = 1 << i;
        let mut count = 0;
        for &a in &arr {
            if a & bit > 0 {
                count += 1;
            }
        }

        let tmp = Modulo(count) * Modulo(n - count) * Modulo(2).pow(i);
        ans = ans + tmp;
    }

    println!("{}", ans.0);
}

fn positive_rem(a: isize, b: usize) -> usize {
    let b = b as isize;
    let mut value = a % b;
    if value < 0 {
        value += b;
    }
    // TODO: TryFrom
    value as usize
}

/// Return (x, y) s.t. ax + by = d where d = gcd(a, b)
fn ext_gcd(a: usize, b: usize) -> (isize, isize) {
    if b == 0 {
        return (1, 0);
    }

    let q = (a / b) as isize;
    let r = a % b;
    let (x1, y1) = ext_gcd(b, r);
    (y1, x1 - q * y1)
}

#[derive(Debug, Copy, Clone)]
struct Modulo(usize);

const MODULO: usize = 1_000_000_000 + 7;

impl Modulo {
    fn from_isize(n: isize) -> Modulo {
        // TODO: use TryFrom
        Modulo(positive_rem(n, MODULO as usize))
    }

    fn pow(self, p: usize) -> Modulo {
        if self == Modulo(0) {
            return Modulo(0);
        }
        if p == 0 {
            return Modulo(1);
        }

        if p % 2 == 0 {
            let half = self.pow(p / 2);
            half * half
        } else {
            self.pow(p - 1) * self
        }
    }

    // when MODULO is prime
    fn inv(self) -> Modulo {
        let (x, _) = ext_gcd(self.0 as usize, MODULO as usize);
        Modulo::from_isize(x)
    }

    // when MODULO is prime
    fn binom_coef(n: isize, k: isize) -> Modulo {
        let mut ret = Modulo::from_isize(1);
        for i in 1..(k + 1) {
            ret = ret * Modulo::from_isize(n - i + 1) * Modulo::from_isize(i).inv();
        }
        ret
    }
}

impl Add for Modulo {
    type Output = Modulo;

    fn add(self, other: Modulo) -> Modulo {
        Modulo((self.0 + other.0) % MODULO)
    }
}

impl Sub for Modulo {
    type Output = Modulo;

    fn sub(self, other: Modulo) -> Modulo {
        Modulo(positive_rem(
            self.0 as isize - other.0 as isize,
            MODULO as usize,
        ))
    }
}

impl Mul for Modulo {
    type Output = Modulo;

    fn mul(self, other: Modulo) -> Modulo {
        Modulo((self.0 * other.0) % MODULO)
    }
}

impl PartialEq for Modulo {
    fn eq(&self, &other: &Self) -> bool {
        self.0 == other.0
    }
}

impl Eq for Modulo {}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

long int M = 1e+5;
int main(void){
    int n;
    cin >> n;
    long int abc[M][3],dp[M][3];
    rep(i,n){
        cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
        dp[i][0]=0; dp[i][1]=0; dp[i][2]=0;
    }
    dp[0][0]=abc[0][0]; dp[0][1]=abc[0][1]; dp[0][2]=abc[0][2];
    rep(i,n-1){
        rep(j,3){
            rep(k,3){
                if(j != k){
                    dp[i+1][k] = max(dp[i+1][k] , dp[i][j]+abc[i+1][k]);
                }
            }
        }
    }
    cout << max( dp[n-1][0], max(dp[n-1][1], dp[n-1][2]) ) << endl;
    return 0;
}

Measured memory_bytes: 4992
#C
l, r = map(int, input().split())

if r - l >= 2018:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, i * j % 2019)
            #print(ans)
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    string s;
    cin >> s;

    if (s == "Sunny")
    {
        cout << "Cloudy" << endl;
        return 0;
    }
    else if (s == "Cloudy")
    {
        cout << "Rainy" << endl;
        return 0;
    }
    else
    {
        cout << "Sunny" << endl;
    }
    
    return 0;
}

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

int main() {
    int a,b;
    cin >> a>>b;
 
  if (a*b%2 == 1) {
    cout << "Odd" << endl;
  }
  if (a*b%2 == 0) {
    cout << "Even" << endl;
  }

}

Measured memory_bytes: 256
// AtCoder.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <math.h>
#include <cmath>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(a > 0 && c > 0){
        c -= b;
        if(c <= 0)break;
        a -= d;
        //cout << a << " " << c << endl;
    }
    bool ans = a > 0;
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, a, b, c, d;
	string s;
	cin>>n>>a>>b>>c>>d>>s;
	--a;
	--b;
	--c;
	--d;
	if(c==d){
		cout<<"No"<<'\n';
		return 0;
	}
	if(c<d){
		bool ok=true, ng=false;
		FOR(i, a, c+1){
			if(ng && s[i]=='#'){
				ok=false;
				break;
			}
			if(s[i]=='#'){
				ng=true;
			}
			else{
				ng=false;
			}
		}
		ng=false;
		FOR(i, b, d+1){
			if(ng && s[i]=='#'){
				ok=false;
				break;
			}
			if(s[i]=='#'){
				ng=true;
			}
			else{
				ng=false;
			}
		}
		cout<<(ok ? "Yes" : "No")<<'\n';
		return 0;
	}
	bool ok=true, ng=false;
	FOR(i, a, c+1){
		if(ng && s[i]=='#'){
			ok=false;
			break;
		}
		if(s[i]=='#'){
			ng=true;
		}
		else{
			ng=false;
		}
	}
	ng=false;
	FOR(i, b, d+1){
		if(ng && s[i]=='#'){
			ok=false;
			break;
		}
		if(s[i]=='#'){
			ng=true;
		}
		else{
			ng=false;
		}
	}
	if(!ok){
		cout<<"No"<<'\n';
		return 0;
	}
	ok=false;
	int cnt=0;
	FOR(i, b-1, min(n, d+2)){
		if(cnt==2 && s[i]=='.'){
			ok=true;
			break;
		}
		if(s[i]=='.'){
			++cnt;
		}
		else{
			cnt=0;
		}
	}
	cout<<(ok ? "Yes" : "No")<<'\n';
	return 0;
}


Measured memory_bytes: 592
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    ll N, M;
    cin >> N >> M;
    ll X[M];
    REP(i, 0, M) {
        cin >> X[i];
    }
    sort(X, X + M);
    ll dis[M - 1];
    REP(i, 0, M - 1) {
        dis[i] = X[i + 1] - X[i];
    }
    sort(dis, dis + M - 1);
    reverse(dis, dis + M - 1);
    ll ans = X[M - 1] - X[0];
    REP(i, 0, min(M - 1, N - 1)) {
        ans -= dis[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N,A,B;
    long long sumBlue=0;
    cin >> N >> A >> B;
    if (A==0 && B==0) {
        cout << 0 << endl;
        return 0;
    }
    sumBlue = N / (A+B) * A;
    if (N % (A+B) > A) sumBlue = sumBlue + A;
    else sumBlue = sumBlue + (N % (A+B));
    cout << sumBlue << endl;
}

Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.Queue

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val H, W = in.next().toInt

  val ar = new Array[String](H+1)

  for(y <- 1 to H) {
    ar(y) = "#" + in.next()
  }

  def isCorrect(x: Int, y: Int): Boolean =
    1 <= x && x <= W && 1 <= y && y <= H

  def mk4dir(x: Int, y: Int): List[(Int, Int)] = {
    List((x+1, y), (x-1, y), (x, y+1), (x, y-1))
      .filter{ case (x, y) => isCorrect(x, y) }
  }

  //
  val q = new Queue[((Int, Int), Int)]()
  q.enqueue(((1, 1), 0))

  val dp = Array.ofDim[Int](H+1, W+1)
  for(y <- 1 to H; x <- 1 to W)
    dp(y)(x) = -1

  var hoge = -1
  while(!q.isEmpty) {
    val ((x, y), cost) = q.dequeue
    

    if((x, y) == (W, H)) {
      hoge = cost
      q.clear
    }
    else if(dp(y)(x) == -1 && ar(y)(x) != '#') {
      dp(y)(x) = cost
      mk4dir(x, y).foreach{ case (x, y) => q.enqueue(((x, y), cost+1)) }
    }
  }

  var cnt = 0
  for(y <- 1 to H; x <- 1 to W) {
    if(ar(y)(x) == '.'){
      cnt += 1
    }
  }



  if(hoge == -1)
    println(-1)
  else{
    println(cnt-1-hoge)
  }

}



class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 30444
#include<iostream>
using namespace std;
int selectionSort(int (&A)[100],int N){
	int i, j, minj, tmp, cnt=0;
	for(i=0;i<N;i++){
		minj = i;
		for(j=i;j<N;j++){
			if(A[j] < A[minj])
				minj = j;
		}
		if(A[i] != A[minj])
			cnt++;
		tmp = A[i];
		A[i] = A[minj];
		A[minj] = tmp;
	}
	return cnt;
}

int main(){
	int n, cnt, a[100], i;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	cnt = selectionSort(a, n);
	cout << a[0];
	for(i=1;i<n;i++){
		cout << " " << a[i];
	}
	cout << endl << cnt << endl;
	return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    
    vector< pair<int, char> > conds;
    
    for (int i = 0; i < M; i++) {
        pair<int, char> p;
        int s, c;
        cin >> s >> c;
        p.first = s - 1;
        p.second = to_string(c)[0];
        conds.push_back(p);
    }
    
    for (int i = 0; i < 999; i++) {
        bool isOk = true;
        string x = to_string(i) + "xxx";
        for (int j = 0; j < M; j++) {
            int s = conds[j].first;
            char c = conds[j].second;
            isOk = isOk && (x[s] == c);
        }
        if (isOk && x.length() == (N + 3)) {
            cout << i;
            return 0;
        }
    }
    cout << "-1";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF (1<<29)
using namespace std;

const int nlimit=201;
int graph[nlimit][nlimit];
int rs[9];
bool used[9];
int n, m, r;

int dfs(int, int);
int main(){
  cin >> n >> m >> r;

  //グラフの初期化
  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
      if(i!=j) graph[i][j]=INF;
    }
  }

  //訪問すべき頂点集合
  for(int i=1; i<=r; i++) cin >> rs[i];

  int a, b, c;
  for(int i=1; i<=m; i++){
    cin >> a >> b >> c;
    graph[a][b] = min(graph[a][b], c);//二重辺対策
    graph[b][a] = graph[a][b];
  }

  //ワーシャルフロイド
  for(int k=1; k<=n; k++){
    for(int i=1; i<=n; i++){
      for(int j=1; j<=n; j++){
        graph[i][j] = min(graph[i][j], graph[i][k]+graph[k][j]);
      }
    }
  }

  for(int i=1; i<=r; i++) used[i]=false;
  int ans = dfs(0, -1);

  cout << ans << endl;

  return 0;

}

int dfs(int c, int last){
  int ans=0;
  if(c==r) ans=0;
  else{
    //rこの順列について調査
    int m=INF;
    for(int i=1; i<=r; i++){
      if(!used[i]){
        used[i]=true;
        if(last==-1) m = min(m, dfs(c+1, i));
        else m = min(m, dfs(c+1, i)+graph[rs[last]][rs[i]]);
        used[i]=false;
      }
    }
    ans = m;
  }
  return ans;
}


Measured memory_bytes: 512