akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	string s,t,u;
	cin >> s>> t>>u;
	s[0]=s[0]-'a'+'A';
	t[0]=t[0]-'a'+'A';
	u[0]=u[0]-'a'+'A';
	
	cout<<s[0]<<t[0]<<u[0]<<endl;
}

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

int main(){
    int N;
    cin >> N;
    bool flag = true;
    for(int i = 0;i<N;i++){
        int A;
        cin >> A;
        if (A%2 == 0){
            if (A % 3 && A % 5) flag = false;
        }
    }
    cout << (flag ? "APPROVED" : "DENIED") << endl;
}

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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;
const int N = 1e5 + 5;

ll dp[N][2];
vector <int> g[N];

void go(int u, int p) {
  for(auto v : g[u]) {
    if(v == p) continue;
    go(v, u);
    dp[u][0] = ((dp[u][0] % mod) * (dp[v][0] + dp[v][1]) % mod) % mod;
    dp[u][1] = (dp[u][1] * dp[v][0]) % mod;
  }
}

int main() {
  int n; cin >> n;
  for(int i = 0; i < N; i++) dp[i][0] = dp[i][1] = 1;
  for(int i = 1; i < n; i++) {
    int u, v; cin >> u >> v;
    g[u].push_back(v); g[v].push_back(u);
  }
  go(1, -1);
  cout << (dp[1][0] + dp[1][1]) % mod << '\n';
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  ll a, b;
  cin >> a >> b;
  int lim = 100000;
  int ans = -1;
  for (int i = 0; i <= lim; ++i) {
    int t1 = i * 0.08;
    int t2 = i * 0.1;
    // cout << t1 << " " << t2 << " " << i << endl;
    if (t1 == a && t2 == b) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}

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

#define pb push_back
#define ff first
#define ss second

const int MAXN = 505;

int n, m;
int a[MAXN][MAXN];
char c;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		a[i][0] = 1;
  		a[i][m - 1] = 2;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 1; j < m - 1; j++)
			a[i][j] = (i & 1) + 1;
    }
  
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			cin >> c;
			if(c == '#')
				a[i][j] = 3;
		}
  
	for (int i = 0; i < n; i++, cout << '\n')
		for (int j = 0; j < m; j++)
			cout << (a[i][j] & 1? '#': '.');
	
  	cout << '\n';
	
	for (int i = 0; i < n; i++, cout << '\n')
		for (int j = 0; j < m; j++)
			cout << (a[i][j] & 2? '#': '.');
	return 0;
}

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

using namespace std;

int n;

vector<int> edge[200000];
int color[200000];
int ans[200000];
int c[2];
int three[3];

void dfs(int p,int d){
    color[p] = d%2;
    for(int i = 0;i < edge[p].size();i++){
        if(color[edge[p][i]] == -1) dfs(edge[p][i],d+1);
    }
}

void solve(){
    int i,j;
    string str;
    cin >> n;
    int a,b;
    for(i = 0;i < n-1;i++){
        cin >> a >> b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    memset(color,-1,sizeof(color));
    dfs(0,0);
    for(i = 0;i < n;i++){
        c[color[i]]++;
        three[(i+1)%3] = three[(i+1)%3]+1;
    }
    if(c[0] > three[0] && c[1] > three[0]){
        for(i = 0;i < n;i++){
            if(color[i] == 0 && three[1] > 0){
                three[1]--;
                ans[i] = three[1]*3+1;
            }
            else if(color[i] == 1 && three[2] > 0){
                three[2]--;
                ans[i] = three[2]*3+2;
            }
            else{
                ans[i] = three[0]*3;
                three[0]--;
            }
        }
    }
    else{
        int mic = 0;
        if(c[1] < c[0]) mic = 1;
        for(i = 0;i < n;i++){
            if(color[i] == mic){
                ans[i] = three[0]*3;
                three[0]--;
            }
            else if(three[1] > 0){
                three[1]--;
                ans[i] = three[1]*3+1;
            }
            else if(three[2] > 0){
                three[2]--;
                ans[i] = three[2]*3+2;
            }
            else{
                ans[i] = three[0]*3;
                three[0]--;
            }
        }
    }
    for(i = 0;i < n;i++) printf("%d ",ans[i]);
    printf("\n");
}

int main(){
    solve();
}


Measured memory_bytes: 19200
#include "stdio.h"
int main(void){
int a;
int b;
int c;
int tmp;
scanf("%d %d %d",&a,&b,&c);
if(a>c){
tmp=a;
a=c;
c=tmp;
}
if(a>b){
tmp=a;
a=b;
b=tmp;
}else if(b>c){
tmp=b;
b=c;
c=tmp;
}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=200005;
const int MOD=1000000007;

int n,m,a,b,jc[N],ny[N];

int C(int n,int m)
{
	return (LL)jc[n]*ny[m]%MOD*ny[n-m]%MOD;
}

int main()
{
	scanf("%d%d%d%d",&n,&m,&a,&b);
	jc[0]=jc[1]=ny[0]=ny[1]=1;
	for (int i=2;i<=n+m;i++) jc[i]=(LL)jc[i-1]*i%MOD,ny[i]=(LL)(MOD-MOD/i)*ny[MOD%i]%MOD;
	for (int i=2;i<=n+m;i++) ny[i]=(LL)ny[i-1]*ny[i]%MOD;
	int ans=0;
	for (int i=1;i<=n-a;i++) (ans+=(LL)C(i+b-2,b-1)*C(n-i+m-b-1,n-i)%MOD)%=MOD;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

unsigned long long *cache;

unsigned long long fun(int n) {
	if (cache[n] == -1) {
		cache[n] = fun(n-1) + fun(n-2);
	}
	return cache[n];
}

int main() {
	int n;
	cin >> n;
	cache = new unsigned long long[n+2];
	cache[0] = cache[1] = 1;
	for (int i = 2;i<n+2;i++) {
		cache[i] = -1;
	}
	fun(n);
	cout << cache[n] << endl;
	return 0;

}


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

//Algae
int main(){
	int r,D,tmp_w;
	cin >> r >> D >> tmp_w;
	int new_w;
	for(int y = 1; y<=10; y++){
		new_w = r*tmp_w - D;
		tmp_w = new_w;
		cout << new_w << endl;
	}
	return 0; 
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 2e5 + 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, a[N], c[2];

int gcd(int a, int b) {
  while(b) {
    a %= b;
    swap(a, b);
  }
  return a;
}

void solve() { 
  cin >> n;
  for (int i = 1;i <= n;i++) {
    cin >> a[i];
  }
  for (int it = 0;;it++) {
    bool fail = 0;
    for (int i = 1;i <= n;i++) fail |= (a[i] > 1);
    if (!fail) {
      if (it & 1) cout << "First\n";
      else cout << "Second\n";
      return; 
    }
    c[0] = c[1] = 0;
    for (int i = 1;i <= n;i++) c[a[i] & 1]++;
    if (c[0] & 1) {
      if (it & 1) cout << "Second\n";
      else cout << "First\n";
      return;
    }
    if (c[1] > 1) {
      if (it & 1) cout << "First\n";
      else cout << "Second\n";
      return;
    }
    bool ok = 0;
    for (int i = 1;i <= n;i++) {
      if (a[i] & 1) {
        if (a[i] == 1) ok = 1;
        a[i]--;
        break;
      }
    }
    if (ok) {
      if (it & 1) cout << "First\n";
      else cout << "Second\n";
      return;
    }
    int g = 0;
    for (int i = 1;i <= n;i++) g = gcd(g, a[i]);
    for (int i = 1;i <= n;i++) a[i] /= g;
    continue;
    cout << "i = " << it << " g = " << g << endl;
    for (int i = 1;i <= n;i++) cout << a[i] << " ";
    cout << endl;
  } 
}

int main() {
  #ifdef wws
   freopen("in", "r", stdin);
   // freopen("in", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  int tt = 1; 
  while(tt--) solve();
  return 0;
}

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

void fail(){
    cout << -1 << endl;
    exit(0);
}

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        return true;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int size(int x){
        return sz[find(x)];
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> D(N);
    map<int, vector<int>> d2p;
    for(int i=0; i<N; i++){
        cin >> D[i];
        d2p[D[i]].push_back(i);
    }
    vector<pair<int, int>> edges[100000];
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].emplace_back(b, i);
        edges[b].emplace_back(a, i);
    }
    vector<int> ans(M), col(N, -1);

    UnionFind uf(N);
    bitset<100000> olds;
    bitset<2> exist;
    for(auto& ppp : d2p){
        int d = ppp.first;
        auto& v = ppp.second;
        for(int i : v){
            exist.reset();
            for(auto& p : edges[i]){
                int j = p.first;
                if(olds[j]) exist[col[j]] = 1;
            }
            col[i] = (exist[0] ? 1 : 0);
            for(auto& p : edges[i]){
                int j = p.first;
                if(olds[j]){
                    uf.unite(i, j);
                    ans[p.second] = (col[i] == col[j] ? 1e9 : d);
                }
            }
            olds[i] = 1;
        }
        
        for(int i : v){
            if(uf.size(i) == 1) fail();
        }
    }

    for(int i=0; i<N; i++) cout << (col[i] ? "W" : "B");
    cout << endl;
    for(int a : ans) cout << a << endl;
    return 0;
}


Measured memory_bytes: 22784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split();
            int iN = int.Parse(sS[0]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = (iN - (iN / 1000) * 1000);
            if (iOut > 0) { iOut = 1000 - iOut; }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 27364
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<list>
#include<queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define first fi
#define second se
const int MAX=100000;
const int inf=1e9;
vi G[MAX];
list<int> out;
bool V[MAX];
int indeg[MAX];
int v,e;

class DisjointSet
{
  public:
    vector<int> rank,p;
    DisjointSet(){}
    DisjointSet(int size)
    {
      rank.resize(size,0);
      p.resize(size,0);
      for(int i=0;i<size;i++)makeSet(i);
    }

    void makeSet(int x)
    {
      p[x]=x;
      rank[x]=0;
    }
    bool same(int x,int y)
    {
      return findSet(x)==findSet(y);
    }
    void unite(int x,int y)
    {
      link(findSet(x),findSet(y));
    }

    void link(int x,int y)
    {
      if(rank[x]>rank[y])
      {
        p[y]=x;
      }
      else
      {
        p[x]=y;
        if(rank[x]==rank[y])
        {
          rank[y]++;
        }
      }
    }

    int findSet(int x)
    {
      if(x!=p[x])
      {
        p[x]=findSet(p[x]);
      }
      return p[x];
    }
};

class Edge
{
  public:
  int source,target,cost;
  Edge(int source=0,int target=0,int cost=0):
  source(source),target(target),cost(cost){}
  bool operator < (const Edge &e ) const
  {
    return cost < e.cost;
  }
};

int kruskal(int N,vector<Edge> edges)
{
  int totalCost=0;
  sort(edges.begin(),edges.end());
  DisjointSet dset =DisjointSet(N+1);
  for (int i=0;i<N;i++) dset.makeSet(i);
  int source,target;
  for(int i=0;i<edges.size();i++)
  {
    Edge e=edges[i];
    if(!dset.same(e.source,e.target) )
    {
      totalCost+=e.cost;
      dset.unite(e.source,e.target);
    }
  }
  return totalCost;
}


int main(void)
{
  int N,M,cost;
  int source,target;
  cin >> N >> M;
  vector<Edge> edges;
  for(int i=0;i<M;i++)
  {
    cin >> source >> target >> cost;
    edges.push_back(Edge(source,target,cost));
  }
  cout << kruskal(N,edges) << endl;
  return 0;
}



Measured memory_bytes: 7764
//Fibonacci Number
#include<stdio.h>

#define HISTORY_MAX 45

int searchFibonacci(int);
int fn[HISTORY_MAX];


int main(){
	int n;


	//init
	for(n=0;n<HISTORY_MAX;n++){
		fn[n]=-1;
	}


	//input
	scanf("%d",&n);


	//output
	printf("%d\n",searchFibonacci(n));

	return 0;
}


int searchFibonacci(int n){

	switch (n) {
		case 0:
		case 1: return fn[n]=1;break;
		default:
			if(fn[n]!=-1){
				return fn[n];
			}
			else{
				fn[n]=searchFibonacci(n-2)+searchFibonacci(n-1);
				return fn[n];
			}
	}
}



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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}


int main() {
int N;
cin>>N;
vector<int> v(N);
int beginIndex = -1;
for(int i=0;i<N;i++) {
    cin>>v[i];
    if(v[i]==1) beginIndex = i;
}
if(beginIndex==-1) cout<<-1<<endl;
else {
    int curr = 2, l = 1;
    for(int i=beginIndex+1;i<N;i++) {
        if(v[i]==curr) {l++;curr++;}
    }
    cout<<N-l<<endl;
}
return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  string s;
  cin>>s;
  int n=s.size();
  rep(i,n-1){
    if(s[i]==s[i+1]){
      cout<<i+1<<" "<<i+2;
      return;
    }
  }
  rep(i,n-2){
    if(s[i]==s[i+2]){
      cout<<i+1<<" "<<i+3;
      return;
    }
  }
  cout<<-1<<" "<<-1;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    while(n>=2){
    	if(s=="hi"){
    		cout <<"Yes"<<endl;
    		return 0;
    	}
    	if(s.substr(0,2)=="hi"){
    		s=s.substr(2,n-2);
    		n-=2;
    	}else{
    		cout << "No" <<endl;
    		return 0;
    	}
    }
    cout << "No" <<endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
ll K,X;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>K>>X;
	REP(i,K*2-1){
		cout<<X-K+i+1<<endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		var h=new int[n];
		for(int i = 0;i<n;i++) {
			h[i]=a[i]-i;
		}
		var hs=new Dictionary<int,int>();
		long ans=0;
		for(int i = n-1;i>=0;i--) {
			int d=-(a[i]+i);
			if(hs.ContainsKey(d)){
				ans+=hs[d];
			}
			if(hs.ContainsKey(h[i])){hs[h[i]]++;}
			else{hs.Add(h[i],1);}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

const int INF = 1e9+7;
vector<int> l;
int N, A, B, C;
int rec(int i, int a, int b, int c) {
	if(i == N){
		if(!a || !b || !c) return INF;

		return abs(a-A) + abs(b-B) + abs(c-C);
	}
	int res = rec(i+1, a, b, c);

	chmin(res, rec(i+1, a + l[i], b, c) + (a ? 10: 0));
	chmin(res, rec(i+1, a, b + l[i], c) + (b ? 10: 0));
	chmin(res, rec(i+1, a, b, c + l[i]) + (c ? 10: 0));

	return res;
}

int main()
{
	cin >> N >> A >> B >> C;
	l.resize(N);
	rep(i, N)cin>>l[i];
	cout << rec(0,0,0,0) << endl;

}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    int n, m, d;
    cin >> n >> m >> d;
    
    cout << fixed;
    cout << setprecision(10);
    if (d == 0) {
        cout << (double) (m-1) / n << endl;
    } else {
        cout << (double) 2 * (n-d) / n / n * (m - 1) << endl;
    }
    
    return 0;
}


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

using namespace std;
using ll = int64_t;

int reverse_game(ll i, const vector<ll>& as, ll& n_min, ll& n_max) {
  i--;
  if (n_max < as[i])
    return -1;
  if (i == 0) {
    n_max += as[0] - 1;
    return 0;
  }
  auto d_min = (n_min - 1)/as[i - 1];
  n_max += as[i] - 1;
  auto d_max = n_max/as[i - 1];
  if (d_min==d_max)
    return -1;
  n_min = (d_min + 1)*as[i - 1];
  n_max = d_max*as[i - 1];
  return reverse_game(i, as, n_min, n_max);
}

int main() {
  ll k;
  cin >> k;
  if (k < 1 || pow(10, 5) < k) {
    cout << "-1";
    return 0;
  }
  vector<ll> a(k);
  for (auto & z : a) {
    cin >> z;
  }
  for (auto & z : a) {
    if (z < 2 || pow(10, 9) < z ) {
      cout << "-1";
      return 0;
    }
  }

  ll n_min=2, n_max=2;
  if(reverse_game(k, a, n_min, n_max) == 0) {
    cout << n_min << " " << n_max;
  } else {
    cout << "-1";
  }
  return 0;
}


Measured memory_bytes: 1024
from collections import deque
import heapq
INF = float('inf')

# n : 頂点の数 m : 辺の数 r : 始点
n, m, r = [int(x) for x in input().split()]
E = [tuple([int(x) for x in input().split()]) for _ in range(m)]

AL = [[] for _ in range(n)] # 隣接リスト
for i in range(m):
    AL[E[i][0]].append(tuple(E[i][1:]) )  # AL[head] = [(tail, cost), ..., (tail, cost)]

fixed = [False] * n # 重み確定したかどうか
nfixed = 0 # 確定した数
vertex_cost = [INF] * n  # 始点rから各頂点への重み

# 1. 始点に0を書き込む
vertex_cost[r] = 0
H = []  # (cost, vertex)のheap
heapq.heappush(H, (0, r))

i = 0
while(H): # Hが空になるまで
    i += 1
    # 2. 未確定の地点の中からもっとも小さい値を持つ地点を1つ選び、その値を確定させる
    u_cost, u = heapq.heappop(H)
    if fixed[u]: continue
    fixed[u] = True
    nfixed += 1

    # 3. 2で確定した地点から直接繋がっていて、かつ未確定な地点に対し、
    #    重みを計算し、書き込まれている値より小さければ更新する
    for v, edge_cost in AL[u]:
        if fixed[v]: continue
        newcost = vertex_cost[u] + edge_cost
        if newcost < vertex_cost[v]:
            vertex_cost[v] = newcost
            heapq.heappush(H, (newcost, v))

    # 4. 全ての地点が確定していれば終了。そうでなければ2に戻る
    if nfixed == n: break

for i in range(n):
    if vertex_cost[i] == INF:
        print("INF")
    else:
        print(vertex_cost[i])


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

long long int bord[502][502];
long long int ans[100000][4];

int main() {
  long long int h, w;
  cin >> h >> w;

  for (long long int k = 1; k < h+1; k++) {
    for (long long int l = 1; l < w+1; l++) {
      cin >> bord[k][l];
    }
  }

  long long int count = 0;
  for (long long int k = 1; k < h+1; k++) {
    for (long long int l = 1; l < w+1; l++) {
      if (bord[k][l] % 2 != 0) {
        if (l != w) {
          ans[count][0] = k;
          ans[count][1] = l;
          ans[count][2] = k;
          ans[count][3] = l+1;
          bord[k][l+1]++;
        count++;
        }
        else {
          if (k != h) {
            ans[count][0] = k;
            ans[count][1] = l;
            ans[count][2] = k+1;
            ans[count][3] = l;
            bord[k+1][l]++;
        count++;
          }
        }
      }
    }
  }

  cout << count << endl;
  for (long long int k = 0; k < count; k++) {
    for (long long int l = 0; l < 4; l++) { 
      cout << ans[k][l];
      if (l != 3) cout << ' ';
    }
    cout << endl;
  } 

}


Measured memory_bytes: 7168
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 200000LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
ll popCount (ll x) {
	ll ret = 0;
	while (x) {
		ret += (x & 1);
		x >>= 1;
	}
	return ret;
}

ll f (ll x, ll popCounts[]) {
	if (x == 0) {
		return 0;
	} else {
		return f((x % popCounts[x]), popCounts) + 1;
	}
}

ll modexp(ll x, ll n, ll mod){
    if(n==0){
        return 1;
    }else if(n&1){
        return ((x%mod)*(modexp((x%mod*x%mod),n/2,mod)%mod)%mod)%mod;
    }else{
        return modexp((x%mod*x%mod),n/2,mod)%mod;
    }
}

ll modInv(ll x, ll mod){
	return modexp(x,mod-2,mod)%mod;
}

void Flash(){
	ll n;
	cin>>n;
	string x;
	cin>>x;

	ll popCounts[MAX + 1];
	memset(popCounts, 0, sizeof(popCounts));
	for (ll i = 1; i <= MAX; i++) {
		popCounts[i] = popCount(i); 
	}

	ll preCompute[MAX + 1];
	memset(preCompute, 0, sizeof(preCompute));
	for (ll i = 1; i <= MAX; i++) {
		preCompute[i] = f (i, popCounts);
	}

	ll setBits = 0;
	for (auto it: x) {
		setBits += (it == '1');
	}
	
	ll setBitInverted = setBits - 1, unsetBitInverted = setBits + 1;
	ll preForUnsetBits = 0;
	for (ll i = 0; i < n; i++) {
		if (x[i] == '1') {
			preForUnsetBits = (preForUnsetBits + modexp (2, n - i - 1, unsetBitInverted)) % unsetBitInverted;
		}
	}

	ll preForSetBits = 0;
	if (setBitInverted) {
		for (ll i = 0; i < n; i++) {
			if (x[i] == '1') {
				preForSetBits = (preForSetBits + modexp (2, n - i - 1, setBitInverted)) % setBitInverted;
			}
		}
	}

	ll temp;
	for (ll i = 0; i < n; i++) {
		if (x[i] == '1') {
			if (setBitInverted) {
				temp = (preForSetBits - modexp (2, n - i - 1, setBitInverted) + setBitInverted) % setBitInverted;
				cout<<preCompute[temp] + 1<<"\n";	
			} else {
				cout<<"0\n";
			}
		} else {
			temp = (preForUnsetBits + modexp (2, n - i - 1, unsetBitInverted) + unsetBitInverted) % unsetBitInverted;
			cout<<preCompute[temp] + 1<<"\n";
		}
		//debugg(temp);
	}
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


Measured memory_bytes: 6904
#include <iostream>
#include<vector>


//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;


//std::ios::sync_with_stdio(false); cin.tie(NULL);

int main()
{
     long long int  n,sum=0;
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
  vector<long long int> v(n+1);
    for(long long int i=1; i<=n; i++){
        for(long long int j=i; j<=n; j+=i){
            v[j]++;
        }
    }
    for( long long int i=1;i<=n;++i)
    {
        sum+=i*v[i];
    }
    cout<<sum<<endl;
  return 0;
}



Measured memory_bytes: 81028
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		String N=sc.nextLine();
		if(N.contains("9")) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

		//System.out.println(d);

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int x,y;
  cin >> s >> x >> y;
  int n = count(s.begin(),s.end(),'T')+1;
  vector<int> F(n);
  for (int i = s.length()-1, j = n-1; i+1; j -= s[i--] == 'T') {
    F[j] += s[i] == 'F';
  }
  map<int,bool> X[(n-1)/2+1], Y[n/2+1];
  X[0][F[0]] = true;
  Y[0][0] = true;
  for (int i = 1; 2*i < n; i++) {
    for (auto p : X[i-1]) {
      X[i][p.first+F[2*i]] = p.second;
      X[i][p.first-F[2*i]] = p.second;
    }
  }
  for (int i = 0; 2*i+1 < n; i++) {
    for (auto p : Y[i]) {
      Y[i+1][p.first+F[2*i+1]] = p.second;
      Y[i+1][p.first-F[2*i+1]] = p.second;
    }
  }
  if (X[(n-1)/2][x] && Y[n/2][y]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 235592
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
			
			Scanner input = new Scanner(System.in);
			int N = input.nextInt();
			int[] A = new int[N];
			for(int i = 0; i<N; i++){
				A[i] = input.nextInt();
			}
			
			int[] ans = new int[N];
			ans[0] = 0;
			for(int i = 0; i<N; i++){
				ans[0] = (int)(ans[0]+A[i]*Math.pow(-1, i));
			}
			System.out.println(ans[0]);
			for(int i=1; i<N; i++){
				ans[i] = 2* A[i-1] - ans[i-1];
				System.out.println(" ");
				System.out.println(ans[i]);
			}
	}
}


Measured memory_bytes: 63212
n,m = map(int,input().split())
g = sorted([list(map(int,input().split())) for _ in range(m)])
def BellmanFord(edges,num_v,source):
  #グラフの初期化
  inf=float("inf")
  dist=[inf for i in range(num_v)]
  dist[source-1]=0
  
  #辺の緩和
  for i in range(num_v):
    for edge in edges:
      if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] - edge[2]:
        dist[edge[1]-1] = dist[edge[0]-1] - edge[2]
        if i==num_v-1 and edge[0] == num_v-1: 
          return -1
  return dist
if BellmanFord(g,n,1) == -1:
  print("inf")
else:
  print(-BellmanFord(g,n,1)[-1])
  

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

bool isPrime[100010];
bool islike2017[100010];
int cnt[100010];

int main(){
	fill(isPrime,isPrime+100010,true);
	isPrime[0]=isPrime[1]=false;
	for(int i=2;i<=100000;i++){
		if(isPrime[i]){
			for(int j=2;i*j<=100000;j++){
				isPrime[i*j]=false;
			}
		}
	}
	for(int i=3;i<100000;i+=2){
		if(isPrime[i] && isPrime[(i+1)/2])islike2017[i]=true;
	}
	int now=0;
	for(int i=1;i<100000;i+=2){
		if(islike2017[i])now++;
		cnt[i]=now;
	}
	int Q;
	cin>>Q;
	vector<int>L;
	vector<int>R;
	for(int i=0;i<Q;i++){
		int l,r;
		cin>>l>>r;
		L.push_back(l);
		R.push_back(r);
	}
	for(int i=0;i<Q;i++){
		cout<<cnt[R[i]]-cnt[max(1,L[i]-2)]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2164
#include <stdio.h>

int main( void ){
  int K, X, min, max;

  scanf("%d %d", &K, &X);

  K--;
  min = X - K;
  max = X + K;

  if(min < -1000000) min = -1000000;
  if(max > 1000000) max = 1000000;

  for(int i = min; i <= max; i++){
    printf("%d ", i);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        int n;
        int k;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            k = int.Parse(words[1]);
        }

        int[] h = new int[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                h[i] = int.Parse(words[i]);
            }
        }

        int[] answer = new int[n];
        for (int i = 0; i < n; i++)
        {
            answer[i] = int.MaxValue;
        }
        answer[0] = 0;

        for (int i = 1; i < n; i++)
        {
            for (int j = 1; j <= k; j++)
            {
                if (i - j < 0)
                {
                    continue;
                }
                answer[i] = Math.Min(answer[i], answer[i - j] + Math.Abs(h[i] - h[i - j]));
            }
        }

        Console.WriteLine(answer[n - 1]);
    }
}

Measured memory_bytes: 16864
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
   ll a, b, c, x, y;
   scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &x, &y);
   if(a > 2 * c && x > y){
      printf("%lld\n", 2*c*y + 2*c*(x-y));
   }else if(b > 2 * c && y > x){
      printf("%lld\n", 2*c*x + 2*c*(y-x));
   }else if(a + b > 2 * c){
      if(x > y) printf("%lld\n", 2*c*y + a*(x-y));
      else printf("%lld\n", 2*c*x + b*(y-x));
   }else{
      printf("%lld\n", a*x + b*y);
   }
}

Measured memory_bytes: 128
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,x = na()
a = na()
dp = [i for i in a]
ans = sum(dp)

for i in range(1,n):
    for j in range(n):
        dp[(j+i)%n] = min(dp[(j+i)%n], a[j])
    ans = min(ans, sum(dp)+x*i)

print(ans)

Measured memory_bytes: 42604
#include <bits/stdc++.h>
#define rep(i,s,e) for(int i = s; i < e; i++)
#define test(t) int t; cin >> t; while(t--) 
#define iterate(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef set<int> si;
typedef long long ll;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,h,w;
  cin >> n >> h >> w;
  int r = n - h + 1;
  int c = n - w + 1;
  if(r < 0 || c < 0) {
    cout << 0 << endl;
  } else {
    cout <<  (r*c) << endl;
  }
  return 0;
}


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

//---------------------------------------------------------------
// ワーシャル・フロイド
//---------------------------------------------------------------

int H, W;
int C[10][10];

signed main(){
	cin >> H >> W;
	REP(i, 0, 10)
		REP(j, 0, 10)
			cin >> C[i][j];

	// 最短経路を計算する
	REP(k, 0, 10)	REP(i, 0, 10)	REP(j, 0, 10)
		C[i][j] = min(C[i][j], C[i][k] + C[k][j]);

	int ans = 0;
	int wk;
	REP(i, 0, H) {
		REP(j, 0, W) {
			cin >> wk;
			if(wk != -1) 
				ans += C[wk][1];
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
'use strict'
// inputに入力データ全体が入る
function Main(input) {
    let v = input.trim().split('\n').map((v)=>parseInt(v));
    
    if( v[4]-v[0]>v[5] ){
        console.log(':(');
    }else{
        console.log('Yay!');
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int s;

void pro(int n, char c) {
	if (c == '+') s += n;
	else s -= n;
}

int main() {
	int num; cin >> num;
	vector<int> n(4);
	rem(i, 3, 0) {
		n[i] = num % 10;
		num /= 10;
	}

	vector<char> op = { '+','-' };
	rep(i, 0, 2) {
		rep(j, 0, 2) {
			rep(k, 0, 2) {
				s = n[0];
				pro(n[1], op[i]);
				pro(n[2], op[j]);
				pro(n[3], op[k]);
				if (s == 7) {
					cout << n[0] << op[i] << n[1] << op[j] << n[2] << op[k] << n[3] << "=7" << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  ll n,m,l;
  cin>>n>>m>>l;
  vector<vector<ll>> dist1 (n,vector<ll>(n,INF));
  vector<vector<ll>> dist2 (n,vector<ll>(n,INF));
  rep(i,m){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    chmin(dist1[a][b],c);
    chmin(dist1[b][a],c);
  }
  ll q;
  cin>>q;
  vector<pair<ll,ll>> query;
  rep(i,q){
    ll s,t;
    cin>>s>>t;
    s--;t--;
    query.emplace_back(s,t);
  }

  rep(k,n)rep(i,n)rep(j,n){
    chmin(dist1[i][j],dist1[i][k]+dist1[k][j]);
  }

  rep(i,n)rep(j,n){
    if(dist1[i][j]<=l)dist2[i][j]=1;
  }

  rep(k,n)rep(i,n)rep(j,n){
    chmin(dist2[i][j],dist2[i][k]+dist2[k][j]);
  }

  rep(i,q){
    ll s,t;tie(s,t)=query[i];
    if(dist2[s][t]==INF)cout<<(-1)<<endl;
    else cout<<to_string(dist2[s][t]-1)<<endl;
  }

}


Measured memory_bytes: 4852
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author SimplyDivine
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            long a[] = new long[n];
            long sum = 0;
            long pre[] = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
                if (i == 0) pre[i] = a[i];
                else
                    pre[i] = pre[i - 1] + a[i];
                sum += a[i];
            }
            //System.out.println(Arrays.toString(pre));
            long diff = Long.MAX_VALUE;
            for (int i = 0; i < n - 1; i++) {
                diff = Math.min(diff, Math.abs(2 * pre[i] - sum));

            }
            out.println(diff);

        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream i) {
            br = new BufferedReader(new
                    InputStreamReader(i));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 46136
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n;cin >> n;
	vector<int> v;
	REP(i,n)
	{
		int tmp;cin >> tmp;v.PB(tmp);
	}
	
	if(n <= 2)
	{
		cout << 1 << endl;
		return 0;
	}
	
	int now;
	int nxt = v[0];
	int dir = -1;
	int ans = 1;
	
	REP(i,n-1)
	{
		now = nxt;
		nxt = v[i+1];
		if(dir == -1)
		{
			if(now < nxt)dir = 1;
			else if(now > nxt)dir = 0;
		}
		else
		{
			if(dir == 1)
			{
				if(now > nxt)
				{
					//cout << now << ' ' << nxt << endl;
					dir = -1;
					ans++;
				}
			}
			else
			{
				if(now < nxt)
				{
					//cout << now << ' ' << nxt << endl;
					dir = -1;
					ans++;
				}
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 892
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int mod=998244353;
int n,q;
int power[200005];
int cumsum[200005];
int tree[1000005];
int lazy[1000005];
void propogate(int i,int l,int r)
{
    int a=0;
    if(l-2>=0)
        a=(cumsum[r-1]-cumsum[l-2]+mod)%mod;
    else
        a=(cumsum[r-1])%mod;
    a=(a*lazy[i])%mod;
    tree[i]=a;
    if(l!=r)
        lazy[i*2]=lazy[i],lazy[i*2+1]=lazy[i];
    lazy[i]=0;
}
void build(int i,int l,int r)
{
    if(l==r)
    {
        tree[i]=power[l-1];
        return;
    }
    int mid=(l+r)/2;
    build(i*2,l,mid);
    build(i*2+1,mid+1,r);
    tree[i]=(tree[i*2]+tree[i*2+1])%mod;
}
void update(int i,int l,int r,int l1,int r1,int val)
{
    if(lazy[i])
        propogate(i,l,r);
    if(l1>r1 || l>r1 || l1>r)
        return;
    if(l1<=l && r<=r1)
    {
        int a=0;
        if(l-2>=0)
            a=(cumsum[r-1]-cumsum[l-2]+mod)%mod;
        else
            a=cumsum[r-1]%mod;
        a=(a*val)%mod;
        tree[i]=a;
        if(l!=r)
            lazy[i*2]=val,lazy[i*2+1]=val;
        return;
    }
    int mid=(l+r)/2;
    update(i*2,l,mid,l1,r1,val);
    update(i*2+1,mid+1,r,l1,r1,val);
    tree[i]=(tree[i*2]+tree[i*2+1])%mod;
}
int query(int i,int l,int r,int l1,int r1)
{
    if(l1>r1 || l>r1 || l1>r)
        return 0;
    if(lazy[i])
        propogate(i,l,r);
    if(l1<=l && r<=r1)
        return tree[i];
    int mid=(l+r)/2;
    return (query(i*2,l,mid,l1,r1)+query(i*2+1,mid+1,r,l1,r1))%mod;
}
int32_t main()
{
    IOS;
    power[0]=1;
    cumsum[0]=1;
    for(int i=1;i<=200003;i++)
    {
        power[i]=(10*power[i-1])%mod;
        cumsum[i]=(power[i]+cumsum[i-1])%mod;
    }
    cin>>n>>q;
    build(1,1,n);
    while(q--)
    {
        int l,r,d;
        cin>>l>>r>>d;
        l=n-l+1;
        r=n-r+1;
        update(1,1,n,r,l,d);
        cout<<query(1,1,n,1,n)<<endl;
    }
}

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

public class Main {


    private void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        if (n < 1200){
            out.println("ABC");
        }else if (n < 2800){
            out.println("ARC");
        }else {
            out.println("AGC");
        }
    }


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

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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


        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    }

}


Measured memory_bytes: 22356
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

l = [a, b, c, d, e]
d = list()

for i, x in enumerate(l[:-1]):
    l2 = l[i+1:]
    for y in l2:
        d.append(y-x)

if max(d) <= k:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    string S, T; cin >> S >> T;
    if (S == T) {
        cout << "Yes" << endl;
        return 0;
    };
    REP(i, S.size()) {
        rep(j, S.size()-1)swap(S.at(j),S.at(j+1));
        if (S == T) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3608