akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	static Scanner scan;

	static int solve(int n) {
		int[][] memo = count(n);
		int max = 0;
		for (int w = n; w > max; w--) {
			for (int y = n - 1; y >= max - 1; y--) {
				for (int x = n - 1; x >= max - 1; x--) {
					if( x - w + 1 < 0 || y - w + 1 < 0)
						continue;
					if (isSquare(memo, x, y, w)) {
						max = (max < w)? w : max;
						break;
					}
				}
			}
		}
		return max;
	}

	static int[][] count(int n) {
		int[][] result = new int[n + 1][n + 1];
		initialize(result, 0);
		String data = null;
		int count = 0;
		for (int y = 1; y < n + 1; y++) {
			data = scan.next();
			count = 0;
			for (int x = 1; x < n + 1; x++) {
				if (data.charAt(x - 1) == '.')
					count++;
				result[y][x] = count + result[y - 1][x];
			}
		}
		return result;
	}

	static void initialize(int[][] array, int value) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[0].length; j++) {
				array[i][j] = value;
			}
		}
	}
	
	static boolean isSquare(int[][] memo, int x, int y, int w) {
		int s = memo[y + 1][x + 1] - memo[y + 1 - w][x + 1]	- memo[y + 1][x + 1 - w] + memo[y + 1 - w][x + 1 - w];
		return s == w * w;
	}

	public static void main(String[] args) {
		scan = new Scanner(System.in);
		int n = 0;
		while ((n = scan.nextInt()) != 0) {
			System.out.println(solve(n));
		}
		scan.close();
	}

	static void print(int[][] array){
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[0].length; j++) {
				System.out.printf("%d ", array[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 59140
#include <bits/stdc++.h>
using namespace std;
int main(void){
    cout << fixed << setprecision(12);
    double L;
    cin >> L;
    double T,Y;
    T = Y = L / 3;
    //cout << T << endl;
    double H = L - T - Y;
    double V = T * Y * H;
    /*for(int i = 1; i <= L; i++){
        for(int j = 1; j <= L-i; j++){
            double H = L - i - j;
            V_max = max(V_max,i*j*H);
        }
    }*/

    cout << V << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int slove(int n) {
  int s;
  if(n == 1) s = 300000;
  else if(n == 2) s = 200000;
  else if(n == 3) s = 100000;
  else s = 0;
  return s;
}

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

  int ans = 0;
  cin >> x >> y;
  ans += slove(x);
  ans += slove(y);

  if(x == 1 && y == 1) ans += 400000;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define mod 1e9+7
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))
int compare(const void *a,const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int N,D;
	scanf("%d%d",&N,&D);
	printf("%d",(N+D+D)/(D+D+1));
	return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll k;
    cin >> k;
    ll a = 7;
    REP(i, k){
        ll b = a % k;
        if(b == 0){
            cout << i + 1;
            return 0;
        }
        a = b*10 + 7;
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 3632
from collections import defaultdict


def p_d():
    N, Q = map(int, input().split())
    l = defaultdict(list)
    ans = [0] * N

    for _ in range(N - 1):
        a, b = map(int, input().split())
        l[a].append(b)

    for _ in range(Q):
        p, x = map(int, input().split())
        ans[p - 1] += x

    for i in range(N):
        for j in l[i]:
            ans[j - 1] += ans[i - 1]

    print(*ans)


if __name__ == '__main__':
    p_d()


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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int n;
  cin >> n;
  vi t(n), v(n);
  int sum = 0;
  rep(i, 0, n) {
    cin >> t[i];
    t[i] *= 2;
    sum += t[i];
  }
  rep(i, 0, n) {
    cin >> v[i];
    v[i] *= 2;
  }

  int nw = 0, tot = 0;
  vi d(sum + 1);
  rep(i, 0, n) {
    tot += t[i];
    d[nw] = min(d[nw], v[i]);
    nw++;
    for(; nw <= tot; ++nw) d[nw] = min(d[nw - 1] + 1, v[i]);
    nw--;
  }

  int s = 0, mn = 0;
  for(int i = nw - 1; i > 0; --i) {
    mn = min(mn + 1, d[i]);
    s += mn;
  }
  cout << fixed << setprecision(20) << (double)s / 4 << endl;
}


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

int main(){
  int n, q;
  cin >> n >> q;
  
  string s;
  cin >> s;
  
  vector<int> sum(n + 1);  // 累積和配列 [l, r]の和はsum[r] - sum[l - 1]
  for(int i = 1 ; i < n ; ++i){
    if(s[i - 1] == 'A' && s[i] == 'C'){
      // ACが現れた位置をインクリメント
      // クエリは1-indexedで与えられるのでそれに合わせると便利
      ++sum[i + 1];
    }
  }
  
  for(int i = 1 ; i <= n ; ++i){
    // [0, i - 1]の和をiの値に足すと、[0, i]の和になる
    sum[i] += sum[i - 1];
  }
  
  for(int i = 0 ; i < q ; ++i){
    int l, r;
    cin >> l >> r;
    // 通常は、先程書いた通りsum[r] - sum[l - 1]
    // しかし、累積和配列はACのCが現れた位置で+1してるので
    // l文字目がCでl - 1文字目がAのときに1多くなってしまう
    // なので、今回はsum[r] - sum[l]として、それを避ける
    cout << sum[r] - sum[l] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1408
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        while(true){
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        if(h == 0 && w == 0){
            break;
        }
        int[][] yard = new int[h][w];
        int max = 0;
        int cap = 0;
        int lakemax = 0;
        int yardmin = 10;
        int flag = 0;
        int cap1 = 0;
        for(int i = 0;i<h;i++){
            for(int j = 0;j<w;j++){
                yard[i][j] = scanner.nextInt();
            }
        }

        for(int i = 3;i <= h;i++){
            for(int j = 3;j<=w;j++){
                for(int h_start = 0;h_start<=h-i;h_start++){
                    for(int w_start = 0;w_start<=w-j;w_start++){
                        for(int h_yardsearch = h_start;h_yardsearch<h_start+i;h_yardsearch++){
                            for(int w_yardsearch = w_start;w_yardsearch<w_start+j;w_yardsearch++){
                                if(h_yardsearch != h_start && h_yardsearch != h_start+i-1){
                                    yardmin = yardmin>yard[h_yardsearch][w_yardsearch]?yard[h_yardsearch][w_yardsearch]:yardmin;
                                    yardmin = yardmin>yard[h_yardsearch][w_yardsearch+j-1]?yard[h_yardsearch][w_yardsearch+j-1]:yardmin;
                                    break;
                                }
                                yardmin = yardmin>yard[h_yardsearch][w_yardsearch]?yard[h_yardsearch][w_yardsearch]:yardmin;
                                
                            }
                        }
                        for(int h_lakesearch = h_start+1;h_lakesearch<h_start+i-1;h_lakesearch++){
                            for(int w_lakesearch = w_start+1;w_lakesearch<w_start+j-1;w_lakesearch++){
                                cap1 = yardmin-yard[h_lakesearch][w_lakesearch];
                                if(cap1<=0){
                                    flag = 1;
                                    break;
                                }else{
                                    cap += cap1;
                                }
                            }
                            if(flag == 1){
                                break;
                            }
                        }
                        if(flag ==1){
                        }else{
                            max = max<cap?cap:max;
                        }
                        cap = 0;
                        flag = 0;
                        yardmin = 10;
                    }
                }
            }
        }

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


Measured memory_bytes: 37344
//////////////////////////
/*      _        ____   */
/*  U  /"\  u U /"___|  */
/*   \/ _ \/  \| | u    */
/*   / ___ \   | |/__   */
/*  /_/   \_\   \____|  */
/*   \\    >>  _// \\   */
/*  (__)  (__)(__)(__)  */
/*  Compro by NULL_CT©  */
//////////////////////////
/*STL Libs*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

/*Boost to boost compile time*/
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long // Black Magic
#define REP(I, LIM) for (int I = 0; I < LIM; I++)
#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;
using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 10000007;

vector<int> divisor(int n) {
  vector<int> head, tail;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      head.push_back(i);
      if (i * i != n)
        tail.push_back(n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return (head);
}

//--------------------------------

void execute() {
  string s;
  cin>>s;
  int num;
  if(s=="SUN")num=7;
  if(s=="MON")num=6;
  if(s=="TUE")num=5;
  if(s=="WED")num=4;
  if(s=="THU")num=3;
  if(s=="FRI")num=2;
  if(s=="SAT")num=1;
  cout<<num<<endl;
}

//--------------------------------

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  // cout<<fixed<<setprecision(20);

  execute();

  return (0);
}


Measured memory_bytes: 3220
s = gets.chop.to_s

i = 1
ret = true
s.chars {|ch|
  if ch.match(/[UD]/)
  elsif i % 2 == 1 and ch.match(/R/)
  elsif i % 2 == 0 and ch.match(/L/)
  else
    ret = false
  end

  if !ret
    break
  end

  i += 1
}

if ret
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
int N, M;
vector <int> G[100005];
 
bool visited[100005];
 
void dfs(int v) {
    visited[v] = true;
    for(auto u: G[v]) if(!visited[u]) {
        dfs(u);
    }
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int ans = 0;
    for(int i = 1; i <= N; i++) {
        if(!visited[i]) {
            ans++;
            dfs(i);
        }
    }
    cout << ans;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a ,b ,c ,t1 ,t2;
	scanf("%d%d%d",&a,&b,&c);
	if(a > b)
		swap(a,b);
	if(a > c)
		swap(a,c);
	if(b > c)
		swap(b,c);
	t1 = c-a;
	t2 = c-b;
	if((t1+t2)%2)
		printf("%d",((c+1)*3-(a+b+c))/2);
	else printf("%d",(t1+t2)/2);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int num;
  int line[3];
  int i, j;

  scanf("%d", &num);
  for (i = 0; i < num; i++) {
    for (j = 0; j < 3; j++) {
      scanf("%d", &line[j]);
      line[j] *= line[j];
    }
    if (line[0] + line[1] == line[2] ||
	line[1] + line[2] == line[0] ||
	line[2] + line[0] == line[1]) {
      puts("YES");
    } else {
      puts("NO");
    }
  }

  return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

// https://atcoder.jp/contests/m-solutions2020/submissions/15428468
// ピークだけを見る解法
// 下りピーク, 上がりピーク1つで売買を終えたとする
// 最初より所持金増えてる
// よって, ピークの度売買すべき

// https://img.atcoder.jp/m-solutions2020/editorial.pdf
// 100≤ai≤200, 最大2倍を80/2=40回できる
// 1000 * 2^40 < 2^10 * 2^40 = 2^50
// 前日より値上がりする度売買すべき
void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;
    
    ll ans = 1000;
    rep(i, n - 1) {
        if (a[i] < a[i + 1]) ans += ans / a[i] * (a[i + 1] - a[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<climits>
using namespace std;
void File(){
	freopen("AGC02E.in","r",stdin);
	freopen("AGC02E.out","w",stdout);
}
template<typename T>bool chkmax(T &_,T __){return _<__ ? (_=__,1) : 0;}
template<typename T>bool chkmin(T &_,T __){return _>__ ? (_=__,1) : 0;}
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
#define MREP(i,x) for(register int i=beg[x];i;i=E[i].last)
#define mem(a) memset(a,0,sizeof(a))
#define inf INT_MAX
const int maxn=1e5+10;
int n,a[maxn],SG[1010][1010];
bool cmp(int _,int __){return _>__;}
bool judge(int x,int y){return x<=n && y<=a[x];}	
int main(){
	//File();
	scanf("%d",&n);
	REP(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	int px=1,py=1,step1=0,step2=0;
	while(judge(px+1,py+1))++px,++py;
	while(judge(px+step1,py))++step1;
	while(judge(px,py+step2))++step2;
	//cout<<px<<" "<<py<<endl;
	if(step1%2==0 || step2%2==0)puts("First");
	else puts("Second");
	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

int main(){

  int flag,a[100],i,num,swap,count=0;
  
  scanf("%d",&num);
  for(i = 0; i < num; i++){
    scanf("%d",&a[i]);
  }

  flag=1;
  while(flag){
    flag=0;

    for(i = num-1; i >= 1; i--){
      if(a[i]<a[i-1]){
	swap  =  a[i];
	a[i]  =  a[i-1];
	a[i-1] = swap;
	count ++;
	flag = 1;
      }
    }

  }
  for(i = 0; i < num-1; i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[i]);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 600
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop
# https://atcoder.jp/contests/abc056/tasks/abc056_b

def main():
    w, a, b = map(int, input().split())
    print(max(0, abs(a - b) - w, 0))

if __name__ == '__main__':
    main()


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using pii = pair<int, int>;

inline void Main() {
  // code
  int n,a[200000],b[200000];
  cin>>n;
  rep(i,n) cin>>a[i];
  memcpy(b, a, sizeof(a));
  sort(b,b+n);

  rep(i, n) {
    if(a[i] == b[n-1]) {
      cout << b[n-2] << endl;
    } else {
      cout << b[n-1] << endl;
    }
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<math.h>
int main()
{
	int h, w, n;
	scanf("%d %d %d", &h, &w, &n);
	int max,count=0;
	max = h > w ?  h: w;
	for (count = 0;; count++)
	{
		if (count * max >= n)
		{
			printf("%d", count);
			break;
		}
	}
}

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

int main()
{
  char number[1001];
  int i,sum,len;

  while (1){
    sum=0;
    scanf("%s",number);
    len=strlen(number);
    if (number[0]=='0'){
      break;
    }else{
      for (i=0;i<len;i++){
        sum+=(int)(number[i]-'0');
      }
    }
    printf("%d\n",sum);
  }

  return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;

int main(){
 ll n; cin>>n;
  vector<ll>h(n);
  bool ok=true;
  rep(i,n){ cin>>h[i]; }
  //reverse(h.begin(),h.end());
  h[0]--;
  for(ll i=1;i<n;i++){
    if(h[i]-h[i-1]<0){ ok=false; break; }
    else if(h[i]-h[i-1]>0) h[i]--;
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

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

    for(int i=0; str[i]!='\0'; i++)
    {
        if(str[i]==',') cout << ' ';
        else cout << str[i];
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 3620
a,b,c,k=map(int,input().split())
a_=min(a,k)
sum_=max(0,k-a)
res=a_*1
b_=min(sum_,b)
sum_=max(0,sum_-b)
res+=b_*0
c_=min(sum_,c)
res+=(-1)*c_
print(res)

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

int main() {
	int n;
	unordered_set<string> d;
	string ope, contents;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ope >> contents;
		if (ope == "insert") d.insert(contents);
		else if (ope == "find") {
			if (d.count(contents) >= 1) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 32200
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
using namespace std;


int main() {
	map<int, int> mp;
	long long int a, b = 0, num[200005], sum[200005] = {}, n, cou = 0, res = 0, memo,min=10000;
	string str,str2,str3;
	cin >>n;
	
	for (int i = 0; i < n; i++) {
		cin >> num[i]>>sum[i];
	}
	for (int i = n-1; i >=0; i--) {
		if((num[i]+cou)%sum[i]!=0)cou +=sum[i] - (num[i]+cou) % sum[i];
	}
	cout <<cou;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;
ll k;

ll count(string t) {
  ll cnt = 0LL;

  t.push_back('_');

  ll cur = 1LL;
  for (int i = 1; i < t.size(); ++i) {
    if (t[i] == t[i - 1]) {
      cur += 1LL;
    } else {
      cnt += cur / 2LL;
      cur = 1LL;
    }
  }

  return cnt;
}

int main(void) {
  // Here your code !
  cin >> s;
  scanf("%lld", &k);

  ll ans = count(s) * k;

  string tmp(s.size(), s[0]);

  if (tmp == s) {
    printf("%lld\n", (ll)(s.size()) * k / 2LL);
    return 0;
  }

  if (s[0] == s.back()) {
    char target = s[0];

    ll a = 0LL;
    for (int i = s.size() - 1; i >= 0; --i) {
      if (s[i] != target) break;
      a += 1LL;
    }

    ll b = 0LL;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] != target) break;
      b += 1LL;
    }

    ll connect_part = (a + b) / 2LL - (a / 2LL + b / 2LL);

    ans += connect_part * (k - 1LL);
  }

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

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

int main() {
    int n, m;
    cin >> n >> m;
    vi x(m);
    vi y(m);
    rep (i, m) {
        int xx, yy;
        cin >> xx >> yy;
        --xx; --yy;
        x[i] = xx;
        y[i] = yy;
    }

    vi amount(n, 1);
    deque<bool> red(n, false);
    red[0] = true;
    rep (i, m) {
        amount[x[i]] -= 1;
        amount[y[i]] += 1;
        if ( red[x[i]] ) {
            red[y[i]] = true;
            if ( amount[x[i]] == 0 ) {
                red[x[i]] = false;
            }
        }
    }
    int ans = 0;
    rep (i, n) {
        if ( red[i] ) {
            ans += 1;
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 1536
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>

int main()
{
	int n, a, b;
	int min, max;

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

	max = a < b ? a : b;

	min = (a + b - n) > 0 ? a + b - n : 0;

	printf("%d %d\n", max, min);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cassert>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds; 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int MAXN=2e6+1;
const int M=1e9+7;
const int N=6e6+6;

void solve(){
	int n,k,c;
	sfi(n) sfi(k) sfi(c)

	vector<int> dp(n+1,0),dp1(n+1,0),v(n);

	string s;
	cin>>s;

	f(i,0,n){
		cin>>v[i];
	}

	int maxi=0,ind=0;

	int cnt=0;

	f(i,0,n){

		while((i-ind)>=(c+1)){
			maxi=max(maxi,dp[ind]);
			ind++;
		}
		if(s[i]=='x'){
			dp[i]=maxi;
		}
		else{
			cnt++;
			dp[i]=1+maxi;
		}

		if(i!=0){
			dp[i]=max(dp[i],dp[i-1]);
		}
		//cout<<dp[i]<<" "<<ind<<endl;
	}

	ind=n-1,maxi=0;

	dp1[n]=0;

	for(int i=n-1;i>=0;i--){
		while((ind-i)>=(c+1)){
			maxi=max(maxi,dp1[ind]);
			ind--;
		}
		if(s[i]=='x'){
			dp1[i]=maxi;
		}
		else{
			dp1[i]=1+maxi;
		}

		if(i!=n-1){
			dp1[i]=max(dp1[i],dp1[i+1]);
		}
	}

	vector<int> fin;

	int util[n+2]={0};

	for(int i=-1;i+c+1<=n;i++){
		//cout<<i<<endl;
		int val1=(i==-1)?0:dp[i];
		int val2=dp1[i+c+1];

		//cout<<i<<" "<<i+c+1<<" "<<val1<<" "<<val2<<endl;
		if(val1+val2>=(k)){
			util[i+1]+=1;
			util[i+c+1]-=1;
		}

		
	}

	int tot=0;



	for(int i=0;i<n;i++){
		tot+=util[i];

		int val1=(i-1)==-1?0:dp[i-1];
		int val2=(i+1)==n?0:dp1[i+1];

		//cout<<tot<<" "<<val1<<" "<<val2<<endl;
		if(s[i]=='o' && tot<=0 && val1<k && val2<k){
			fin.push_back(i);
		}
	}

	if(c==0){
		if(cnt==k){
			for(int i=0;i<n;i++){
				if(s[i]=='o'){
					cout<<i+1<<endl;
				}
			}
		}
		else{

		}
		return;
	}


	for(int x:fin){
		cout<<x+1<<"\n";
	}
	//cout<<"**";
	

}
int main(){	
	
	solve();
	return 0;	
}

Measured memory_bytes: 5752
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7


    N = II()
    if N == 0:
        print(0)
        return
    ans_stack = deque()
    determined = 0
    for i in range(100):
        if (N - determined) % 2 ** (i+1) != 0:
            ans_stack.append(1)
            determined += (-2) ** i
        else:
            ans_stack.append(0)
        if determined == N:
            break
    ans_str = ''
    while len(ans_stack) > 0:
        item = ans_stack.pop()
        ans_str += str(item)
    print(ans_str)
    '''
    1 -2 4 -8 16 -32 64 -128
    '''
            
if __name__ == '__main__':
    main()

Measured memory_bytes: 64364
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    a = int(input())
    b = int(input())
    c = int(input())

    print((a + b) * c // 2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10272
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int N,A,B,C;
vint l;

int rec(int i,int a,int b,int c){
    if(i==N){
        if(!a or !b or !c) return 1e9;
        return abs(a-A)+abs(b-B)+abs(c-C);
    }
    int res=rec(i+1,a,b,c);
    res=min(res,rec(i+1,a+l[i],b,c)+(a>0? 10:0));
    res=min(res,rec(i+1,a,b+l[i],c)+(b>0? 10:0));
    res=min(res,rec(i+1,a,b,c+l[i])+(c>0? 10:0));
    return res;
}

signed main()
{
    cin>>N>>A>>B>>C; 
    l.resize(N);
    REP(i,N) cin>>l[i];
    cout<<rec(0,0,0,0)<<endl;
}


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


#define ll long long
#define IM INT_MAX
#define LM LLONG_MAX
#define m_p make_pair
#define MOD 1000000007
#define dbg(x) cerr << #x << " = " << x << "\n"


/*
ID: vlad.io1
TASK: 
LANG: C++
*/


bool comp(int a, int b) {
	return a > b;
}


template<typename T>
T gcd(T a, T b) {
	while (a != 0 && b != 0) {
		if (a > b) {
			a %= b;
		} else {
			b %= a;
		}
	}
	return (a > b ? a : b);
}


void solve() {
	int n;
	cin >> n;
	int cnt=0;
	for(int i = 1, x; i <= n; i++) {
		cin >> x;
		if((i&1) && (x&1)) cnt++;
	}
	cout << cnt << ' ';
}


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

	//freopen("output.txt", "w", stdout);
	//freopen("input.txt", "r", stdin);

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

	while(t--)
		solve();
}


























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

int sq(int x){
  return x*x*x*x*x;
}

signed main(){


  int x;
  cin >> x;
  for(int a=-5000;a<=5000;a++){
    for(int b=-5000;b<=5000;b++){
      if(sq(a)-sq(b)==x){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3636
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  string S;
  cin >> N >> S;
  vector<int64_t> digits(N);
  int64_t original_pop_count = 0;
  for (int64_t i = 0; i < N; ++i) {
    digits[i] = static_cast<int64_t>(S[i] - '0');
    if (digits[i] == 1) {
      ++original_pop_count;
    }
  }
  const int64_t plus_pop_count = original_pop_count + 1;
  const int64_t minus_pop_count = original_pop_count - 1;

  int64_t original_plus = 0;
  int64_t original_minus = 0;
  if (plus_pop_count > 1) {
    for (int64_t i = 0; i < N; ++i) {
      original_plus *= 2;
      original_plus += digits[i];
      original_plus %= plus_pop_count;
    }
  }
  if (minus_pop_count > 1) {
    for (int64_t i = 0; i < N; ++i) {
      original_minus *= 2;
      original_minus += digits[i];
      original_minus %= minus_pop_count;
    }
  }

  auto PopCount = [&](int64_t n) -> int64_t {
    int64_t result = 0;
    while (n > 0) {
      result += (n & 1L);
      n = (n >> 1L);
    }
    return result;
  };
  auto F = [&](auto &&Func, const int64_t n) -> int64_t {
    if (n == 0) {
      return 0;
    }
    const int64_t p = PopCount(n);
    if (p == 1) {
      return 1;
    }
    int64_t next = n % p;
    const int64_t result = Func(Func, next) + 1;
    return result;
  };

  int64_t diff_plus = 1;
  int64_t diff_minus = 1;
  vector<int64_t> results(N, 0);
  for (int64_t i = N - 1; i >= 0; --i) {
    int64_t pop_count = (digits[i] == 0) ? plus_pop_count : minus_pop_count;
    if (pop_count <= 0) {
      results[i] = 0;
      continue;
    }
    int64_t next_val = 0;
    if (digits[i] == 0) {
      next_val = original_plus + diff_plus;
      next_val %= pop_count;
    } else {
      next_val = original_minus - diff_minus;
      next_val %= pop_count;
      next_val += pop_count;
      next_val %= pop_count;
    }
    results[i] = F(F, next_val) + 1;

    if (plus_pop_count > 0) {
      diff_plus *= 2;
      diff_plus %= plus_pop_count;
    }
    if (minus_pop_count > 0) {
      diff_minus *= 2;
      diff_minus %= minus_pop_count;
    }
  }
  for (const auto &r : results) {
    cout << r << endl;
  }
  return 0;
}


Measured memory_bytes: 6756
_n = gets.to_i
a = gets.split.map(&:to_i).sort
max = a.max
dp = Array.new(max + 1) { true }
h = Hash.new(0)

a.each do |e|
  h[e] += 1 if dp[e]

  (max / e - 1).times do |i|
    dp[e * (i + 2)] = nil
  end
end

puts h.count { |_k, v| v == 1 }

Measured memory_bytes: 46644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string A,B;
    string g = "GREATER";
    string l = "LESS";
    string e = "EQUAL";
    cin >> A >> B;
    if(A == B) {
        cout << e << endl;
        return 0;
    }
    if(A.length()>B.length()){
        cout << g << endl;
    }else if(A.length()<B.length()){
        cout << l << endl;
    }else{
        if(A > B){
            cout << g << endl;
        }else{
            cout << l << endl;
        }
    }
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = []
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(tuple([b,a]))
    A.sort()
    total = 0
    for a, b in A:
        total+=b
        if a < total:
            print('No')
            return
    print('Yes')
main()

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

int main() {
  int N, x; cin >> N >> x;
  vector<int> a(N);
  rep(i, N) {cin >> a.at(i);}
  sort(a.begin(), a.end());

  int counter = 0;

  for(int i = 0; i < a.size(); i++){
    x -= a.at(i);
    counter++;

    if(x == 0) {
      break;
    } else if(x < 0){
      counter--;
      break;
    }
  }

  if(x > 0) counter--;

  cout << counter << endl;
}

Measured memory_bytes: 256
// 

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int reach(int n, int dst) {
    int count = 0;
    for (; n < dst; count++) {
        n *= 2;
    }
    return count;
}

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

    double ans = 0.0;
    for (int i = 1; i <= n; i++) {
        //double tmp = (1.0 / (double)n) * pow(0.5, reach(i, k));
        //cout << i << ": " << tmp << endl;
        ans += (1.0 / (double)n) * pow(0.5, reach(i, k));
    }

    cout << setprecision(12) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;

namespace B_105
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var b = 0;
            for (var i = 1; i <= n; i++)
            {
                var a = 0;
                for (var j = 1; j <= i; j++)
                {
                    if (i % 2 == 1 && i % j == 0)
                    {
                        a++;
                    }  
                }
                if (a == 8)
                {
                    b++;
                }
            }
            Console.WriteLine(b);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define int long long
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}
bool vis[100005];
vector<int> vec[100005];
int child[100005];
void dfs(int node)
{
    vis[node] = 1;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            child[node] += child[vec[node][i]];
        }
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    cin >> str;
    int n;
    n = str.length();
    int i;
    bool flag = 0;
    for (i = n - 2; i >= 0; i--)
    {
        flag = 0;
        if ((i) % 2 == 0)
        {
            for (int j = 0; j < i / 2; j++)
            {
                if (str[j] != str[j + (i / 2)])
                    flag = 1;
            }
            if (flag == 0)
                break;
        }
    }
    cout << i << "\n";

    return 0;
}


Measured memory_bytes: 5932
#include <iostream>
#include <cstdio>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    if(n % 2 == 0){
        cout << 0.5 << endl;
    }else{
        printf("%.7f\n", (double)(n / 2 + 1) / n);
    }
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005

int n,a,b,c;
vector<int> G[MAX];
int size[MAX];
int par[MAX];
int dep[MAX];
int depth[MAX];
int parent[MAX];

void idfs(int pos){
  int m=-1;
  if(G[pos].empty())return;
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    depth[to]=depth[pos]+1;
    idfs(to);
    size[pos]+=size[to];
    if(m==-1||size[m]<size[to])m=to;
  }
  par[m]=pos;
}

int calc(int x){
  if(par[x]==x)return x;
  return par[x]=calc(par[x]);
}

void init(){
  for(int i=0;i<MAX;i++){
    size[i]=1;
    par[i]=i;
  }
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    while(a--){
      scanf("%d",&b);
      G[i].push_back(b);
      parent[b]=i;
    }
  }
  idfs(0);
  for(int i=0;i<n;i++){
    int p=calc(i);
    while(p){
      p=par[parent[p]];
      dep[i]++;
    }
  }
}

int main(){
  scanf("%d",&n);
  init();
  int q;
  scanf("%d",&q);
  while(q--){
    scanf("%d %d",&a,&b);
    while(par[a]!=par[b]){
      if(dep[a]<dep[b])swap(a,b);
      a=parent[par[a]];
    }
    printf("%d\n",(depth[a]<depth[b]?a:b));      
  }
  return 0;
}

Measured memory_bytes: 16032
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll dp[43][(1 << 17) + 3];

ll pow(int N) {
	ll num = 1; while(N--) num = (num * 10) % mod;
	return num;
}

int main() {
	int N, X, Y, Z; cin >> N >> X >> Y >> Z; Y += X; Z += Y;
	dp[0][0] = 1; int maxx = (1 << 17);
	for(int i = 0; i < N; ++i) {
		for(int j = 0; j < maxx; ++j) {
			if((j & (1 << (X - 1))) && (j & (1 << (Y - 1))) && (j & (1 << (Z - 1)))) continue;
			for(int k = 1; k <= 10; ++k) {
				int mask = (maxx - 1) & ((j << k) | (1 << (k - 1)));
				dp[i + 1][mask] = (dp[i + 1][mask] + dp[i][j]) % mod;
			}
		}
	}
	ll ans = 0;
	for(int j = 0; j < maxx; ++j) {
		if((j & (1 << (X - 1))) && (j & (1 << (Y - 1))) && (j & (1 << (Z - 1)))) continue;
		ans = (ans + dp[N][j]) % mod;
	}
	ll t = pow(N);
	ans = ((t - ans) % mod + mod) % mod;
	printf("%lld\n", ans);
	return 0;
}

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

vector<int> G[100];
pair<int, int> T[100];
const int Inf = 10000*100000+100;
int timer = 1;

int main() {
  void dfs(int cur);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int u, k;
    cin >> u >> k;
    for (int l = 0; l < k; l++) {
      int v;
      cin >> v;
      G[i].push_back(v - 1);
    }
    T[i] = make_pair(Inf, Inf);
  }
  for (int i = 0; i < n; i++) {
    if (T[i].first == Inf) {
      dfs(i);
    }
  }
  for (int i = 0; i < n; i++)
  {
    cout << i + 1 << " " << T[i].first << " " << T[i].second << endl;
  }
}

void dfs(int cur) { // cur を訪問
  // cur の訪問時刻を記録
  T[cur].first = timer;
  timer += 1;
  // 動作確認用表示
  for (int dst : G[cur]) { // 全ての節点 dst について
    if (T[dst].first == Inf)
    { // cur から dst に辺があり，dst を未訪問なら
      dfs(dst);
    }
  }
  T[cur].second = timer;
  timer += 1;
}


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

using namespace std;
long long MOD=1000000007;
long long MOD2=998244353;

int main(){
  int A,B; cin>>A>>B;
  if(A+B==3) cout<<3;
  else if(A+B==4) cout<<2;
  else cout<<1;
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main
{
    public static void main(String args[])
    {
        
        Scanner sc = new Scanner(System.in);
      String line=sc.next();
        
        String[] Array= line.split("");
        
        for(int i=0; i<Array.length;i++)
        {
            if(Array[i].equals("?"))
            {
                Array[i]="D";
            }
            System.out.print(Array[i]);
        }
    }
}
            

Measured memory_bytes: 68488
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[1000006] = {};
	ll y[200005] = {};
	ll z[200005] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;

	cin >> a;
	cin >> b;
	if (abs(a-b)>1)
	{
		cout << 0 << endl;
		return 0;
	}
	else
	{

		ans = 1;
		if (a==b)
		{
			ans *= 2;
		}
		while (a>0)
		{
			ans *= a;
			ans %= 1000000007;
			a--;
		}
		while (b>0)
		{
			ans *= b;
			ans %= 1000000007;
			b--;
		}
	}

	cout << ans << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

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

typedef long long ll;
typedef pair<int,int> P;

int n,p;
int a[101];
ll dp[101][2];

int main(void){
	scanf("%d%d",&n,&p);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<2;j++){
			dp[i+1][(j+a[i])%2]+=dp[i][j];
			dp[i+1][j]+=dp[i][j];
		}
	}
	printf("%lld\n",dp[n][p]);
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().strip()

class PERM_COMB_MOD():
    # http://drken1215.hatenablog.com/entry/2018/06/08/210000
    def __init__(self, max_n=510000, mod=10**9+7):
        self.fac = [0]*max_n
        self.finv = [0]*max_n
        self.inv = [0]*max_n
        self.fac[0] = self.fac[1] = 1
        self.finv[0] = self.finv[1] = 1
        self.inv[1] = 1
        self.max = max_n
        self.mod = mod
        self._maesyori()

    def _maesyori(self):
        for i in range(2,self.max):
            self.fac[i] = self.fac[i-1] * i % self.mod
            self.inv[i] = self.mod - self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod

    def comb(self, n, k):
        if n < k : return 0
        if n < 0 or k < 0:return 0
        return self.fac[n] * (self.finv[k] * self.finv[n-k] % self.mod) % self.mod

mod = 10**9+7
PCM = PERM_COMB_MOD(3*10**5, mod=mod)

h,w,n = map(int, input().split())
rc = [list(map(int, input().split())) for i in range(n)]
rc.append([h,w])
n += 1

rc.sort()

DP = [0]*(n+1)
# start地点
DP[0] = 1
for i in range(n):
    r,c = rc[i]
    DP[i+1] = PCM.comb(r-1+c-1, r-1)
    for j in range(i):
        rj, cj = rc[j]
        if rj <= r and cj <= c:
            DP[i+1] -= DP[j+1]*PCM.comb(r-rj+c-cj, r-rj)
    DP[i+1] %= mod

print(DP[-1])

Measured memory_bytes: 51180
N, A, B = map(int, input().split())
S = input()
y = 0
k = 0
for i in S:
    if i=='c':
        print('No')
    elif i=='a':
        if (y<(A+B)):
            print('Yes')
            y += 1
        else:
            print('No')
    else:
        if (y<(A+B))and(k<B):
            print('Yes')
            y += 1
            k += 1
        else:
            print('No')

Measured memory_bytes: 4016
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";

        int const N = 200009;
        map<pair<int,int>,int> mp;
        int a[N];
        int const inf = 1e15;

        int fun(int n, int k)
        {

            if(k < 0 || n < 0)
                return -inf;
            else if(k == 1)
            {
                int mx = -inf;
                for(int i = 1; i <= n; i++)
                    mx = max(mx, a[i]);
                return mx;
            }
            else if(mp.find({n, k})!=mp.end())
                return mp[{n,k}];
            else
            {
               
                int ans = -inf;
                if((k-1) <= (n-1)/2)
                    ans = max(ans, a[n] + fun(n-2,k-1));
                if(k <= n/2)
                    ans = max(ans, fun(n-1, k));
                return mp[{n,k}] = ans;
            }
        }

    
       

        int32_t main()
        {
            tani_nachi_ke  
            
           int n;
           cin >> n;
           for(int i = 1; i <= n; i++)
            cin >> a[i];
       
        cout << fun(n, n/2) << endl;
            





           return 0;
        }
          

Measured memory_bytes: 33332
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>a>>b;
    if(abs(a-b)>=2) {
        cout<<0<<endl;
        return 0;
    }
    c=1;
    REP(i,1,a+1){ 
        c*=i;
        c%=mod;
    }
    d=1;
    REP(i,1,b+1) {
        d*=i;
        d%=mod;
    }
    if(a==b)cout<<c*d*2%mod<<endl;
    else cout<<c*d%mod<<endl;

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

#define mod 1000000007

int main(){
	int n;
	cin >> n;
	int ans = 1;
	int now = 0;
	int p;
	cin >> p;
	for(int i = 1;i < n;i++){
		int j;
		cin >> j;
		switch(now){
		case -1:
			if(p < j){
				now = 0;
				ans++;
			}
			break;
		case 0:
			if(p < j) now = 1;
			if(p > j) now = -1;
			break;
		case 1:
			if(p > j){
				now = 0;
				ans++;
			}
			break;
		}
		p = j;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256