akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> x(n);
  vector<ll> y(n);
  vector<ll> z(n);
  rep(i,n){
    cin >> x[i] >> y[i] >> z[i];
  }
  vector<ll> v(n);
  priority_queue<ll> q;
  rep(j,8){
    rep(i,n){
      if(j&(1<<0)) v[i]=x[i];
      else v[i]=-x[i];
      if(j&(1<<1)) v[i]+=y[i];
      else v[i]-=y[i];
      if(j&(1<<2)) v[i]+=z[i];
      else v[i]-=z[i];
    }
    sort(all(v));
    reverse(all(v));
    ll sum=0;
    rep(i,m) sum+=v[i];
    q.push(sum);
  }
  cout << q.top() << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
using namespace std;

// Debug Vector
template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v)
{
    if (!v.empty())
    {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p)
{
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}

typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
    return 0;
}

Measured memory_bytes: 256
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int h = -1, w;
		cin >> h >> w;
		if (h < 0) return 0;
		vector<string> b(h);
		int whites = h * w;
		for (int i = 0; i < h; ++i) {
			cin >> b[i];
			whites -= count(b[i].begin(), b[i].end(), '#');
		}
		vector<pair<int, int>> q;
		q.push_back({ 0,0 });
		int ans = -1, dist = 0;
		while (!q.empty() && ans < 0) {
			++dist;
			vector<pair<int, int>> nq;
			const int dx[4] = { -1,1,0,0 };
			const int dy[4] = { 0,0,-1,1 };
			for (auto kv : q) {
				if (kv.first == h - 1 && kv.second == w - 1) {
					ans = whites - dist;
					break;
				}
				for (int dir = 0; dir < 4; ++dir) {
					int ny = kv.first + dy[dir], nx = kv.second + dx[dir];
					if (ny >= 0 && ny < h && nx >= 0 && nx < w && b[ny][nx] == '.') {
						b[ny][nx] = 0;
						nq.push_back({ ny, nx });
					}
				}
			}
			q = nq;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def query(n: int):
    print(n, flush=True)
    res = input().rstrip()[0]
    if res == "V":
        sys.exit()
    return res


def main():
    n = input_int()
    record = [None] * n
    # 方針：
    # 2分探索で探す
    # 初期状態を見つける
    left = 0
    right = n - 1
    record[left] = query(left)
    record[right] = query(right)

    for i in range(18):
        mid = (left + right) // 2
        record[mid] = query(mid)
        if (mid - left) % 2 == 1:
            # 差が奇数で性別が一致する場合は空白が間に存在する
            if record[left] == record[mid]:
                right = mid
            else:
                left = mid
        else:
            # 差が偶数で性別が一致する場合は空白が間に存在しない
            if record[left] == record[mid]:
                left = mid
            else:
                right = mid

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 62908
H, W, D = map(int, input().split())
p = {}
for i in range(H):
    inp = list(map(int, input().split()))
    for j, value in enumerate(inp):
        p[value] = (i, j)
# print(p)

cost = {i: 0 for i in range(1, D + 1)}
for i in range(1, D + 1):
    now = i + D
    while now <= H * W:
        cost[now] = cost[now - D] + abs(p[now][0] - p[now - D][0]) + abs(p[now][1] - p[now - D][1])
        now += D

# print(cost)

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    print(cost[R] - cost[L])


Measured memory_bytes: 35980
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=s-1; i>=s; i--)

int main(){

    int n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll b[n];

    b[0] = 0;
    rep(i, n){
        b[0] += (-2*(i%2) + 1)*a[i];
    }

    reps(i, 1, n){
        b[i] = 2*a[i-1] - b[i-1];
    }

    rep(i, n){
        cout << b[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2816
#include<stdio.h>
int main(void){
	char str[1010];
	int i,sum;
	scanf("%s",str);
	while(str[0]!='0'){
		i=0;
		sum=0;
			while(str[i]){
			sum+=str[i]-'0';
			i++;
		}
	printf("%d\n",sum);
	scanf("%s",str);
	}
	return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end(), greater<int>());
  int ans = p[0] / 2 + accumulate(p.begin() + 1, p.end(), 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int direc = 0;
    int n;
    cin >> n;
    deque<int> a;
    for(int i = 0; i < n; i++){
        int b;
        cin >> b;
        if(i % 2 == 1)
        direc = 0;
        else 
        direc = 1;
        if(direc == 0)
        a.push_back(b);
        else 
        a.push_front(b);
    }
   if(direc == 0){
       for(int i = a.size() - 1; 0 <= i; i--){
           if(i > 0)
           cout << a[i] << " ";
           else
           cout << a[i];

       }
   }
   else
   {
       for(int i = 0; i < a.size(); i++){
           if(i < a.size() - 1)
           cout << a[i] << " ";
           else
           cout << a[i];
       }
   }
   cout << "\n";
}

Measured memory_bytes: 2944
N = int(input())
list = list(map(int,input().split()))
#print(list)
sa_list = []
ai = max(list)
for i in range(N):
    sa2 = abs(( list[i] - ai/2 ) *2)
    
   #print(sa)
    sa_list.append(int(sa2))
#print(sa_list)
basyo = (sa_list.index(min(sa_list)))
ar = list[basyo]
if ai == ar:
    print(str(ai) + " " + str(ai - ar))
else:
    print(str(ai) + " " + str(ar))
    


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

int get(int a, int k) {
    if (a < k) return 0;
    if (a % k == 0) return a / k;
    int r = a / k + 1;
    int frm = a / k * k;
    int ad = a - frm;
    ad %= r;
    // cout << a << " ";
    a = frm + ad;
    // cout << a << endl;
    if (a % k == 0) return a / k;
    return get(a - a / k - 1, k);
}

int main() {
    int sum = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a,k;
        cin >> a >> k;
        sum ^= get(a,k);
    }
    if (sum == 0) cout << "Aoki" << endl;
    else cout << "Takahashi" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps i.00000001
#define LINF 1e15+7  
#define INF 1001001001
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;

int main() {
    ll n;
    cin >> n;
    
    vector<ll>v(5);
    rep(i,5)cin>>v[i];
    ll m=LINF;
    rep(i,5)m=min(m,v[i]);
    
    n=(n-1)/m+1;
    cout<<n+4<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100000000
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)			//counts no of ones in binary representation
#define w(t) 	int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

ll power(int a,int n){
	ll ans=1;
	while(n){
		if(n%2==0){
			a*=a;
			n/=2;
		}
		else{
			ans*=a;
			n--;
		}
	}
	return ans;
}

int main(){
	fast;
	int n;
	cin>>n;
	vector<int> v(n);
	forn(i,n)	cin>>v[i];
	set<int> se;
	map<int,int> ma;
	ll sum=0;
	forn(i,n)	sum+=v[i];
	forn(i,n){
		if(se.find(v[i])==se.end()){
			ma[v[i]]=1;
			se.insert(v[i]);
		}
		else	ma[v[i]]++;
	}
	w(q){
		ll b,c;
		cin>>b>>c;
		if(se.find(b)==se.end()){
			cout<<sum<<endl;
			continue;
		}
		else{
			ll x=ma[b];
			ma.erase(b);
			sum-=(x*b);
			if(se.find(c)==se.end()){
				sum+=(x*c);
				ma[c]=x;
			}
			else{
				sum+=(x*c);
				ma[c]+=x;
			}
			se.insert(c);
			se.erase(b);
			cout<<sum<<endl;
		}
	}
}

Measured memory_bytes: 9556
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int A,B;
  cin >> A >> B;
  if(A==B) {
    cout << "Draw" << endl;
    return 0;
  }
  if(A==1) {
    cout << "Alice" << endl;
    return 0;
  }
  if(B==1){
    cout << "Bob" << endl;
    return 0;
  }
  cout << (A>B?"Alice":"Bob") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>

using namespace std;

typedef long long ll;
const int maxn = 5005;

int main(){
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	bool flag=false;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++){
			if((k+2*i*j)==(i*m+j*n)){
				flag=true;
				break;
			}
	}
	if(flag) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
count = 10**9
ans = 0
for i in range(N):
    aveT = abs(A- (T - 0.006 * H[i]))
    if count >= aveT:
        count = aveT
        ans = i+1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 998244353
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI 3.14159265
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;  }  return res;  
}
bool sortinrev(const pair<vector<int>,int>&a,const pair<vector<int>,int>&b){if(a.fi==b.fi)return b.se>a.se;return a.fi>b.fi;}
void run(vector<int>v){for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;}
int modInverse(ll a, ll m) 
{ ll m0 = m;   ll y = 0, x = 1; if (m == 1) return 0; while (a > 1) { 
ll q = a / m;ll t = m; m = a % m, a = t; t = y;y = x - q * y; x = t; } if (x < 0) x += m0; return x; } 

int main() 
{ 
    
    
   int x;
   cin>>x;
   int gc = __gcd(360,x);
   int lcm = (x*360)/gc;
   cout<<lcm/x;
    return 0; 
} 


Measured memory_bytes: 3636
from collections import Counter

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

acnt = Counter(A)

b = []

for k, v in acnt.items():
    if v < 2:
        continue
    if v >= 4:
        b.append(k)
    b.append(k)

b.sort()
if len(b) < 2:
    print(0)
else:
    print(b[-1]*b[-2])

Measured memory_bytes: 22160
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Palindromic Number
            string n = Console.ReadLine();

            string left = n.Substring(0, 1);
            string right = n.Substring(2, 1);

            if (left == right)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }            
        }
    }
}

Measured memory_bytes: 11092
from bisect import bisect_right


def solve():
    A, B, Q, *stx = map(int, open(0).read().split())
    INF = 10 ** 12
    s, t, x = [-INF] + stx[:A] + [INF], [-INF] + stx[A:A + B] + [INF], stx[A + B:]
    
    for xi in x:
        b, d = bisect_right(s, xi), bisect_right(t, xi)
        ans = INF
        for si in [s[b - 1], s[b]]:
            for ti in [t[d - 1], t[d]]:
                d1, d2 = abs(si - xi) + abs(ti - si), abs(ti - xi) + abs(si - ti)
                ans = min(ans, d1, d2)
        print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38660
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int x;
      x=Integer.parseInt(sc.next());

      if(x==7 || x==5 || x==3){
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
      
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(a, b) for (ll i = a; i <= b; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define N 200005
const ll INF = 1000000001;
const ll MOD = 1000000007;

vector< vector<ll> > g(N);
//vector< pair<ll, pair< ll, ll > > > g(N);
ll vis[N] = {0}, par[N] = {0}, child[N] = {0},cnt = 0;
map< pair<ll, ll> , ll> ump;

void dfs(ll v){
    vis[v] = 1;
    cnt++;
    for(auto u: g[v]) if(!vis[u]) dfs(u);
}

void solve(){
    ll n, m;
    cin >> n >>m;
    f(1, n) g[i].clear();
    f(0, m-1) {
        ll x, y; cin >> x>> y;
        if(ump[{x, y}] != 0) continue;
        g[x].pb(y);
        g[y].pb(x);
        ump[{x, y}]+=1; ump[{y, x}]+=1;
    }
    ll ans = 0;
    f(1, n){
        if(!vis[i]){
            cnt = 0;
            dfs(i);
            ans = max(ans , cnt);
        }
    }
    cout << ans << "\n";
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    //ll t;cin >> t;for(ll index=1; index<=t; index++){
        //cout << "Case #" << index << ": " ;
        solve();
    //}
    return 0;
}


Measured memory_bytes: 46972
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

LL a, b;

LL get(LL x){
  LL ones = (x + 1) / 2;
  LL result = 0;
  if(ones & 1) result = 1;
  
  if(x % 2 == 0) result ^= x;

  return result;
}

int main(){
  FAST_IO
  cin >> a >> b;
  LL A = get(a - 1);
  LL B = get(b);

  cout << (A ^ B) << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(void){
    int n,m,k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    int deg[n]={0};
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        deg[a]++;deg[b]++;
        uf.unite(a,b);
    }
    vector<int> to[100005];
    REP(i,k){
        int c,d;
        cin >> c >> d;
        c--;d--;
        to[c].push_back(d);
        to[d].push_back(c);
    }
    REP(i,n){
        int ans=uf.size(i)-1-deg[i];
        for(int u : to[i]){
            if(uf.same(i,u)) --ans;
        }
        printf("%d%c",ans,i==n-1?'\n':' ');
    }
    return 0;
}

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

int main(){
    int item;
    int waiting=0;
    int max_waiting = 0;
    int sum =0;
    for(int i=0; i<5 ; i++){
        cin >> item;
        sum +=item;
        if(item%10 == 0){
            waiting +=0;
        }else{
            waiting += 10 - item%10;
            if(max_waiting < 10 - item%10)
            max_waiting = 10 - item%10;
        }
    }
    cout << sum + waiting -max_waiting<< endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    void run(){
        int MAX = 300000;
        Scanner sc = new Scanner(System.in);
        boolean[] is_MS_Prime = new boolean[MAX+1];
        Arrays.fill(is_MS_Prime, true);
        is_MS_Prime[0] = is_MS_Prime[1] = false;
        for(int i = 0; i <= MAX; i++){
            if(!is_MS_Prime[i]){
                continue;
            }
            if(i % 7 != 1 && i % 7 != 6){
                is_MS_Prime[i] = false;
            }
            else{
                for(int ii = i + i; ii <= MAX; ii += i){
                    is_MS_Prime[ii] = false;
                }
            }
        }
        //System.out.println(Arrays.toString(is_MS_Prime));
        while(true){
            int n = sc.nextInt();
            if(n == 1){
                break;
            }
            String ans = n + ":";
            for(int i = 6; i <= n; i++){
                if(is_MS_Prime[i] && n % i == 0){
                    ans = ans + " " + i;
                }
            }
            System.out.println(ans);
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}

Measured memory_bytes: 24036
<?php
[$K] = ints();
[$A, $B] = ints();
$flag = false;
for($i = $A; $i<=$B; $i++)if($i%$K==0)$flag = true;
echo $flag ? "OK":"NG";

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$M = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


Measured memory_bytes: 16096
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return sys.stdin.readline()[:-1]

def main():
    n = II()
    s = S()
    inf = n + 2
    m = [[0 for i in range(n)] for i in range(n)]
    first = [[inf for i in range(n)] for i in range(n)]
    # set 1st index value
    lcs = 0
    for i, c in enumerate(s):
        # print(c, s[0])
        if c == s[0]:
            m[i][0] = 1
            first[i][0] = i
            if i != 0:
                lcs = 1
    for i in range(1, n):
        for j in range(1, n):
            if i <= j:
                continue
            if s[i] == s[j]:
                if first[i-1][j-1] > j:
                    m[i][j] = m[i-1][j-1] + 1
                    lcs = max(m[i][j], lcs)
                    if first[i-1][j-1] == inf:
                        first[i][j] = i
                    else:
                        first[i][j] = first[i-1][j-1]
            else:
                m[i][j] = 0

    # print(m)
    print(lcs)


if __name__ == '__main__':
    main()

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define int long long
//for set
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
// for multiset
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;


#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
// #define PI 3.1415926535897932384626433832795
#define PI acos(-1.0)
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&!(1<<i);}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

// map<char, int> m;
// bool cmp(char a, char b) {
// 	return m[a]<m[b];
// }

int32_t main(void)
{
	// IOS;
	// int n, d, e; cin>>n>>d>>e;
	// e*=5;
	// vector<bool> reach(1e8+10, false);
	// reach[0]=true;
	// // reach[d]=true; reach[e]=true;
	// for(int i = 0; i < n; i++) {
	// 	if(reach[i] && i+d  <= n)
	// 		reach[i+d]=true;
	// 	if(reach[i] && i+e <= n)
	// 		reach[i+e]=true;
	// }
	// for(int i = n; i >= 0; i--) {
	// 	if(reach[i]) {
	// 		cout<<n-i<<endl;
	// 		return 0;
	// 	}
	// }

	// int b,g,n; cin>>b>>g>>n;
	// int cnt;
	// for(int i = 0; i <= min(n, b); i++) {
	// 	int bb=i; int gg = n-bb;
	// 	if(gg > g) continue;
	// 	cnt++;
	// }
	// cout<<cnt<<endl;

	// int n; cin>>n;
	// string s;  cin>>s;
	// int cnt1=0; int cnt2=0;
	// for(int i = 0; i < n; i++) {
	// 	if(s[i]=='(') cnt1++;
	// 	else cnt2++;
	// }
	// if(cnt1!=cnt2) {
	// 	cout<<"No"<<endl;
	// 	return 0;
	// }
	// stack<int> st;
	// int unmatched=0;
	// for(int i = 0; i < n; i++) {
	// 	if(s[i]=='(') st.push(i);
	// 	else if(st.empty()) unmatched++;
	// 	else st.pop();
	// }
	// while(!st.empty()) {
	// 	unmatched++; st.pop();
	// }
	// if(unmatched==2 || !unmatched) cout<<"Yes"<<endl;
	// else cout<<"No"<<endl;

	int n; cin>>n;
	cout<<n*n*n<<endl;
	time();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
 
int main(void){
    int n,t;
    cin >> n >> t;
    int memo1[n];
    int memo2[n];
    int ans = INT_MAX;
    rep(i,n){
        cin >> memo1[i] >> memo2[i];
        if(memo2[i] <= t &&memo1[i] < ans)ans =memo1[i];
    }
    if(ans == INT_MAX)cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main (){
  ll x;
  cin >> x;
  ll ans = 0;
  ans += (x/11)*2;
  x%=11;
  if(x<=6&&x!=0){
    ans++;
  }else if(x>=7){
    ans += 2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

const long long mod = pow(10, 9) + 7;

int main() {
	int A, B; cin >> A >> B;
	vector<bool> a(4, 0);
	a[A] = 1; a[B] = 1;
	for (int i = 1; i <= 3; i++)if (a[i] == 0)cout << i << endl;
	
}





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

#define MAXN 107

int n ;
int a[ MAXN ] ;

void input ( ) {
    cin >> n ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        cin >> a[ i ] ;
    }
    sort ( a + 1 , a + n + 1 ) ;
}

void solve ( ) {
    int ans = 0 ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        for ( int j = i + 1 ; j <= n ; ++ j ) {
            for ( int t = j + 1 ; t <= n ; ++ t ) {
                if ( a[ i ] == a[ j ] ) { continue ; }
                if ( a[ j ] == a[ t ] ) { continue ; }
                if ( a[ i ] + a[ j ] > a[ t ] ) { ++ ans ; }
            }
        }
    }
    cout << ans << "\n" ;
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define PI 3.141592653589793238
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    	freopen("in2.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    #endif

	int T=1;
	//cin >> T;
	FOR1(tp, T)
	{
		//cout << "Case #" << tp << ": ";
		int n; cin >> n;
		int a[n+1];
		int full = 0;
		FOR1(i, n){
			cin >> a[i];
			full ^= a[i];
		}
		FOR1(i, n){
			cout << (full^a[i]) << " ";
		}
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 5096
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int N=sc.nextInt();
      int R=sc.nextInt();
      if(N>=10){
         System.out.print(R);
      }else{
         System.out.print(R+100*(10-N));
      }
   }
}


Measured memory_bytes: 35752
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a-b>c) cout<<0;
    else cout<<c-(a-b);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  int c, d;
  cin >> c >> d >> n >> m;
  n %= 12;
  double a, b;
  a = m * 6.0;
  b = n * 30.0 + a / 12.0;
  // printf("%.5f %.5f\n", a, b);
  // printf("%.5f\n", min(max(a, b) - min(a, b), min(a, b) + 360 - max(a, b)));
  long double ans = min(max(a, b) - min(a, b), min(a, b) + 360 - max(a, b));
  ans = c * c + d * d - 2 * c * d * cos(2 * acos(-1) * ans / 360.0);
  ans = sqrt(ans);
  printf("%.12Lf\n", ans);
  return 0;
}


Measured memory_bytes: 4144
import java.io.*;
import java.util.*;
 
public class Main{
	public void solve(){
		if(next().startsWith("YAKI")){
			out.println("Yes");
		}else{
			out.println("No");
		}
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 21204
//shan61916
#include <bits/stdc++.h>
    using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;

int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i = 0; i < n; i++) cin >> a[i];
  vector<ll> ans(n) ;
  ll prev = 0;
  for(ll i = 0; i < n; i++) {
    if(i == 0) {
      ll xx = 0;
      for(ll j = 1; j< n-1; j++) {
         xx+=a[j] ;
      }
      ll tt = 2 ;
      for(ll j = 2; j < n-2; j++) {
        if(j == tt) {
        xx-= 2*a[j]; 
        tt+=2;
        }
      }
      ans[i] = a[0] + a[n-1] - xx;
      prev = ans[i];
      continue;
    }
    ans[i] = 2*((a[i-1] - prev/2));
    prev = ans[i] ;
  }
  for(ll i = 0; i < n; i++) cout << ans[i] << " ";
  return 0;
} //good night.

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<int,int> pi;
int k,x,y,t;
pi a[200020];
pi cal(int x,int y){
	if (x>y){
		pi t=cal(y,x);
		return {t.y,t.x};
	}
	if (x<0){
		pi t=cal(-x,y);
		return {-t.x,t.y};
	}
	if (x+y>=2*k) return {x,y-k};
	if (x+y==k) return {0,0};
	int t=k-(x+y)/2;
	return {-t,x+y-(x+y)/2};
}
int main(){
	scanf("%d%d%d",&k,&x,&y);
	if (!(k&1) && (x+y)&1) return puts("-1"),0;
	a[0]={x,y};
	for (;a[t].x || a[t].y;t++) a[t+1]=cal(a[t].x,a[t].y);
	printf("%d\n",t);
	for (;t--;) printf("%d %d\n",a[t].x,a[t].y);
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <utility>
#include <cstdlib>
#include <set>
#include <map>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint n;
map<P, llint> mp;
set<P> S;

llint get(llint x, llint y)
{
	if(mp.count(P(x, y))) return mp[P(x, y)];
	return 0;
}

int main(void)
{
	cin >> n;
	llint x, y, w;
	for(int i = 1; i <= n; i++){
		cin >> x >> y >> w;
		mp[P(x, y)] += w;
		S.insert(P(x, y));
	}
	for(auto it = S.begin(); it != S.end(); it++){
		llint x = it->first, y = it->second;
		mp[P(x, y)], mp[P(x-1, y)], mp[P(x, y-1)], mp[P(x-1, y-1)];
	}
	
	llint ans = 0;
	for(auto it = mp.begin(); it != mp.end(); it++){
		llint x = it->first.first, y = it->first.second;
		ans = max(ans, get(x, y)+get(x+1, y)+get(x, y+1)+get(x+1, y+1));
	}
	cout << ans << " / " << 1 << endl;
	
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);

  int A, B;
  A = 0;
  B = 0;

  for (int i = 0; i < N; i++) {
    int max =0;
    
    for (int j = 0; j < N; j++) {
      if (a.at(max) < a.at(j)) max = j;
    }

    if (i%2 == 0) {
      A += a.at(max);
    }
    else {
      B += a.at(max);
    }
    a.at(max) = 0;
  }
  cout << A - B << endl;
}

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

int main(){

  int n; cin >> n;
  long long  mini = 1e+20,maxi=-1e+20,sum=0;
  for(int i=0; i<n; i++){
    long long t; cin >> t;
    mini = min(mini,t);
    maxi = max(maxi,t);
    sum += t;
  }
  cout << mini << " " << maxi << " " << sum << endl;;
}

Measured memory_bytes: 1172
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
// cout << fixed << setprecision(10);
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long N,K;
long long dp[60][2],a[100010];
int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < 59; i++){
        long long z = 0, o = 0;
        for(int j = 0; j < N; j++){
            if ((a[j] & (1LL << i)) == 0) z++;
            else o++;
        }
        if ((K & (1LL << i)) == 0) dp[i][0] = dp[i-1][0] + (o << i);
        else dp[i][0] = max(dp[i-1][0] + (z << i), dp[i-1][1] + (o << i));
        dp[i][1] = dp[i-1][1] + (max(z,o) << i);
    }
    cout << dp[58][0] << endl;
}

Measured memory_bytes: 1024
sx, sy, tx, ty = map(int, input().split())
ans = "U"*(ty-sy) + "R"*(tx-sx) + "D"*(ty-sy) + "L"*(tx-sx) + "L" + "U"*(ty-sy+1) + "R"*(tx-sx+1) + "D" + "R" + "D"*(ty-sy+1) + "L"*(tx-sx+1) + "U"
print(ans)

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n;

main() {
    cin >> n;
    if(n>=2800) ct("AGC")
    else if (n>=1200) ct("ARC")
    else ct("ABC")
}



Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1179&lang=jp

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main() 
{
	// 普通:195	 3:200 大:20(1) 小:19(2)			
	int N;
	cin >> N;

	rep(i,N)
	{
		int Y,M,D;
		int day[3] = {200, 195, 195};
		cin >> Y >> M >> D;

		int ans=1;//誕生日を含めるため

		//日の計算
		if(Y%3==0)
		{
			ans += 20-D;
		}else
		{
			if(M%2==0){
				ans += 19-D;
			}else{
				ans += 20-D;
			}

		}


		//月の計算
		REP(m, M+1, 11)
		{
			if(Y%3==0)
			{
				ans+=20;
			}else
			{
				if(m%2==0){
					ans+=19;
				}else{
					ans+=20;
				}
			}
		}

		//年の計算
		REP(y, Y+1, 1000){
			ans+=day[y%3];
		}

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

Measured memory_bytes: 1160
l=[0]*10001
1.upto(100) do |x|
  1.upto(x) do |y|
    1.upto(y) do |z|
      n=x**2+y**2+z**2+x*y+y*z+z*x
      if n<=10000
        if x==y&&y==z
          l[n]+=1
        elsif x==y||y==z
          l[n]+=3
        else
          l[n]+=6
        end
      end
    end
  end
end
puts l[1..gets.to_i]

Measured memory_bytes: 14292
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	int n;
	cin>>n;
	string s;
	cin>>s;
	char last='*';
	int ans=0;
	for (int i = 0; i < sz(s); ++i)
		if(s[i]!=last)ans++,last=s[i];
	cout<<ans;
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int w[1000],v[1000];
int memo[1001][1001];
int dfs(int pos,int win){
    if(memo[pos][win]!=-1)return memo[pos][win];
    int res;
    if(pos<1)res=0;
    else if(win-w[pos-1]<0)res=dfs(pos-1,win);
    else res=max(dfs(pos-1,win),dfs(pos-1,win-w[pos-1])+v[pos-1]);
    return memo[pos][win]=res;
}
int main(){
    int W;
    for(int cnt=0;scanf("%d",&W),W;cnt++){
        int n;
        scanf("%d",&n);
        for(int i=0;i<n;i++)scanf("%d,%d",v+i,w+i);
        fill_n(*memo,1001*1001,-1);
        int ans=dfs(n,W);
        printf("Case %d:\n",cnt+1);
        for(int i=W-1;i>=0;i--){
            if(ans==dfs(n,i))continue;
            printf("%d\n%d\n",ans,i+1);
            break;
        }

    }
    return 0;
}

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

int main() {
  int h, w, k; cin >> h >> w >> k;
  vector<string> c(h);
  rep(i,h) cin >> c[i];
  int ans = 0;

  for (int bi = 0; bi<=(1<<h); bi++) {
    for (int bj = 0; bj<=(1<<w); bj++) {
      int sum=0;
      rep(i,h) {
        if (bi & (1<<i)) {
          rep(j,w) {
          if ((bj & (1<<j)) && c[i][j] == '#') sum++;
          }
        }
      }
      if (sum == k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<cmath>
#include<time.h>
#include<cstdlib>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define rep(i,x) for(int i = 0 ; i < x ; i ++)
#define rep1(i,x) for(int i = 1 ; i <= x ; i ++)
#define rrep(i,x) for(int i = x-1 ; i >= 0 ; i --)
#define rrep1(i,x) for(int i = x ; i > 0 ; i --)
#define pb push_back
#define fr first
#define sc second
#define sor(vec) sort(vec.begin(),vec.end())
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))

int d,siz;
int s[400010];
vector<int> t[400010];

void init(int n){
	siz = 1;
	while(siz < n)siz *= 2;
}

void merge_sort(){
	rep(i,d)t[i+siz-1].pb(s[i]);
	rrep(i,siz-1){
		int a = 0 , b = 0;
		while(1){
			if(a >= t[2*i+1].size() && b >= t[2*i+2].size())break;
			if(a >= t[2*i+1].size()){
				while(b < t[2*i+2].size()){
					t[i].pb(t[2*i+2][b]);
					b ++;
				}
				break;
			}
			if(b >= t[2*i+2].size()){
				while(a < t[2*i+1].size()){
					t[i].pb(t[2*i+1][a]);
					a ++;
				}
				break;
			}
			if(t[2*i+1][a] <= t[2*i+2][b]){
				t[i].pb(t[2*i+1][a]);
				a ++;
			}
			else {
				t[i].pb(t[2*i+2][b]);
				b ++;
			}
		}
	}
}

int cnt_u(int a,int b,int x,int k,int l,int r){
	if(b <= l || r <= a)return 0;
	if(a <= l && r <= b)return t[k].end() - ub(t[k],x);
	int vl = cnt_u(a,b,x,2*k+1,l,(l+r)/2);
	int vr = cnt_u(a,b,x,2*k+2,(l+r)/2,r);
	return vl+vr;
}

int cnt_d(int a,int b,int x,int k,int l,int r){
	if(b <= l || r <= a)return 0;
	if(a <= l && r <= b)return lb(t[k],x) - t[k].begin();
	int vl = cnt_d(a,b,x,2*k+1,l,(l+r)/2);
	int vr = cnt_d(a,b,x,2*k+2,(l+r)/2,r);
	return vl+vr;
}

int main(){
	scanf("%d",&d);
	init(d);
	rep(i,d){
		scanf("%d",&s[i]);
	}
	merge_sort();
	int q;
	scanf("%d",&q);
	rep(i,q){
		int l,r,e;
		scanf("%d%d%d",&l,&r,&e); l --; r --;
		int a = min ( s[l] , s[r] );
		int b = max ( s[l] , s[r] );
		//printf("%d %d\n",a,b);;
		//printf("%d %d\n",cnt_u(l,r+1,b+e,0,0,siz),cnt_d(l,r+1,a-e,0,0,siz));
		printf("%d\n",cnt_u(l,r+1,b+e,0,0,siz) + cnt_d(l,r+1,a-e,0,0,siz));
	}
	
	/*rep(i,2*siz-1){
		printf("%d:\n",i);
		rep(j,t[i].size()){
			printf("%d ",t[i][j]);
		}
		puts("");
	}*/
}

Measured memory_bytes: 23320
#include<cstdio>
using namespace std;
int n,m,a[105],sum=0;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    scanf("%d",&m);
    while(m--){
        int p,x;
        scanf("%d%d",&p,&x);
        printf("%d\n",sum-a[p]+x);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int du(int p,int q)
{
	return ceil(p/double(q))*q;
}
bool si(int p,int q,int r)
{ 
 return du(p,q)>=p && du(p,q)<=r;
}
void solve(int x,int y,int z)
{
 cout<<(si(y,x,z) && (z/x)*x<=z?"OK":"NG")<<"\n";
}
int main()
{
 int a,b,k;
 cin>>k>>a>>b;
 solve(k,a,b);
 return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[100001],n,m;
vector<vector<int>> g(100001,vector<int>());

int call(int u){
    if(dp[u]!=-1)
        return dp[u];
    int res=0;
   for(auto v:g[u]){
        res=max(res,1+call(v));
   }
   return dp[u]=res;
}


int main(){

    cin>>n>>m;
    while(m--){
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
    }
    int ans=0;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++){
        if(dp[i]==-1){
            ans=max(ans,call(i));
        }
    }
    cout<<ans;



return 0;
}


Measured memory_bytes: 11044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll ans = 0,n;
void dfs(ll x,bool f3,bool f5,bool f7){
    if(x > n) return;
    if(f3&&f5&&f7) ans++;
    dfs(10*x+3,true,f5,f7);
    dfs(10*x+5,f3,true,f7);
    dfs(10*x+7,f3,f5,true);
}
int main() {
    cin >> n;
    dfs(0,0,0,0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256