akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
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>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a[N], ans, sum;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> a[i], sum += a[i];
   ans = sum;
   int sum1 = 0;
   for (int i = 1; i <= n; i ++) {
      sum1 += a[i];
      sum -= a[i];
      ans = min (ans, abs (sum1 - sum));   
   }
   cout << ans;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProCon
{

    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string[] input = Console.ReadLine().Split(' ');
            List<int> nums = new List<int>();
            for (int i = 0; i < input.Count(); ++i)
            {
                nums.Add( int.Parse(input[i]) );
            }
            nums.Sort();
            int b = -1;
            int maxNum = 0;
            for( int i = 0; i < input.Count(); ++i)
            {
                if( b == nums[i])
                {
                    continue;
                }
                b = nums[i];
                int res = 1;
                for( int x = i + 1; x < input.Count(); ++x)
                {                   
                    if ( nums[x] >= b + 3 )
                    {
                        break;
                    }
                    res++;
                }
                if(res > maxNum)
                {
                    maxNum = res;
                }
            }
            Console.WriteLine(maxNum);
        }
    }

}

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

const int N=200100;
int clk,cnt,a[N],fa[N],n,vis[N],sg[N],tmp[N];
vector<int>g[N];

void dfs(int x){
	for(int i:g[x])if(!vis[i])dfs(i);
	++clk;
	for(int i:g[x])if(!vis[i])tmp[sg[i]]=clk;
	for(sg[x]=0;tmp[sg[x]]==clk;++sg[x]);
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>fa[i],g[fa[i]].push_back(i);
	int rt=1;
	for(int i=1;i<=n;++i)rt=fa[rt];
	for(int i=1;i<=n;++i)vis[rt]=1,rt=fa[rt];
	for(int i=1;i<=n;++i)
		if(vis[i]==1)dfs(i),a[++cnt]=sg[i];
	sort(a+1,a+cnt+1);
	cout<<(a[1]!=a[cnt]||(a[1]==a[cnt]&&cnt%2==0)?"POSSIBLE\n":"IMPOSSIBLE\n");
	return 0;
}


Measured memory_bytes: 13952
from collections import deque

def bfs(maze, visited, sy, sx):
  queue = deque([[sy, sx]])
  visited[sy][sx] = 0
  #　返り値
  va = 0
  while queue:
    y,x = queue.popleft()
    #　返り値に関する条件
    if visited[y][x] > va :
      va = visited[y][x]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
        #　移動回数の計算
        visited[new_y][new_x] = visited[y][x] + 1
        queue.append([new_y, new_x])
  return va

h,w = map(int,input().split())
wall = ''
for i in range(w+2):
  wall += '#'
maze = [wall]
for i in range(h) :
  m1 = input()
  maze.append('#'+m1+'#')
maze .append(wall)

ans = []
for sy in range(1,h+1) :
  for sx in range(1+w+1):
    if maze[sy][sx] == '#' :
      continue
    visited = [[-1]*(w+2) for _ in range(h+2)]
    ans.append(bfs(maze, visited, sy, sx))

print(max(ans))

Measured memory_bytes: 3316
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in(), a = in(), b = in();
    cout << min(n * a, b) << endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    char op;
    while(true){
        cin >> a >> op >> b;
        if (op == '?'){
            break;
        }
        if ( op == '+'){
            cout << (a+b) << endl;
        }
        if ( op == '-'){
            cout << (a-b) << endl;
        }
        if ( op == '*'){
            cout << (a*b) << endl;
        }
        if ( op == '/'){
            cout << (a/b) << endl;
        }
        
        
        
        
        
        
        
    }
}




Measured memory_bytes: 3096
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
  }
  else {
    cout << (h * w + 1) / 2 << endl;
  }
}


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

Measured memory_bytes: 3608
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
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(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#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(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int dp[3005][3005];
PII pre[3005][3005];

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.length();
	int m = t.length();
	REP(i, n) {
		REP(j, m) {
			if (dp[i][j + 1] > dp[i + 1][j]) {
				dp[i + 1][j + 1] = dp[i][j + 1];
				pre[i + 1][j + 1] = pre[i][j + 1];
			}
			else {
				dp[i + 1][j + 1] = dp[i+1][j];
				pre[i + 1][j + 1] = pre[i+1][j];
			}
			if (s[i] == t[j]) {
				if (dp[i + 1][j + 1] < dp[i][j] + 1) {
					dp[i + 1][j + 1] = dp[i][j] + 1;
					pre[i + 1][j + 1] = MP(i, j);
				}
			}
		}
	}
	int i = n;
	int j = m;
	string r;
	while (dp[i][j]) {
		auto pre_i = pre[i][j].first;
		auto pre_j = pre[i][j].second;
		if (dp[i][j] != dp[pre_i][pre_j]) r = s[pre_i] + r;
		i = pre_i;
		j = pre_j;		
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 105984
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(v)";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var x = o.a();
  var y = o.a();
  var z = o.a();
  var K = o.a();
  var a = o.l().sort((a,b)=>b-a);
  var b = o.l().sort((a,b)=>b-a);
  var c = o.l().sort((a,b)=>b-a);
  var ok = 3, ng = a[0]+b[0]+c[0]+1;
  while(ng-ok>1){
    var m = Math.floor((ok+ng)/2);
    if(solve(m))ok = m;
    else ng = m;
  }
  var ans = [];
  for(var i = 0, j = 1, k; i < x; i++){
    for(j = 0 , k = 1; j < y; j++){
      if(k === 0)break;
      for(k = 0; k < z; k++){
        var t = a[i]+b[j]+c[k];
        if(t <= ok)break;
        ans.push(t);
      }
    }
  }
  ans.sort((a,b)=>b-a);
  while(ans.length < K)ans.push(ok);
  return ans.join("\n");

  function solve(p){
    var cnt = 0;
    for(var i = 0, j = 1, k; i < x; i++){
      if(j === 0)return;
      for(j = 0, k = 1; j < y; j++){
        if(k === 0)break;
        for(k = 0; k < z; k++){
          if(a[i]+b[j]+c[k] < p)break;
          cnt++;
          if(K === cnt)return true;
        }
      }
    }
  }
}


Measured memory_bytes: 10332
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        if(N % 2 == 1){
            System.out.println(0);
            return;
        }
        long top = N/2;
        long sum = 0;
        for(long i=1;i<=27;i++){
            long res = pow(5,i);
            sum += top/res;
        }
        System.out.println(sum);
    }

    private static long pow(long a, long b){
        if(b == 0){return 1;}
        return pow(a,b-1)*a;
    }
}


Measured memory_bytes: 22612
#include <iostream>

#define N 100

using namespace std;

void dump(int n, int a[]) {
    for (int i=0; i<n; i++) {
        if (i>0) { cout<<" "; }
        cout<<a[i];
    }
    cout<<endl;
}

void bubble_sort(int n, int a[], int& swapCount) {
    for (int i=0; i<n; i++) {
        for (int j=n-1; j>i; --j) {
            if (a[j] < a[j-1]) {
                int tmp = a[j];
                a[j] = a[j-1];
                a[j-1] = tmp;
                swapCount++;
            }
        }
    }
}

int main() {
    int n;
    int a[N];
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>a[i];
    }
    int count = 0;
    bubble_sort(n, a, count);
    dump(n, a);
    cout<<count<<endl;
    return 0;
}



Measured memory_bytes: 3096
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  string S; cin >> S;

  string ans = "No";
  string A[5];
  for (int i = 0; i < 5; i++){
    string now = "";
    for (int j = 0; j <= i; j++){
      now = now + "hi";
    }
    A[i] = now;
  }
  
  for (int i = 0; i < 5; i++){
    if (A[i] == S) ans = "Yes";
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
a=N*(N-1)/2
b=M*(M-1)/2
if N<1.5 and M>1.5:
    print(int(b))
elif M<1.5 and N>1.5:
    print(int(a))
elif N<1.5 and N<1.5:
    print(int(0))
else:
    print(int(a+b))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n;
  std::cin >> n;
  vt<int> a(n+1), b(n);
  rep(i,n+1)
    std::cin >> a[i];
  rep(i,n)
    std::cin >> b[i];

  ll ans = 0;
  rep(i,n) {
    if(b[i] >= a[i] + a[i+1]) {
      ans += a[i] + a[i+1];
      a[i] = 0;
      a[i+1] = 0;
    }
    else {
      ans += b[i];
      if(b[i] > a[i])
        a[i+1] -= b[i] - a[i];
    }
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;
const int MOD=998244353;

char s[MAXN+1]; int n;

set<string> seen;

void go(string s) {
	if(seen.count(s)) return; else seen.insert(s);
	//printf("%s\n",s.c_str());
	FORSZ(i,1,s) if(s[i-1]!=s[i]) {
		char c='c'-s[i-1]+'b'-s[i]+'a';
		string ns=s; ns[i-1]=ns[i]=c; go(ns);
	}
}

void go(string &t,int at,int sum) {
	if(at>=n) {
		bool adj=false; FORSZ(i,1,t) if(t[i-1]==t[i]) adj=true;
		if(adj&&sum==0&&!seen.count(t)) printf("%s: not %s\n",s,t.c_str());
		return;
	}
	for(t[at]='a';t[at]<='c';++t[at]) go(t,at+1,(sum+3-(t[at]-'a'))%3);
}

int dp[MAXN+1][3][3][2]; // dp[i][last][sum][adj] = # ways to make a string of i characters with given last character, sum and whether any two adjacent characters are the same

void inc(int &a,int b) { if((a+=b)>=MOD) a-=MOD; }
int solve() {
	int wantsum=0; REP(i,n) wantsum+=s[i]-'a'; wantsum%=3;
	if(n<=3) {
		seen.clear();
		go(s);
		return SZ(seen);
	} else {
		bool same=true; FOR(i,1,n) if(s[i]!=s[0]) same=false; if(same) return 1;
		bool initadj=false; FOR(i,1,n) if(s[i]==s[i-1]) initadj=true;
		memset(dp,0,sizeof(dp));
		REP(i,3) dp[1][i][i][0]=1;
		FOR(i,1,n) REP(last,3) REP(sum,3) REP(adj,2) {
			REP(c,3) {
				int ni=i+1,nlast=c,nsum=(sum+c)%3,nadj=adj==1||last==c?1:0;
				inc(dp[ni][nlast][nsum][nadj],dp[i][last][sum][adj]);
			}
		}
		int ret=0; REP(last,3) inc(ret,dp[n][last][wantsum][1]); if(!initadj) inc(ret,1); return ret;
	}
	//printf("SZ(seen)=%d\n",SZ(seen));

	//string t(n,'?'); go(t,0,wantsum);
}

void run() {
	scanf("%s",s); n=strlen(s);
	printf("%d\n",solve());
}

void stress() {
	for(n=3;n<=20;++n) {
		printf("%d\n",n);
		int p=1; REP(i,n) p*=3;
		REP(i,p) {
			int j=i; REP(i,n) s[i]='a'+j%3,j/=3; s[n]='\0';
			bool same=true; FOR(j,1,n) if(s[j]!=s[0]) same=false; if(same) continue;
			//printf("%s\n",s);
			solve();
		}
	}
}


int main() {
	run();
	//stress();
	return 0;
}


Measured memory_bytes: 14464
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B, C; cin >> A >> B >> C;
    int ans = C - (A - B);
    if (ans >= 0) cout << ans << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
 
		if(X >= 30 && X <= 40)
		System.out.println("Yes");
		if(X >= -40 && X <= 29)
		System.out.println("No");
	}
}

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

using ll = long long;

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int a,b,c,d;
	cin>>a>>b>>c>>d;

	while(1)
	{
		c -= b;

		if(c<=0)
		{
			cout << "Yes" << endl;
			return 0;
		}

		a -= d;

		if(a<=0)
		{
			cout << "No" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		int n = Integer.parseInt(line1);

		int[] num = new int[n];

		for (int i = 0; i < n; i++) {
			String kari = sc.nextLine();
			num[i] = Integer.parseInt(kari);
		}

		int answer = 0;

		for (int i = 0; i < n; i++) {
			if (num[i] == 2) {
				answer++;
			} else if (num[i] % 2 != 0 && num[i] >= 3) {
				double sq = Math.sqrt((double) num[i]);
				int sqr = (int) sq +1;

				int j = 3;
				int breakcount = 0;
				while (j <= sqr) {
					if (num[i] % j == 0) {
						breakcount = 1;
						break;
					}
					j += 2;
				}
				if (breakcount == 0) {
					answer++;
				}
			}
		}
		System.out.println(answer);

	}

}

Measured memory_bytes: 64892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    vector<ll> vec = {A, B, C};
    sort(ALL(vec));
    cout << vec[0]*vec[1]*(vec[2]%2) << endl;
    return 0;
}

Measured memory_bytes: 3628
package main

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

type As [][]int

func (a As) Len() int {
	return len(a)
}

func (a As) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a As) Less(i, j int) bool {
	return a[i][0] < a[j][0]
}

func main() {
	var n, d, a int
	fmt.Scan(&n, &d, &a)

	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	xs := make(As, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		x, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		h, _ := strconv.Atoi(sc.Text())
		xs[i] = []int{x, h}
	}

	sort.Sort(xs)

	var ans, sdmg int
	sds := make([][]int, 0)
	for i := range xs {
		if xs[i][1] > 0 {
			for len(sds) > 0 && sds[0][0] < xs[i][0] {
				sdmg -= sds[0][1]
				sds = sds[1:]
			}
			xs[i][1] -= sdmg
			if xs[i][1] <= 0 {
				continue
			}

			bn := (xs[i][1] + a - 1) / a
			dmg := bn * a
			sdmg += dmg
			ans += bn
			sds = append(sds, []int{xs[i][0] + d*2, dmg})
		}
	}

	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 23552
n = int(input())
a = list(map(int, input().split()))

b = [0]*200003

ans = 0

for i in a:
    b[i] += 1
    if b[i] >= 2:
        ans = ans + b[i]-1

for i in range(n):
    if b[a[i]] >= 2:
        print(ans-b[a[i]]+1)
    else:
        print(ans)




Measured memory_bytes: 26140
#include <stdio.h>

int main(){
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if(a<=b&&b<=c || b<=a&&a<=c)
    printf("%d\n", a+b);
  else if(a<=c&&c<=b || c<=a&&a<=b)
    printf("%d\n", a+c);
  else
    printf("%d\n", b+c);
  return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class DGoodGrid {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), c = in.nextInt();
            int[][] count = {new int[c], new int[c], new int[c]};
            int[][] d = new int[c][];
            for (int i = 0; i < c; i++) {
                d[i] = new int[c];
            }
            for (int i = 0; i < c; i++) {
                for (int j = 0; j < c; j++) {
                    d[j][i] = in.nextInt();
                }
            }
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    count[(i + j) % 3][in.nextInt() - 1]++;
                }
            }
            int[][] cost = {new int[c], new int[c], new int[c]};
            for (int i = 0; i < c; i++) {
                cost[0][i] = dot(count[0], d[i]);
                cost[1][i] = dot(count[1], d[i]);
                cost[2][i] = dot(count[2], d[i]);
            }
            int res = Integer.MAX_VALUE;
            for (int i = 0; i < c; i++) {
                for (int j = 0; j < c; j++) {
                    if (i == j) {
                        continue;
                    }
                    for (int k = 0; k < c; k++) {
                        if (i == k || j == k) {
                            continue;
                        }
                        res = Math.min(cost[0][i] + cost[1][j] + cost[2][k], res);
                    }
                }
            }
            out.println(res);
        }

        static int dot(int[] a1, int[] a2) {
            int r = 0;
            for (int i = 0; i < a1.length; i++) {
                r += a1[i] * a2[i];
            }
            return r;
        }

    }
}



Measured memory_bytes: 80464
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::HashMap;

fn main() {
    input!{
        s: chars
    }
    let mut ans = s.len() * (s.len() - 1) / 2 + 1;
    let mut map = HashMap::new();
    for &c in &s {
        let e = map.entry(c).or_insert(0);
        ans -= *e;
        *e += 1;
    }
    println!("{}", ans);
}



Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#define LEN 100005
#define EMPTY -1
#define FULL -1

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=1, tail=1, n;

int isFull();
int isEmpty();

void enqueue(P x){
  if(isFull()==FULL){
    fprintf(stderr,"オーバーフロー\n");
    exit(1);
  }
  Q[tail]=x;
  if(tail+1==LEN)
    tail=0;
  else
    tail++;
}

P dequeue(){
  P x;
  if(isEmpty()==EMPTY){
    fprintf(stderr,"アンダーフロー\n");
    exit(2);
  }    
  x=Q[head];
  if(head+1==LEN)
    head=0;
  else 
    head++;
  return x;
   
}

int main(){
  int elaps = 0, c=0;;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    tail++;        
  }
  while(c!=n){
    u=dequeue();
    if(u.t<=q){
      elaps+=u.t;
      printf("%s %d\n",u.name,elaps);
      c++;      
    }
    else {
      u.t-=q;
      enqueue(u);  
      elaps+=q;    
    }
    
    
  }
  
  return 0;
}


int isEmpty(){
  if(head==tail)return EMPTY;  
  else return 0;
}
int isFull(){
  if(head==(tail+1)%LEN)return FULL;
  else return 0;
}



Measured memory_bytes: 11900
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

void solve() {
	int n;
	string s; cin >> s; n = s.size();
	int cur = 0;
	ll sum = 0;
	rep(i, n) {
		if (s[i] == '<') {
			cur++; sum += cur;
		}
		else {
			int le = i;
			while (i + 1 < n&&s[i] == s[i + 1])i++;
			ll len = i - le + 1;
			sum += len * (len - 1) / 2;
			sum += max((ll)0,len - cur);
			cur = 0;
		}
	}
	cout << sum << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(7);
	//init();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 1172
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;

struct BinaryIndexedTree{
    int N;
    vector<long long> bit;
    //全て0で初期化
    BinaryIndexedTree(int size){
        bit.resize(size+1,0);
        N=size+1;
    }
    //bit[a]に値wを加える。O(log n)
    void add(int a,long long w){
        for(int x=a;x<=N;x+=(x & -x)) bit[x]+=w;
        return;
    }
    //bit[1,a]の和bit[1]+bit[2]+   +bit[a]を求める。 O(log n)
    long long sum(int a){
        long long ret=0;
        for(int x=a;x>0;x-=(x & -x)) ret+=bit[x];
        return ret;
    }

    int lower_bound(int  w) { // a_1 + a_2 + ... + a_x >= w となるような最小の x を求め
        if (w <= 0) {
            return 0;
        } else {
            int x = 0, r = 1;
            while (r < N) r = r << 1;
            for (int len = r; len > 0; len = len >> 1) { // 長さlenは1段下るごとに半分に
                if (x + len < N && bit[x + len] < w) { // 採用するとき
                    w -= bit[x + len];
                    x += len;
                }
            }
            return x + 1;
        }
    }

};

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,q;
  cin>>n>>q;
  BinaryIndexedTree BIT(n);
  rep(i,n){
    int a;
    cin>>a;
    BIT.add(i+1,a);
  }
  rep(i,q){
    int t,l,r;
    cin>>t>>l>>r;
    if(t==0){
      BIT.add(l+1,r);
    }
    else{
      cout<<BIT.sum(r)-BIT.sum(l)<<'\n';
    }
  }

  return(0);
}

Measured memory_bytes: 8256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int>len(n);
  for(int i = 0;i < n;i++){
    cin >> len[i];
  }
  int max = *max_element(len.begin(),len.end());
  int sum = 0;
  for(int i = 0;i < n;i++){
    sum += len[i];
  }
  if(max >= sum - max){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

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

static const int N = 1000;

int lcs(string X,string Y)
{
    int c[N+1][N+1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    int i,j;

    X = ' ' + X;
    Y = ' ' + Y;

    for(i=0;i <= m;i++) c[i][0] = 0;
    for(j = 1; j <= n;j++) c[0][j] = 0;

    for(i = 1 ;i <= m;i++)
    {
        for(j=1 ; j <= n;j++)
        {
            if(X[i] == Y[j])
            {
                c[i][j] = c[i-1][j-1] + 1;
            }
            else
            {
                c[i][j] = max(c[i-1][j],c[i][j-1]);
            }
            maxl = max(maxl,c[i][j]);
        }
    }

    return maxl;

}

int main()
{
    string s1,s2;
    int n;

    cin >> n;

    for(int i = 0;i<n;i++)
    {
        cin >> s1 >> s2;
        cout << lcs(s1,s2) << endl;
    }

    return 0;

}


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

int main() {
    ll N; cin >> N;
    int size = 1;
    ll now = 0;
    while(1){
        ll k = pow(26, size);
        now += k;
        if(now >= N)break;
        size++;
    }

    now -= pow(26, size);
    ll kouho = N - now;
    kouho--;
    vector<int> A(size);
    rep(i, size){
        int x = kouho % 26;
        A[i] = x;
        kouho /= 26;
    }

    char S[size];
    rep(i, size){
        S[i] = 'a';
    }

    for (int i = 0; i < size; i++){
        S[i] += A[size-1-i];
    }

    rep(i, size){
        cout << S[i];
        if(i == size-1){
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4100
#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>
#include <math.h>

// ===============================================================
//using系

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using Graph = vvi;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
using kaage = priority_queue<int, vector<int>, greater<int>>;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;

// ========================================================================
//define系

#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)

// ========================================================================


ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll mch(ll n) {
	if (n == 1) return 1;
	else return n * mch(n - 1);
}
//1から整数nまでの階乗を出す(INFで割っていない)
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します 


// ========================================================================


//ある程度のテンプレ(いじって使う)
//これとBFS、あとその時その時で使うものはここに書く



// ========================================================================


signed /*int*/ main() {
	ll r, d; cin >> r >> d;
	ll x; cin >> x;
	ll cnt = x;
	for (int i = 0; i < 10; i++) {
		cnt = cnt * r - d;
		cout << cnt << endl;
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll N;
int L[600][600];
int isvisit[600];
int rem;

void dfs(int v, int t, int level){
    isvisit[v] = t; 
    for(int i = 0; i < N; i++){
            if(L[v][i] != 0 || L[i][v]) continue;
            if(isvisit[i] == t) continue;
            L[v][i] = L[i][v] = level;
            rem--;
            if(isvisit[i] == 0)
                dfs(i, -t, level);
    }
}

int main(){
    cin >> N;

    rem = N*(N-1) / 2;

    int level = 1;
    while(rem > 0){
        fill(isvisit, isvisit+N, 0);
        for(int i = 0; i < N; i++){
            if(isvisit[i] == 0)
                dfs(i, 1, level);
        }
        level++;
    }

    //cout << level - 1<< endl;

    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            printf("%d ", L[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    int A[N - 1];
    REP(i, N -1) cin >> A[i];
    int c[N];
    REP(i, N) c[i] = 0;
    REP(i, N - 1) c[A[i] - 1]++;

    REP(i, N) cout << c[i] << endl;
    return 0;
}


Measured memory_bytes: 5184
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
const int maxn = 1000100;
const int INF = 0x3f3f3f3f;
int main() {
    int n;
    cin >> n;
    int num, time, _max = 0;
    while (n) {
        int t = n % 10;
        if (t == num) {
            time++;
        } else {
            num = t;
            time = 1;
        }
        n /= 10;
        _max = max(_max, time);
    }
    if (_max >= 3) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	if(y==0) return x;
	return gcd(y,x%y);	
}

ll lcm(ll x, ll y) {
	ll z=gcd(x,y);
	return x/z*y;
}

int main()
{
	string s;
	cin >> s;
	int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
	if(a+b+c+d==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
	else if(a+b+c-d==7) printf("%d+%d+%d-%d=7\n",a,b,c,d);
	else if(a+b-c+d==7) printf("%d+%d-%d+%d=7\n",a,b,c,d);
	else if(a+b-c-d==7) printf("%d+%d-%d-%d=7\n",a,b,c,d);
	else if(a-b+c+d==7) printf("%d-%d+%d+%d=7\n",a,b,c,d);
	else if(a-b+c-d==7) printf("%d-%d+%d-%d=7\n",a,b,c,d);
	else if(a-b-c+d==7) printf("%d-%d-%d+%d=7\n",a,b,c,d);
	else if(a-b-c-d==7) printf("%d-%d-%d-%d=7\n",a,b,c,d);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 2000005
typedef unsigned long long ll;
ll mod=1e9+7;
 
bool isNum(char ch){
  return ('0'<=ch&&ch<='9');
}
 
bool check(char ch){
  return (ch=='\0'||ch=='>');
}
 
int n,a;
int p;
 
char t[MAX];
 
 
ll solve();
 
ll getNum(){
  if(t[p]=='S'){
    p+=2;
    ll res=solve();
    p++;
    return (res*res)%mod; 
  }
  ll res=0;
  while(isNum(t[p])){
    res=res*10LL+(t[p]-'0');
    p++;
  }
  return res;
}
 
ll solve(){
  ll res=getNum();
  while(1){
    if(check(t[p])&&check(t[p+1])&&check(t[p+2])){
      break;
    }
    p+=2;
    ll num=min(63ULL,getNum());
 
    res=(res>>num);
    //cout<<res<<endl;
  }
  return res;
}
 
int main(){
  while(1){
    n=0;
    while(1){
      scanf("%c",&t[n]);
      if(t[n]==' ')continue;
      if(t[n]=='\n')break;
      n++;
    }
    if(t[0]=='#')break;
 
    while(n<MAX){
      t[n]='\0';
      n++;
    }
    // printf("%s\n",t);
    p=0;
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 4656
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a1 = list(_ for _ in input())
    a2 = list(_ for _ in input())
    if a2[2] == a1[0] and a1[1] == a2[1] and a1[2] == a2[0]:
        print('YES')
    else:
        print('NO')
    
if __name__ == '__main__':
    main()


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

#define x first
#define y second
#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

typedef pair<int, int> PII;

const int N = 810;
const int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};

int n, m, k;
char Map[N][N];
int dis[N][N];

int BFS(PII S){
	queue<PII> q;
	q.push(S);
	int ans = 1e9;
	while(!q.empty()){
		PII o = q.front(); q.pop();
		if(dis[o.x][o.y] > k) break;
		ans = min(ans, (min(min(n - o.x, o.x - 1), min(o.y - 1, m - o.y)) + k - 1) / k);

		For(i, 0, 3){
			int u = o.x + dx[i], v = o.y + dy[i];
			if(Map[u][v] == '.') q.push(PII(u, v)), dis[u][v] = dis[o.x][o.y] + 1, Map[u][v] = '#';
		}
	}
	return ans;
}

int main(){
	
	scanf("%d%d%d", &n, &m, &k);
	For(i, 1, n) scanf("%s", Map[i] + 1);
	PII S;
	For(i, 1, n) For(j, 1, m) if(Map[i][j] == 'S') S = PII(i, j);
	printf("%d\n", BFS(S) + 1);

	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<int>
using namespace std;
using ll = long long;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    rep(i,1,b){
        if((a*i)%b==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
  
#define for1(i,a,b) for (int i = a; i <= b; i++)
#define for2(i,a,b) for (int i = a; i >= b; i--)
#define int long long

using namespace std;

signed main() {
    int n, c=0;
    cin >> n;
    for1(i,1,n) {
        int d1,d2;
        cin >> d1 >> d2;
        if (d1==d2) c++;
        else c=0;
        if (c>=3) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	std::vector<std::vector<int>> g(n);
	std::vector<int> a(n - 1), b(n - 1);
	for(int i = 0; i < n - 1; i++) {
		scanf("%d%d", &a[i], &b[i]);
		a[i]--; b[i]--;

		g[a[i]].push_back(i);
		g[b[i]].push_back(i);
	}

	i64 ans = 0;
	const int MOD = 1e9 + 7;

	std::vector<int> sz(n);
	auto dfs = [&](auto&& dfs, int v, int par) -> void {
		sz[v] = 1;
		for(int id: g[v]) {
			int to = a[id] ^ b[id] ^ v;
			if(to == par) continue;

			dfs(dfs, to, v);
			sz[v] += sz[to];
		}
	};
	dfs(dfs, 0, -1);

	std::vector<i64> pow(n + 1, 1);
	for(int i = 1; i < n + 1; i++) pow[i] = pow[i - 1] * 2LL % MOD;
	auto solve = [&](auto&& solve, int v, int par, int cnt) -> void {
		i64 tmp = pow[n - 1] - 1;
		for(int id: g[v]) {
			int to = a[id] ^ b[id] ^ v;
			
			if(to == par and cnt) {
				tmp = (tmp - (pow[cnt] - 1) + MOD) % MOD;
			} else {
				tmp = (tmp - (pow[sz[to]] - 1) + MOD) % MOD;
			}
		}
		ans = (ans + tmp) % MOD;

		int sum = cnt + 1;
		for(int id: g[v]) {
			int to = a[id] ^ b[id] ^ v;
			if(to == par) continue;

			sum += sz[to];
		}
			
		for(int id: g[v]) {
			int to = a[id] ^ b[id] ^ v;
			if(to == par) continue;

			solve(solve, to, v, sum - sz[to]);
		}
	};
	solve(solve, 0, -1, 0);

	const int INV = 500000004;
	for(int i = 0; i < n; i++) ans = ans * INV % MOD;
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

using ll = long long;

const int inf = (int) 1e9 + 7;

mt19937 mt(736);


template<class T>
T sqr(T x)
{
	return x * x;
}


ll powmod(ll x, ll y)
{
	return y ? (y & 1 ? x * powmod(x, y - 1) : sqr(powmod(x, y / 2))) % inf : 1;
}


void stress(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;

	cin >> n;

	vector<int> arr(n);

	for (auto &it : arr)
		cin >> it;

	vector<int> px(n + 1);

	for (int i = 1; i < (int) px.size(); i++)
		px[i] = px[i - 1] ^ arr[i - 1];

	vector<vector<int>> pos(1 << 20);

	for (int i = 0; i < (int) px.size(); i++)
		pos[px[i]].push_back(i);

	ll ans = 0;

	for (int x = 0; x < (int) pos.size(); x++)
		if (!pos[x].empty() && (pos[x].back() == n || pos[0].back() == n))
		{
			if (x == 0)
				ans += powmod(2, pos[0].size() - 2);
			else
			{
				int z = 0, y = 0, sz = 1, sy = 0;

				while (z < (int) pos[0].size() || y < (int) pos[x].size())
				{
					if (z < (int) pos[0].size() && (y == (int) pos[x].size() || pos[0][z] < pos[x][y]))
					{
						sz += sy;
						if (sz >= inf)
							sz -= inf;
						z++;
					}
					else
					{
						sy += sz;
						if (sy >= inf)
							sy -= inf;
						y++;
					}
				}

				ans += (pos[0].back() == n ? sy : sz);
			}
		}

	cout << ans % inf << endl;
}


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;

	cin >> n;

	vector<int> arr(n);

	for (auto &it : arr)
		cin >> it;

	vector<int> px(n + 1), pz(n + 2);

	for (int i = 1; i < (int) px.size(); i++)
		px[i] = px[i - 1] ^ arr[i - 1];
	for (int i = 1; i < (int) pz.size(); i++)
		pz[i] = pz[i - 1] + (px[i - 1] == 0 ? 1 : 0);

	vector<vector<int>> pos(1u << 20u);

	for (int i = 0; i < (int) px.size(); i++)
		pos[px[i]].push_back(i);

	ll ans = 0;

	for (int x = 0; x < (int) pos.size(); x++)
		if (!pos[x].empty() && (pos[x].back() == n || pos[0].back() == n))
		{
			if (x == 0)
				ans += powmod(2, pos[0].size() - 2);
			else
			{
				ll z = 0, y = 0, sz = 1, sy = 0;

				while (z < (int) pos[0].size() || y < (int) pos[x].size())
				{
					if (z < (int) pos[0].size() && (y == (int) pos[x].size() || pos[0][z] < pos[x][y]))
					{
						int ny = (y == (int) pos[x].size() ? n + 1 : pos[x][y]);
						int add = pz[ny] - pz[pos[0][z]];

						sz += add * (ll) sy;
						sz %= inf;
						z += add;
					}
					else
					{
						sy += sz;
						if (sy >= inf)
							sy -= inf;
						y++;
					}
				}

				ans += (pos[0].back() == n ? sy : sz);
			}
		}

	cout << ans % inf << endl;
}


void gen(ostream &cout = std::cout)
{
	const int n = (int) 5e2;

	uniform_int_distribution<int> uid(0, 7);

	cout << n << endl;

	for (int i = 0; i < n; i++)
		cout << uid(mt) << ' ';
	cout << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	ifstream fin("../input.txt");
	stringstream ss, in1, in2;

	gen(ss);

	in1 << ss.str ();
	in2 << ss.str ();

	stress(in1);
	solve(in2);

	cout << setprecision(4) << "clock: " << clock() / (double) CLOCKS_PER_SEC << endl;
#else
	cout << setprecision(20);

	solve();
#endif

	return 0;
}


Measured memory_bytes: 40308