akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(a%b,b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    ll ans = lcm(a,b);
    cout << ans << "\n";
    return 0;
}


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

const long long MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  long long N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> Summ(N+1);
  for(int i = 0; i < N; i++){
    cin >> A[i];
    Summ[i+1] = Summ[i] + A[i]; 
    Summ[i+1] %= MOD;
  }
  long long ans = 0;
  for(int i = 0; i < N; i++){
    ans += Summ[i] * A[i]; 
    ans %= MOD;
  }
  cout << ans <<endl;
}



Measured memory_bytes: 6328
#include <iostream>

int main()
{
    int n;
    std::cin >> n;

    if((n%10==7)||((n-(n%10))%100==70)||((n-(n%100))==700))
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }
}

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



int main(){
    int n;
    ll sum=0, ans=0;
    
    cin>> n;

    map<int, ll> a;
    for(int i=0; i<n; i++){
        ll input;
        cin>>input;
        a[input]++;
        sum+=input;
    }
   // cout<<sum<<endl;
    int q;
    cin>>q;
    for(int i=0; i<q; i++){
        int b, c;
        cin>> b >>c;

        sum-=a[b]*b;
        sum+=a[b]*c;
        if(c!=b){
            a[c]+=a[b];        
            a[b]=0;
        }

        cout<<sum<<endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator*(long long y,const mint& m){ return m*y; }

int main(){
	int n,k; scanf("%d%d",&n,&k);

	// dp[i][j][s] := 左の頂点 {1,2,...,i} と右の頂点 {1,2,...,i} に対して,
	//                j 組がマッチング済みで, "その時点で確定したスコア" が s であるような場合の数
	static mint dp[51][51][2501];
	dp[0][0][0]=1;
	rep(i,n) rep(j,i+1) rep(s,n*n+1) {
		int s2;
		// 左の i+1 と右の i+1 をマッチング
		s2=s+2*(i-j);
		if(s2<=n*n) dp[i+1][j+1][s2]+=dp[i][j][s];
		// 左の i+1 も右の i+1 も保留
		s2=s+2*(i-j+1);
		if(s2<=n*n) dp[i+1][j][s2]+=dp[i][j][s];
		// 片方の i+1 をもう片方の保留にしていた頂点とマッチング, 残った i+1 は保留
		s2=s+2*(i-j);
		if(s2<=n*n) dp[i+1][j+1][s2]+=2*(i-j)*dp[i][j][s];
		// 左の i+1 を右の保留にしていた頂点とマッチング, 右の i+1 を右の保留にしていた頂点とマッチング
		s2=s+2*(i-j-1);
		if(s2<=n*n && j<i) dp[i+1][j+2][s2]+=(i-j)*(i-j)*dp[i][j][s];
	}
	printf("%d\n",dp[n][n][k].to_int());

	return 0;
}


Measured memory_bytes: 25600
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define REP1(i,n) for(long long i=1;i<=(n);i++)
#define REP2D(i,j,h,w) for(long long i=0;i<(h);i++) for(long long j=0;j<(w);j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=(h);i++) for(long long j=1;j<=(w);j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) ((a).begin()),((a).end())
#define RANGE(a) (a),((a)+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl

#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << (a) << endl
#define DBSTART if(1){
#define DBEND }
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#else
#define DBPRT(a) if(0){}
#define DBSTART if(0){
#define DBEND }
#define PRTLST(arr,num) if(0){}
#define PRTLST2(arr2,d1,d2) if(0){}
#define PRTLST2D(arr2,d1,d2) if(0){}
#endif

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 100000
//---------------------

ll a,b;
int gcdr ( int a, int b )
{
  if ( a==0 ) return b;
  return gcdr ( b%a, a );
}


int main(){
	cin >> a >> b;
	PRT(((a*b)/gcdr(a,b)));
	return 0;
}









Measured memory_bytes: 256
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 998244353;
const int N = 100000 + 7;

int n,k,q,x;
vector<int>freq;
int main()
{
    scanf("%d%d%d",&n,&k,&q);
    freq.resize(n+1);
    for(int i=0;i<q;i++)
    {
        scanf("%d",&x);
        freq[x]++;
    }
    for(int i=1;i<=n;i++)
    {
        int t=q-freq[i];
        if(k-t>0)
            puts("Yes");
        else
            puts("No");
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int H, W;
    int h, w;
 
    while (1) {
        scanf("%d%d", &H, &W);
        if (H == 0 && W == 0) break;
        for (h = 0; h < H; h++) {
            for (w = 0; w < W; w++) putchar('#');
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}


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

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

    int temp1 = 0;
    int temp2 = 0;
    temp1 = x;
    for(int i = 0; i < 10; i++){
        temp2 = r * temp1 - D;
        cout << temp2 << "\n";
        temp1 = temp2;
    }

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Node ns[] = new Node[n];
        for (int i = 0; i < n; i++) {
            ns[i] = new Node(i, sc.nextLong(), sc.nextLong());
        }

        ArrayList<Edge> es[] = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            es[i] = new ArrayList<>();
        }
        Arrays.sort(ns, (n1, n2) -> Long.compare(n1.x, n2.x));
        createEdge(es, ns, n);
        Arrays.sort(ns, (n1, n2) -> Long.compare(n1.y, n2.y));
        createEdge(es, ns, n);

        boolean used[] = new boolean[n];
        long res = 0;
        PriorityQueue<Edge> queue = new PriorityQueue<>((e1, e2) ->
                Long.compare(e1.cost, e2.cost));
        used[0] = true;
        queue.addAll(es[0]);

        while (!queue.isEmpty()) {
            Edge e = queue.poll();
            if (used[e.to]) continue;
            used[e.to] = true;
            res += e.cost;

            queue.addAll(es[e.to]);
        }
        System.out.println(res);
    }

    static long dist(int i, int j, Node[] ns) {
        return Math.min(Math.abs(ns[i].x - ns[j].x), Math.abs(ns[i].y - ns[j].y));
    }

    static void createEdge(ArrayList<Edge> es[], Node[] ns, int n) {
        for (int i = 1; i < n; i++) {
            long dist1 = dist(i, i-1, ns);
            int prevID = ns[i-1].id;
            int ID = ns[i].id;
            Edge e1 = new Edge(prevID, ID, dist1);
            Edge e2 = new Edge(ID, prevID, dist1);
            es[prevID].add(e1);
            es[ID].add(e2);
        }

    }

    static class Node {
        int id;
        long x, y;
        Node(int id, long x, long y) {
            this.id = id;
            this.x = x;
            this.y = y;
        }

    }

    static class Edge {
        int from, to;
        long cost;
        Edge(int f, int t, long c) {
            from = f;
            to = t;
            cost = c;
        }

    }


}


Measured memory_bytes: 105496
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,b)  for(int i=0;i<(int)(b);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    cs;
    ll ans=0,t;
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<int> aa(a);
    vector<int> bb(b);
    vector<int> cc(c);
    rep(i,a) cin>>aa[i];
    rep(i,b) cin>>bb[i];
    rep(i,c) cin>>cc[i];
    sort(aa.rbegin(),aa.rend());
    sort(bb.rbegin(),bb.rend());
    rep(i,x) cc.push_back(aa[i]);
    rep(i,y) cc.push_back(bb[i]);
    sort(cc.rbegin(),cc.rend());
    t=x+y;
    rep(i,t) ans+=cc[i];
    cout<<ans;
}

Measured memory_bytes: 2552
N = int(input())
Alist = list(map(int,input().split()))
Aplu = []
Amin = dict()
for i in range(N):
    A = Alist[i]
    Aplu.append(A+(i+1))
    if (i+1)-A not in Amin:
        Amin[(i+1)-A] = 1
    else:
        Amin[(i+1)-A] += 1
Answer = 0
for k in Aplu:
    if k in Amin:
        Answer += Amin[k]
print(Answer)

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

using namespace std;

int lt[1000005], a[1000005], flag[1000005];

int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	memset(lt, -1, sizeof(lt));
	
	for (int i = 2; i <= 1000000; i++) {
		if (lt[i] != -1) continue;
		lt[i] = i;
		for (int j = i; j <= 1000000 / i; j++) {
			if (lt[j * i] == -1) lt[j * i] = i;
		}
	}
	
	bool ok = 1;
	memset(flag, -1, sizeof(flag));
	
	for (int i = 0; i < n; i++) {
		int tmp = a[i];
		while (tmp > 1) {
			int pf = lt[tmp];
			if (flag[pf] != -1 && flag[pf] != i) ok = 0;
			flag[pf] = i;
			tmp /= pf;
		}
	}
	
	if (ok) return 0 * printf("pairwise coprime\n");

	bool ok1 = 1;
	int gcd = 0;
	
	for (int i = 0; i < n; i++) gcd = __gcd(gcd, a[i]);
	
	if (gcd == 1) return 0 * printf("setwise coprime\n");
	
	printf("not coprime\n");
}


Measured memory_bytes: 15360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
ll qpow(ll a, ll b)
{
    ll r = 1;
    for (;b;b>>=1,a=a*a%MOD)
        if (b&1)
            r = r*a%MOD;
    return r;
}
ll c(ll n, ll k)
{
    ll u = 1, d = 1;
    for (int i = 0; i < k; ++i) {
        u = u * (n - i) % MOD;
        d = d * (i + 1) % MOD;
    }
    return u * qpow(d, MOD - 2) % MOD;
}
int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = qpow(2, n) + MOD - 1 + MOD - c(n, a) + MOD - c(n, b);
    cout << ans % MOD << endl;
}


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

int main (void) {
  int N;
  cin >> N;
  int d[N+10];
  for (int i=0; i<=N-1; i++) {
    cin >> d[i];
  }
  int num[110]={0};
  for (int i=0; i<=N-1; i++) {
    num[d[i]]++;
  }
  int ans=0;
  for (int i=1; i<=100; i++) {
    if (num[i]>0){
      ++ans;
    }
  }
  cout << ans;
}

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

using namespace std;

const int MAX_N = 100;
int v[2*MAX_N];

int main() {
  int n;
  long long s = 0LL;

  scanf("%d", &n);
  n = 2 * n;
  for(int i = 0; i < n; ++i)
    scanf("%d", &v[i]);

  sort(v, v + n);

  for(int i = 0; i < n; i += 2)
    s = s + v[i];

  printf("%lld", s);
  return 0;
}


Measured memory_bytes: 256
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
ans = "No"
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = -1

for i in range(3):
    if A[0][i] + A[1][i] + A[2][i] == -3:
        print("Yes")
        exit()
    if A[i][0] + A[i][1] + A[i][2] == -3:
        print("Yes")
        exit()
if A[0][0] + A[1][1] + A[2][2] == -3 or A[0][2] + A[1][1] + A[2][0] == -3:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 9056
dishes = []
serve = []
for i in range(5):
    dish = int(input())
    dishes.append(dish)
    if dish % 10 != 0:
        time = 10 - dish%10
        serve.append(time)
if serve == []:
    print(sum(dishes))
else:
    sort_serve = sorted(serve)
    sort_serve.remove(sort_serve[len(sort_serve)-1])
    ans = sum(dishes) + sum(sort_serve)
    print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  string s,r;
  cin >> s >> r;
  char bkn=s[0];
  int bkt;
  ll ans;

  if(n==1||bkn!=s[1]) {
    bkt=1;
    ans=3;
  }else{
    bkt=0;
    ans=6;
  }
  
  for(ll i=(bkt?1:2);i<s.length();i++){
    if(s[i]==s[i+1]){
      // 今横長
      if(bkt) ans = ans%mod * 2;
      else ans = ans%mod * 3;
      bkt=0;
      i++;
    }else{
      //今縦長
      if(bkt) ans = ans%mod * 2;
      bkt=1;
    }
  }
  pri(ans%mod);


  return 0;
}



Measured memory_bytes: 384
import sys
n = int(input())
xyh = []
fxyh = []
for _ in range(n):
    xyh.append(list(map(int, input().split())))
    if xyh[-1][2]:
        fxyh = xyh[-1]


for i in range(100 + 1):
    for j in range(100 + 1):
        h = fxyh[2] + abs(fxyh[0] - i) + abs(fxyh[1] - j)
        if 1 > h:
            continue
        ok = True
        for k in range(n):
            if xyh[k][2] != max(0, h - abs(xyh[k][0] - i) - abs(xyh[k][1] - j)):
                ok = False
                break
        if ok:
            print(str(i) + ' ' + str(j) + ' ' + str(h))
            sys.exit(0)


Measured memory_bytes: 3064
import Control.Applicative
main = do
    ns <- fmap (read :: String -> Int) . words <$> getLine
    let m = ns !! 0
        f = ns !! 1
        r = ns !! 2
    putResult m f r

putResult :: Int -> Int -> Int -> IO ()
putResult m f r
    | m == -1 && f == -1 && r == -1 = return ()
    | m == -1 || f == -1 = putStrLn "F" >> main
    | 80 <= sum_mf = putStrLn "A" >> main
    | 65 <= sum_mf && sum_mf < 80 =  putStrLn "B" >> main
    | 50 <= sum_mf && sum_mf < 65 || 50 <= r = putStrLn "C" >> main
    | 30 <= sum_mf && sum_mf < 50 = putStrLn "D" >> main
    | sum_mf < 30 = putStrLn "F" >> main
    where
        sum_mf = m + f

Measured memory_bytes: 4080
#include <set>
#include <cstdio>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

typedef long long ll;

using namespace std;

int main(){
  int n = getInt();
  vector<int> l(n - 1);
  vector<int> r(n - 1);

  vector<ll> dp1(n);
  vector<ll> dp2(n);
  vector<ll> dp(n);
  vector<ll> depth(n);

  REP(i,n - 1){
    l[i] = getInt() - 1;
    r[i] = getInt() - 1;
    depth[r[i]] = depth[i] + 1;
    depth[l[i]] = depth[i] + 1;
  }

  dp[n - 1] = dp2[n - 1] = 0;
  dp1[n - 1] = 1;

  for(int i = n - 2; i >= 0; i--){
    dp1[i] = dp1[l[i]] + dp1[r[i]];
    dp2[i] = dp2[l[i]] + dp2[r[i]] + dp1[i];

    dp[i] = min(dp[l[i]] + dp2[r[i]] + dp1[r[i]] + 1,
                dp[r[i]] + dp2[l[i]] + dp1[l[i]] + 1);
    dp[i] = min(dp[i], 1 + dp[l[i]] + depth[i] + 1 + dp[r[i]]);
  }
  // REP(i,n-1) printf("%d: dp1 = %lld  dp2 = %lld  dp = %lld\n", i, dp1[i], dp2[i], dp[i]);

  printf("%lld\n", dp[0]);

  return 0;
}

Measured memory_bytes: 19000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    int a,b;
    cin>>a>>b;
    if(a>0){
        cout<<"Positive";
        return 0;
    }
    if(a<0&&b>0){
        cout<<"Zero";
        return 0;
    }
    else{
        a=abs(a)-abs(b)+1;
        if(a%2==0){
            cout<<"Positive";
        }
        else cout<<"Negative";
        return 0;
    }
}



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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	while(p){
		if(p&1)mult(s,a);
		mult(a,a);
		p>>=1;
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

const int Vmax=1000010;
int fact[Vmax],factInv[Vmax];
void Init(){
	fact[0]=1;
	FOR(i,1,Vmax){
		fact[i]=fact[i-1];
		mult(fact[i],i);
	}
	factInv[Vmax-1]=modInv(fact[Vmax-1]);
	for(int i=Vmax-2;i>=0;i--){
		factInv[i]=factInv[i+1];
		mult(factInv[i],i+1);
	}
}
int Choose(int n,int k){
	return fact[n]*factInv[n-k]%mod*factInv[k]%mod;
}

int Hogloid(int x){
	int res=0;
	while(x){
		res++;
		x/=10;
	}
	return res;
}

int Sigma(int s){
	int b=1,e=1,sum=0,ans=0;
	while(e<10000000){
		sum+=Hogloid(e++);
		while(sum>s)
			sum-=Hogloid(b++);
		if(sum==s){
			ans++;
			sum-=Hogloid(b++);
		}
	}
	while(b<e){
		if((s-sum)%8==0)ans++;
		sum-=Hogloid(b++);
	}
	return ans;
}

int Wo(int s){
	int ans=0,t=90000000;
	FOR(i,8,s+1){
		int y=s%i;
		int x=s/i-y;
		if(x>=1)add(ans,(x-1)/(i+1)+1);
		if(y==0){
			int w=t;
			sub(w,x);
			add(ans,w);
		}
		mult(t,10);
	}
	return ans;
}

signed main(){
	int s=read();
	int ans=0;
	add(ans,Sigma(s));
	add(ans,Wo(s));
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((abs(a-b)<=d&&abs(c-b)<=d)||abs(c-a)<=d){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main()
{
	long int k,n;
	cin>>k;
	cin>>n;
	long int i;
	long int a[n],da[n];
//	scanf("%ld",&a[0]);
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<n;i++)
	{
		da[i]=a[i+1]-a[i];
		if(i==(n-1))
			da[i]=k-a[i]+a[0];
	}
	sort(da, da+n);
	long int dis=0;
	for(i=0;i<n-1;i++)
	{
		dis+=da[i];
	}
	cout<<dis;
	return 0;
}

Measured memory_bytes: 3328
import qualified Data.ByteString.Char8 as B
import           Data.List             (foldl', unfoldr)


main :: IO ()
main = do
  n <- readLn
  as <- readIntsLn
  print $ solve n as

solve :: Int -> [Int] -> Int
solve n as
  | k == 0    = -1
  | otherwise = n - k
  where k = foldl' f 1 as - 1

f :: Int -> Int -> Int
f x a
  | x == a    = x + 1
  | otherwise = x

readIntsLn :: IO [Int]
readIntsLn = unfoldr (B.readInt . B.dropWhile (== ' ')) <$> B.getLine


Measured memory_bytes: 4476
x, y = map(int, input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
if x in c or y in c:
	print ("No")
	exit()
if (x in a and y in a) or (x in b and y in b):
	print ("Yes")
else:
	print ("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
        using namespace std;
        #define rep(i,a,b) for(ll i =a; i<b;++i)
        #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        #define endl "\n"
        #define pb push_back
        #define print(a)       for(auto x : a) cout << x << " "; cout << endl
        #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
        #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
        #define mk(x,y)  make_pair(x,y)
        typedef  long long  int ll;
        const int N = ( 2e5 + 5 );
        const int mod = 1e9+7;
        ll n,a[N],p;
        vector<int> g[N];
ll pow_mod_m(ll a , ll n)
{
    if(!n)
        return 1;
    ll pt =  pow_mod_m(a,n/2);
    pt *= pt ; pt %= mod;
    if(n&1)
        pt *= a , pt %= mod;
    return pt;
}

map <ll,ll > m;

void lcm(ll a)
{
   for( int i = 2; i*i <= a;i++ )
   {
       ll cnt =  1;
       while( a%i == 0 )
       {
           a /= i, cnt*= i;
       }
       m[i] = max(m[i],cnt);
   }
   if(a  > 1)
     m[a] = max(m[a],a);
}
int main()
{
    IOS;
    int ts = 1;
 //   cin>>ts;
	while(ts--)
    {
            cin>>n;
            ll l = 1;
            rep(i,0,n)
            {
                cin>>a[i];
                lcm(a[i]);
            }
            ll ans= 0;
            for(auto u : m)
            {
                l = l * u.second % mod;
            }
            rep(i,0,n)
            {
                ans += pow_mod_m(a[i],mod-2);
            }
            ans = (ans%mod) * (l%mod)%mod ;
            cout<<ans % mod <<endl;
    }
	return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  
  int a[m],b[m];
  //cout << "n:" << n << " m:" << m << endl;
  for(int i=0 ; i<m ; i++){
    cin >> a[i] >> b[i];
    //cout << a[i] << ":" << b[i] << endl;
  }
  
  for(int i=1 ; i<=n ; i++){
    //cout << "i:" << i ;
    int ans=0;
    for(int j=0 ; j<m ; j++){
      //cout << "i:" << i << endl;
      //cout << a[j] << ":" << b[j] << endl;
      if(i==a[j]){
        ans++;
        //cout << "i==a[j]" << endl;
      }
      if(i==b[j]){
        ans++;
        //cout << "i==b[j]" << endl;
      }
    }
    
    cout << ans << endl;
  }

}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c; cin>>a>>b>>c;
    set<int> s;
    int now = a;
    bool ok=false;
    while(true){
        if (s.count(now%b)) break;
        s.ins(now%b);
        if (now%b==c){
            ok = true;
            break;
        }
        now+=a;
    }
    if (ok){
        cout<<"YES\n";
    }else{
        cout<<"NO\n";
    }
    return 0;
}


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

using namespace std;

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

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

int main() {
  ll r;cin>>r;
  OUT(r*r);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  char a[6];
  for(int i = 0; i < 6; i++)cin >> a[i];
  for(int i = 0; i < 3; i++){
    if(a[i]!=a[5-i]){
      cout << "NO" << endl;
      exit(0);
    }
  }
  cout << "YES" << endl;
  return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<stdlib.h>
int comp(const void * a, const void * b)
{
    if(*(int*)a > *(int*)b) return -1;
    if(*(int*)a < *(int*)b) return 1;
    return 0;
}
int main(void)
{
    long n = 0;
    char c=getchar_unlocked();
    while(c<='9'&&c>='0') {n=(n<<1)+(n<<3)+c-'0'; c=getchar_unlocked();}
    int ary[200000];
    for(int i = 0;i < n;++i) {
        ary[i] = 0;
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {ary[i]=(ary[i]<<1)+(ary[i]<<3)+c-'0'; c=getchar_unlocked();}
    }
    qsort(ary, n, 4, comp);
    long ans = 0;
    for(int i = 0;i < n;++i) {
        ans += ary[i/2];
    }
    printf("%ld", ans - ary[0]);
    return 0;
}


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

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

  vector<int> snukes(n, 0);

  rep(i, k) {
    int count;
    cin >> count;

    rep(j, count) {
      int sn;
      cin >> sn;
      snukes[sn - 1] = 1;
    }
  }

  int result = 0;

  rep(i, n) {
    if (snukes[i] == 0) {
      result++;
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 3616
import java.math.BigDecimal;
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();

        HashSet<Integer> kinds = new HashSet<>();
        int any = 0;

        for (int i = 0; i < N; i++) {
            int value = sc.nextInt();

            if (value <= 399) {
                kinds.add(0);
            } else if (value <= 799) {
                kinds.add(1);
            } else if (value <= 1199) {
                kinds.add(2);
            } else if (value <= 1599) {
                kinds.add(3);
            } else if (value <= 1999) {
                kinds.add(4);
            } else if (value <= 2399) {
                kinds.add(5);
            } else if (value <= 2799) {
                kinds.add(6);
            } else if (value <= 3199) {
                kinds.add(7);
            } else {
                any++;
            }
        }

        int min = (kinds.size() == 0) ? 1 : kinds.size();
        int max = kinds.size() + any;

        System.out.println(min + " "+ max);
    }
}

Measured memory_bytes: 21332
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {

        try (final Scanner sc = new Scanner(System.in)) {
            final int n = sc.nextInt();
            final int k = sc.nextInt();
            final String s = sc.next();

            List<Integer> nums = new ArrayList<Integer>();
            int now = 1; // これにより、numsの最初の要素は必ず1に対応する（文字列の最初の要素が1でないときでも）
            int count = 0;
            for (int i = 0; i < n; i++) {
                if (s.charAt(i) == (char) ('0' + now)) {
                    count += 1;
                } else {
                    nums.add(count);
                    now = 1 - now; // now ^= 1もあり
                    count = 1;
                }
            }
            nums.add(count);
            // numsの末尾も1に対応させたいので、0対応で終わっていたら（数が偶数個なら）1に対応する要素を追加（実際は存在しないので数は0）
            if (nums.size() % 2 == 0) {
                nums.add(0);
            }
            // 累積和
            List<Integer> sums = new ArrayList<>(nums.size() + 1);
            sums.add(0);
            for (int i = 0; i < nums.size(); i++) {
                sums.add(sums.get(i) + nums.get(i));
            }
            int ans = 0;
            int add = 2 * k + 1;
            for (int i = 0; i < nums.size(); i += 2) {
                int left = i;
                int right = Math.min(left + add, nums.size());
                int temp = sums.get(right) - sums.get(left);
                ans = Math.max(ans, temp);
            }
            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 27932
public class Main {


  private static void solve() {
    int N = ni();
    int C = ni();
    int[][] D = ntable(C, C);
    int[][] c = ntable(N, N);

    int[][] dp = new int[C][3];
    for (int i = 0; i < C; i++) {
      for (int x = 0; x < N; x++) {
        for (int y = 0; y < N; y++) {
          dp[i][(x + y) % 3] += D[c[x][y] - 1][i];
        }
      }
    }

    int min = Integer.MAX_VALUE;
    for (int i = 0; i < C; i++) {
      for (int j = 0; j < C; j++) {
        if (i == j)
          continue;
        for (int k = 0; k < C; k++) {
          if (i == k || j == k)
            continue;

          int now = dp[i][0] + dp[j][1] + dp[k][2];
          min = Math.min(now, min);
        }
      }
    }
    System.out.println(min);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int flag = 0;
    while(a < b){
        if(!flag){
            a++;
            flag = 1;
        }
        else{
            b--;
            flag = 0;
        }
    }
    if(b - a == 1){}
    else if((b - a) % 2 == 0) b++;
    else a--;

    if(flag) cout << "Borys\n";
    else cout << "Alice\n";
    return 0;
}


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


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

int main() {
	long long n,m,k,i,j,res,a,b,t,crit;
	cin >> n >> m;
	k=1;
	for(i=0; i<n; i++){
		k*=2;
	}
	vector<long long> ans(k,10000000),bin={1,2,4,8,16,32,64,128,256,512,1024,2048};
	ans[0]=0;
	
	for(i=0; i<m; i++){
		cin >> a >> b;
		crit=0;
		for(j=0; j<b; j++){
			cin >> res; res--;
			crit+=bin[res];
		}
		
		for(t=0; t<k; t++){
			ans[t | crit]=min(ans[t]+a,ans[t|crit]);
		}
	}
	if(ans[k-1]==10000000){
		cout << -1;  return 0;
	}
	cout << ans[k-1];
}


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

# D - Chat in a Circle
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

i = 0
ans = A[i]
count = 2

while True:	
	if count == N:
		break
	else:
		if count % 2 == 0:
			i += 1
		
		ans += A[i]
		count += 1

print(ans)

Measured memory_bytes: 31392
a, b = map(int, input().split())

width, height = 100, 100

ans = [['#'] * width for _ in range(height//2)]
for _ in range(height//2):
    ans.append(['.'] * width)

for i in range(height // 2 // 2):
    if a == 1:
        break
    for j in range(width // 2):
        if a == 1:
            break
        ans[i*2][j*2] = '.'
        a -= 1

for i in range(height // 2 // 2):
    if b == 1:
        break
    for j in range(width // 2):
        if b == 1:
            break
        ans[-i*2-1][-j*2-1] = '#'
        b -= 1

print(height, width)
print('\n'.join(map(lambda x: ''.join(x), ans)))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b==c||b+c==a||c+a==b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	long int N, p = 1;
	long int i;

	scanf("%d", &N);

	for(i=1; i<=N; i++){
		p = p * i;
		p = p%1000000007;
		if(p < 0){
			p = p+1000000007;
		}
	}

	printf("%ld", p);

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int oo = 1e9;
const int MOD = 1000000007;
const int BASE = 26;
const int N = 202010;
const int MX = 200000;
#define x first
#define y second
#define pb push_back
#define mp make_pair

int n , m , b[N], seg[4 * N], lazy[4 * N], dp[N], gg;
pii iv[N];
vector<int> g[N];


void build(int n , int s , int e) {
	lazy[n] = oo;
	if (s == e) {
		seg[n] = oo;
		return;
	}
	build(2 * n, s, (s + e) / 2);
	build(2 * n + 1, (s + e) / 2 + 1, e);
	seg[n] = min(seg[2 * n], seg[2 * n + 1]);
}
void push(int n , int s , int e) {
	seg[n] = min(seg[n], lazy[n]);
	if (s != e) {
		lazy[2 * n] = min(lazy[2 * n], lazy[n]);
		lazy[2 * n + 1] = min(lazy[2 * n + 1], lazy[n]);
	}
	lazy[n] = oo;
}
void update(int n, int s , int e, int l ,  int r , int val) {
	push(n, s, e);
	if (s > r || e < l)return;
	if (s >= l && e <= r) {
		lazy[n] = val;
		push(n, s, e);
		return;
	}
	update(2 * n, s, (s + e) / 2, l, r, val);
	update(2 * n + 1, (s + e) / 2 + 1, e, l, r, val);
	seg[n] = min(seg[2 * n], seg[2 * n + 1]);
}
int get(int n , int s , int e, int l , int r) {
	push(n, s, e);
	if (s > r || e < l)return oo;
	if (s >= l && e <= r)
		return seg[n];
	return min(get(2 * n, s, (s + e) / 2, l, r), get(2 * n + 1, (s + e) / 2 + 1, e, l, r));
}
int main() {
	scanf("%d", &n);
	for (int i = 1 ; i <= n; ++i) {
		scanf("%d", &b[i]);
		if (!b[i])++gg;
	}
	++n;
	build(1, 1, n);
	update(1, 1, n, n, n, 0);
	scanf("%d", &m);
	for (int i = 1; i <= m; ++i) {
		scanf("%d%d", &iv[i].x, &iv[i].y);
		g[iv[i].x].pb(iv[i].y);
	}
	for (int i = n - 1 ; i >= 1 ; --i) {
		dp[i] = (b[i] ? 1 : -1) + dp[i + 1];
		update(1, 1, n, i, i, dp[i]);
		for (auto j : g[i]) {
			dp[i] = min(dp[i], get(1, 1, n, j + 1, j + 1));
			update(1, 1, n, i, j, get(1, 1, n, j + 1, j + 1));
		}
	}


	printf("%d\n", dp[1] + gg);
	return 0;
}


Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
char c[4005];
vector<int>g;
char qry(int a,int b)
{
	printf("? %d %d\n",a,b);
	fflush(stdout);
	char c;
	scanf("\n%c",&c);
	return c;
}
int main()
{
	int n,a,b;
	scanf("%d%d",&a,&b);
	n=a+b;
	if(b>=a)
	{
		printf("Impossible\n");
		fflush(stdout);
	}
	else
	{
		g.push_back(0);
		for(int i=1;i<n;i++)
		{
			if(g.empty())g.push_back(i);
			else if(qry(g.back(),i)=='N')g.pop_back();
			else g.push_back(i);
		}
		for(int i=0;i<n;i++)if(qry(g.back(),i)=='N')c[i]='0';else c[i]='1';
		c[n]=0;
		printf("! %s\n",c);
		fflush(stdout);
	}
	return 0;
}

Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

// 1-indexed
class BIT {
 public:
  vector<int> bit;
  int M;

  BIT(int M) : bit(vector<int>(M + 1, 0)), M(M) {}

  // a[1] + a[2] + ... + a[i]を求める
  int sum(int i) {
    if (i == 0) return 0;
    return bit[i] + sum(i - (i & -i));
  }
  // a[i] += x
  void add(int i, int x) {
    if (i > M) return;
    bit[i] += x;
    add(i + (i & -i), x);
  }

  // iがa[i]個あるとき，k番目に小さい要素を取得
  int getKthSmallest(int k) {
    int c = 1;
    while (c <= M) {
      c *= 2;
    }
    c /= 2;
    int x = 0;
    for (; c > 0; c /= 2) {
      if (x + c <= M && bit[x + c] < k) {
        k -= bit[x + c];
        x += c;
      }
    }
    return x + 1;
  }
};

int main() {
  ll n, q;
  cin >> n >> q;
  vector<ll> c(n);
  REP(i, n) {
    cin >> c[i];
    c[i]--;
  }
  vector<ll> l(q), r(q);
  REP(i, q) {
    cin >> l[i] >> r[i];
    l[i]--, r[i]--;
  }
  vector<ll> ord(q);
  iota(ALL(ord), 0);
  sort(ALL(ord), [&](ll i, ll j) { return r[i] < r[j]; });

  BIT b(n + 5);
  vector<ll> ans(q), lastAppeared(n, -1);
  ll cur = 0;
  REP(i, q) {
    ll j = ord[i];
    while (cur <= r[j]) {
      ll tmp = lastAppeared[c[cur]];
      lastAppeared[c[cur]] = cur;
      if (tmp != -1) {
        b.add(tmp + 1, -1);
      }
      b.add(cur + 1, 1);

      cur++;
    }
    ans[j] = b.sum(r[j] + 1) - b.sum(l[j]);
  }

  REP(i, q) { cout << ans[i] << endl; }
}

Measured memory_bytes: 29192
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll long long
#define MOD 1000000007
#define pll             pair<ll,ll>
#define pii             pair<int,int> 
#define mp(a,b)         make_pair(a,b)
#define pb 				push_back
#define vi				vector<int>
#define vl 				vector<long long>
#define vb 				vector<bool>
#define printv(v)		for(auto x : v) cout<<x<<' ';br;
#define FOR(i,a,b) 		for(ll i = a; i <= b ; i++)
#define forn(i,n) 		for(ll i = 0 ; i < n; i++)
#define br 				cout<<endl;
#define testc()			ll t;cin>>t;while(t--)
 
#define fast 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define INF				INT_MAX
#define INFL			LLONG_MAX
#define max1(x,y) (x)>(y)?(x):(y)
#define ss second
#define ff first
#define MAXN 1000000001

struct item
{
    /* data */
    ll wt,val;
};

int main(){
    fast
    ll n,w;
    cin>>n>>w;
    ll total_val=0;
    vector<ll> wt(n),val(n);
    forn(i,n){
        cin>>wt[i]>>val[i];
        total_val+=val[i];
    }
    vector<ll> dp(total_val+1, INF);
    dp[0]=0;
    FOR(i,0,n-1){
        for(ll j=total_val;j>=val[i];j--){
            dp[j]=min(dp[j],dp[j-val[i]]+wt[i]);
        }
    }
    // forn(i,total_val+1)
    // cout<<i<<" "<<dp[i]<<endl;
    ll ans=0;
    forn(i,total_val+1){
        if(dp[i]<=w)
        ans=max(ans,i);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
def calc(b,A,N):
    sadness = 0
    for i in range(N):
        sadness += abs(A[i] - (b + i))
    return sadness

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

k = []
for i in range(N):
    k.append(A[i] - i)

k = sorted(k)

sadness = 0
if N % 2 == 1:
    sadness = calc(k[N//2],A,N)
else:
    sadness = min(calc(k[N//2],A,N),calc(k[(N//2)+1],A,N))

print(sadness)


Measured memory_bytes: 26020
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define double long double
int main(int argc,char *argv[])
{
    static int num[200000];
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&num[i]);
    int index=1;
    for(int i=0; i<n; i++)
    {
        if(num[i]==index)
            index++;
    }
    if(index==1)
        printf("-1");
    else
        printf("%d",n-index+1);
    return 0;
}


Measured memory_bytes: 896