akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

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

int a[200005];
int b[200005];

int main() {
    int n; cin >> n;
    for (int i = 1; i<= n; ++i) cin >> a[i];

    for (int i = n; i > 0; --i) {
        int other = 0;
        for (int x = i * 2; x <= n; x += i) if (b[x]) other++;
        if (other % 2 != a[i]) b[i] = 1;
    }

    vector<int> ans;
    for (int i = 1; i <= n; ++i) if (b[i]) ans.push_back(i);

    int m = ans.size();
    cout << m << endl;

    rep(i, m) {
        if (i) cout << " ";
        cout << ans[i];
    }
    cout << endl; 
}

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

using namespace std;

struct Item {
  int w;
  int v;
};

int main() {
  int N, W;
  cin >> N >> W;
  
  vector<Item> items(N);
  
  for (int i = 0; i < N; i++) {
    int v, w;
    cin >> v >> w;
    Item item = { v, w };
    items.at(i) = item;
  }
  
  vector<vector<unsigned long long>> memo(N, vector<unsigned long long>(W + 1, 0));
  
  for (int i = 0; i < N; i++) {
    for (int w = 1; w <= W; w++) {
      // 1行目を初期化
      if (i == 0) {
        if (w < items.at(i).w) {
          memo.at(i).at(w) = 0;
        } else {
          memo.at(i).at(w) = items.at(i).v;
        }
        continue;
      }
      // 2行目以降
      Item item = items.at(i);
      if (w < item.w) {
        // アイテムが入らなければ1行上と同じ
        memo.at(i).at(w) = memo.at(i - 1).at(w);
      } else {
        memo.at(i).at(w) = max(
          memo.at(i - 1).at(w),
          memo.at(i - 1).at(w - item.w) + item.v
        );
      }      
    }
  }
    
  cout << memo.at(N - 1).at(W) << endl;
}

Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int h,w,n;
  cin>>h>>w>>n;
  vin a(n+1);
  rep(i,0,n) cin>>a[i+1];
  //////
  vector<deque<int>> dq(h);
  int g=1;
  rep(i,0,h){
    
    int cnt=0;
   bool ful=false;
    while(!ful &&a[g]>0){
     // cout<<i<<" "<<g<<" "<<a[g]<<endl;
      if(i%2==0){//usirokara
        dq[i].push_back(g);
        
        a[g]--;
      }
      else{//maekara
        dq[i].push_front(g);
        
        a[g]--;
        
        
      }
       cnt++;
      if(cnt==w) ful=true;
      if(a[g]==0) g++;
    }//while
    
  }
  rep(i,0,h) {
    while(dq[i].size()>0){
     cout<<dq[i].front()<<" ";
      dq[i].pop_front();
    }
    cout<<endl;
  }
}

Measured memory_bytes: 384
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

string s;

int main(){
  cin >> s;
  string last = "";
  last += s[0];
  int ans = 1;
  for(int i = 1; i < sz(s);){
    if(sz(last) == 1){
      if(s[i] != last[0]){
        last[0] = s[i];
        ++ans;
        ++i;
      } else{
        if(i == sz(s) - 1){
          ++i;
        } else{
          ++ans;
          last = s.substr(i, 2);
          i += 2;
        }
      }
    } else{
      last = s.substr(i, 1);
      ans++, ++i;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll h;
    cin>>h;
    ll tmp=0;
    ll res=0;
    while(1){
        if(h<=1){
            break;
        }
        tmp++;
        res += pow(2,tmp);
        h=floor(h/2);
    }
    cout<<res+1<<endl;
    return 0;
}

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

int main() {
  long long int w, h, x, y;
  cin >> w >> h >> x >> y;
  if ((w*h)%2==0) {
    printf("%lld", w*h/2);
  }
  else {
    printf("%lld", w*h/2);
    cout << ".5";
  }
  if (x*2==w&&y*2==h) {
    cout << " 1" <<endl;
  }
  else {
    cout << " 0" <<endl;
  }
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define MOD 1000000007


int main(){
    int s;
    cin>>s;
    vector<ll> dp(s+1,0);
    dp[0]=1;
    for(int i=1;i<=s;i++){
        for(int j=0;j<=i-3;j++){ 
            dp[i]+=dp[j];
            dp[i]%=MOD;
        }
    }
    cout<<dp[s]<<endl;
    return 0;
}

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

int main() {
  int A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R;
  cin >> N;
  
    A = N / 100000000; // 1
    B = N % 100000000;
    C = B / 10000000;// 2
    D = B % 10000000;
    E = D / 1000000; // 3
    F = D % 1000000;
    G = F / 100000;  //4
    H = F % 100000;
    I = H / 10000; //5
    J = H % 10000;
    K = J / 1000; //6
    L = J % 1000;
    M = L / 100; // 7
    O = L % 100;
    P = O / 10; //8
    Q = O % 10; //9
     
    R = A + C + E + G + I + K + M + P + Q;
    
    if (N%R == 0) {
      cout << "Yes" << endl;
    }
    else if (N%R !=0) {
      cout << "No" << endl;
    }
}
     

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
vector<ll> v;

struct C
{
    ll x, y, h;
};
int cnt = 0;
int N;

int h[110];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> h[i + 1];
    }
    int ans = 0;

    for (int i = 0; i < N; ++i)
    {
        ans += max(0, h[i + 1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	char c;
	cin >> c;
	if ('A' <= c && c <= 'Z') cout << "A\n";
	else cout << "a\n";
}

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

Measured memory_bytes: 1816
import java.util.*;

class Main {
	
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		for(;;){
			int n = in.nextInt();
			if(n == 0) return ;
			int mat[][] = new int[n][n];
			int up[][]  = new int[n][n];
			for(int i=0; i<n; i++)
				for(int j=0; j<n; j++)
					mat[i][j] = in.nextInt();
			for(int i=0; i<n; i++){
				Vector<Integer> pos = new Vector<Integer>();
				int mi = 1<<30;
				for(int j=0; j<n; j++){
					if(mat[i][j] == mi){
						pos.add(j);
					}
					else if(mat[i][j] < mi){
						mi = mat[i][j];
						pos.clear();
						pos.add(j);
					}
				}
				Enumeration<Integer> e = pos.elements();
				while(e.hasMoreElements()){
					up[i][e.nextElement().intValue()] += 1;
				}
			}
			for(int j=0; j<n; j++){
				Vector<Integer> pos = new Vector<Integer>();
				int ma = -(1<<30);
				for(int i=0; i<n; i++){
					if(mat[i][j] == ma){
						pos.add(new Integer(i));
					}
					else if(mat[i][j] > ma){
						ma = mat[i][j];
						pos.clear();
						pos.add(new Integer(i));
					}
				}
				Enumeration<Integer> e = pos.elements();
				while(e.hasMoreElements()){
					up[e.nextElement().intValue()][j] += 2;
				}
			}
			int i=0, j=0;
			boolean f=true;
			for(i=0; i<n; i++){
				for(j=0; j<n; j++){
					if(up[i][j] == 3){
						f = false;
						break;
					}
				}
				if(!f) break;
			}
			System.out.println(((i==n) && (j==n))?0:mat[i][j]);
		}
	}
}

Measured memory_bytes: 12000
from itertools import accumulate


def solve(string):
    n, *a = map(int, string.split())
    *a, = accumulate(a)
    l, r, e, ans = 0, 2, a[-1], a[-1]
    for c in a[1:-2]:
        while a[l] + a[l + 1] < c:
            l += 1
        while a[r] + a[r + 1] < c + e:
            r += 1
        t = sorted([a[l], c - a[l], a[r] - c, e - a[r]])
        ans = min(ans, t[-1] - t[0])
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


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

const int NN=1e5+10;
char a[1010][1010];
int vis[1010][1010];
int visc[1010];
int h,w;
struct Node{
    int i,j;
};
queue<Node> que;

int main()
{
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++){
        scanf("%s",&a[i]);
    }
    int step=0;
    memset(vis,0,sizeof(vis));
    memset(visc,-1,sizeof(visc));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#'){
                Node node;
                node.i=i;
                node.j=j;
                que.push(node);
            }
        }
    }
    while(!que.empty())
    {
        Node node=que.front();
        int c=node.i;
        int l=node.j;
        if(vis[c][l]==step) step++;
        if(vis[c][l]==step-1){
            if(c-1>=0&&a[c-1][l]=='.'){
                a[c-1][l]='#';
                vis[c-1][l]=step;
                Node temp;
                temp.i=c-1;
                temp.j=l;
                que.push(temp);
            }
            if(c+1<h&&a[c+1][l]=='.'){
                a[c+1][l]='#';
                vis[c+1][l]=step;
                Node temp;
                temp.i=c+1;
                temp.j=l;
                que.push(temp);
            }
            if(l-1>=0&&a[c][l-1]=='.'){
                a[c][l-1]='#';
                vis[c][l-1]=step;
                Node temp;
                temp.i=c;
                temp.j=l-1;
                que.push(temp);
            }
            if(l+1<w&&a[c][l+1]=='.'){
                a[c][l+1]='#';
                vis[c][l+1]=step;
                Node temp;
                temp.i=c;
                temp.j=l+1;
                que.push(temp);
            }
        }
        que.pop();
    }
    printf("%d\n",step-1);
}



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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  set<int> st;
  st.insert(a);
  st.insert(b);
  st.insert(c);
  if(st.size()==2){
    cout << "Yes" << "\n";
  }else{
    cout << "No" << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
//---------------------------------------------
 

int main(void)
{

int n,m;

cin>>n>>m;

//n gu m ki

int ans =0;
// gu gu
ans+= n*(n-1)/2;

//kiki
ans +=m*(m-1)/2;

cout<<ans<<endl;





}

Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int n;
vector<int> adj[N];

int cache[N][2];

int dfs(int v, int par, int color){
    int &ans=cache[v][color];
    if(ans!=-1) return ans;
    ans=1;
    for(auto u: adj[v]){
        if(u==par) continue;
        if(!color){
            ans*=(dfs(u,v,color)+dfs(u,v,color^1));
            ans%=mod;
        }
        else{
            ans*=dfs(u,v,color^1);
            ans%=mod;
        }
    }
    return ans;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    rep(i,1,n){
        int x,y;
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    mst(cache,-1);
    int ans=(dfs(1,0,0)+dfs(1,0,1))%mod;
    cout << ans;
    return 0;
}

Measured memory_bytes: 14208
class Canbus
  def initialize
    @arr = Array.new(14){Array.new(14,0)}
  end
  
  def small(x, y)
    for i in 1..3
      @arr[x + 2][y + i] += 1
    end
    @arr[x + 1][y + 2] += 1
    @arr[x + 3][y + 2] += 1
  end
  
  def midium(x, y)
    for i in 1..3
      for j in 1..3
        @arr[x + i][y + j] += 1
      end
    end
  end
  
  def big(x, y)
    midium(x, y)
    @arr[x][y + 2] += 1
    @arr[x + 2][y] += 1
    @arr[x + 2][y + 4] += 1
    @arr[x + 4][y + 2] += 1
  end
  
  def count
    return @arr[2..11].inject(0){|sum,i|sum + i[2..11].select{|j|j == 0}.size}, @arr[2..12].inject(0){|max,i|max > i[2..12].inject(0){|max,j|max > j ? max: j} ? max: i[2..12].inject(0){|max,j|max > j ? max: j}}
  end
end
Comand = [:small, :midium, :big]
can = Canbus.new
while arg = gets
  arg = arg.split(",").map(&:to_i)
  can.send(Comand[arg[2] - 1],*arg[0..1])
end
puts can.count

Measured memory_bytes: 6128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{
    int n,m;
    int f[21][21];
    char news;
    int d;
    int x,y;
    int flag;
    while(cin>>n&&n)
    {
        for(int i=0;i<21;++i)
        {
            for(int j=0;j<21;++j)
            {
                f[i][j] = 0;
            }
        }
        for(int i=0;i<n;++i)
        {
            cin >> x >> y;
            f[x][y] =1;
        }
        x=10,y=10;
        f[x][y] = 0;
        cin >> m;
        for(int i=0;i<m;++i)
        {
            cin >> news >> d;
            if(news=='N') for(int j=1;j<=d;++j) f[x][++y] = 0;
            if(news=='E') for(int j=1;j<=d;++j) f[++x][y] = 0;
            if(news=='W') for(int j=1;j<=d;++j) f[--x][y] = 0;
            if(news=='S') for(int j=1;j<=d;++j) f[x][--y] = 0;
        }
        flag=0;
        for(int i=0;i<21;++i)
        {
            for(int j=0;j<21;++j)
            {
                if(f[i][j])
                {
                    flag=1;
                    break;
                }
            }
            if(flag) break;
        }
        if(flag) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a + b >= 10)
        cout << "error"
             << "\n";
    else
        cout << a + b << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a;
  string str;
  cin>>str;
  char curr=str[0];
  int ans=1;
  for(int i=1;i<a;i++)
  {
     if(str[i]==curr)
       continue;
     else
     {
       curr=str[i];
       ans++;
     }
  }
  cout<<ans<<"\n";
}


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

using namespace std;

int main(void)
{
    long long int X, K, D, ans;
    cin >> X >> K >> D;
    
    X = abs(X);
    if(K > X / D){
        ans = ((K - X / D) % 2 == 0) ? X % D : X % D - D;
    }
    else{
        ans = X - D * K;
    }
    cout << abs(ans) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string s; cin>>s;
    bool N=false,W=false,E=false,S=false;
    rep(i,s.size()){
        if(s[i]=='W')W=true;
        if(s[i]=='S')S=true;
        if(s[i]=='E')E=true;
        if(s[i]=='N')N=true;
    }
    if((W==true&&E==true)&&(N==true&&S==true))return puts("Yes")*0;
    else if((W==true&&E==true)&&(N==false && S==false))return puts("Yes")*0;
    else if((N==true&&S==true)&&(W==true&&E==true))return puts("Yes")*0;
    else if((N==true&&S==true)&&(W==false && E==false))return puts("Yes")*0;
    
    puts("No");
    return 0;
}

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

int main()
{
ll n , m ;
cin >> n >> m ;
vector<vector<ll>> g(n);
rep(i, m)
{
  ll a, b;
  cin >> a >> b;
  g[a - 1].push_back(b - 1);
}
vector<double> dp(n);
for (ll i = n-2; i >= 0; i--)
{
  for(auto r:g[i]){
    dp[i]+=(dp[r]+1)/g[i].size();
  }
}
ans=dp[0];
rep(i,n-1){
  ll to;
  double e=0;
  if(g[i].size()==1)continue;
  for(auto r:g[i]){
    if(dp[r]>e){
      e=dp[r];
      to=r;
    }
  }
  vector<double> dpp(n);
  for (ll j = n-2; j >= 0; j--)
  {
    if(i==j)for(auto r:g[j]){
      if(to==r)continue;
      dpp[j]+=(dpp[r]+1)/(g[j].size()-1);
    }
    else for(auto r:g[j]){
      dpp[j]+=(dpp[r]+1)/g[j].size();
    }
  }
  ans=min(ans,dpp[0]);
}
cout<<fixed<<setprecision(12)<<ans<<endl;
return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n;
   cin>>n;
   int ans=0;
   ans+=(n/500)*1000;
   n%=500;
   ans+=(n/5)*5;
   cout<<ans;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 256
// Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int t[5];
		cin >> t[0];

		if(t[0]==0)
			break;

		for(int i=1; i<5; i++){
			cin >> t[i];
		}

		int cnt[4] = {0};

		for(int i=0; i<5; i++){
			cnt[t[i]]++;
		}

		int r[5];
		if((cnt[2]==0&&cnt[3]==0)
		 ||(cnt[3]==0&&cnt[1]==0)
		 ||(cnt[1]==0&&cnt[2]==0)
		 ||(cnt[1]!=0&&cnt[2]!=0&&cnt[3]!=0)){
			for(int i=0; i<5; i++){
				r[i] = 3;
			}
		}
		else if(cnt[3]==0){
			for(int i=0; i<5; i++){
				if(t[i]==1){
					r[i] = 1;
				}
				else{
					r[i] = 2;
				}
			}
		}
		else if(cnt[1]==0){
			for(int i=0; i<5; i++){
				if(t[i]==2){
					r[i] = 1;
				}
				else{
					r[i] = 2;
				}
			}
		}
		else if(cnt[2]==0){
			for(int i=0; i<5; i++){
				if(t[i]==3){
					r[i] = 1;
				}
				else{
					r[i] = 2;
				}
			}
		}

		for(int i=0; i<5; i++){
			cout << r[i] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;



int main() {
	while (true) {
		int N,M;cin>>N>>M;
		if(!N)break;
		map<string,int>stmp;
		string S,P,G;cin>>S>>P>>G;
		stmp[S]=0;
		stmp[P]=1;
		stmp[G]=2;
		int id=3;
		vector<vector<pair<int,int>>>edges(N);
		for (int i = 0; i < M; ++i) {
			string s,t;cin>>s>>t;
			int d,c;cin>>d>>c;
			int cost=d/40+c;
			if (stmp.find(s) == stmp.end()) {
				stmp[s]=id++;
			}
			if (stmp.find(t) == stmp.end()) {
				stmp[t]=id++;
			}
			edges[stmp[s]].push_back(make_pair(stmp[t],cost));
			edges[stmp[t]].push_back(make_pair(stmp[s],cost));
		}
		vector<int>memo(N,1e9);
		memo[stmp[P]]=0;
		priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>que;
		que.push(make_pair(0,stmp[P]));
		while (!que.empty()) {
			auto atop(que.top());
			que.pop();
			int now=atop.second;
			int cost=atop.first;
			for (auto e : edges[now]) {
				const int nextcost=cost+e.second;
				const int next=e.first;
				if (memo[next] > nextcost) {
					memo[next]=nextcost;
					que.push(make_pair(memo[next],next));
				}
			}
		}
		int ans=memo[stmp[S]]+memo[stmp[G]];
		cout<<ans<<endl;

	}
	return 0;
}

Measured memory_bytes: 3340
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  int n, m;cin>>n>>m;
  int a;
  fr(i, m) cin>>a, n-=a;
  cout << (n<0? -1:n) << endl;

  return 0;
}

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

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

int n,cnt;
ll modpow(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main(){
    map<pair<ll,ll>,pair<int,int> >m;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        ll a,b;
        cin>>a>>b;
        if(!a&&!b){
            cnt++;
            continue;
        }
        ll g=__gcd(a,b);
        a/=g,b/=g;
        if(b<0) a=-a,b=-b;
        if(a<=0) m[{b,-a}].second++;
        else m[{a,b}].first++;    
    }
    ll ans=1;
    for(auto u:m){
        ans=(ans*(mod+modpow(2,u.second.first)+modpow(2,u.second.second)-1)%mod)%mod;
    }
    cout<<(mod+ans+cnt-1)%mod;
    return 0;
}  

Measured memory_bytes: 16172
// 単一始点最短経路 ( ダイクストラ法 : 優先度付きキュー )
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

static const int MAX_N = 10000;
static const int INFTY = (1 <<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

class q_element
{
    public:
        // 各頂点のNo.と経路の値
        int vertex_num;
        int vertex_val;

        // コンストラクタ
        q_element(int a, int b)
        {
            vertex_num = a;
            vertex_val = b;
        };
};

// ">" のオーバーロード [ receive_val ] を基準に大小比較を行う
bool operator> (const q_element &q_element_1, const q_element &q_element_2)
{
    return q_element_1.vertex_val > q_element_2.vertex_val;
};

// q_elementクラスのオブジェクトを昇順にするためのキューの定義
std::priority_queue< q_element,
                     std::vector<q_element>,
                     std::greater<q_element> > pqEle;

// 隣接リストを作成する ( 頂点と重みの情報を格納する )
vector<q_element> v_Link[MAX_N + 1];

int n;

// ダイクストラ法を実施するメソッド( 優先度付きキュー )
int Dijkstra_priority_queue();

int main(void)
{

    cin >> n;

    int k, c, u, v;
    q_element q_entity(0, 0);

    for(int i = 0; i < n; i++)
    {
        cin >> u >> k;

        for(int j = 0; j < k; j++)
        {
            cin >> v >> c;

            // 隣接リストの作成
            q_entity.vertex_num = v;
            q_entity.vertex_val = c;

            v_Link[u].push_back(q_entity);
        }
    }

    // 優先度付きキューを用いたダイクストラ法
    Dijkstra_priority_queue();

    return 0;

}

// 優先度付きキューを用いたダイクストラ法を実施するメソッド
int Dijkstra_priority_queue()
{
    int u, v, minv;
    int d[MAX_N], p[MAX_N], color[MAX_N];

    for(int i = 0; i < n; i++)
    {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    // 初期値の設定
    d[0] = 0;
    color[0] = GRAY;
    // キューに要素を入れる
    pqEle.push( q_element(0, 0) );

    while( !pqEle.empty() )
    {
        //minv = INFTY;
        // 次に移動するべき頂点
        //u = -1;

        // 最小の値を持つ要素を取り出す ( キューの先頭 )
        u = pqEle.top().vertex_num;
        minv = pqEle.top().vertex_val;
        pqEle.pop();

        // 訪問完了
        color[u] = BLACK;

        for(int v_num = 0; v_num < v_Link[u].size(); v_num++)
        {
            // 隣接リストから要素を取得する
            v = v_Link[u][v_num].vertex_num;

            if( color[v] != BLACK )
            {
                // u → v の経路の中で, vのコストが最小のものが見つかれば更新する
                if( d[v] > d[u] + v_Link[u][v_num].vertex_val )
                {
                    // コストの記録
                    d[v] = d[u] + v_Link[u][v_num].vertex_val;
                    // 頂点 v の親を記録する
                    p[v] = u;
                    // 訪問状態の記録
                    color[v] = GRAY;

                    // キューに要素を入れる
                    pqEle.push( q_element(v, d[v]) );
                }
            }
        }
    }

    // 結果の表示
    for(int i = 0; i < n; i++)
    {
        cout << i << " " << ( d[i] == INFTY ? -1 : d[i] ) << endl;
    }

    return 0;
}



Measured memory_bytes: 7724
x,y,z,k=map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

d = []#a+bを格納
for i in range(x):
    for j in range(y):
        p = a[i] + b[j]
        d.append(p)
d.sort()

#print(d)

e = [] #dの上位k個を入れる
for i in range(min(k,len(d))):
    p = d.pop()
    e.append(p)
e.sort()
m = len(e)
#print(e)

ans = []#e+cを格納
for i in range(m):
    for j in range(z):
        p = e[i] + c[j]
        ans.append(p)
ans.sort()
for i in range(k):
    print(ans[-1-i])

Measured memory_bytes: 139328
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
seat = [a1, a2, a3]
n = int(input())
b = [int(input()) for i in range(n)]

seat_tf = [[False, False, False] for _ in range(3)]

for k in b:
    for i in range(3):
        for j in range(3):
            if seat[i][j] == k:
                seat_tf[i][j] = True

for i in range(3):
    if seat_tf[i][0] and seat_tf[i][1] and seat_tf[i][2]:
        print("Yes")
        exit()

for j in range(3):
    if seat_tf[0][j] and seat_tf[1][j] and seat_tf[2][j]:
        print("Yes")
        exit()

if (seat_tf[0][0] and seat_tf[1][1] and seat_tf[2][2]) or (seat_tf[0][2] and seat_tf[1][1] and seat_tf[2][0]):
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

long long a[50];
int main(){
    int N;
    cin >> N;

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

    int max_a = INT_MIN;
    int min_a = INT_MAX;
    int max_a_ind = -1;
    int min_a_ind = -1;
    for(int i = 0; i < N; i++){
        if(max_a < a[i]){
            max_a = a[i];
            max_a_ind = i;
        }
        if(min_a > a[i]){
            min_a = a[i];
            min_a_ind = i;
        }
    }

    if(min_a >= 0){
        cout << N - 1 << endl;
        for(int i = 0; i < N - 1; i++){
            cout << i + 1 << " " << i + 2 << endl;
        }
    } else if(max_a <= 0){
        cout << N - 1 << endl;
        for(int i = N - 1; i > 0; i--){
            cout << i + 1 << " " << i  << endl; 
        }
    } else if(abs(max_a) > abs(min_a)){
        cout << 2 * (N - 1) << endl;
        for(int i = 0; i < N; i++){
            if(i != max_a_ind){
                cout << max_a_ind + 1 << " " << i + 1 << endl;
            }
        }
        for(int i = 0; i < N - 1; i++){
            cout << i + 1 << " " << i + 2 << endl;
        }
    } else {
        cout << 2 * (N - 1) << endl;
        for(int i = 0; i < N; i++){
            if(i != min_a_ind){
                cout << min_a_ind + 1 << " " << i + 1 << endl;
            }
        }
        for(int i = N - 1; i > 0; i--){
            cout << i + 1 << " " << i << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<set>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<stack>
#include<tuple>
#include<utility>
#define mod 1000000007;
typedef long long ll;
#define rep(i,n) for(ll i=0; i<n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  pair< pair<string,int>,int> pr[n];
  rep(i,n){
    string s;  int p;
    cin >> s >> p;
    pr[i] = make_pair(make_pair(s,-p),i);
  }
  sort(pr, pr+n);
  rep(i,n){
    cout << pr[i].second+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<pll>> sect(n);
    for (int i = 1; i < n; ++i) {
        if (s.substr(i - 1, 3) == "101") {
            int l = i - 1, r = i + 1;
            while (l >= 0 && s[l] == '1') {
                sect[i + 1].emplace_back(l, i - l);
                --l;
            }
            while (r <= n - 1 && s[r] == '1') {
                sect[r].emplace_back(i - 1, r - i);
                ++r;
            }
        }
    }
    vl dp(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        chmax(dp[i], dp[i - 1]);
        for (auto &p : sect[i - 1]) {
            chmax(dp[i], dp[p.first] + p.second);
        }
    }
    cout << dp[n] << "\n";
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    char str[n+5];
    getchar();
    scanf("%s",str);
    int sum1, sum2, max1 = 1, max2 = 1, xam = -10, sum = -1;
    for(int i = 1; i < n; i++)
    {
        sum1 = 0;
        int ar[26] = {0};
        int br[26] = {0};
        for(int j = 0; j < i; j++)
        {
            if(ar[str[j]-'a']==0){
                sum1++;
                ar[str[j]-'a'] = 1;
            }
        }
        sum2 = 0;
        for(int j = i; j < n; j++)
        {
            if(br[str[j]-'a']==0){
                sum2++;
                br[str[j]-'a'] = 1;
            }
        }
        sum = sum1 + sum2;
        if(xam<=sum)
        {
            max1=0;
            for(int j = 0; j < 26; j++)
                if(ar[j]==1&&br[j]==1)
                    max1++;
            xam = sum;
        }
    }
    cout<<max1<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

N = int(input())
S = input()

def isOk(leng):
    hashList = set()
    que = deque([])
    for left in range(N - leng + 1):
        hs = hash(S[left: left + leng])
        if hs in hashList:
            return True
        que.append(hs)
        if len(que) >= leng:
            hashList.add(que.popleft())
    return False

ok = 0
ng = N

while ng - ok > 1:
    mid = (ng + ok) // 2
    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(ok)

Measured memory_bytes: 3720
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

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

if __name__ == '__main__':
    s = input()
    s = s.replace("hi","")

    if s =="":
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3828
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin>>N;
  vector<int> A(N),B(N+1,0);
  ll i;
  for (i=0;i<N;i++) {
    cin>>A[i];
    if (i+1+A[i]<=N) {
      B[i+1+A[i]]++;
    }
  }
  ll ans=0;
  for (i=0;i<N;i++) {
    if (i+1>=A[i]) {
      ans += B[i+1-A[i]];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4444
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
  string s ,t;
  cin >> s >> t;
  cout << t+s << endl;
  return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())

b=[]
for i in range(N):
    a=list(map(int,input().split()))
    a=a[1:]
    for j in a:
        b.append(j)

count=0
for k in range(1,M+1):
    if b.count(k) == N:
        count +=1
        
print(count)        

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int funcPow(int a, int b){
  int k = 1;
  for(int i = 0; i < b; i++){
    k *= a;
  }
  return k;
}
int main(void){
  int n;
  cin >> n;

  int dp[n + 1];
  dp[0] = 0;
  int tmp;
  int _min = MOD;
  for(int i = 1; i <= n; i++){
    _min = MOD;
    int power = 1;
    while(i - power >= 0){
      tmp = 1 + dp[i - power];
      _min = min(_min, tmp);
      power *= 6;
    }
    power = 1;
    while(i - power >= 0){
      tmp = 1 + dp[i - power];
      _min = min(_min, tmp);
      power *= 9;
    }
    dp[i] = _min;
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 640
abcd = input()

a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])
for X in range(1, 3):
    for Y in range(1, 3):
        for Z in range(1, 3):
            if b * ((-1) ** X) + c * ((-1) ** Y) + d * ((-1) ** Z) == (7 - a):
                op1 = '-' if X == 1 else '+'
                op2 = '-' if Y == 1 else '+'
                op3 = '-' if Z == 1 else '+'
                print("{}{}{}{}{}{}{}=7".format(a, op1, b, op2, c, op3, d))
                exit(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){
  ll n,sum=0;
  cin>>n;
    for(ll i=1;i<=n;i++){
       for(ll j=1;j<=n;j++){
          for(ll k=1;k<=n;k++){
              sum+=gcd(i,gcd(j,k)); 
    }
    }
    }
    cout<<sum;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cmath>
 
using namespace std;
 
int main()
{
    int countNum[100010] = {0};
    int maxCount = 0;
 
    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        int a; cin >> a;
        countNum[a]++;
        if (a > 0) countNum[a - 1]++;
        if (a < 100000) countNum[a + 1]++;
 
        // if (a > 0 && a < 100000) {
        //     maxCount = max(max(maxCount, countNum[a]), max(countNum[a - 1], countNum[a + 1]));
        // } else if (a == 0) {
        //     maxCount = max(max(maxCount, countNum[a]), countNum[a + 1]);
        // } else if (a == 99999) {
        //     maxCount = max(max(maxCount, countNum[a]), countNum[a - 1]);
        // }
    }

    for (int i = 0; i <=100000; i++) {
        if (i != 0) {
            maxCount = max(max(maxCount, countNum[i]), max(countNum[i - 1], countNum[i + 1]));
        } else {
            maxCount = max(max(maxCount, countNum[i]), countNum[i + 1]);
        }
    }
    cout << maxCount << endl;
 
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin>>s>>t;
  int l = s.size();

  for(int i=0; i<l; i++){
    if(s[i]!=t[i]){
      cout<<"No\n";
      return 0;
    }
  }
  cout<<"Yes\n";
  return 0;
}

Measured memory_bytes: 3628
public class Main {
  public static void main(String...args) {
    java.util.Scanner in = new java.util.Scanner(System.in);
    int n = in.nextInt(), m = in.nextInt(), ans = 0;
    boolean[][] a = new boolean[n][n];
    for (int i = 0; i < m; i++) {
      int x = in.nextInt() - 1, y = in.nextInt() - 1;
      a[x][y] = a[y][x] = true;
    }
    Permutation perm = new Permutation(n);
    outer:
    for (int[] p : perm) {
      if (p[0] != 0) continue;
      for (int i = 1; i < n; i++) {
        if (!a[p[i - 1]][p[i]]) continue outer;
      }
      ans++;
    }
    System.out.println(ans);
  }
}
class Permutation implements java.util.Iterator<int[]>, Iterable<int[]> {
    private int[] next;

    public Permutation(int n) {
        next = java.util.stream.IntStream.range(0, n).toArray();
    }

    @Override
    public boolean hasNext() {
        return next != null;
    }

    @Override
    public int[] next() {
        int[] r = next.clone();
        next = nextPermutation(next);
        return r;
    }

    @Override
    public java.util.Iterator<int[]> iterator() {
        return this;
    }

    public static int[] nextPermutation(int[] a) {
        if (a == null || a.length < 2)
            return null;
        int p = 0;
        for (int i = a.length - 2; i >= 0; i--) {
            if (a[i] >= a[i + 1])
                continue;
            p = i;
            break;
        }
        int q = 0;
        for (int i = a.length - 1; i > p; i--) {
            if (a[i] <= a[p])
                continue;
            q = i;
            break;
        }
        if (p == 0 && q == 0)
            return null;
        int temp = a[p];
        a[p] = a[q];
        a[q] = temp;
        int l = p, r = a.length;
        while (++l < --r) {
            temp = a[l];
            a[l] = a[r];
            a[r] = temp;
        }
        return a;
    }
}


Measured memory_bytes: 39084
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x += [X]
y += [Y]
max_x = max(x)
min_y = min(y)
if max_x < min_y:
    print("No War")
else:
    print("War")


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

int main() {
  int N;
  cin >> N;
  vector<pair<pair<string,int>,int>> V(N);
  for (int i = 0; i < N; i++) {
    cin >> V.at(i).first.first >> V.at(i).first.second;
    V.at(i).second = i + 1;
    V.at(i).first.second *= -1;
  }
  sort(V.begin(),V.end());
  for (int j = 0; j < N; j++) 
    cout << V.at(j).second << endl;
    
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll i,j,n,x,y,z=0,p,q,m;
cin>>n>>m;
char a[n][m];
ll b[n][m];
for(i=0;i<n;i++)
for(j=0;j<m;j++)
cin>>a[i][j];
memset(b,0,sizeof(b));
for(i=n-1;i>=0;i--)
{
    for(j=m-1;j>=0;j--)
    {
        if(a[i][j]=='#')
         b[i][j]=0;
        else
        {
            if(i==n-1&&j==m-1)
            b[i][j]=1;
            else
            {
                if(i!=n-1&&j!=m-1)
                {
                    b[i][j]=(b[i+1][j]+b[i][j+1])%1000000007;
                }
                else if(i!=n-1)
                b[i][j]=b[i+1][j];
                else
                b[i][j]=b[i][j+1];

            }
        }
    }
}

cout<<b[0][0];
      return 0;
    }


Measured memory_bytes: 9088