akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
int main()
{
    double x,a,b;
    while(scanf("%lf%lf%lf",&x,&a,&b)!=EOF)
    {
        if(fabs(x-a)<fabs(x-b))printf("A\n");
        if(fabs(x-a)>fabs(x-b))printf("B\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>                                                                        
using namespace std;                                                                            
using ll = long long;                                                                           
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }         
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }         
#define rep(i,n) for (int i=0; i< (n); ++i)                                                     
typedef pair<int, int> P;                                                                       
                                                                                                
long double to_deg(long double r) {                                                             
  return r * 180.0 / M_PI;                                                                      
}                                                                                               
                                                                                                
int main() {                                                                                    
  long double a, b, x;                                                                          
  cin >> a >> b >> x;                                                                           
  long double all = a*a* b;                                                                     
  long double half = all/2;                                                                     
  if ((long double)x == all/2) {                                                                
    long double tan = b/a;                                                                      
    printf("%.06Lf\n", to_deg(atanl(tan)));                                                     
  } else if (x < all/2) {                                                                       
    long double soko = 2.0 * x / (a*b);                                                         
    long double tan = b/soko;                                                                   
    printf("%.06Lf\n", to_deg(atan2l(b,soko)));                                                 
  } else {                                                                                      
    long double tile = x - half;                                                                
    long double htile = 2.0 * tile / (a*a);                                                     
    long double tan = (b-htile)/a;                                                              
    printf("%.06Lf\n", to_deg(atanl(tan)));                                                     
  }                                                                                             
  return 0;                                                                                     
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

A, B, N = map(int, input().split())

ans = 0
if N >= B-1:
    ans = max(ans, ((A*(B-1))//B) - A * ((B-1)//B))
else:
    ans = max(ans, ((A*N)//B) - A * (N//B))


print(ans)

Measured memory_bytes: 9196
class cmbs(object):
    def __init__(self, mod):
        self.mod = mod
        self.g1 = [1, 1]
        self.g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, 10 ** 6 + 1):
            self.g1.append((self.g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            self.g2.append((self.g2[-1] * inverse[-1]) % mod)

    def cmb(self, n, r):
        if n > 10 ** 6:
            return self.cmbl(n, r)
        return self.cmbr(n, r)

    def cmbr(self, n, r):
        if r < 0 or r > n:
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.mod

    def cmbl(self, n, r):
        t = 1
        r = min(r, n-r)
        for i in range(n - r + 1, n + 1):
            t = t * i % self.mod
        return t * self.g2[r] % self.mod

def main():
    N, M, K = map(int, input().split())
    mod = 10**9 + 7
    c = cmbs(mod)
    r = c.cmb((N*M)-2, K-2)
    r2 = 0
    for i in range(N):
        r2 += i * (N - i)
        #r2 += ((i + 1) * i + (N - i - 1) * (N-i))//2
    r2 *= pow(M, 2, mod)
    r2 %= mod
    r3 = 0
    for i in range(M):
        r3 += i * (M-i)
        #r3 += ((i + 1) * i + (M - i - 1) * (M-i))//2
    r3 *= pow(N, 2, mod)
    r3 %= mod
    r = r * (r2 + r3) #// 2
    return r % mod
print(main())


Measured memory_bytes: 128508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a>=k)
  {
    cout<<k<<'\n';
  }
  else if(a+b>=k)
  {
    cout<<a<<'\n';
  }
  else
  {
    cout<<a-(k-a-b)<<'\n';
  }

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

const int maxn = 112345;

int n, dep[maxn], x, y, f[maxn], pre[maxn], mx;
vector<int> G[maxn];

void dfs(int u, int par, int d) {
  dep[u] = d;
  for (auto v : G[u]) if (v != par) dfs(v, u, d + 1);
  chkmax(mx, dep[u]);
}

int main() {
  scanf("%d%d%d", &n, &x, &y);
  REP(i, n - 1) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].eb(v); G[v].eb(u);
  }
  queue<int> q;
  q.emplace(x);
  int st = -1;
  while (!q.empty()) {
    auto u = q.front(); q.pop();
    for (auto v : G[u]) if (v != pre[u]) {
      if (v == y) {
        st = u;
        goto label;
      }
      f[v] = f[u] + 1;
      pre[v] = u;
      q.emplace(v);
    }
  }
  label:
  assert(~st);
  int need = f[st] / 2, r;
  for (r = st; f[pre[r]] != need; r = pre[r]);
  dfs(pre[r], r, 0);
  int ans = need + mx;
  if (f[st] & 1) ans++;
  printf("%d", ans);
}


Measured memory_bytes: 11776
from math import gcd

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

a,b,c,d = map(int,input().split())

cd = lcm(c,d)
ab = b-a+1

print(ab-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//cd-(a-1)//cd))

Measured memory_bytes: 9144
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)


  int main(){
    int a,b,c;
    string s;
    cin >> a >> b >> c;
    if (b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
  }


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

int main(){
  string ans = "AMBIGUOUS";
  int S;

  cin >>S;

  if((S/100 > 12 && S%100 > 12) || ((S/100 > 12 && S%100 == 0)|| (S%100 > 12 && S/100 == 0) || (S%100 ==0 && S/100 == 0))){
      ans = "NA";
      cout <<ans<<endl;
      return 0;
  }
  if((S/100 > 12 || S/100 == 0) && S%100 <= 12 ){
      ans = "YYMM";
      cout <<ans<<endl;
  }
  if((S%100 > 12 || S%100 == 0)&& S/100 <= 12){
      ans = "MMYY";
      cout <<ans<<endl;
  }
  if(S%100 <= 12 && S/100 <= 12 && S/100 != 0 && S%100 != 0){
      ans = "AMBIGUOUS";
      cout <<ans<<endl;
  }
  return 0;
  }

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

#define mod 1000000007
#define LOCAL 0
#define pb push_back
#define ll long long

ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

int main(){
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		int a,b,c,d,e,f;
		scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
		long double now = -1.0;
		int water,sugar;
		for(int a1=0;a1<=30;a1++){
			for(int b1=0;b1<=30;b1++){
				for(int c1=0;c1<=3000;c1++){
					if((a1*a + b1*b)*100 + c1 > f){
						break;
					}
					for(int d1=0;d1<=3000;d1++){
						int tot = (a1*a + b1*b) * 100 + c1*c + d1*d;
						//int water = (a1*a + b1*b)*100;
						//int sugar = (c1*c+d1*d);
                                                if(tot>f) break;
						if(tot > 0 && tot <= f && (c1*c + d1*d) <= (a1*a+b1*b)*e){
							/*if(water == 100 && sugar == 100){
								printf("Hell\n");
							}*/
							long double tmp = c1*c + d1*d;
							tmp /= (tot*1.0);
							if(now < tmp){
								now = tmp;
								water = (a1*a + b1*b)*100;
								sugar = c1*c + d1*d;
								water += sugar;
								now = tmp;
							}
						}
					}
				}
			}
		}
		printf("%d %d\n",water,sugar);		
	}
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s; ll n;
    cin >> n; cin >> s;
    ll count = 0;
    for(ll i = 0; i < n - 2; i++)
    {
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

int n, a[6005], dp[2005][2005], rmx[2005], mx;
int todo[100005][3], tsz;

void add_todo(int x, int y, int v) { todo[tsz][0] = x; todo[tsz][1] = y; todo[tsz ++][2] = v; }
void upd(int x, int y, int v) { rep(_, 2) { dp[x][y] = max(dp[x][y], v); rmx[x] = max(rmx[x], v); mx = max(mx, v); swap(x, y); } }
void fix() { rep(i, tsz) upd(todo[i][0], todo[i][1], todo[i][2]); tsz = 0; }

int main() {
	scanf("%d", &n);
	rep(i, n * 3) scanf("%d", &a[i]), -- a[i];
	memset(rmx, -0x3f, sizeof(rmx));
	memset(dp, -0x3f, sizeof(dp));
	mx = -0x3f3f3f3f;
	upd(a[0], a[1], 0);
	int extra = 0;
	rep(i, n - 1) {
		int x[3] = { a[i * 3 + 2], a[i * 3 + 3], a[i * 3 + 4] };
		if (x[0] == x[1] && x[1] == x[2]) { ++ extra; continue; }
		rep(_, 3) {
			add_todo(x[0], x[1], max(mx, dp[x[2]][x[2]] + 1));
			rep(j, n) {
				if (x[0] == x[1]) add_todo(j, x[2], dp[j][x[0]] + 1);
				add_todo(j, x[2], rmx[j]);
			}
			swap(x[0], x[1]); swap(x[1], x[2]);
		}
		fix();
	}
	int ans = mx;
	ans = max(ans, dp[a[n * 3 - 1]][a[n * 3 - 1]] + 1);
	printf("%d\n", ans + extra);
	return 0;
}


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

int main(){
  string a, b;
  cin >> a >> b;
  int num = stoi(a + b);
  for(int i=0; i<num; i++){
    if(i*i==num){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H.at(i);
	}
	sort(H.begin(), H.end(), greater<int>());
	long long ans = 0;
	for (int i = K; i < N; i++) {
		ans += H.at(i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        double a = sc.nextDouble();

        double min = Double.MAX_VALUE;
        int num = 0;

        for (int i = 0; i < n; i++) {
            int h = sc.nextInt();
            double k = t - h * 0.006;
            double sa = Math.abs(a - k);
            if (min > sa) {
                min = sa;
                num = i + 1;
            }
        }

        sc.close();

        System.out.print(num);

    }
}

Measured memory_bytes: 25696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } return 0; }


int main(){
  ll n, m;
  string s;
  cin >> n >> m >> s;
  ll at = n;
  vector<ll> ans;
  while(at){
    bool flag = 1;
    for(ll i = min(m, at); i; i--) if(s[at - i] == '0'){
      ans.push_back(i);
      at -= i;
      flag = 0;
      break;
    }
    if(flag){
      puts("-1");
      return 0;
    }
  }
  cout << ans.back();
  for(ll i = ans.size() - 2; i >= 0; i--) cout << ' ' << ans[i];
  cout << endl;
}


Measured memory_bytes: 1528
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int n,k;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  cin >> n >> k;
  cout << n-k+1 << endl;

return 0;
}
///....


Measured memory_bytes: 256
#include<stdio.h>
#define NUM 500000
#define INFTY 1000000000

int L[NUM/2+2],R[NUM/2+2],count=0;

void merge(int A[], int left, int mid, int right){
  int n1,n2,i,j=0,k;

  n1 = mid-left;
  n2 = right - mid;

  for(i = 0; i < n1; i++)
    L[i] = A[left+i];

  for(i = 0; i < n2; i++)
    R[i] = A[mid+i];

  L[n1] = INFTY;
  R[n2] = INFTY;

  i=0;

  for(k = left; k < right; k++){
    count++;

    if(L[i] <= R[j]){
      A[k] = L[i];
      i += 1;
    }

    else{
      A[k] = R[j];
      j += 1;
    }
  }
}

void mergeSort(int A[], int left, int right){
  int mid;

  if(left+1 < right){
    mid = (left+right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(){
  int n,S[NUM],i;
   
  scanf("%d",&n);

  for(i = 0; i < n; i++)
    scanf("%d",&S[i]);

  mergeSort(S, 0, n);

  for(i = 0; i < n-1; i++)
    printf("%d ",S[i]);

  printf("%d\n",S[n-1]);

  printf("%d\n",count);

  return 0;

}

Measured memory_bytes: 4504
#include<bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define ff first
#define ss second
typedef long long ll;

const int mod =1e9+7;

ll dp[20];
ll new_dp[20];



int main(){
	string s;cin>>s;
	dp[0]=1;
	int inv=1;
	for(int i=0;i<11;i++)inv=(10*inv)%13;
	for(char c: s){
		memset(new_dp,0,sizeof(new_dp));
		if(c=='?'){
			for(int i=0;i<10;i++)for(int rem=0;rem<13;rem++){
				int see=(rem-i+13)%13;
				see*=inv;
				see%=13;
				new_dp[rem]+=dp[see];
				new_dp[rem]%=mod;
			}
			swap(dp,new_dp);
			continue;
		}
		int val=c-'0';
		for(int rem=0;rem<13;rem++){
			int see=(rem-val+13)%13;
			see*=inv;
			see%=13;
			new_dp[rem]+=dp[see];
			new_dp[rem]%=mod;
		}
		swap(dp,new_dp);
	}
	cout<<dp[5]<<endl;

	return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

struct edge { int to, cost; };
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

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

  int x = 1900*M+100*(N-M);
  int p = pow(2,M);
  OUT(x*p);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const ll inf = 1e18;
ll n, m, r;
vector<ll>adj[207];
vector<bool>vis(207, false);
vector<ll>v;
vector<vector<ll>>dis(207, vector<ll>(207, inf));
void flyodwarshasll() {
	for (ll k = 0; k < n; k++) {
		for (ll i = 0; i < n; i++) {
			for (ll j = 0; j < n; j++) {
				if (dis[i][j] >= dis[i][k] + dis[k][j])
					dis[i][j] = dis[i][k] + dis[k][j];
			}
		}
	}
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m >> r;
	for (int i = 0; i < n; i++)dis[i][i] = 0;
	for (ll i = 0; i < r; i++) {
		ll x;
		cin >> x;
		--x;
		v.pb(x);
	}
	for (ll i = 0; i < m; i++) {
		ll u, v, c;
		cin >> u >> v >> c;
		--u, --v;
		dis[u][v] = c;
		dis[v][u] = c;
	}
	flyodwarshasll();
	sort(v.begin(), v.end());
	ll nax = 1e18;
	do {
		ll ans = 0;
		for (ll i = 0; i < ll(v.size() - 1); i++) {
			ll to = v[i];
			ll from = v[i + 1];
			ans += dis[to][from];
		}
		nax = min(ans, nax);
	} while (next_permutation(v.begin(), v.end()));
	cout << nax << endl;
}

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

int main() {
    long long int A;
    std::string B;
    std::cin >> A >> B;

    B.erase(1, 1);
    long long int ib = atoi(B.c_str());
    long long int FACTOR = 100;

    std::cout << A * ib / FACTOR << std::endl;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define let const auto
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'

int main()
{
   cin.tie(0), ios::sync_with_stdio(false);
   int X, A, B;
   char s[1024];


   cin >> A  >> B >> X;
   outl( A<=X && A+B >= X ? "YES" : "NO");
}



Measured memory_bytes: 892
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int under = 0;
    int top = Integer.MAX_VALUE;
    for(int i=0; i<M; i++){
      under = Math.max(sc.nextInt(),under);
      top = Math.min(sc.nextInt(),top);
    }
    int diff = top - under;
    int ans =diff + 1;
    System.out.print(((ans<0)?0:ans));
  }
}
    


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 998244353;
const int maxn = 400;
const int maxa = 300*300 + 400;

int n;
int a[maxn];

ll dp1[maxn][maxa];
ll dp2[maxn][maxa];

void push(ll &x, ll y) {
    x %= mod;
    y %= mod;
    x += y;
    x %= mod;
}

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

    int s = 0;

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



    // dp1[][j]: # of ways to have j of color R (2 options, B or G, for times we don't paint ith elem as R).
    // dp2[][j]: # of ways to paint elems such that sum=j for color R.

    // for cases of the form (R,G,B)=(s/2,s/2,0) we over count when bad is multipled by 3.
    // The multiple of 3 is a cyclic remapping of (R,G,B) -> (B,R,G)

    // [BBRR] -> [RRGG] -> GGBB -> ..
    

    dp1[0][0] = dp2[0][0] = 1;

    ll all = 1;

    for (int i=0; i<n; i++) {
	all *= 3ll; all %= mod;
	for (int j=0; j<=s; j++) {
	    push(dp1[i+1][j], 2ll*dp1[i][j]);
	    push(dp1[i+1][j+a[i]], dp1[i][j]);

	    push(dp2[i+1][j], dp2[i][j]);
	    push(dp2[i+1][j+a[i]], dp2[i][j]);
	}
    }


    ll res = all;
    ll bad = 0;
    for (int j=(s+1)/2; j<=s; j++) {
	bad += dp1[n][j];
	bad %= mod;
    }
    ll dup = (s%2 == 0 ? dp2[n][s/2] : 0);

    // watch(res);
    // watch(bad);
    // watch(dup);

    res -= (3ll*bad%mod);
    res %= mod;
    res += (3ll*dup%mod);
    res %= mod;


    res %= mod;
    res += mod;
    res %= mod;
    cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 427192
A, B = map(int, input().split())

ans = 0
for a in range(A, B + 1):
    s15 = (a // 10000) == (a % 10)
    s23 = (a // 1000) % 10 == (a % 100) // 10

    if s15 & s23:
        ans += 1

print(ans)


Measured memory_bytes: 2940
n,t=map(int,input().split())
ct= [list(map(int, input().split())) for _ in range(n)]
ct1=[]
for i in range(n):
    if ct[i][1]<=t:ct1.append(ct[i])
if len(ct1)==0:print('TLE')
else:print(min(ct1[j][0] for j in range(len(ct1))))

Measured memory_bytes: 3060
N = int(input())
S1 = input()
S2 = input()
p = 0
ans = 0
if S1[0]==S2[0]:
    ans = 3
    p = 1
else:
    ans = 6
    p = 2
while p < N:
    if S1[p]!=S2[p]:
        if S1[p-1]!=S2[p-1]:
            ans = (ans*3)%(10**9+7)
        else:
            ans = (ans*2)%(10**9+7)
        p += 2
    else:
        if S1[p-1]==S2[p-1]:
            ans = (ans*2)%(10**9+7)
        p+=1
print(ans)

Measured memory_bytes: 3064
N = int(input())

t,x,y = [0] * (N+1), [0] * (N+1), [0] * (N+1)
for i in range(1,N+1):
    t[i], x[i], y[i] = map(int, input().split())

can = "Yes"
for j in range(N):
    dt = t[j+1] - t[j]
    dr = abs(x[j+1]-x[j]) + abs(y[j+1] - y[j])

    if (dt < dr) | (dr % 2 != dt % 2):
        can = "No"
        break
    
print(can)

Measured memory_bytes: 11636
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 998244353
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
ll binarySearch(ll arr[], ll l, ll r,ll x) 
{ 
    if (r >= l) 
    { 
        ll mid = l + (r - l) / 2;  
        if (arr[mid] == x) 
        return mid; 
        if (arr[mid] > x) 
        return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    }
    return -1; 
} 
int main()
{
    fast;
        ll n,k,v,t,y,x=0,a,b,c,d,e,f;
        std::cin >> x>>y;
        if(y%2!=0)
        {
            cout<<"No\n";
        }
        else
        {
            if((y-2*x)/2>=0&&x-((y-2*x)/2)>=0)
            cout<<"Yes\n";
            else
            cout<<"No\n";
        }
        
}

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

int main() {
  int N,count=0;
  vector <int> a(N);
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a.at(i); 
  }
 // cout<<a<<endl;
  for(int i=0;i<N;i++){
    if(i%2==0){
  if(a.at(i)%2==1){
      count++;
    }
  }
  }
   
  cout << count << endl;
}






Measured memory_bytes: 3740
import java.util.*;

public class Main{

	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		
		int tmp = a;
		a =b;
		b=tmp;
		
		tmp=a;
		a=c;
		c=tmp;
		
		System.out.println(a+" "+b+" "+c);
		
	}

}

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

int main()
{
    string s;
    int ans=700;
    cin >> s;
    REP(i,3){
        if(s.at(i)=='o')
            ans += 100;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>



int main(void) {

	// 1_7-C Spreadsheet
	
	int r,c;
	int tbl[101][101];
	int i,j;

	scanf("%d",&r);
	scanf("%d",&c);

	for(i=0; i<(r+1); i++){
		tbl[i][c] = 0;
	}
	for(i=0; i<(c+1); i++){
		tbl[r][i] = 0;
	}
	for(i=0; i<(r+1); i++){
		for(j=0; j<(c+1); j++){
			
			tbl[i][j]=0;
		}
	}
	
	for(i=0; i<r; i++){
		for(j=0; j<c; j++){
			scanf("%d",&tbl[i][j]);
			tbl[r][j] += tbl[i][j];
			tbl[i][c] += tbl[i][j];
			tbl[r][c] += tbl[i][j];
		}
	}
	for(i=0; i<(r+1); i++){
		for(j=0; j<(c+1); j++){
			printf("%d",tbl[i][j]);
			if(j<c){
				putchar(' ');
			}else{
				putchar('\n');
			}
		}
	}

	return 0;

}

Measured memory_bytes: 644
#include <iostream>

using namespace std;

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

  int ans = 0;

  if(k % 2 == 1){
    ans = (k/2) * (k/2 + 1);
  } else {
    ans = (k/2) * (k/2);
  }

  if (k == 3) {
    ans = 2;
  }
  cout << ans << endl;

  return 0;
}


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


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll n, p;

map<ll, ll> prime_factor(ll n){
  map<ll, ll> res;
  for(ll i = 2; i * i <= n; i++){
    while(n % i == 0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}


int main(){
  cin >> n >> p;

  ll ans = 1;
  map<ll, ll> primes = prime_factor(p);
  for(auto itr = primes.begin(); itr != primes.end(); itr++) {
    if(itr->second >= n) {
      REP(j, itr->second/ n) ans *= itr->first;
    }
  }

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


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let n:usize = read();
    let a:Vec<u64> = (0..n).map(|_| read()).collect();
    let mut ans:u64 = 1;
    if a.contains(&0) {
        println!("0");
        return;
    }
    for i in a.iter(){
        let check = ans.checked_mul(*i);
        if check == None {
            println!("-1");
            return;
        }else{
            ans = check.unwrap();
        }
    }

    if ans > 1_000_000_000_000_000_000 {
        println!("-1");
    }else{
        println!("{}",ans);
    }
}


Measured memory_bytes: 2852
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int n;
double x[50], y[50];
double dis(double x1, double y1, double x2, double y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}

double calc(double xx, double yy) {
  double res = 0.0;
  for (int i = 0; i < n; i++) {
    res = max(res, dis(xx, yy, x[i], y[i]));
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lf%lf", &x[i], &y[i]);
    x[i] += 2.0;
  }
  double cx = 2.5, cy = 0.5, r, left = 0.0, right, alpha = 1e2;
  for (int i = 0; i < 5000000; i++) {
    double dx = (sqrt(calc(cx + 1e-7, cy)) - sqrt(calc(cx-1e-7, cy))) / 2e-7;
    double dy = (sqrt(calc(cx, cy + 1e-7)) - sqrt(calc(cx, cy-1e-7))) / 2e-7;
    cx -= alpha * dx;
    cy -= alpha * dy;
    alpha *= 0.9999;
  }
  printf("%.10f\n", sqrt(calc(cx, cy)));
}


Measured memory_bytes: 256
// 別解 : deque を使う
// cf.) https://atcoder.jp/contests/abc066/submissions/7447558

#include <bits/stdc++.h>
using namespace std;

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

    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    deque<int> b;
    for (int i = 0; i < n; ++i) {
        if (i%2 == n%2) {
            b.push_back(a[i]);
        } else {
            b.push_front(a[i]);
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << b[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3840
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
using namespace std;
 
int H,W;
string mapper[20];
int ans = 0;

int num_map[20][20];

void num_map_init(){
	for(int c=0;c<H;c++){
		for(int l=0;l<W;l++) num_map[c][l] = -1;
	}
}
bool has_num_map_been(int x,int y){//すでにx,yに入ったかどうかを返す
	if(num_map[y][x]==-1) return false;
	return true;
}
int max_num_map(){
	int ret = 0;
	for(int i=0;i<H;i++){
		int *max_cand = max_element(num_map[i],num_map[i]+W);
		if(ret<*max_cand) ret = *max_cand;
	}
	return ret;
}

bool is_inrange(int x,int y){//x,yがmapの範囲内に収まっているかどうかを返す
	if(x<0 || y<0 || x>=W || y>=H) return false;
	return true;
}
bool cango(int x,int y){//x,yに行けるかどうか返す
	if(mapper[y][x]=='#') return false;
	return true;
}
bool is_OK(int x,int y){//x,yに入っても問題ないかどうかを返す
	if(is_inrange(x,y)){
		if(cango(x,y)&&!has_num_map_been(x,y)) return true;
	}
	return false;
}
 
void solve(){
	//DFS
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(mapper[i][j]=='.'){
				num_map_init();
				queue<pair<int,int>> q;
				q.push(make_pair(j,i));//横、縦の順
				num_map[i][j] = 0;
				while(!q.empty()){
					pair<int,int> point = q.front();
					q.pop();
					if(is_OK(point.first,point.second-1)){
						num_map[point.second-1][point.first] = num_map[point.second][point.first]+1;
						q.push(make_pair(point.first,point.second-1));
					}
					if(is_OK(point.first,point.second+1)){
						num_map[point.second+1][point.first] = num_map[point.second][point.first]+1;
						q.push(make_pair(point.first,point.second+1));
					}
					if(is_OK(point.first-1,point.second)){
						num_map[point.second][point.first-1] = num_map[point.second][point.first]+1;
						q.push(make_pair(point.first-1,point.second));
					}
					if(is_OK(point.first+1,point.second)){
						num_map[point.second][point.first+1] = num_map[point.second][point.first]+1;
						q.push(make_pair(point.first+1,point.second));
					}
				}
			}
			int max_cand = max_num_map();
			if(ans<max_cand) ans = max_cand;
		}
	}
}
 
int main(){
	cin>>H>>W;
	for(int i=0;i<H;i++) cin>>mapper[i];

	solve();

	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int THP = A;
  int AHP = C;
  for(int i=0;i<100;i++)
  {
    AHP -= B;
    if(AHP<=0)
    {
      cout << "Yes" << endl;
      break;
    }
    THP -= D;
    if(THP<=0)
    {
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	int a = sca.nextInt(); // 8％
	int b = sca.nextInt(); // 10％
	int ans = 0;

	for(int i = 1 ; i <= 1251; i++) {
		if((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
			ans = i;
			break;
		}
		if(i == 1251) {
			ans = -1;
		}
	}

	System.out.println(ans);

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 23508
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int X = Integer.parseInt(sc.next());
		int Y = Integer.parseInt(sc.next());
		ArrayList<Integer> listX = new ArrayList<>();
		ArrayList<Integer> listY = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			listX.add(Integer.parseInt(sc.next()));
		}
		for(int i = 0; i < M; i++) {
			listY.add(Integer.parseInt(sc.next()));
		}

		sc.close();
		Collections.sort(listX, Collections.reverseOrder());
		Collections.sort(listY);

		boolean check = false;
		if(X >= Y) {
			System.out.println("War");
			return;
		}else {
			for(int i = X + 1; i <= Y; i++) {
				if(listX.get(0) < i & i <= listY.get(0)) {
					check = true;
					break;
				}else {
					continue;
				}
			}
		}
		if(check) {
			System.out.println("No War");
		}else {
			System.out.println("War");
		}

	}

}

Measured memory_bytes: 22740
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
#include <cassert>
using namespace std;

typedef long long ll;

struct Line {
	mutable ll k, m, p;
	bool operator<(const Line& o) const { return k < o.k; }
	bool operator<(ll x) const { return p < x; }
};

struct LineContainer : multiset<Line, less<>> {
	// (for doubles, use inf = 1/.0, div(a,b) = a/b)
	const ll inf = LLONG_MAX;
	ll div(ll a, ll b) { // floored division
		return a / b - ((a ^ b) < 0 && a % b); }
	bool isect(iterator x, iterator y) {
		if (y == end()) { x->p = inf; return false; }
		if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
		else x->p = div(y->m - x->m, x->k - y->k);
		return x->p >= y->p;
	}
	void add(ll k, ll m) {
		auto z = insert({k, m, 0}), y = z++, x = y;
		while (isect(y, z)) z = erase(z);
		if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
		while ((y = x) != begin() && (--x)->p >= y->p)
			isect(x, erase(y));
	}
	ll query(ll x) {
		assert(!empty());
		auto l = *lower_bound(x);
		return l.k * x + l.m;
	}
}solver;

int n;
ll C;
const int maxn = 2e5 + 5;
ll h[maxn];
ll dp[maxn];

int main(){
    cin >> n >> C;
    for(int i = 1;i <= n;i++){
        scanf("%lld", &h[i]);
    }
    dp[1] = 0;
    for(int i = 2;i <= n;i++){
        solver.add(2 * h[i - 1], -dp[i - 1] - h[i - 1] * h[i - 1]);
        ll ans = solver.query(h[i]);
        dp[i] = -ans + h[i] * h[i] + C;
    }
    cout << dp[n] << endl;
    return 0;
}


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


int gcd(int a, int b) {
    int max, min;
    int tmp;
    
    if (a < b) {
        max = b;
        min = a;
    } else {
        max = a;
        min = b;
    }
    
    while(1) {
        if (max % min == 0) {
            break;
        }
        tmp = min;
        min = max % min;
        max = tmp;
        
    }

    
    return min;
}


int main(void){
    int in;
    int sum = 0;
    int tmp;
    int i, j, k;
    
    cin >> in;
    
    
    for(i = 1; i <= in; i++) {
        for (j = 1; j <= in; j++) {
            for (k = 1; k <= in; k++) {
                tmp = gcd(i, j);
                sum += gcd(tmp, k);
            }
        }
    }
    
    
    cout << sum << endl;
    
    return 0;
    
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import math
     
N = int(input())
     
m = N - 1#mはNが素数だった時の保険
for i in range(1, math.floor(N ** 0.5) + 1):
#当該整数の2分の1乗まで考えれば距離計算の最小値は導出できるためこうしている
#math.floor(x)はxの小数点以下の切り捨てを行っている．
        if N % i == 0:
            m = min(m, math.floor(i + (N / i) - 2))
     
print(m)

# N = int(input())
     
# m = N - 1
# for i in range(1, N):#これだと計算オーダーが大きくなりすぎてTLEになる
#         if N % i == 0:
#             m = min(m, math.floor(i + (N / i) - 2))
#             #iが割るやつ
# print(m)


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

typedef long long ll;

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

  vector<ll> c(27,0);
  for(int i=1;i<=26;++i) cin>>c[i];

  vector<vector<ll>> s(D+1,vector<ll>(27,0));
  for(int i=1;i<=D;++i){
    for(int j=1;j<=26;++j){
      cin>>s[i][j];
    }
  }

  vector<ll> t(D+1);
  for(int i=1;i<=D;++i) cin>>t[i];

  int64_t score=0;

  vector<set<ll>> next(27);

  for(int i=1;i<=D;++i){
    next[t[i]].insert(i);
  }

  for(int i=1;i<=26;++i){
    next[i].insert(0);
    next[i].insert(D+1);
  }

  for(int i=1;i<=D;++i){
    score += s[i][t[i]];
    for(int j=1;j<=26;++j){
      auto k=next[j].upper_bound(i);
      --k;
      ll l=*k;
      score -= c[j]*(i-l);
    }
  }

  int M;
  cin>>M;
  for(int i=0;i<M;++i){
    int d,q;
    cin>>d>>q;

    //up

    ll l,r;
    auto j=next[q].lower_bound(d);
    r=*j;
    --j;
    l=*j;
    score += s[d][q]+((r-d)*(d-l))*c[q];
    next[q].insert(d);

    //down

    next[t[d]].erase(d);
    auto k=next[t[d]].lower_bound(d);
    r=*k;
    --k;
    l=*k;
    score -= s[d][t[d]]+((r-d)*(d-l))*c[t[d]];

    //update
    t[d]=q;
    cout<<score<<endl;
  }

}

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

struct seg
{
	ll l, r, d;
	inline int operator<(const seg &a) const {return d > a.d;}
} s[5010];

const ll inf = (1ll<<62) - 1;
int n, m;
ll f[2510][2510][2];

int main()
{
	ios::sync_with_stdio(0);
	
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> s[i].l >> s[i].r;
		s[i].d = s[i].l + s[i].r;
	}
	sort(s+1, s+n+1);
	m = n >> 1;
	for (int i = 0; i <= m; ++i)
		for (int j = 0; j <= m; ++j)
			f[i][j][0] = f[i][j][1] = inf;
	f[0][0][0] = 0;
	
	for (int i = 0; i <= m; ++i)
		for (int j = 0; j <= m && i+j < n; ++j)
			for (int k = 0; k <= 1 && i+j+k < n; ++k)
			{
				const ll tmp = f[i][j][k]; const seg p = s[i+j+k+1];
				if (i < m)	f[i+1][j][k] = min(f[i+1][j][k], tmp + p.r + i*p.d);
				if (j < m)	f[i][j+1][k] = min(f[i][j+1][k], tmp + p.l + j*p.d);
				if (!k)		f[i][j][k|1] = min(f[i][j][k|1], tmp + m * p.d);
			}
	
	cout << f[m][m][n&1] << endl;
	
	return 0;
}

Measured memory_bytes: 98688
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    long long N, K, minimum;

    scanf("%lld%lld", &N, &K);
    minimum = N % K;
    minimum = min(minimum, abs(minimum - K));
    printf("%lld", minimum);

    return 0;
}


Measured memory_bytes: 128
A = sum([list(map(int, input().split())) for _ in range(3)], [])
N = int(input())
for i in range(N):
    b = int(input())
    if b in A:
        A[A.index(b)] = 0

temp = False
temp = temp or (A[0] + A[1] + A[2]) == 0
temp = temp or (A[3] + A[4] + A[5]) == 0
temp = temp or (A[6] + A[7] + A[8]) == 0
temp = temp or (A[0] + A[3] + A[6]) == 0
temp = temp or (A[1] + A[4] + A[7]) == 0
temp = temp or (A[2] + A[5] + A[8]) == 0
temp = temp or (A[0] + A[4] + A[8]) == 0
temp = temp or (A[2] + A[4] + A[6]) == 0

print('Yes') if temp else print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
double p[3005], dp[3005][3005];
int n;
signed main() {
	cin >> n;
	rep(i, n)cin >> p[i];
	dp[0][0] = (1. - p[0]), dp[0][1] = p[0];
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= i + 1; j++) {
			if (!j)dp[i][j] = dp[i - 1][j] * (1. - p[i]);
			else dp[i][j] = dp[i - 1][j] * (1. - p[i]) + dp[i - 1][j - 1] * p[i];
		}
	}
	double ans = 0.;
	for (int i = n / 2 + 1; i <= n; i++) {
		ans += dp[n - 1][i];
	}
	printf("%.15lf\n", ans);
	endre;
}

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

int main() {
    int r;
    cin>>r;
    double PI = 3.14159265359;
    cout<<r*2*PI<<endl;
}

Measured memory_bytes: 3752
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def calc_gcd(a, b):
  if a > b:
    a, b = b, a
  while True:
    a, b = b%a, a
    if a == 0:
      return b

def calc_lcm(a, b):
  gcd = calc_gcd(a, b)
  return int(a * b // gcd)

def main():
  n = int(input())
  As = list(map(int, input().strip().split()))
  lcm = As[0]
  total = 0
  for a in As[1:]:
    lcm = calc_lcm(lcm, a)
  for a in As:
    total += lcm // a
  print(total % (10**9+7))


if __name__=='__main__':
  main()

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

/*long mem[3001][3001];

long rec(int a[], int n, int i, int j, int ch)
{
  if(i==j)
    return ch?-a[i]:a[i];
  if(mem[i][j]!=1e9+5)
    return mem[i][j];
  long ans=0;
  long ans1=rec(a,n,i+1,j,!ch);
  long ans2=rec(a,n,i,j-1,!ch);
  if(ch==0) 
    ans=max(ans1+a[i],ans2+a[j]);
  else
    ans=min(ans1-a[i],ans2-a[j]);
  mem[i][j]=ans;
  return ans;
}*/

int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  /*for(int i=0;i<=3000;i++)
  {
  	for(int j=0;j<=3000;j++)
  		mem[i][j]=1e9+5;
  }
  cout<<rec(a,n,0,n-1,0)<<endl;*/
  
  
  long dp[n+1][n+1];
  int sign=n%2?1:-1;
  for(int i=0;i<n;i++)
  {
    dp[i][0]=0;
    dp[0][i]=0;
    dp[i][i]=a[i]*sign;
  }
  int ch=0;
  for(int i=2;i<=n;i++)
  {
  	ch=0;
    for(int j=0;j+i<=n;j++)
    {
      int right=j+i-1;
      ch=(n-(right-j+1))%2;
      if(ch==0)
      {
        dp[j][i+j-1]=max(dp[j+1][i+j-1]+a[j],dp[j][i+j-2]+a[i+j-1]);
        ch=1;
      }
      else
      {
        dp[j][i+j-1]=min(dp[j+1][i+j-1]-a[j],dp[j][i+j-2]-a[i+j-1]);
        ch=0;
      }
    }
  }
  cout<<dp[0][n-1];
  
}

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

using namespace std;

bool isin(int a,int c,int b){
	//c is in [a-b]
	return ((a < b) && (a <= c && c <= b)) || ((b < a)&&(a <= c||c <= b));
}

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int x=0;
	for(int i=0;i<60;i++){
		if(isin(x%60,c,(x+a)%60)){
			cout << (int)(x/60)*60+c << endl;
			return 0;
		}
		x+=a+b;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
struct edge {
    int to;
    ll cap;
    int rev;
};
vector<edge> G[110];
bool used[110];

void add_edge(int from, int to, ll cap) {
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size()-1});
}
ll dfs(int v, int t, ll f) {
    if(v == t) return f;
    used[v] = true;
    for(int i = 0;i < G[v].size();i++) {
        edge &e = G[v][i];
        if(!used[e.to] && e.cap>0) {
            ll d = dfs(e.to, t, min(f,e.cap));
            if(d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

ll max_flow(int s, int t) {
    ll flow = 0;
    for(;;) {
        memset(used, 0, sizeof(used));
        ll f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}

int main() {
    int N;
    cin >> N;
    ll sum = 0;
    for(int i = 1;i <= N;i++) {
        ll a;
        cin >> a;
        if(a >= 0) {
            sum += a;
            add_edge(0, i, a);
        }
        else add_edge(i, N+1, -a);
    }
    for(int i = 1;i <= N;i++) {
        for(int j = 1;j < N;j++) {
            if(i%j == 0) add_edge(i, j, INF);
        }
    }
    cout << sum - max_flow(0, N+1) << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int a,b;
	cin>>a>>b;
	long long int ans=max(a,b);
	if(a>=b){
		a--;
		if(a>0&&a>=b){
			cout<<ans+a;
		}
		else{
			cout<<ans+b;
		}
	}
	else{
		b--;
		if(b>0&&b>=a){
			cout<<ans+b;
		}
		else{
			cout<<ans+a;
		}
	}
	return 0;
}

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

string longestCommonSubsequence(string &s1, string &s2){

    int n = s1.size(), m = s2.size();
    // When building the answer, use the DP table itself
    // For each state check from which state we have arrived to the current state
    // If arrived from a diagonal state that means we need to include the
    // current character
    int dp[n+1][m+1];
    for(int i=0; i<=n; i++)
        dp[i][0] = 0;
    for(int j=0; j<=m; j++)
        dp[0][j] = 0;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++){
            if(s1[i-1] == s2[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }

    // Now we need to build the actual answer
    // Start from last cell
    // and check from which cell we reached that cell

    string ans;
    int i = n, j = m;
    while(i>0 and j>0){
//        if(dp[i][j] == dp[i-1][j])
//            i--;
//        else if(dp[i][j] == dp[i][j-1])
//            j--;
//        else{
//            // That means we have reached here from diagonally so include the
//            // current character
//            ans.push_back(s1[i-1]);
//            i--;
//            j--;
//        }
        if(s1[i-1]==s2[j-1] and dp[i][j] == dp[i-1][j-1] + 1){
            // That means we have reached here from diagonally so include the
            // current character
            ans.push_back(s1[i-1]);
            i--;
            j--;
        }
        else if(dp[i][j] == dp[i-1][j])
            i--; // We have come here from the above row
        else
            j--;
    }

    reverse(ans.begin(), ans.end());
    return ans;
}

int main()
{
 string s1, s2;
 cin>>s1>>s2;
 string ans = longestCommonSubsequence(s1, s2);
 cout<<ans;
 return 0;
}



Measured memory_bytes: 38772