akhauriyash/Code-Regression huggingface dataset:
from collections import deque
from sys import stdin

def create_links(n, k):
  links = [[] for _ in range(n)]
  for i in range(k):
    p, q = map(int, stdin.readline().split())
    links[p - 1].append(q - 1)
    links[q - 1].append(p - 1)
  return links

def create_groups(n, links):
  groups = list(range(n))
  for i in range(n):
    if groups[i] != i:
      continue
    d = deque()
    d.append(i)
    while len(d) != 0:
      j = d.popleft()
      for k in links[j]:
        if groups[k] != i:
          groups[k] = i
          d.append(k)
  return groups

n, k, l = map(int, input().split())
road_links = create_links(n, k)
rail_links = create_links(n, l)
road_groups = create_groups(n, road_links)
rail_groups = create_groups(n, rail_links)

d = {}
for i in range(n):
  t = (road_groups[i], rail_groups[i])
  if t in d:
    d[t] += 1
  else:
    d[t] = 1

print(*[d[(road_groups[i], rail_groups[i])] for i in range(n)])


Measured memory_bytes: 89584
#include <bits/stdc++.h>
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
using namespace std;
template <class T> void rd(T &x){
  x = 0; int f = 1; char ch = getchar();
  while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
  while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}

typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 5;
int n;
ll a, b, c;
ll fac[maxn], fin[maxn];
ll ans;

ll C(ll n, ll m){ return fac[n] * fin[m] % mod * fin[n - m] % mod; }

ll power(ll x, ll n){
  ll y = 1;
  for(; n; n >>= 1, x = x * x % mod)
    if(n & 1) y = y * x % mod;
  return y;
}

#define inv(x) power(x, mod - 2)

int main(){
  rd(n), rd(a), rd(b), rd(c);
  ll t = a + b;
  a = a * inv(t) % mod;
  b = b * inv(t) % mod;
  fac[0] = 1;
  rep(i, 1, 2 * n) fac[i] = fac[i - 1] * i % mod;
  fin[2 * n] = inv(fac[2 * n]);
  per(i, 2 * n, 1) fin[i - 1] = fin[i] * i % mod;
  rep(i, 0, n - 1){
    ans = (ans + (i + n) * power(a, i) % mod * power(b, n) % mod * C(n + i - 1, i) % mod) % mod;
    ans = (ans + (i + n) * power(a, n) % mod * power(b, i) % mod * C(n + i - 1, i) % mod) % mod;
  }
  ans = ans * 100 % mod * inv(100 - c) % mod;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3328
fn main() {
    let type_counts = read();
    let mut type_counts = type_counts.split(' ').map(|s| s.parse::<usize>().unwrap());
    let _reizouko_cnt = type_counts.next().unwrap();
    let _denshirenji_cnt = type_counts.next().unwrap();
    let waribikiken_cnt = type_counts.next().unwrap();

    let reizoukos = read();
    let reizoukos: Vec<usize> = reizoukos.split(' ').map(|s| s.parse::<usize>().unwrap()).collect();
    let denshirenjis = read();
    let denshirenjis: Vec<usize> = denshirenjis.split(' ').map(|s| s.parse::<usize>().unwrap()).collect();
    let mut minumum_reizouko = reizoukos[0];
    for reizouko in &reizoukos {
        if minumum_reizouko > *reizouko {
            minumum_reizouko = *reizouko;
        }
    }
    let mut minumum_denshirenji = denshirenjis[0];
    for denshirenji in &denshirenjis {
        if minumum_denshirenji > *denshirenji {
            minumum_denshirenji = *denshirenji;
        }
    }
    let mut current_min = minumum_denshirenji + minumum_reizouko;
    for _ in 0..waribikiken_cnt {
        let values = read();
        let mut values = values.split(' ').map(|s| s.parse::<usize>().unwrap());
        let target_reizouko = values.next().unwrap();
        let target_denshirenji = values.next().unwrap();
        let waribiki_nedan = values.next().unwrap();

        let applied = reizoukos[target_reizouko - 1] + denshirenjis[target_denshirenji - 1] - waribiki_nedan;
        if current_min > applied {
            current_min = applied;
        }
    }
    println!("{}", current_min);
}
fn read() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}


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

int gcd(int,int);

int main() {
	long int N,ans=0;
	cin >> N;

	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			for(int k=1;k<=N;k++){
				ans+=gcd(gcd(i,j),k);
			}
		}
	}

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

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


Measured memory_bytes: 3636
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

def main():
	n = int(input())
	a = list(map(int,input().split()))
	b = list(map(int,input().split()))
	t = sum(b)
	for i in reversed(range(n)):
		c = a[i+1] - b[i]
		a[i+1] = 0 if c<0 else c
		b[i] = 0 - c if c < 0 else 0
		c = a[i] - b[i]
		a[i] = 0 if c<0 else c
		b[i] = 0 - c if c < 0 else 0
	print(t-sum(b))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


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

int main(){
    int N, l[120000], r[120000], sum = 0;
    cin >> N;

    for(int i=0; i<N; i++){
        cin >> l[i] >> r[i];
        if(l[i] == r[i]){
            sum ++;
        }

        else{
            sum += r[i] - l[i] +1;
        }

    }
    cout << sum << endl;
}



Measured memory_bytes: 256
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<climits>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 1000
#define INF 0x3f3f3f3f
int n,len,x[MAXN+5],y[MAXN+5],d[35];
void Print(int X,int Y){//贪心策略
	for(int i=1;i<=len;i++){
		if(abs(X)>abs(Y)){
			if(X>0) putchar('R'),X-=d[i];
			else putchar('L'),X+=d[i];
		}
		else{
			if(Y>0) putchar('U'),Y-=d[i];
			else putchar('D'),Y+=d[i];
		}
	}
	puts("");
	return ;
}
int main(){
	bool f[2]={0};
	n=read();
	for(int i=1;i<=n;i++)
		x[i]=read(),y[i]=read(),f[(x[i]+y[i])%2]=1;
	if(f[0]&&f[1]){//判断奇偶有无解
		puts("-1");
		return 0;
	}
	for(int i=30;i+1;i--)
		d[++len]=(1<<i);
	if(f[0]) d[++len]=1;//奇偶处理
	printf("%d\n",len);
	for(int i=1;i<len;i++)
		printf("%d ",d[i]);
	printf("%d\n",d[len]);
	for(int i=1;i<=n;i++)
		Print(x[i],y[i]);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


ll getTwo(ll x){
  ll ans = 0;
  while(x % 2 == 0)
  {
    ans ++;
    x /=2;
  }
  return ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll a[n];
    ll mn = INF;
    rp(i,n){
      cin >> a[i];
      if(mn > getTwo(a[i])) mn = getTwo(a[i]);
    }
    cout << mn << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

using namespace std;

int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   
  int n;
  cin>>n;
  int x[n];
  int y[n];
  
  for(int i=0; i<n; i++){
      cin>>x[i];
  }
  for(int i=0; i<n; i++){
      cin>>y[i];
  }
  for(int k=1; k<=3; k++){
      double sum =0;
      for(int i=0; i<n; i++) sum += pow(abs(x[i]-y[i]),k);
      printf("%.5lf\n",pow(sum,(double)1/k));
  }
  double max = abs(x[0]-y[0]);
  for(int i=0; i<n; i++){
      if(abs(x[i]-y[i])>=max) max = abs(x[i]-y[i]);
  }
  printf("%.5lf\n",max);
   
   
   return 0;
}


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

using namespace std;

#define N 3000
int n,m,d;
const char f[2][2]={'R','Y','G','B'};

char calc(int i,int j,int d){
	int x=i+j+N,y=i-j+N;
	return f[(x/d)&1][(y/d)&1];
}	
	
int main(){
	scanf("%d%d%d",&n,&m,&d);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++) putchar(calc(i,j,d));
		puts("");
	}
	
	return 0;
}
			

Measured memory_bytes: 512
import sys

def main():
    line = sys.stdin.readline()
    lst = line.split()
    a = int(lst[0])
    b = int(lst[1])
    c = int(lst[2])
    if a <= c and c <=b:
        print("Yes")
    else:
        print("No")
    return 0

if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

class Solver {
};

int main() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0)break;

		vector<vector<int>> range(m, vector<int>(2000, 0));
		int r;
		cin >> r;
		for (int i = 0; i < r; i++) {
			int ti, ni, mi, si;
			cin >> ti >> ni >> mi >> si;
			if (si == 0)range[mi - 1][ti]--;
			else range[mi - 1][ti]++;
		}

		for (int i = 0; i < m; i++) {
			for (int j = 1; j < 2000; j++) {
				range[i][j] += range[i][j - 1];
			}
		}

		int q;
		cin >> q;
		for (int i = 0; i < q; i++) {
			int ts, te, mi;
			cin >> ts >> te >> mi;
			int res = 0;
			for (int j = ts; j < te; j++) {
				if (range[mi - 1][j] > 0)res++;
			}
			cout << res << endl;
		}
	}
}



Measured memory_bytes: 78864
n = int(input())
#dp[i][x][y][z] i文字目、3つ前がx, 2つ前がy, 1つ前がz
#A->0, C->1, G->2, T->3
#だめなパターンはA-GC, AG-C, GAC, ACGのみ

dp = [[[[0]*4 for i in range(4)] for j in range(4)] for k in range(n+1)]
for i in range(4):
    for j in range(4):
        for k in range(4):
            dp[3][i][j][k] = 1
dp[3][0][2][1] = 0
dp[3][0][1][2] = 0
dp[3][2][0][1] = 0

for i in range(3, n):
    for x in range(4):
        for y in range(4):
            for z in range(4):
                for w in range(4):
                    if (y, z, w) == (2, 0, 1):
                        continue
                    if (y, z, w) == (0, 1, 2):
                        continue
                    if (y, z, w) == (0, 2, 1):
                        continue
                    if (x, y, w) == (0, 2, 1):
                        continue
                    if (x, z, w) == (0, 2, 1):
                        continue
                    dp[i+1][y][z][w] += dp[i][x][y][z]
                    dp[i+1][y][z][w] %= 10**9+7
ans = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[n][i][j][k]
print(ans%(10**9+7))


Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;

	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		long wa = 0;
		for(int i = 0; i < s.Length; i++)
		{
			wa += (s[i] - '0');
		}
		Console.WriteLine(wa%9==0?"Yes":"No");
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 26428
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n,m;cin>>n>>m;
  ll ans[n+1];
  REP(i,n+1){
    ans[i] = 0;
  }
  ans[0] = 1;
  ans[1] = 1;
  REP(i,m){
    int t;cin>>t;
    ans[t] = -1;
  }

  for(int i=2;i<=n;i++){
    if(ans[i]!=-1){
      ans[i] = max((ll)0,ans[i-1]) + max((ll)0,ans[i-2]);
      ans[i] %= MOD;
    }
  }

  cout<<ans[n]%MOD<<endl;



 

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i=0; i<n; i++)
 
using namespace std;
const double PI = acos(-1);
using Graph = vector<vector<int>>;
 
int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n+1, -1);
	rep(i, k)
	{
		int d;
		cin >> d;
		rep(j, d)
		{
			int index;
			cin >> index;
			a[index]++;
		}
	}
	int count = 0;
	for (int i = 1; i < n+1; i++)
	{
		if (a[i] == -1)
			count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 3568
h,w = map(int, input().strip().split())
arr = []
arr = [list(input()) for i in range(h)]
for i in range(h):
  for j in range(w):
    if arr[i][j] == ".":
      u = max(i-1,0)
      d = min(i+2,h)
      l = max(j-1,0)
      r = min(j+2,w)
      n = 0
      for line in arr[u:d]:
          n += line[l:r].count("#")
      arr[i][j] = str(n)

for line in arr:
    print("".join(line))

Measured memory_bytes: 3188
import java.util.*;

public class Main{
	void solve(){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		if(n < 1000) {
			System.out.println("ABC");
		}else {
			System.out.println("ABD");
		}
		scan.close();
	}

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

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define bits(n) __builtin_popcount(n)


void solve()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
    #endif

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int lli;

string charset[10][5] = {
	{},
	{".", ",", "!", "?", " "},
	{"a", "b", "c"},
	{"d", "e", "f"},
	{"g", "h", "i"},
	{"j", "k", "l"},
	{"m", "n", "o"},
	{"p", "q", "r", "s"},
	{"t", "u", "v"},
	{"w", "x", "y", "z"}
};
int loop[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};

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

	int N;
	cin >> N;
	vector<string> ansvec;
	for (int n = 0; n < N; n++){
		string s;
		cin >> s;

		int i = 0;
		int push = -1;
		string ans = "";
		while (i < s.length()){
			int num = stoi(s.substr(i, 1));
			if (num != 0){
				int thisnum = num;
				while (num != 0){
					push++;
					i++;
					num = stoi(s.substr(i, 1));
				}
				ans += charset[thisnum][push % loop[thisnum]];
				push = -1;
			}
			i++;
		}
		cout << ans << endl;
		//ansvec.push_back(ans);
	}
/*
	for (auto it = ansvec.begin(); it != ansvec.end(); it++){
		cout << *it << endl;
	}*/
	return 0;
}

Measured memory_bytes: 1228
n = int(input())
a = list(map(int, input().split()))

import collections

c = collections.Counter(a)
f = 0
for i in c.items():
    if n % 2 != 0 and i[0] == 0 and i[1] == 1:
        pass
    elif i[1] == 2:
        pass
    else:
        f = 1
        break
if f == 1:
    print(0)
else:
    print((2 ** (n // 2)) % (10 ** 9 + 7))


Measured memory_bytes: 55632
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int (i) = (x); (i) <= (y); (i) ++)
#define eps 1e-9
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 310;
 
int a[N][N], is[N], ct[N];
int n, m;
 
bool check(int mid)
{
	memset(is, 0, sizeof is);
	rep(t, 1, m - 1)
	{
		memset(ct, 0, sizeof ct);
		rep(i, 1, n)
			rep(j, 1, m)
				if (!is[a[i][j]])
				{
					ct[a[i][j]] ++;
					break;
				}
		int mx = 0;
		rep(i, 1, m - 1)
			if (ct[i] > ct[mx]) mx = i;
		if (ct[mx] <= mid) return 0;
		is[mx] = 1;
	}
	return 1;
}
 
int main()
{
	n = read();
	m = read();
	rep(i, 1, n)
		rep(j, 1, m)
			a[i][j] = read(), a[i][j] --;
 
	int l = 0, r = n;
	int ans = n;
	while(l <= r)
	{
		int mid = (l + r) >> 1;
		if(check(mid)) l = mid + 1;
		else ans = mid, r = mid - 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
from functools import reduce
from fractions import gcd
import numpy as np

MOD = 10**9+7

def lcm_base(x, y):
    return x * (y // gcd(x, y))

def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    A = np.array(a)  

    lcm = reduce(lcm_base, a, 1)
    B = lcm // A

    print(np.sum(B) % MOD)


if __name__ == "__main__":
    main()


Measured memory_bytes: 272644
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  char c;
  cin >> c;
  cout << char(c + 1) << endl;
}


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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define endl            "\n"

#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define mii             map <int, int>
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))


#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 3e5 + 7;
vector <vi > adj;
bool vis[N];




void solve()
{
	int n;
	cin >> n;
	int a[n];
	bool flag = 1;
	loop(i, 0, n)
	{
		cin >> a[i];
		if (a[i] % 2 == 0)
		{
			if (a[i] % 3 != 0 and a[i] % 5 != 0)
				flag = 0;
		}
	}
	if (flag) cout << "APPROVED";
	else cout << "DENIED";
	return;

}

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


	cout << setprecision(9) << fixed;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}


	return 0;
}

Measured memory_bytes: 256
def main():
    N, Y = map(int,input().split())
    bill = [10000, 5000, 1000]
    for num_10000 in range(N+1):# Nが3なら[0,1,2]なので+1する
        for num_5000 in range(N-num_10000+1):
            if Y == bill[0] * num_10000 + bill[1] * num_5000 + bill[2] * (N-num_10000-num_5000):
                print(' '.join([str(num_10000),str(num_5000),str(N-num_10000-num_5000)]))
                return

    print('-1 -1 -1')

    return 

main()


Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <cmath>
#include <algorithm>
#include <array>

int main(int argc, char *argv[]){
    int N;
    long long K;
    std::cin >> N >> K;
    std::array<long long,(1<<17)> A;
    for(int i=0; i<N; ++i){
        std::cin >> A[i];
    }

    std::array<long long, 2> dp;
    for(int j=0; j<2; ++j){
        dp[j] = 0LL;
    }
    long long xor0, xor1;
    long long tmp0, tmp1;
    bool isStarted = false;
    for(int i=0; i<41; ++i){
        xor0 = 0LL; xor1 = 0LL;
        for(int j=0; j<N; ++j){
            xor0 += ((A[j]>>(40-i))&1LL)^0LL; 
            xor1 += ((A[j]>>(40-i))&1LL)^1LL; 
        }
        xor0 <<= 40-i; xor1 <<= 40-i;
        if(((K>>(40-i))&1LL) == 1LL){
            if(isStarted){
                tmp0 = dp[0] + xor0;
                tmp1 = dp[1] + std::max(xor0, xor1);
                dp[0] += xor1;
                dp[1] = std::max(tmp0,tmp1);            
            }else{
                isStarted = true;
                dp[0] += xor1;
                dp[1] += xor0;
            }
        }else{
            if(isStarted){
                dp[0] += xor0;
                dp[1] += std::max(xor0, xor1);
            }else{
                dp[0] += xor0;
            }
        }
    }

    std::cout << std::max(dp[0],dp[1]) << std::endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

#define MAX 1000001
ll fac[MAX]; // 累乗 n!
ll inv[MAX]; // 逆元 1/n
ll finv[MAX]; // 逆元の累乗 (n^-1)! = (1/n)!

void init(ll n, ll p){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rp(i,2,n+1){
		fac[i] = fac[i-1] * i % p;
		inv[i] = p - inv[p%i] * (p/i) % p;
		finv[i] = finv[i-1] * inv[i] % p;
	}
}

ll comb(int n, int r, int m){
	if(n<r || n<0 || r<0) return 0;
	return fac[n] * (finv[n-r] * finv[r] % m) % m;
}

int main(){

	ll X,Y; cin>>X>>Y;
	ll MOD = 1000000007;
	init(max(X,Y)+1, MOD);

	ll k = (Y - X/2 - X%2*2)/3;
	ll y = X/2 + X%2*2 + 3*k;

	// printf("k %lld\n",k);//
	// printf("(Y y) =  (%lld %lld)\n",Y,y);//

	if(y!=Y){//NG
		puts("0");
		return 0;
	}
	if(k<0 || X/2<k){//NG
		puts("0");
		return 0;
	}

	ll n = X/2 + X%2 + k;
	ll r = X-n;

	// cout<<n<<" "<<r<<"\n";//
	// cout<<"nCr : "<< comb(n, r, MOD) % MOD << endl;
	cout<< comb(n, r, MOD) % MOD << endl;

}


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

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }

    for (int i = 0; i < s.size() - 2; i++) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }

    cout << "-1 -1" << endl;
}

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

using namespace std;

int n;
char S[5005];
int A[5005];

int solve(char S[], int n) {
    int l = -1, r = -1;
    for (int i = 1; i < n; ++i) {
        if (i <= r) A[i] = min(r - i, A[i - l]);
        else A[i] = -1;
        while (i + A[i] + 1 < n && S[i + A[i] + 1] == S[A[i] + 1]) ++A[i];
        if (r < i + A[i]) r = i + A[i], l = i;
    }
    int ret = 0;
    for (int i = 1; i < n; ++i) {
        ret = max(ret, min(A[i] + 1, i));
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> S + 1;
    int ans = 0;
    for (int i = 1; i <= n; ++i) ans = max(ans, solve(S + i, n - i + 1));
    cout << ans;
    return 0;
}

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

int main(){
    int N,W; cin>>N>>W;
    int weight[110],value[110];
    for(int i=0;i<N;i++) cin>>value[i]>>weight[i];
    
    int dp[110][10010];
//To do 初期値設定
    for(int i=0;i<N;i++) dp[i][0] = 0;
    for(int i=0;i<=W;i++) dp[0][i] = 0;
    for(int i=0;i<N;i++){
        for(int w = 0;w<=W;w++){
            if(w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w]);
            else dp[i+1][w] =dp[i][w];
        }
    }
    cout<<dp[N][W]<<endl; //W-1?
    
    return 0;
}


Measured memory_bytes: 7048
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n, x;
	cin >> n >> x;
	VI a(n);
	REP(i, n) { cin >> a[i]; }

	ll result = 0;
	REP(i, n - 1) {
		if(a[i] + a[i + 1] > x) {
			int d = a[i] + a[i + 1] - x;
			if(a[i + 1] < d) {
				a[i] -= d - a[i + 1];
				a[i + 1] = 0;
			} else {
				a[i + 1] -= d;
			}
			result += d;
		}
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
int main()
{
	int n,m;
	ll sum=0,i;
	vector<ll> ys;
	map<ll,int> ww;
	ys.push_back(1);
	ww[0] = 0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	{
		ll ns;
		scanf("%lld",&ns);
		sum += ns;
		if(ww.find(sum%m) == ww.end())
		{
			ys.push_back(0);
			ww[sum%m] = ys.size()-1;
		}
		ys[ww[sum%m]] ++;
	}
	ll ans = 0;
	for(i=0;i<ys.size();i++)
		ans += ys[i]*(ys[i]-1)/2;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4728
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>
 
#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>
 
#define cauto const auto&
#else
 
#endif
 
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;
 
#define VV(T) vector<vector< T > >
 
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
 
template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}
 
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
 
#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
 
vvint vv;

void dfs(int ind, int d, int pre, vint &vis) {
    if (vis[ind] != -1){
        return;
    }
    vis[ind] = d;
    for(int x: vv[ind]) {
        if (x == pre){
            continue;
        }
        dfs(x, d+1, ind, vis);
    }
}


void main2(){
    int N;
    cin >> N;
    vv = vvint(N);
    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--,b--;
        vv[a].PB(b);
        swap(a, b);
        vv[a].PB(b);
    }
    vint vis(N, -1);
    dfs(0, 0, -1, vis);
    int ind = 0;
    rep(i, N) {
        if (vis[ind] < vis[i]) {
            ind = i;
        }
    }
    vis = vint(N, -1);
    dfs(ind, 0, -1, vis);
    int ans = 0;
    rep(i, N) {
        maxs(ans, vis[i]);
    }
    if (ans % 3 == 1) {
        cout << "Second" << endl;
    }
    else {
        cout << "First" << endl;
    }
}
 
 
signed main() {
    main2();
}

Measured memory_bytes: 24704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main() {
	int n;
	cin>>n;
	vector<ll> a(n);
	rep(i,n) cin>>a[i];

	ll res=0;
	int right=0;
	ll sum=0;
	rep(left,n){
		while(right<n && (sum^a[right])==(sum+a[right])){
			sum+=a[right];
			right++;
		}
		res+=right-left;
		if(left==right) right++;
		else{
			sum-=a[left];
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long               ll;
const int mod = 1e9+7;
#ifndef M_PI
#define M_PI acos(-1.0)
#endif

int main(){
	ll n;
	cin>>n;
	vector<ll> a(n);
	ll sum=0;
	for(int i=0; i<n; ++i){
		scanf("%d", &a[i]);
		sum += a[i];
	}
	if(sum % ((n+1)*n/2)){
		cout<<"NO\n";
		return 0;
	}
	ll cnt = sum/((n+1)*n/2);
	ll cnt2 = 0;
	for(int i=0; i<n; ++i){
		ll diff = a[i] - a[(i+1)%n];
		if((diff+cnt) % n){
			cout<<"NO\n";
			return 0;
		}
		if(diff+cnt < 0){
			cout<<"NO\n";
			return 0;
		}
		cnt2 += (diff+cnt)/n;
	}
	if(cnt != cnt2){
		cout<<"NO\n";
		return 0;
	}
	cout<<"YES\n";
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  char a;
  cin>>a;
  if('A'<=a&&a<='Z'){
    cout<<"A"<<endl;
    return 0;
  }
  cout<<"a"<<endl;
}

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


typedef long long ll;
#define reg register
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)


char IO;
inline ll rd(){
	ll s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}


const int N=2e5+10;

int a,b,c;


int main(){
	a=rd(),b=rd();
	cout<<max(max(a+b,a-b),a*b)<<endl;
}




Measured memory_bytes: 256
#include <stdio.h>

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;
}

int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);

    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);

  return j;
}


void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);
    quick_sort(array, pivot+1, right);
  }
}

int main() {
    int n;
    int i,j,k;
    int ans = 0;
    scanf("%d", &n);
    unsigned int sides[n];
    for (i = 0; i < n; i++) {
        scanf("%d", &sides[i]);
    }
    quick_sort(sides, 0, n-1);

    unsigned int longest;
    unsigned int short_sum;

    for (i = 0; i < n-2; i++) {
        for (j = i+1; j < n-1; j++) {
            for (k = j+1; k < n; k++) {
                longest = sides[k];
                short_sum = sides[i] + sides[j];
                if (longest < short_sum && sides[k] != sides[i] && sides[i] != sides[j] && sides[k] != sides[j]) {
                    ans++;
                }
            }
        }
    }
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 1736
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vi lmax(n), rmax(n);
    for (int i = 0; i < n; ++i) {
        lmax[i] = rmax[i] = a[i];
    }
    for (int i = 1; i < n; ++i) {
        chmax(lmax[i], lmax[i - 1]);
    }
    for (int i = n - 2; i >= 0; --i) {
        chmax(rmax[i], rmax[i + 1]);
    }
    for (int i = 0; i < n; ++i) {
        if (i == 0)
            cout << rmax[1] << "\n";
        else if (i == n - 1)
            cout << lmax[n - 2] << "\n";
        else
            cout << max(lmax[i - 1], rmax[i + 1]) << "\n";
    }

    return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
int n;
vector<int> v;

ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

void solve() {
  if (n % 2 == 1) {
    v.push_back(0);
  }
  sort(v.begin(), v.end());
  int pos = 0;
  for (int i = (n + 1) % 2;i < n;i+=2) {
    if (i == v[pos] && i == v[pos+1]) {
      pos += 2;
    } else {
      cout << 0 << endl;
      return;
    }
  }
  cout << mod_pow(2, n / 2) << endl;
}

int main() {
  cin >> n;
  int tmp;
  for (int i=0;i<n;i++) {
    cin >> tmp;
    v.push_back(tmp);
  }
  solve();
}


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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str = br.readLine();
            boolean flag1 = false;
            boolean flag2 = false;
            for (int i = 0; i < str.length(); i++) {
                char ch = str.charAt(i);
                if (ch == 'A') {
                    flag1 = true;
                } else if (ch == 'C') {
                    if (flag1) {
                        flag2 = true;
                        break;
                    } else {
                        flag1 = false;
                    }
                } else {
                    flag1 = false;
                }
            }
            if (flag2) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 22612
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;

ll C[3000][3000];
void com(){
    C[0][0]=1;
    for(ll i=1;i<2010;i++){
        for(ll j=0;j<i+1;j++){
            if(j==0||j==i) C[i][j]=1;
            else{
                C[i][j]=C[i-1][j-1]+C[i-1][j];
                C[i][j]%=1000000007;
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    com();
    ll n,x,y,z,ans=1;
    ll dp[50][1<<19];
    cin>>n>>x>>y>>z;
    rep(i,n){
        ans*=10;
        ans%=MOD;
    }
    ll ng = 0;
    ng |= 1<<z;
    ng |= 1<<(y+z);
    ng |= 1<<(x+y+z);
    ll mask = 1<<(x+y+z+1); mask--;
    rep(i,42)rep(j,(1<<19)) dp[i][j]=0;
    dp[0][1]=1;
    rep(i,n){
        rep(bit,mask+1){
            rep2(j,1,11){
                ll ns = ((bit<<j)&mask)+1;
                if((ns&ng) == ng) continue;
                dp[i+1][ns] += dp[i][bit];
                dp[i+1][ns] %= MOD;
            }
        }
    }
    rep(i,mask){
        ans-=dp[n][i];
        ans%=MOD;
    }
    cout<<(ans+MOD)%MOD<<endl;
    return 0;
}

Measured memory_bytes: 221696
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

string s;
int n;

int main(){
	cin>>s;
	n=s.size();
	ll A=1,B=0;
	for(int i=0;i<n;i++){
		(B*=3)%=mod;
		if(s[i]=='1'){
			(B+=A)%mod;
			(A*=2)%=mod;
		}
	}
	cout<<(A+B)%mod<<endl;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N;
string s;
ll a[555555];
ll b[555555];

int main() {
   cin >> N >> s;
   rep (i, N) {
      if (s[i] == 'W') a[i] = 1;
      if (s[i] == 'E') b[i] = 1;
   }

   repp (i, 1, N ){
      a[i] += a[i-1];
      // b[i] += b[i-1];
   }

   for (int i = N-1; i >= 0; i--) {
      b[i-1] += b[i];
   }

   ll ans = 1e15;
   rep (i, N) {
      ans = min(ans, a[i]+b[i]-1);
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 8836
#include <stdio.h>
int main(){
    int n,x,i,j,a[4][17]={};
    char y;

    scanf("%d",&n);  //何枚入力するか入力

    for(i=0;i<n;i++){
     scanf(" %c %d",&y,&x);   //xは数字、yはマーク
     switch(y){
         case'S':
             a[0][x-1]=x;
             break;
         case'H':
             a[1][x-1]=x;
             break;
         case'C':
             a[2][x-1]=x;
             break;
         case'D':
             a[3][x-1]=x;
             break;
     }
    }

    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(a[i][j]==0){
                switch(i){
                    case 0:
                        printf("%c %d\n",'S',j+1);
                        break;
                    case 1:
                        printf("%c %d\n",'H',j+1);
                        break;
                    case 2:
                        printf("%c %d\n",'C',j+1);
                        break;
                    case 3:
                        printf("%c %d\n",'D',j+1);
                        break;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2044
#include <iostream>

using namespace std;

// ABC051-B - Sum of Three Integers
int main()
{
    int k, s;
    cin >> k >> s;

    int output = 0;

    for (int z = 0; (z <= k) && (z <= s); z++)
    {
        if (z < (s - 2 * k))
            continue;
        if (z < (s - k))
        {
            output += 2 * k - s + z + 1;
        }
        else
        {
            output += s - z + 1;
        }
    }

    cout << output << endl;
    return 0;
}


Measured memory_bytes: 256