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

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int Q=sc.nextInt();
		long[] d=new long[K];
		long[] n=new long[Q];
		long[] x=new long[Q];
		long[] m=new long[Q];
		for(int i=0;i<K;++i) {
			d[i]=sc.nextLong();
		}
		for(int i=0;i<Q;++i) {
			n[i]=sc.nextLong();
			x[i]=sc.nextLong();
			m[i]=sc.nextLong();
		}
		
		PrintWriter pw=new PrintWriter(System.out);
		for(int q=0;q<Q;++q) {
			long[] sum=new long[K];
			for(int i=0;i<K;++i) {
				long add=d[i]%m[q];
				if(add==0)add=m[q];
				sum[i]=(i>0?sum[i-1]:0)+add;
			}
			long all=sum[K-1];
			long first=x[q];
			long last=x[q]+sum[(int)((n[q]-2)%K)]+all*((n[q]-2)/K);
			long ans=(last/m[q]*m[q]-first/m[q]*m[q])/m[q];
			pw.println(n[q]-1-ans);
		}
		pw.close();
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 88336
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

struct node {
    int id;
    int par = -1;
    int deapth = 0;
    vector<int> children;
    node() : id(-2), children(vector<int>(0)) {}
    node(int id, vector<int> children) : id(id), children(children) {}
    string checkType() {
        if (this->par == -1) return "root";
        if (children.size() > 0) return "internal node";
        return "leaf";
    }
};

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

    int i, j, n;
    cin>>n;
    vector<node> tree(n);
    rep(i, n) {
        int id, k;
        cin>>id>>k;
        vector<int> children(k);
        rep(j, k) cin>>children[j];

        tree[id].id = id;
        tree[id].children = children;
        rep(j, k) tree[children[j]].par = id;
    }

    int root;
    rep(i, n) {
        if (tree[i].checkType() == "root") root = i;
    }

    queue<node> q; q.push(tree[root]);
    while (!q.empty()) {
        node n = q.front(); q.pop();
        rep(i, n.children.size()) {
            tree[n.children[i]].deapth = n.deapth + 1;
            q.push(tree[n.children[i]]);
        }
    }
    rep(i, n) {
        node n = tree[i];
        cout<<"node "<<n.id<<": parent = "<<n.par<<", depth = "<<n.deapth<<", "<<n.checkType()<<", ";
        cout<<"[";
        if (n.children.size() > 0) {
            rep(i, n.children.size() - 1) cout<<n.children[i]<<", ";
            cout<<n.children[n.children.size() - 1];
        }
        cout<<"]"<<endl;
    }
}


Measured memory_bytes: 11752
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    sort(a.begin(),a.end());

        ll ans = -a[0] + a.back();
        for(int i = 1; i < n-1; i++){
            ans += abs(a[i]);
        }
        cout << ans << endl;
        for(int i = 1; i < n-1; i++){
            if(a[i] < 0){
                cout << a.back() << " ";
                cout << a[i] << endl;
                a.back() -= a[i];
            }else{
                cout << a[0] << " ";
                cout << a[i] << endl;
                a[0] -= a[i];
            }
        }
                    cout << a.back() << " ";
            cout << a[0] << endl;
    return 0;
}

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

int keta(int n) {
  string s = to_string(n);
  return s.size();
}
int main() {
  int n;
  cin >> n;
  int total = 0;
  for (int i = 1; i < n+1; i++) {
    int num = keta(i);
    if (num % 2 != 0) {
      total++;
    }
  }
  cout << total << endl;
}


Measured memory_bytes: 3764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()){
			boolean[] card = new boolean[11];
			int my1 = stdIn.nextInt();
			int my2 = stdIn.nextInt();
			int your = stdIn.nextInt();
			card[my1] = true;
			card[my2] = true;
			card[your] = true;
			int  zan = 20-my1-my2;
			int cnt = 0;
			for(int i=1;i<=10;i++){
				if(!card[i]&&zan>=i){
					cnt++;
				}
			}
			System.out.println(cnt>3?"YES":"NO");
		}
	}
}

Measured memory_bytes: 12000
n, x = gets.chomp.split(' ').map(&:to_i)
list = gets.chomp.split(' ').map(&:to_i).sort

count = 0

n.times do |i|
  x -= list[i]
  if x >= 0
    count += 1
  else
    break;
  end
end

if x > 0
  n.times do |i|
    if x > 0
      x -= list[i]
      count -= 1
    else
      break;
    end
  end
end

print count

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

int N, M, K;
bool solve() {
    for (int a = 0; a <= N; ++a) {
        for (int b = 0; b <= M; ++b) {
            if (a * b + (N-a) * (M-b) == K) return true;
        }
    }
    return false;
}

int main() {
    while (cin >> N >> M >> K) {
        if (solve()) puts("Yes");
        else puts("No");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    int n; cin >> n;
    int t[n], x[n], y[n];

    bool traveling = true;

    for (int i = 0; i < n; i++) cin >> t[i] >> x[i] >> y[i];

    for (int i = 0; i < n; i++) {

        int dt = 0, ds = 0;

        if (i == 0) {
            dt = t[i];
            ds = x[i] + y[i];
        } else {
            dt = t[i] - t[i - 1];
            ds = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        }
        if (dt < ds) {
            traveling = false;
            break;
        } else if (ds % 2 == 0 && dt % 2 != 0) {
            traveling = false;
            break;
        } else if (ds % 2 != 0 && dt % 2 == 0) {
            traveling = false;
            break;
        }
    }

    if (traveling) cout << "Yes" << endl;
    else           cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(a) (a.begin(),a.end())
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  ll n;
  cin >> n;
  string ans;
  while(n != 0){
    ll tmp = n % 26;
    if(tmp - 1 == -1){
      ans += 'z';
      n--;
    }
    else ans += ('a' + tmp - 1);
    n /= 26;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
A,B,C=input().split()

if A==B:
  if A==C:
    print("No")
    exit()
  else:
    print("Yes")
    exit()
elif A==C:
  if A!=B:
    print("Yes")
    exit()
elif B==C:
  print("Yes")
  exit()
else:
  print("No")
  exit()
    

Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=1e5+10;
    int N,M;
    vector<int>G[MAXN];
    int ans=0;
    int vis[MAXN];
    void dfs(int root){
        vis[root]=true;
        for(auto v:G[root]){
            if(vis[v])continue;
            dfs(v);
        }
    }
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>N>>M;
        for(int u=0;u<M;u++){
            int x,y,z;
            cin>>x>>y>>z;
            G[x].push_back(y);
            G[y].push_back(x);
        }
        for(int r=1;r<=N;r++){
            if(vis[r])continue;
            dfs(r);
            ans++;
        }
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

Measured memory_bytes: 8064
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

//const long long MOD = 1000000007;
const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;

bool s[11];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<vector<int>>a(m);
	rep(i, m) {
		int k; cin >> k;
		a[i].resize(k);
		rep(j, k) {
			cin >> a[i][j]; a[i][j]--;
		}
	}
	VE p(m); rep(i, m)cin >> p[i];
	int ans = 0;
	rep(bit, 1 << n) {
		rep(i, 11)s[i] = false;
		rep(i, n) {
			if (bit & (1 << i)) {
				s[i] = true;
			}
		}
		bool ok = true;
		rep(i, m) {
			int cnt = 0;
			rep(j, a[i].size()) {
				if (s[a[i][j]])cnt++;
			}
			if (cnt % 2 != p[i]) {
				ok = false;
			}
		}
		if (ok)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
    // Your code here!
   char a[4];
   int count = 0;
   scanf("%s",a);
   if(a[0]=='R'&&a[1]=='R'&&a[2]=='R'){
       count = 3;
   }
   else if(a[0]=='S'&&a[1]=='R'&&a[2]=='R'){
       count = 2;
   }
   else if(a[0]=='R'&&a[1]=='S'&&a[2]=='R'){
       count = 1;
   }
   else if(a[0]=='R'&&a[1]=='R'&&a[2]=='S'){
       count = 2;
   }
   else if(a[0]=='S'&&a[1]=='S'&&a[2]=='R'){
       count = 1;
   }
   else if(a[0]=='S'&&a[1]=='S'&&a[2]=='S'){
       count = 0;
   }
   else if(a[0]=='S'&&a[1]=='R'&&a[2]=='S'){
       count = 1;
   }
   else if(a[0]=='R'&&a[1]=='S'&&a[2]=='S'){
       count = 1;
   }
   printf("%d",count);
    return 0;
}

Measured memory_bytes: 1728
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>

#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int gcd(int a, int b);

int main(){
  string s;
  cin >> s;
  string week[] = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
  rep(i,7){
    if(s == week[i]){
      printf("%d\n", i+1);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class A {
    static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static void Main(string[] args) {
        string S;
        Input(out S);
        switch(S) {
        case "hi":
        case "hihi":
        case "hihihi":
        case "hihihihi":
        case "hihihihihi":
            Print("Yes");
            break;
        default:
            Print("No");
            break;
        }
        Out.Flush();
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void Inputs<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
    static void Print<T>(T s) => Out.WriteLine(s);
    static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
    static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(3e3+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
ll n;
vector <dd> v(NN);
ll vis[NN][NN];
dd dp[NN][NN];
dd func(ll ind,ll heads)
{
    if(ind==n+1)
     return (heads*2>=n);
    if(vis[ind][heads])
     return dp[ind][heads];
    vis[ind][heads]=1;
    dd &ans=dp[ind][heads]; 
    return ans=v[ind]*func(ind+1,heads+1)+(1-v[ind])*func(ind+1,heads);
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       cin>>n;
       for(ll i=1;i<=n;i++)
        cin>>v[i];
       dd ans=func(1,0);
       cout<<fixed<<setprecision(12)<<ans<<"\n";        
   }
}

Measured memory_bytes: 139776
let () =
    let main () =
        let l, r = Scanf.sscanf (read_line ()) "%d %d" (fun l r -> l, r) in
        let rec loop_l li count_l acc =
            let rec loop_r rj count_r acc =
                if rj > r || count_r = 2019 then acc else
                    loop_r (rj + 1) (count_r + 1) (min acc ((li * rj) mod 2019))
            in
            if li = r || count_l = 2019 then acc else
                loop_l (li + 1) (count_l + 1) (loop_r (li + 1) 0 acc)
        in
        Printf.printf "%d\n" (loop_l l 0 2019)
    in
    main ()

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int INF=1e9;
struct dat{
	int x,y,level;
	dat(){}
	dat(int x,int y,int level):x(x),y(y),level(level){}
	bool operator>(const dat &a)const{
		return level>a.level;
	}
};
bool pos(int x,int y,int w,int h){
	return 0<=x&&x<w&&0<=y&&y<h;
}
int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
int fld[2][550][550];
int r,w[2],h[2],sx[2],sy[2];
int main(){
	while(1){
		cin>>r;
		if(r==0)break;
		REP(i,2){
			cin>>w[i]>>h[i]>>sx[i]>>sy[i];sx[i]--;sy[i]--;
			REP(j,h[i])REP(k,w[i]){
				cin>>fld[i][k][j];
			}
		}
		vector<P>V[2];
		REP(i,2){
			V[i].PB(MP(0,0));
			V[i].PB(MP(1,1));
		}
		bool used[2][550][550];
		memset(used,false,sizeof(used));
		REP(i,2){
			used[i][sx[i]][sy[i]]=true;
			priority_queue<dat,vector<dat>,greater<dat> >Q;
			REP(j,4){
				if(pos(sx[i]+dx[j],sy[i]+dy[j],w[i],h[i])){
					Q.push((dat){sx[i]+dx[j],sy[i]+dy[j],fld[i][sx[i]+dx[j]][sy[i]+dy[j]]});
					used[i][sx[i]+dx[j]][sy[i]+dy[j]]=true;
				}
			}
			int cnt=1,ma=0;
			while(!Q.empty()){
				dat d=Q.top();Q.pop();
				int x=d.x,y=d.y;
				cnt++;
				ma=max(d.level,ma);
				V[i].PB(MP(cnt,ma));
				REP(j,4){
					int nx=x+dx[j],ny=y+dy[j];
					if(pos(nx,ny,w[i],h[i])&&!used[i][nx][ny]){
						Q.push((dat){nx,ny,fld[i][nx][ny]});
						used[i][nx][ny]=true;
					}
				}
			}
		}
		REP(i,2)sort(ALL(V[i]));
		int ans=INF;
		REP(i,V[0].size()){
			int cnt=V[0][i].first,level=V[0][i].second;
			if(cnt>=r){
				ans=min(ans,level);
				continue;
			}
			if(cnt+V[1].size()<r){
				continue;
			}
			ans=min(ans,V[1][r-cnt].second+level);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 9708
//probrem_a.go

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	//"strings"
)

const (
	constMod = int(1e9) + 7
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

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

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getIntSlice(n int) []int {
	ns := []int{}
	for i := 0; i < n; i++ {
		ns = append(ns, getInt())
	}
	return ns
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func getStringSlice(n int) []string {
	ss := []string{}
	for i := 0; i < n; i++ {
		ss = append(ss, getString())
	}
	return ss
}

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

// Sort Fanction

func sortIntSlice(ns []int) []int {
	sort.Sort(sort.IntSlice(ns))
	return ns
}

func rsortIntSlice(ns []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(ns)))
	return ns
}

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

// Num Fanction

//numModPow(a, n, m) = a^n % m
func numModPow(a int, n int, m int) int {
	result := 1

	for n > 0 {
		if n%2 == 1 {
			result = (result * a) % m
		}

		a = (a * a) % m
		n >>= 1
	}

	return result
}

// numGcd(a, b) = gcd(a, b)
func numGcd(a int, b int) int {
	if b == 0 {
		return a
	}

	return numGcd(b, a%b)
}

// numLcm(a, b) = lcm(a, b)
func numLcm(a int, b int) int {
	return a * b / numGcd(a, b)
}

// numModInv(a, p) = a^(-1) % p
func numModInv(a int, p int) int {
	if a == 1 {
		return 1
	}

	return p - numModInv(p%a, p)*(p/a)%p
}

// numModFrac(n) = n! % constMod
func numModFrac(n int) []int {
	frac := []int{1}

	for i := 1; i <= n; i++ {
		frac = append(frac, i*frac[i-1]%constMod)
	}

	return frac
}

// numModConb(n, r) = nCr % constMod
func numModConb(n int, r int) int {
	frac := numModFrac(n)

	return (frac[n] / ((frac[n-r] * frac[r]) % constMod)) % constMod
}

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

func solve() {

	s := getString()

	if s[2] == s[3] && s[4] == s[5] {
		fmt.Fprintln(wr, "Yes")
	} else {
		fmt.Fprintln(wr, "No")
	}
}

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

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}


Measured memory_bytes: 640
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    string S;
    cin >> S;
    int minDiff = 10000;
    for (int i = 0; i < S.size() - 2; i++) {
        string subS;
        subS = S.at(i);
        subS += S.at(i + 1);
        subS += S.at(i + 2);
        int diff = abs(753 - stoi(subS));
        minDiff = min(minDiff, diff);
    }

    cout << minDiff << endl;
    
    return 0;
}


Measured memory_bytes: 3572
N = int(input())
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(A[N-1])

Measured memory_bytes: 3060
S = input()

def ticket_sum(i, s, num):
    if i == len(S):
        if num == 7:
            print(s+"=7")
            exit()
        else:
            return False
    
    # 数字を分ける場所
    pos = i - len(S)

    # "+"を入れる場合
    s1 = s[:pos]+"+"+s[pos:]
    num1 = num+int(s[pos])
    # "-"を入れる場合
    s2 = s[:pos]+"-"+s[pos:]
    num2 = num-int(s[pos])
    
    if ticket_sum(i+1, s1, num1):
        return
    elif ticket_sum(i+1, s2, num2):
        return
    
    return False

ticket_sum(1, S, int(S[0]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 1<<18;
int arbre[MAXN * 2];

void ajout(int noeud , int valeur)
{
	noeud += MAXN;
	arbre[noeud] = valeur;
	while (noeud > 0)
	{
		noeud /= 2;
		arbre[noeud] = max(arbre[noeud * 2] , arbre[noeud * 2 + 1]);
	}
}

int trouverMax(int gauche , int droite)
{
	gauche+= MAXN , droite += MAXN;
	int maxi = 0;
	while (gauche<= droite)
	{
		if (gauche % 2 == 1)
		{
			maxi = max(maxi , arbre[gauche]);
			gauche++;
		}
		if (droite % 2 == 0)
		{
			maxi = max(maxi , arbre[droite]);
			droite--;
		}
		gauche/=2;
		droite/=2;
	}
	return maxi;
}

int32_t main()
{
	int N;
	cin >> N;
	int h[N];
	for (int i = 0 ; i < N  ; i++)
	{
		cin>>h[i];
		h[i]--;
	}
	int v[N];
	for (int i = 0 ; i < N  ; i++)
	{
		cin>>v[i];
	}
	for (int i = 0 ; i < N ; i++)
	{
		ajout(h[i] , v[i] + trouverMax(0 , h[i]));
	}
	cout<<trouverMax(0 , N - 1)<<endl;
}

Measured memory_bytes: 7040
#include<iostream>
using namespace std;
struct Activity
{
    int a,b,c;
};
int main()
{
    int n;
    cin>>n;
    struct Activity arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i].a>>arr[i].b>>arr[i].c;
    }
    int dp[n+1][3];
    dp[1][0]=arr[1].a;
    dp[1][1]=arr[1].b;
    dp[1][2]=arr[1].c;
    for(int i=2;i<=n;i++)
    {
        dp[i][0]=arr[i].a + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=arr[i].b + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=arr[i].c + max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}

Measured memory_bytes: 5952
import java.util.List;
import java.util.Scanner;

class Problem {
    private String s;
    private String t;

    Problem() {
        Scanner sc = new Scanner(System.in);

        s = sc.next();
        t = sc.next();
    }

    String solve() {
        int[][] dp = new int[s.length()][t.length()];

        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j < t.length(); j++) {
                if (s.charAt(i) == t.charAt(j)) {
                    dp[i][j] = (i > 0 && j > 0 ? dp[i-1][j-1] : 0) + 1;
                } else {
                    int p1 = i > 0 ? dp[i-1][j] : 0;
                    int p2 = j > 0 ? dp[i][j-1] : 0;
                    dp[i][j] = Math.max(p1, p2);
                }
            }
        }

        int i = s.length() - 1;
        int j = t.length() - 1;
        StringBuilder builder = new StringBuilder(dp[i][j]);

        while (i >= 0 && j >= 0) {
            if (s.charAt(i) == t.charAt(j)) {
                builder.insert(0, s.charAt(i));
                i--;
                j--;
            } else {
                int p1 = i > 0 ? dp[i-1][j] : 0;
                int p2 = j > 0 ? dp[i][j-1] : 0;

                if (p1 >= p2) {
                    i--;
                } else {
                    j--;
                }
            }
        }

        return builder.toString();
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
}


Measured memory_bytes: 80852
import numpy as np 

N, K = map(int, input().split())
vs = np.array([int(v) for v in input().split()])
ak = min(N + 1, K + 1)
max_value = 0

for a in range(ak):
    bk = min(N - a + 1, K - a + 1)
    for b in range(bk):
        n_remove = K - a - b
        l = np.sum(vs[:a]) if a > 0 else 0
        r = np.sum(vs[-b:]) if b > 0 else 0
        
        if a > 0 and b > 0:
            pos = np.r_[vs[:a], vs[-b:]]
            order = np.argsort(pos)
            pos = pos[order]
        elif a > 0:
            pos = vs[:a]
            order = np.argsort(pos)
            pos = pos[order]
        elif b > 0:
            pos = vs[-b:]
            order = np.argsort(pos)
            pos = pos[order]
        else:
            pos = np.array([])

        n_minus = len(np.where(pos < 0)[0])
        
        value = l + r - np.sum(pos[:n_minus]) if n_minus < n_remove else l + r - np.sum(pos[:n_remove])
        
        max_value = max(value, max_value)

print(max_value)

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

def func(v, d, c):
    if memo[v][d]!=0:
        return
    
    memo[v][d] = c
    
    if d==0:
        return
    
    func(v, d-1, c)
    
    for nv in G[v]:
        func(nv, d-1, c)

N, M = map(int, input().split())
G = [[] for _ in range(N)]

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

Q = int(input())
q = [tuple(map(int, input().split())) for _ in range(Q)]
q.reverse()
memo = [[0]*11 for _ in range(N)]

for v, d, c in q:
    func(v-1, d, c)

for v in range(N):
    print(memo[v][0])

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

using ll = long long;
#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 INF 1e9
// const ll INF = 1LL << 60;

vector<int> dijkstra(int s, vector<vector<pair<int, int>>>& g){
  int n = g.size();
  vector<int> dist(n, INF);
  dist[s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
  pq.push({0,s});
  while(!pq.empty()){
    int d, v;
    tie(d, v) = pq.top(); pq.pop();
    if(dist[v] < d) continue;
    for(auto e : g[v]){
      int nv, w;
      tie(nv, w) = e;
      if(dist[v] + w < dist[nv]){
        dist[nv] = dist[v] + w;
        pq.push({dist[nv], nv});
      }
    }
  }
  return dist;
}
int main(){
  int V, E, r;
  cin >> V >> E >> r;
  vector<vector<pair<int, int>>> g(V);
  REP(i, E){
    int s, t, d;
    cin >> s >> t >> d;
    g[s].push_back({t, d});
  }
  vector<int> ans = dijkstra(r, g);
  REP(i, V){
    if(ans[i] == INF){
      cout << "INF" << endl;
    }
    else{
      cout << ans[i] << endl;   
    }
  }
  return 0;
}




Measured memory_bytes: 12968
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
vector<int> v;
class Calc
{
    // 宣言
    long long a;

    public:
        // 素因数分解
        void decompositPrime(long long a);
};

/*
 * 素因数分解
 */
void Calc::decompositPrime(long long n)
{
    // 割る数の初期値
    a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            //printf("%d * ", a);
             v.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    v.push_back(n);
    //printf("%d\n", n);
}

int main(){
    //std::stack<int> stack;
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a(2019, 0);
    a[0] = 1;
    a[s[n-1] - '0'] = 1;
    int keta = 10;
    int tmp = s[n-1] - '0';
    long ans = 0;
    for(int i = 1; i < n; i++){
        tmp += ((s[n-1-i]-'0') * keta);
        tmp %= 2019;
        a[tmp] ++;
        keta = (keta*10) % 2019;
    }
    for(int i = 0; i < 2019; i++){
        ans += a[i]*(a[i]-1) / 2;
    }
    cout << ans << endl;
    return 0;
}





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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int a,b;cin>>a>>b;
	
	if( a <=9 && b <=9){
		writeln(a*b);
	}else {
		writeln(-1);
	}



}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    int n = 0;
    cin >> n;

    long long stol_height = 0;
    long long input = 0;
    long long prev_height = 0;

    while(n--){

        cin >> input;

        if(prev_height <= input) {
            prev_height = max(prev_height, input);
            continue;
        }
        stol_height+=(prev_height-input);
    }

    cout <<stol_height<<std::endl;

    return 0;
}

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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

const int PRIME_MAX_N = 112345;
class PrimeUtil{
    public:
    // 入力はすべて正とする
    // 素数判定O(√n)
    static bool is_prime(int n) {
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0) return false;
        }
        return n != 1; // 1の場合は例外
    }
    // 約数の列挙O(√n)
    static vector<int> divisor(int n) {
        vector<int> res;
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                res.push_back(i);
                if (i != n / i) res.push_back(n / i);
            }
        }
        return res;
    }
    // 素因数分解O(√n)
    static map<int, int> prime_factor(ll n) {
        map<int, int> 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;
    }

    static int prime[PRIME_MAX_N]; // i番目の素数
    static bool sieve_is_prime[PRIME_MAX_N + 1]; // is_prime[i]がtrueならiは素数
    // n以下の素数の数を返す
    static int sieve(int n) {
        int p = 0;
        for (int i = 0; i <= n; i++) sieve_is_prime[i] = true;
        sieve_is_prime[0] = sieve_is_prime[1] = false;
        for (int i = 2; i <= n; i++) {
            if (sieve_is_prime[i]) {
                prime[p++] = i;
                for (int j = 2 * i; j <= n; j += i) sieve_is_prime[j] = false;
            }
        }
        return p;
    }
};
int PrimeUtil::prime[PRIME_MAX_N]; // i番目の素数
bool PrimeUtil::sieve_is_prime[PRIME_MAX_N + 1]; // is_prime[i]がtrueならiは素数


void solve(long long N){
    auto factored = PrimeUtil::prime_factor(N);
    ll res = 0;
    for(auto iter: factored){
        ll i = 0;
        while(i*(i+1)/2 <= iter.second){
            i++;
        }
        i--;
        res += i;
    }
    cout << res << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3700
using System;

class Program
{
	static int count = 0;

	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());

		int[] s = new int[n];
		string[] input = Console.ReadLine().Split(' ');
		for (int i = 0; i < n; i++)
		{
			s[i] = int.Parse(input[i]);
		}

		MergeSort(s, 0, s.Length);

		for (int i = 0; i < s.Length; i++)
		{
			Console.Write((i == 0 ? "" : " ") + s[i]);
		}
		Console.WriteLine();
		Console.WriteLine(count);
	}

	static void MergeSort(int[] s, int left, int right)
	{
		if (left + 1 < right)
		{
			int mid = (left + right)/2;
			MergeSort(s, left, mid);
			MergeSort(s, mid, right);
			Merge(s, left, mid, right);
		}
	}

	static void Merge(int[] s, int left, int mid, int right)
	{
		int n1 = mid - left;
		int n2 = right - mid;

		int[] l = new int[n1];
		int[] r = new int[n2];

		int i = 0;

		for (i = 0; i < n1; i++)
		{
			l[i] = s[left + i];
		}

		for (i = 0; i < n2; i++)
		{
			r[i] = s[mid + i];
		}

		i = 0;
		int j = 0;

		for (int k = left; k < right; k++)
		{
			if (i == l.Length)
			{
				s[k] = r[j];
				j ++;
			}

			else if (j == r.Length)
			{
				s[k] = l[i];
				i ++;
			}
			else if (l[i] <= r[j])
			{
				s[k] = l[i];
				i ++;
			}
			else
			{
				s[k] = r[j];
				j ++;
			}
			count ++;
		}
	}
}



Measured memory_bytes: 71000
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 parent[] = new int[n + 1];
		int size[] = new int[n + 1];
		for (int i = 0; i < n; i++) {
			parent[i] = i;
			size[i] = 1;
		}
		for (int i = 0; i < m; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			union(parent, size, x, y);
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans = Math.max(ans, size[i]);
		}
		System.out.println(ans);
	}
	
	static void union(int parent[], int size[], int i, int j) {
		int root1 = root(parent, i);
		int root2 = root(parent, j);
		if (root1 == root2) return;
		
		if (size[root1] > size[root2]) {
			size[root1] += size[root2];
			parent[root2] = root1;
		}
		else {
			size[root2] += size[root1];
			parent[root1] = root2;
		}
	}
	
	static int root(int parent[], int i) {
		while (parent[i] != i) {
			i = parent[i];
		}
		
		return i;
	}
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

template<typename T> bool chmin(T &a,const T b){if(a>b){a=b; return true;}return false;}
template<typename T> bool chmax(T &a,const T b){if(a<b){a=b; return true;}return false;}

struct edge{int to, cost1, cost2;};
using P=pair<ll, int>;

struct Dijkstra{
    int V, s, t;
    vector<ll> dist1, dist2;
    vector<int> prev;
    Dijkstra(const vector<vector<edge>> &adj, int s_, int t_) : s(s_), t(t_) {init(adj);}
    void init(const vector<vector<edge>> &adj){
        V=(int)adj.size();
        dist1.assign(V, LINF);
        dist2.assign(V, LINF);
        prev.assign(V, -1);
        priority_queue<P, vector<P>, greater<P>> pque1;
        priority_queue<P, vector<P>, greater<P>> pque2;
        dist1[s]=0;
        dist2[t]=0;
        pque1.push({dist1[s], s});
        pque2.push({dist2[t], t});
        while (!pque1.empty()) {
            auto p = pque1.top();
            pque1.pop();
            int v = p.second;
            if (dist1[v] < p.first) continue;
            for (auto &e : adj[v]) {
                if (dist1[e.to] > dist1[v] + e.cost1) {  
                    dist1[e.to] = dist1[v] + e.cost1;
                    prev[e.to]=v;
                    pque1.push({dist1[e.to], e.to});
                }
            }
        }
        while (!pque2.empty()) {
            auto p = pque2.top();
            pque2.pop();
            int v = p.second;
            if (dist2[v] < p.first) continue;
            for (auto &e : adj[v]) {
                if (dist2[e.to] > dist2[v] + e.cost2) {  
                    dist2[e.to] = dist2[v] + e.cost2;
                    prev[e.to]=v;
                    pque2.push({dist2[e.to], e.to});
                }
            }
        }
    }
    vector<int> get_path(int t){
        vector<int> path;
        for(; t != -1; t=prev[t]) path.push_back(t);
        reverse(all(path));
        return path;
    }
};

int main(){
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--, t--;
    vector<vector<edge>> adj(n);
    for(int i=0; i<m; i++){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        adj[u].push_back((struct edge){v, a, b});
        adj[v].push_back((struct edge){u, a, b});
    }
    ll money=1e15;
    Dijkstra dk(adj, s, t);
    vector<P> cost(n);
    for(int i=0; i<n; i++){
        cost[i]={dk.dist1[i]+dk.dist2[i], i};
    }
    sort(all(cost));
    int id=0, ex=cost[0].second;
    for(int i=0; i<n; i++){
        while(cost[id].second <= i-1) id++;
        cout << money-cost[id].first << endl;
    }
    return 0;
}

Measured memory_bytes: 13656
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long int sum=0;
	long long int i;
	for(i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)
		{
			sum+=i;
		}
	}

	cout<<sum;

	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {
	int N,K;
	cin >> N >> K;
	vector<int> h(N);
	for (int i = 0; i < N; i++)cin >> h[i];
	vector<int>dp(N, INF);
	dp[0] = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = 1; j <= K && i + j < N; j++) {
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.List;
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());

        List<Integer> x = new ArrayList<>();
        List<Integer> y = new ArrayList<>();

        for (int i = 0; i < n; i++) x.add(Integer.parseInt(sc.next()));
        for (int i = 0; i < n; i++) y.add(Integer.parseInt(sc.next()));

        List<Double> M = new ArrayList<>();
        for (int i = 1; i <= 3; i++) {
            double tmp = 0.0;
            for (int j = 0; j < n; j++) {
                tmp += Math.pow(Math.abs((double)x.get(j) - (double)y.get(j)), (double)i);
            }
            M.add(Math.pow(tmp, 1.0 / i));
        }

        double max = Double.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            double tmp = Math.abs(x.get(i) - y.get(i));
            if (tmp > max) max = tmp;
        }
        if (max == Double.MIN_VALUE) max = 0.0;
        M.add(max);

        M.forEach(System.out::println);
    }
}

Measured memory_bytes: 32104
#include <stdio.h>

int main(void) {
	char classname[16];
	int gozen,gogo;
	int i;
	for(i=0;i<9;i++) {
		scanf("%s %d %d",classname,&gozen,&gogo);
		printf("%s %d %d\n",classname,gozen+gogo,gozen*200+gogo*300);
	}
	return 0;
}

Measured memory_bytes: 0
n=int(input())
a=[]
for i in range(n):
  x,y=map(int,input().split())
  z=x+y
  a.append([z,x,y])
a.sort(reverse=True)
f=True
s=0
for z,x,y in a:
  if f:
    s+=x
  else:
    s-=y
  f= not f
print(s)

Measured memory_bytes: 23260
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    import math


    a, b, x = map(int, input().split())
    if 2*x > a*a*b:
        x = x/a
        n = b-(2*x/a-b)
        print(math.degrees(math.atan(n/a)))
    else:
        x = x/a
        n = 2*x/b
        print(math.degrees(math.atan(b/n)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

int main(){
    ll H, W;
    cin >> H >> W;
    char a[H][W];
    for(int i=0;i<H;i++)
        for(int j=0;j<W;j++)
            cin >> a[i][j];

    ll dp[H][W] = {};  //dp[i][j] : (i, j)までの経路の総数
    if(a[0][1] == '.')
        dp[0][1] = 1;
    if(a[1][0] == '.')
        dp[1][0] = 1;

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(j != 0){ // 左
                if(a[i][j-1] == '.' && a[i][j] == '.')
                    dp[i][j] += dp[i][j-1];
            }
            if(i != 0){ // 上
                if(a[i-1][j] == '.' && a[i][j] == '.')
                    dp[i][j] += dp[i-1][j];
            }
            if(dp[i][j] != 0)
                dp[i][j] = dp[i][j] % MOD;
        }
    }

    /*
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */

    cout << dp[H-1][W-1] << endl;

}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int n;
  cin >> n;
  
  int a = n / 1000;
  int b = n % 1000;
  
  int c = b / 100;
  int d = b % 100;
  
  int e = d / 10;
  
  int f = d % 10;
  
  if (a == c && a == e) {
    cout << "Yes" << endl;
  }
  
  else if (c == e && c == f) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  
}

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

constexpr int LEN = 55;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
int m[LEN][LEN];
int vis[LEN][LEN];

int main(){
    memset(vis, -1, sizeof(vis));
    int h, w; cin >> h >> w;
    int block = 0;
    rep(i, h)rep(j, w){
        char c; cin >> c;
        m[i][j] = c;
        if(c == '#') {
            block++;
        }
    }

    queue<P> q;
    q.push({0, 0});
    vis[0][0] = 1;
    while(q.size()){
        P now = q.front(); q.pop();
        int i = now.first, j = now.second;
        rep(k, 4){
            int ni = i + di[k], nj = j + dj[k];
            if(0 <= ni && ni < h && 0 <= nj && nj < w && vis[ni][nj] == -1 && m[ni][nj] != '#'){
                vis[ni][nj] = vis[i][j] + 1;
                q.push({ni, nj});
            }
        }
    }
    if(vis[h-1][w-1] == -1) cout << -1 << endl;
    else cout << (h*w - block - vis[h-1][w-1]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
int main(){
	ll N,P,Q;
	cin>>N>>P>>Q;
	ll s=0;
	vector<ll> vc;
	rep(i,N){
		ll c;
		cin>>c;
		vc.pb(c-2*P*(N-1-i)-P*(Q+i));
		s+=P*(Q+i);
	}
	sort(all(vc),greater<ll>());
	ll ans=s;
	rep(i,N){
		s+=vc[i];
		s+=i*2*P;
		chmax(ans,s);
	}
	cout<<ans<<endl;
}

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

#define FOR(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)

int n, a[100005], f[100005];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("FROG1.inp", "r", stdin);
    //freopen("FROG1.out", "w", stdout);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    f[1]=0; f[2]=abs(a[2]-a[1]);
    FOR(i,3,n)
        f[i]=min(f[i-1]+abs(a[i]-a[i-1]), f[i-2]+abs(a[i]-a[i-2]));
    cout << f[n];
    return 0;
}


Measured memory_bytes: 1024
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



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

    int N;cin >> N;
    vector<long long> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    //xorにおいて、bitが1+1→0になると、悲しくなります。
    //尺取り法を頑張る
    long long ans = 0;
    long long sum = 0;
    int right = 0;
    long long nowBit = 0;
    for(int left = 0;left<N;left++){
        if(right < left) right++;
        while(right < N && sum+retu.at(right) == (sum ^ retu.at(right))){
            sum += retu.at(right);
            right++;
            
        }
        ans += right-left;
        //cout << left << " " << right << " " << ans << endl;
        sum -= retu.at(left);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4740
#include<bits/stdc++.h>
    using namespace std ;
    #define ll long long int 
    #define pb push_back 
    #define mp make_pair
    #define mod 1000000007
    int main(){
    	ios_base::sync_with_stdio(false) ;
    	cin.tie(NULL) ;
    	int n , m ;
    	cin >> n >> m ;
    	string s[n] ;
    	for(int i = 0 ; i < n ; i++)
    		cin >> s[i] ;
    	ll dp[n + 1][m + 1] ;
    	memset(dp , 0 , sizeof(dp)) ;
    	for(int i = 0 ; i < m ; i++){
    		if(s[0][i] == '#')
    			break ;
    		dp[0][i] = 1 ;
    	}
    	for(int i = 0 ; i < n ; i++){
    		if(s[i][0] == '#')
    			break ;
    		dp[i][0] = 1 ;
    	}
    	dp[0][0] = 1 ;
    	for(int i = 1 ; i < n ; i++){
    		for(int j = 1 ; j < m ; j++){
    			if(s[i -1 ][j] == '.'){
    				dp[i][j] += dp[i - 1][j] ;
    				dp[i][j]%=mod ;
    			}
    			if(s[i][j - 1] == '.'){
    				dp[i][j] += dp[i][j - 1] ;
    				dp[i][j]%=mod ;
    			}
    		}
    	}
    	cout<< dp[n - 1][m - 1] ;
    }

Measured memory_bytes: 9088
#include<cstdio>
#include<utility>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	pair<ll, int> A[N];
	for (int i = 0; i < N; ++i){
		scanf("%lld %d", &A[i].first, &A[i].second);
	}
	sort(A, A + N);
	int bought = 0, i = 0;
	ll cost = 0;
	while(bought < M){
		if(M - bought > A[i].second){
			bought += A[i].second;
			cost += A[i].first*A[i].second;
		}else{
			cost += A[i].first*(M - bought);
			bought += M - bought;
		}
		i++;
	}
	printf("%lld\n", cost);
	return 0;
}

Measured memory_bytes: 1664