akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
   int N;
   cin >> N;
   string S;
   cin >> S;
   if(N&1){
       cout<<"No"<<endl;
       return;
   }
   REP(i,N/2){
       if(S[i] != S[i+(N/2)]){
           cout<<"No"<<endl;
           return;
       }
   }
   cout<<"Yes"<<endl;
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//nには件数
		int[][][] room = new int[4][3][10];

		for (int i = 0; i < n; i++) {
			int b = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int v = sc.nextInt();
			room[b - 1][f - 1][r - 1] += v;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 10; k++) {
					System.out.print(" " + room[i][j][k]);
				}
				System.out.println();
			}
			if (i < 3) {
				System.out.println("####################");
			}

		}
	}
}



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

int main ()
{
    int a, b;
    char op;
    
  while(1)
  {
    cin >> a >> op >> b;
    
    if (op == '+')
        cout << a + b << endl;
    else if (op == '-')
        cout << a - b << endl;
    else if (op == '*')
        cout << a * b << endl;
    else if (op == '/')
        cout << a / b << endl;
    else
      break;
  }
    return (0);
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 2e5+5 , mod=1e9+7;

ll n , sz[N] , dp[N];
vector<ll> adj[N];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void dfs(int node , int par)
{
    sz[node] = 1;
    for(auto ch : adj[node])
    {
        if (ch != par)
        {
            dfs(ch , node);
            sz[node] += sz[ch];
        }
    }
}

void sheel(int node , int par)
{
   // cout << node << ' ' << par << ' ' << sz[node] << ' ' << sz[par] << " gwa\n";
    sz[par] -= sz[node];
    sz[node] += sz[par];
  //  cout << node << ' ' << par << ' ' << sz[node] << ' ' << sz[par] << " gwa ba3d\n";
}

void erg3(int node , int par)
{
    sz[node] -= sz[par];
    sz[par] += sz[node];
}

void solve(int node , int par)
{
    if (par) sheel(node , par);

    ll ans = fp(2 , sz[node]-1) - 1;
    for(auto ch : adj[node])
    {
        ans -= (fp(2 , sz[ch])-1);
    //    cout << node << ' ' << ch << ' ' << sz[ch] << ' ' << fp(2,sz[ch])-1 << " ha\n";
        ans += 2*mod;
        ans %= mod;
    }
    dp[node] = ans;
//    cout << node << ' ' << par << ' ' << sz[node] << ' ' << sz[par] << ' ' << ans <<  " leh\n";

    for(auto ch : adj[node])
        if (ch != par) solve(ch , node);

 //   cout << node << ' ' << par << ' ' << sz[node] << ' ' << sz[par] << " hahah\n";
    if (par) erg3(node , par);
  //  cout << node << ' ' << par << ' ' << sz[node] << ' ' << sz[par] << " hahah\n";
}

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

    cin >> n;
    for(int i=1; i<n; i++)
    {
        int x,y;
        cin >> x >> y;
        adj[x].push_back(y) , adj[y].push_back(x);
    }

    dfs(1,1);
    solve(1,0);

    ll ans = fp(2 , n) , sum=0;
    ans = fp(ans , mod-2);
    for(int i=1; i<=n; i++)
    {
        sum += dp[i];
        sum %= mod;
    }

   // cout << ans << ' ' << dp[1] << ' ' << dp[2] << ' ' << dp[3] << " ha\n";
    ans *= sum;
    cout << ans%mod << '\n';

    return 0;
}

Measured memory_bytes: 29044
a = list(input())
b = list(input())
c = list(input())

s = a[0]
a = a[1:]

while True:
    if s == 'a':
        if a == []:
            print('A')
            break
        s = a[0]
        a = a[1:]
    elif s == 'b':
        if b == []:
            print('B')
            break
        s = b[0]
        b = b[1:]
    else:
        if c == []:
            print('C')
            break
        s = c[0]
        c = c[1:]

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;
  cin >> N >> A >> B;
 
  if (N*A > B) {
    cout << B << endl;
  }
  if (N*A <= B) {
    cout << N*A << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n;
char s[305][305];
int ans = 0;

bool check(int j){
	for(int k = 0; k < n; k++){
		for(int l = j; l < n+j; l++){
			if(s[k][l%n] != s[l-j][(k+j)%n]){
				return false;
			}
		}
	}
	return true;
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%s", s[i]);
	}
	for(int j = 0; j < n; j++){
		if(check(j)){
			//printf("! %d\n", j);
			ans += n;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
#define ld long double
#define inf 1000000000
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
#define N 200005
#define mod 1000000007
int n,head[N],cnt,dep[N],id[N],all[N],s0[N],s1[N],d[N],tong[N],tot,ans;
struct edge{ int to,nxt; }e[N<<1];
void adde(int x,int y){
	e[++cnt].to=y; e[cnt].nxt=head[x]; head[x]=cnt;
}
void ins(int x,int y){ adde(x,y); }
int ksm(int x,int p){
	int ret=1;
	for (x%=mod; p; p>>=1,x=(ll)x*x%mod) if (p&1) ret=(ll)ret*x%mod;
	return ret;
}
int getinv(int x){ return ksm(x,mod-2); }
vector<pii> dp[N];
void dfs(int u){
	int son=0,ch=0;
	for (int i=head[u],v; i; i=e[i].nxt){
		dfs(v=e[i].to); if (!son || d[v]>d[son]) son=v;
		ch++;
	}
	//d[u]需要转移的深度数量
	if (son) d[u]=d[son]+1,id[u]=id[son];//将最多状态数的son扔到u的状态里
	else id[u]=++tot;
	dp[id[u]].push_back(pii(1,1));
	if (ch==1) return;
	rep (i,0,d[u]-1) all[i]=s0[i]=1,s1[i]=0;
	for (int i=head[u],v; i; i=e[i].nxt){
		v=e[i].to;
		rep (j,0,d[v]){
			int ndep=d[son]-d[v]+j;//转化成从下至上的深度
			all[ndep]=(ll)all[ndep]*((dp[id[v]][j].F+dp[id[v]][j].S)%mod)%mod;
			s0[ndep]=(ll)s0[ndep]*dp[id[v]][j].F%mod;
		}
	}
	for (int i=head[u],v; i; i=e[i].nxt){
		v=e[i].to;
		rep (j,0,d[v]){
			int ndep=d[son]-d[v]+j;
			s1[ndep]=(s1[ndep]+(ll)s0[ndep]*getinv(dp[id[v]][j].F)%mod*dp[id[v]][j].S%mod)%mod;
		}
	}
	rep (i,0,d[u]-1){
		dp[id[u]][i].F=(all[i]+mod-s1[i])%mod;
		dp[id[u]][i].S=s1[i];
	}
}
int main(){
	n=read(); tong[0]++;
	rep (i,2,n+1){
		int x=read()+1; dep[i]=dep[x]+1; ins(x,i);
		tong[dep[i]]++;
	}
	dfs(1);
	rep (i,0,d[1]){
		pii now=dp[id[1]][i];//注意别忘加id[]
		ans=(ans+(ll)now.S*ksm(2,n+1-tong[d[1]-i])%mod)%mod;
	}
	cout<<ans<<endl;
	return 0;
}
/*
31
0 1 0 2 4 0 4 1 6 4 3 9 7 3 7 2 15 6 12 10 12 16 5 3 20 1 25 20 23 24 23

*/

Measured memory_bytes: 38388
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

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

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int ans = 0;
    int h, w;
    cin >> h >> w;
    bool processed[h][w];
    int operations[h][w];
    queue<pii> bfs;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            operations[i][j] = INT_MAX;
            processed[i][j] = 0;
            char temp;
            cin >> temp;
            if(temp == '#')
            {
                operations[i][j] = 0;
                processed[i][j] = 1;
                bfs.push({i - 1, j});
                bfs.push({i + 1, j});
                bfs.push({i, j - 1});
                bfs.push({i, j + 1});
            }
        }
    }
    while(!bfs.empty())
    {
        int i = bfs.front().first;
        int j = bfs.front().second;
        bfs.pop();
        if(i < 0 || j < 0 || i > h - 1|| j > w - 1 || processed[i][j]) continue;
        if(i - 1 > -1) operations[i][j] = min(operations[i][j], operations[i - 1][j]);
        if(j - 1 > -1) operations[i][j] = min(operations[i][j], operations[i][j - 1]);
        if(i + 1 < h) operations[i][j] = min(operations[i][j], operations[i + 1][j]);
        if(j + 1 < w) operations[i][j] = min(operations[i][j], operations[i][j + 1]);
        processed[i][j] = 1;
        operations[i][j]++;
        bfs.push({i - 1, j});
        bfs.push({i + 1, j});
        bfs.push({i, j - 1});
        bfs.push({i, j + 1});
    }
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            ans = max(ans, operations[i][j]);
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 37892
inf = 10**10
def warshall_floyd(d):#d[u][v]:辺uvのコスト.存在しなければinf.d[i][i]は0
    for i in range(N):#0~iとa, bのみを使う最短経路を考える
        for a in range(N):
            for b in range(N):
                d[a][b] = min(d[a][b], d[a][i]+ d[i][b])#頂点iを使う場合と使わない場合
    return d
N, M, L = map(int, input().split())
G = [[inf]*N for _ in range(N)]
for i in range(N):
    G[i][i] = 0
for _ in range(M):
    a, b, c = map(int, input().split())
    G[a-1][b-1] = c
    G[b-1][a-1] = c
G = warshall_floyd(G)
G2 = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            G2[i][j] = 0
        elif G[i][j]<=L:
            G2[i][j] = 1
        else:
            G2[i][j] = inf
d = warshall_floyd(G2)
Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    ans = d[s-1][t-1]-1
    print(ans if ans < 10**9 else -1)

Measured memory_bytes: 59096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int A=stoi(S.substr(0,2)), B=stoi(S.substr(2,2));
  if(1<=A && A<=12 && 1<=B && B<=12) cout << "AMBIGUOUS" << endl;
  else if(1<=A && A<=12) cout << "MMYY" << endl;
  else if(1<=B && B<=12) cout << "YYMM" << endl;
  else cout << "NA" << endl;
 }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

void PrintNoNum(vector<int> data, char picture){
  vector<int>::size_type i = 0;
  int j = 0;

  while(j < 13){
    if(data[i] == j+1){
      // 表示しなくて良い
      // cout << picture << " " << j+1 << endl;
      if(data.size()-1 > i)
        i++;
      j++;
    }else{
      // 入力にjがない
      // iは更新しない
      cout << picture << " " << j+1 << endl;
      j++;
    }
  }
}

int main(){
  int n, num;
  char picture;
  vector<int> S, H, D, C;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> picture >> num;
    if(picture == 'S'){
      S.push_back(num);
    }
    else if(picture == 'D'){
      D.push_back(num);
    }
    else if(picture == 'H'){
      H.push_back(num);
    }
    else if(picture == 'C'){
      C.push_back(num);
    }
  }
  sort(S.begin(), S.end());
  sort(H.begin(), H.end());
  sort(D.begin(), D.end());
  sort(C.begin(), C.end());


  PrintNoNum(S,'S');
  PrintNoNum(H,'H');
  PrintNoNum(C,'C');

  PrintNoNum(D, 'D');

  return 0;
}


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

int main(void)
{
    int x,y;
    cin >> x >> y;
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            if (i*2+j*4==y && i+j==x){
                cout << "Yes" << endl;
                exit(0);
            }

        }
    }
    cout << "No" << endl;

}

Measured memory_bytes: 3632
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int dp[2017][2];
int a[2017];
int n,inf=1001001001;
int cal(int x,int y){
	if(dp[x][y]>=0) return dp[x][y];
	int ret;
	if(y==0) ret=0;else ret=inf;
	REP(i,x+1,n+2){
		int now;
		if(i==n+1) now=abs(a[x]-a[i]);else now=cal(i,1-y);
		if(y==0) ret=max(ret,now);else ret=min(ret,now);
	}
	return dp[x][y]=ret;
}
int main(){
	cin>>n>>a[0]>>a[1];
	rep(i,n) cin>>a[2+i];
	memset(dp,-1,sizeof(dp));
	cout<<cal(1,0)<<endl;
}

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

int main(){
  int table[10];
  for(int i=0;i<10;i++){
	cin >> table[i] ;
  }  
  sort(table,table+10);
  for(int i=9;i>6;i--){
	cout << table[i] <<  endl;
  }
  return 0;
}

Measured memory_bytes: 1172
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[55],n,m,k,b[55],c[55],d[55],s[55];
int ans;
int val()
{
	int re=0;
	for(int i=1;i<=k;i++)
	{
		if(s[b[i]]-s[a[i]]==c[i])re+=d[i];
	}
	return re;
}
void dfs(int now,int t)
{
	if(now>n)
	{
		ans=max(ans,val());
		return;
	}
	for(int i=t;i<=m;i++)
	{
		s[now]=i;
		dfs(now+1,i);
	}
}
signed main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=k;i++)
	{
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	}
	dfs(1,1);
	cout<<ans;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  string s;
  cin >> s;
  bool b = 0;
  rep(i, 1 << 4){
    string t = "";
    if(i & 1 << 0) t += 'A';
    t += 'K';
    t += 'I';
    t += 'H';
    if(i & 1 << 1) t += 'A';
    t += 'B';
    if(i & 1 << 2) t += 'A';
    t += 'R';
    if(i & 1 << 3) t += 'A';
    if(s == t){
      b = 1;
      break;
    }
  }
  if(b) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#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<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#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 complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int N; cin >> N;
   ll h[100100];
   rep(i, N) cin >> h[i];
   ll dp[100100];
   rep(i, N) {
       dp[i] = INF;
   }
   dp[0] = 0;
   dp[1] = abs(h[1] - h[0]);
   Rep(i,2, N) {
       chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
       chmin(dp[i], dp[i - 2] + abs(h[i - 2] - h[i]));
   }
   cout << dp[N - 1] << endl;
   return 0;
}

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

using namespace std;


int main() {

    int n, a[100001], first = -1;
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        if (a[i] > first)
            first = a[i];
    }
    sort(a, a+n);
    
    int ans, value = first;
    for (int i = 0; i < n-1; i++) {
        if (value > abs(first/2.0-a[i])) {
            value = abs(first/2.0-a[i]);
            ans = i;
        }
    }
    printf("%d %d\n", first, a[ans]);
    
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 301;

int main() {
    int n; cin >> n;
    vector<int> a(n, 0);
    vector<int> f(4, 0);

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

    vector<vector<vector<double>>> dp(2, vector<vector<double>> (n + 1, vector<double> (n + 1, 0)));
   
    for (int a = 0; a <= f[3]; a += 1) {
        int now = (a % 2);
        int then = (1 - now);
        for (int b = 0; b <= n; b += 1)
            for (int c = 0; c <= n; c += 1) {
                dp[now][b][c] = 0;
                if (a - 1 >= 0 and b + 1 <= n)
                    dp[now][b][c] += (a + 0.0) / n * (1 + dp[then][b + 1][c]);
                if (b - 1 >= 0 and c + 1 <= n)
                    dp[now][b][c] += (b + 0.0) / n * (1 + dp[now][b - 1][c + 1]);
                if (c - 1 >= 0)
                    dp[now][b][c] += (c + 0.0) / n * (1 + dp[now][b][c - 1]);
                if (a + b + c > 0) {
                    double rem_coef = (n - (a + b + c + 0.0)) / n;
                    dp[now][b][c] += rem_coef;
                    dp[now][b][c] /= (1 - rem_coef);
                }
            }
    }
    
    cout.precision(15);
    cout << dp[f[3] % 2][f[2]][f[1]] << "\n";
}

Measured memory_bytes: 2432
N = int(input())
A = sorted([int(input()) for i in range(N)])
c = 0
n = 1
for i in range(N - 1):
    if A[i + 1] == A[i]:
        n += 1
    else:
        if n % 2 == 1:
            c += 1
        n = 1
if n % 2 == 1:
    c += 1
print(c)

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll inf = 1e18 + 5;
typedef pair<int, bool> pib;
bool cmp(vector<int> one, vector<int> two){
    for (int i = 0; i < one.size(); i++){
        if (one[i] != two[i]){
            return false;
        }
    }
    return true;
}
int main() {
    int n; cin >> n;
    vector<int> vec (n);
    for (int i = 0; i < n; i++){
        vec[i] = i+1;
    }
    vector<int> perm1 (n); vector<int> perm2 (n);
    for (int i = 0; i < n; i++){
        cin >> perm1[i];
    }
    for (int i = 0; i < n; i++){
        cin >> perm2[i];
    }
    int cnt = 1;
    int a,b; a= -1; b = -1;
    do{
        if (cmp(perm1, vec)){
            a = cnt;
        }
        if (cmp(perm2,vec)){
            b = cnt;
        }
        cnt++;
    } while (next_permutation(vec.begin(), vec.end()));
    cout << abs(a-b);
}



Measured memory_bytes: 256
from itertools import permutations, product
INF = float("inf")
N,C=map(int, input().split())
D=[[INF]*(C+1) for _ in range(C+1)]
c = [[-1]*(N+1) for _ in range(N+1)]
for i in range(1, C+1):
    tmp=list(map(int, input().split()))
    for j in range(1, C+1):
        D[i][j] = tmp[j-1]
for i in range(1, N+1):
    tmp=list(map(int, input().split()))
    for j in range(1, N+1):
        c[i][j] = tmp[j-1]
res0 = []
res1 = []
res2 = []
for i in range(1, N+1):
    for j in range(1, N+1):
        if (i+j)%3==0:
            res0.append((i,j))
        elif (i+j)%3==1:
            res1.append((i,j))
        else:
            res2.append((i,j))
ans = INF
dc0 = []
dc1 = []
dc2 = []
for nx in range(1,C+1):
    d0 = 0
    d1 = 0
    d2 = 0
    for i,j in res0:
        d0 += D[c[i][j]][nx]
    for i,j in res1:
        d1 += D[c[i][j]][nx]
    for i,j in res2:
        d2 += D[c[i][j]][nx]
    dc0.append((d0, nx))
    dc1.append((d1, nx))
    dc2.append((d2, nx))
dc0.sort()
dc1.sort()
dc2.sort()

for i, j, k in product(range(0, 3), repeat=3):
    c0 = dc0[i][1]
    c1 = dc1[j][1]
    c2 = dc2[k][1]
    if c0 == c1 or c1 == c2 or c2 == c0:
        continue
    disgust = 0
    for i, j in res0:
        disgust += D[c[i][j]][c0]
    for i, j in res1:
        disgust += D[c[i][j]][c1]
    for i, j in res2:
        disgust += D[c[i][j]][c2]
    ans = min(ans, disgust)
print(ans)

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

long long N;
long long K;
std::vector<long long> H;
vector<ll> uh;

unordered_map<ll, ll> h2i;
array<array<array<ll, 301>, 301>, 301> dp;

ll solve2(ll pos, ll lefth, ll rest){
    if(pos >= N){
        return 0;
    }
    if(dp[pos][h2i[lefth]][rest] != -1){
        return dp[pos][h2i[lefth]][rest];
    }
    ll ret = max(0LL, H.at(pos) - lefth) + solve2(pos + 1, H.at(pos), rest);
    if(rest > 0){
        ret = min(
            ret,
            solve2(pos + 1, lefth, rest - (H.at(pos) != lefth))
        );
    }
    dp[pos][h2i[lefth]][rest] = ret;
    return ret;
}

void solve(){
    uh = H;
    sort(uh.begin(), uh.end());
    uh.erase(unique(uh.begin(), uh.end()), uh.end());
    REP(i, uh.size()){
        h2i[uh.at(i)] = i;
    }
    REP(i, dp.size()){
        REP(j, dp.at(i).size()){
            fill(dp.at(i).at(j).begin(), dp.at(i).at(j).end(), -1);
        }
    }
    cout << solve2(0, 0, K) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    if(0){
        N = 300;
        H.resize(N);
        REP(i, N){
            H[i] = i + 100000000;
        }
        K = 300;
    }else{
        scanf("%lld",&N);
        scanf("%lld",&K);
        H.resize(N);
        for(int i = 0 ; i < N ; i++){
            scanf("%lld",&H[i]);
        }
    }
    solve();
    return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;

  int x1 = (a + b) / 2;
  double x2 = (double)(a + b) / 2;
 
  if(x2 - x1 == 0){
    cout << x1 << endl;
  }else{
    cout << x1 + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>
#include<stack>

using namespace std;

int main() {
	double r;
	cin >> r;
	printf("%.10f %.10f",r*r*3.1415926535897, 2 * r*3.1415926535897);
	return 0;
}

Measured memory_bytes: 3196
#include <stdio.h>

int main(void) {
    

    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: 2112
#include <stdio.h>

int main(){
  int	A, B, C, K;
  
  scanf("%d %d %d %d", &A, &B, &C, &K);
  if	 ( K < A )	{ printf("%d",K); }
  else if( K > A+B ){ printf("%d", A-(K-(A+B))); }
  else				{ printf("%d",A); }
  return 0;
}

Measured memory_bytes: 1728
let str_list str = 
	let len = String.length str in
	let rec sub i result = 
		if i < len then sub (i + 1) ((String.sub str i 1) :: result)
		else result
	in sub 0 []
	
let check_answer lst = 
	let rec sub ls i = 
		match ls with
			[] -> i
			| first :: rest	-> if first = "1" then sub rest (i + 1)
							else sub rest i
	in sub lst 0						

let solve () = 
	let target = read_line() in
	let target_lst = str_list target in 
	print_int (check_answer target_lst);;



solve();;

Measured memory_bytes: 384
#include <stdio.h>

int P[100001];

typedef struct {
	int left, right, max;
} seg_node;

void init_node(seg_node v[], int k, int l, int r)
{
	int i;
	v[k].left = l;
	v[k].right = r;
	v[k].max = 0;	
	if (l < r) {
		init_node(v, k * 2, l, (l + r) / 2);
		init_node(v, k * 2 + 1, (l + r) / 2 + 1, r);
	} else {
		for (i = k; i >= 1; i /= 2) if (P[l] > v[i].max) v[i].max = P[l];
	}
}

int get_max(seg_node v[], int k, int l, int r)
{
	int tmp[2];
	if (v[k].right < l || v[k].left > r) return 0;
	else if (v[k].left >= l && v[k].right <= r) return v[k].max;
	else {
		tmp[0] = get_max(v, k * 2, l, r);
		tmp[1] = get_max(v, k * 2 + 1, l, r);
		return (tmp[0] > tmp[1])? tmp[0]: tmp[1];
	}
}

int main()
{
	int i, N;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(P[i]));
	
	seg_node v[300001];
	init_node(v, 1, 1, N);
	
	int l[4], r[4], m;
	long long ans = 0;
	for (i = 1; i <= N; i++) {
		if (get_max(v, 1, 1, i - 1) < P[i]) {
			l[0] = 0;
			l[1] = 0;
		} else {
			l[0] = 1;
			r[0] = i - 1;
			while (l[0] < r[0]) {
				m = (l[0] + r[0] + 1) / 2;
				if (get_max(v, 1, m, i - 1) < P[i]) r[0] = m - 1;
				else l[0] = m;
			}
			if (get_max(v, 1, 1, l[0] - 1) < P[i]) l[1] = 0;
			else {
				l[1] = 1;
				r[1] = l[0] - 1;
				while (l[1] < r[1]) {
					m = (l[1] + r[1] + 1) / 2;
					if (get_max(v, 1, m, l[0] - 1) < P[i]) r[1] = m - 1;
					else l[1] = m;
				}
			}
		}
		if (get_max(v, 1, i + 1, N) < P[i]) {
			r[2] = N + 1;
			r[3] = N + 1;
		} else {
			l[2] = i + 1;
			r[2] = N;
			while (l[2] < r[2]) {
				m = (l[2] + r[2]) / 2;
				if (get_max(v, 1, i + 1, m) < P[i]) l[2] = m + 1;
				else r[2] = m;
			}
			if (get_max(v, 1, r[2] + 1, N) < P[i]) r[3] = N + 1;
			else {
				l[3] = r[2] + 1;
				r[3] = N;
				while (l[3] < r[3]) {
					m = (l[3] + r[3]) / 2;
					if (get_max(v, 1, r[2] + 1, m) < P[i]) l[3] = m + 1;
					else r[3] = m;
				}
			}
		}
		ans += ((long long)(i - l[0]) * (r[3] - r[2]) + (long long)(r[2] - i) * (l[0] - l[1])) * P[i];
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 5188
line = gets.chomp.split(" ").map(&:to_i)

n = line[0]
x = line[1]

line = gets.chomp.split(" ").map(&:to_i)

times = 1
pos = 0
line.each do |l|
    pos = pos + l
    if pos <= x
        times += 1
    else
        break
    end
end

p times


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
long long dp[(int)1e5+1][4];
int mod = 1e9+7;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    dp[0][0] = 1;
    for (int i = 0; i < (int)S.size(); i++) {
        if (S[i] == '?') {
            dp[i+1][3] = (dp[i][3] * 3 + dp[i][2]) % mod;
            dp[i+1][2] = (dp[i][2] * 3 + dp[i][1]) % mod;
            dp[i+1][1] = (dp[i][1] * 3 + dp[i][0]) % mod;
            dp[i+1][0] = (dp[i][0] * 3) % mod;
        } else {
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][1];
            dp[i+1][2] = dp[i][2];
            dp[i+1][3] = dp[i][3];
            if (S[i] == 'A') {
                dp[i+1][1] += dp[i][0];
                dp[i+1][1] %= mod;
            } else if (S[i] == 'B') {
                dp[i+1][2] += dp[i][1];
                dp[i+1][2] %= mod;
            } else if (S[i] == 'C') {
                dp[i+1][3] += dp[i][2];
                dp[i+1][3] %= mod;
            }
        }
    }
    printf("%lld\n", dp[(int)S.size()][3]);
    return 0;
}

Measured memory_bytes: 3664
#include<iostream>

using namespace std;

long gcd(long a, long b);
long lcm(long a, long b);

int main(){
    long N, M;
    cin >> N >> M;
    long a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
        a[i] /= 2;
    }
    long l;
    if (N >= 2) l = lcm(a[0], a[1]);
    else l = a[0];
    for(int i=2; i<N; i++){
        l = lcm(l, a[i]);
    }
    bool ok = true;
    for(int i=0; i<N; i++){
        if(l%a[i] == 0 && (l/a[i])%2 == 0)
        ok = false;
    }
    if(ok){
    int ans = M / l;
    ans = (ans+1) / 2;
    cout << ans << endl;
    }
    else{
        cout << 0 << endl;
    }
    
    return 0;
}

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

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(100050, 0);
    rep(i, N) cin >> A[i+1];
       
    vector<ll> subs(100050, 0);
    ll sum = 0;
    for(ll i=1; i<N+1; i++) {
        subs[i] = abs(A[i]-A[i-1])+abs(A[i]-A[i+1])-abs(A[i-1]-A[i+1]);
        sum += abs(A[i-1]-A[i]);
    }
    sum += abs(A[N]);

    rep(i, N) {
        cout << sum - subs[i+1] << endl;
    }

    return 0;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

const string D = "NWSE";
const string A = "^v<>";
const int dx[] = {0, -1, 0, 1};
const int dy[] = {-1, 0, 1, 0};

int H, W;
string a[55];
string s;

int sx, sy, dir = 0;
int idx;
stack<int> stk;
int nextIdx[1010];
int ans = 0;

void stop(bool endls = false) {
  cout << (endls ? -1 : ans) << endl;
  exit(0);
}

bool isWall(bool bck = false) {
  if(bck) return a[sy-dy[dir]][sx-dx[dir]] == '#';
  else return a[sy+dy[dir]][sx+dx[dir]] == '#';
}

bool getCond() {
  bool cond = false, rev = false;
  if(s[idx] == '~') idx++, rev = true;

  if(s[idx] == 'N') cond = dir == 0;
  else if(s[idx] == 'E') cond = dir == 3;
  else if(s[idx] == 'S') cond = dir == 2;
  else if(s[idx] == 'W') cond = dir == 1;
  else if(s[idx] == 'C') cond = isWall();
  else if(s[idx] == 'T') cond = true;
  else assert(false);

  idx++;

  return cond ^ rev;
}

void moveAI() {
  ans++;

  if(s[idx] == '^'){
    if(!isWall()) sx += dx[dir], sy += dy[dir];
  } else if(s[idx] == 'v') {
    if(!isWall(true)) sx -= dx[dir], sy -= dy[dir];
  } else if(s[idx] == '<') {
    dir = (dir + 1) % 4;
  } else if(s[idx] == '>') {
    dir = (dir + 3) % 4;
  } else {
    assert(false);
  }

  idx++;

  if(a[sy][sx] == 'g') stop();
}

void solve() {
  if(ans > 10000000) stop(true);

  if(s[idx] == '[') {
    int next = nextIdx[idx];
    idx++;
    if(getCond()) while(s[idx] != ']') solve();
    idx = next;
  } else if(s[idx] == '{') {
    int next = nextIdx[idx];
    idx++;
    stk.push(idx);
    int cnt = 0;
    while(getCond()) {
      cnt++;
      if(cnt > 10000000) stop(true);
      while(s[idx] != '}') solve();
      idx = stk.top();
    }
    stk.pop();
    idx = next;
  } else {
    moveAI();
  }
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> H >> W;
  rep(i, H) {
    cin >> a[i];
    rep(j, W) {
      if(a[i][j] == 's') sx = j, sy = i;
    }
  }

  cin >> s;

  stack<int> stk2;
  rep(i, s.size()) {
    if(s[i] == '[' || s[i] == '{') stk2.push(i);
    else if(s[i] == ']' || s[i] == '}') {
      nextIdx[stk2.top()] = i+1;
      stk2.pop();
    }
  }

  while(idx < s.size()) solve();
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 3248
N = int(input())
A = list(map(int,input().split()))
money = 1000

L = [0 for _ in range(N)] #-1極小。1極大
for i in range(N):
  if i == 0:
    if A[i+1] >= A[i]:
      L[i] = -1
    else:
      L[i] = 1
  elif i == N-1:
    if A[i] >= A[i-1]:
      L[i] = 1
    else:
      L[i] = -1
  else:
    if A[i] >= A[i-1] and A[i] >= A[i+1]:
      L[i] = 1
    elif A[i] <= A[i-1] and A[i] <= A[i+1]:
      L[i] = -1
#print(L)
kabu = 0
for i in range(N):
  #print(money,kabu,L[i])
  if L[i] == 1:
    #print(money,kabu,L[i],"ok")
    money += kabu*A[i]
    kabu = 0
  elif L[i] == -1:
    #print(money,kabu)
    uri = money//A[i]
    money -= uri*A[i]
    kabu += uri
  #print(money,kabu)
ans = money+kabu*A[-1]
print(ans)
    


Measured memory_bytes: 62108
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100005;
int p[N],noww[2*N],goal[2*N],col[N],c[5];
long long n,m,cnt,t1,t2,nb;
void link(int f,int t)
{
	noww[++cnt]=p[f];
	goal[cnt]=t,p[f]=cnt;
}
void dye(int nde,int cor)
{
	col[nde]=cor,c[cor]++;
	for(int i=p[nde];i;i=noww[i])
		if(!col[goal[i]]) dye(goal[i],3-cor);
		else if(col[goal[i]]==cor) {nb=true; return ;}
}
int main ()
{
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%lld%lld",&t1,&t2),link(t1,t2),link(t2,t1);
	for(int i=1;i<=n;i++)
		if(!col[i]) dye(i,1);
	if(nb) printf("%lld",1ll*n*(n-1)/2-m);
	else printf("%lld",1ll*c[1]*c[2]-m);
	return 0;
}

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

public class Main {

	
	public static void main(String[] args) {
		FastScanner in=new FastScanner();
		PrintWriter out=new PrintWriter(System.out);
	//	int t=in.nextInt();
	//	while(t-->0)
		solve(in,out);
		out.close();
	}

    static void solve(FastScanner in,PrintWriter out){
     HashSet<Integer> h=new HashSet<>();
     h.add(in.nextInt());  h.add(in.nextInt());
     for(int i=1;i<4;i++) if(!h.contains(i)) { out.println(i); return; }
    }    
	


	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


Measured memory_bytes: 32588
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int a = sc.nextInt();
        int ans;
        if (h % a == 0) {
            ans = h / a;
        } else {
            ans = h / a + 1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  vector<int>P(N);
  for (int i=0; i<N; i++) cin >> P[i];
  
  int min=200005; //最小値を入れる
  int ans=0;
  for (int i=0; i<N; i++){
    if (P[i]<min){
      ans++;
      min = P[i];
    }
  }
  printf("%d",ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  	int n,t=1,m;
  	cin>>n;
  	m=7%n;
  	while(m!=0){
  		t++;
  		m=((m<<3)+(m<<1))%n+7;
  		m%=n;
  		if(t>n){
  			cout<<-1;
  			return 0;
		  }
	}
  	cout<<t;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main(){
   int n,sum;
   string str;
   while(cin>>n,n){
     int dice[6]={1,6,2,5,3,4};
     sum=1;
     for(int i=1;i<=n;i++){
       cin>>str;
       if(str=="North") {swap(dice[0],dice[3]);swap(dice[0],dice[1]);swap(dice[0],dice[2]);sum=sum+dice[0];}
      else if(str=="East") {swap(dice[1],dice[5]);swap(dice[0],dice[1]);swap(dice[1],dice[4]);sum=sum+dice[0];}
       else if(str=="West")  {swap(dice[0],dice[5]);swap(dice[0],dice[4]);swap(dice[1],dice[4]);sum=sum+dice[0];}
       else if(str=="South") {swap(dice[0],dice[2]);swap(dice[0],dice[3]);swap(dice[1],dice[3]);sum=sum+dice[0];}
       else if(str=="Right") {swap(dice[2],dice[5]);swap(dice[2],dice[4]);swap(dice[3],dice[4]);sum=sum+dice[0];}
       else if(str=="Left")  {swap(dice[2],dice[5]);swap(dice[3],dice[5]);swap(dice[3],dice[4]);sum=sum+dice[0];}

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

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ld, ld> pld;

deque <pld> D;
ll n, k;
ld x, y;

int main()
{
	ll i, t, v;
	ld x1, x2, y1, y2;
	
	scanf("%lld%lld", &n, &k);
	
	D.emplace_back(0, 0);
	
	for(i=0; i<n; i++){
		scanf("%lld%lld", &t, &v);
		x += v; y += (ld)t * v / k;
		for(; D.size() > 1; D.pop_front()){
			tie(x2, y2) = D[1];
			if(x - k < x2) break;
        }
		
		if(i){
			tie(x1, y1) = D[0]; D.pop_front();
			tie(x2, y2) = D[0];
			y1 = (y1 * (x2 - x + k) + y2 * (x - k - x1)) / (x2 - x1);
			x1 = x - k; D.emplace_front(x1, y1);
			
			printf("%.20lf\n", (double)(y - y1));
        }
		else printf("%.20lf\n", (double)y);
		
		for(; D.size() > 1; D.pop_back()){
			tie(x1, y1) = D.back();
			tie(x2, y2) = D[D.size() - 2];
			if(x * y1 + x1 * y2 + x2 * y < y * x1 + y1 * x2 + y2 * x){
				break;
            }
        }
		
		D.emplace_back(x, y);
	}
	
	return 0;
}

Measured memory_bytes: 23312
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

int n,m,query,l,r; 
int train[505][505]; 

signed main()
{
    cin >> n >> m >> query ; 
    for (int  i=0 ; i< m ; i++) { 
    	cin >> l >> r ; 
    	train[l][r]++ ; 
    } 
    // 2D cumulative sum ... 
    for (int i=1;i<=n;i++){
    	for (int j=1;j<=n;j++){
    		train[i][j] += train[i][j-1] + train[i-1][j] - train[i-1][j-1] ; 
    	}
    }
    while (query--){ 
    	cin >> l >> r ; 
    	co ( train[r][r] - train[r][l-1] - train[l-1][r] + train[l-1][l-1] ) ; 
    }
    return 0;
}


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

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int[] abx = ReadAndParseIntArr();
            int a = abx[0];
            int b = abx[1];
            int x = abx[2];
            x -= a;
            if(0 <= x && x <= b)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
        
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>  // ver2.1.9
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lW,0,a.size()){Vout(a[lW]);}
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
 
signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  string s;
  int k;
  cin >> s >> k;
  int ans = 0,n = s.size();
  char c = s[0];
  int st=0,en=0;
  rep(i,0,n){
    if(c == s[i]) st++;
    else break;
  }
  //cout << st << endl;
  
  if(st==n) {
    cout << (n*k)/2 << endl;
    return 0;
  }
  
  repreq(i,n-1,0){
    if(c==s[i]) en++;
    else break;
  }
  //cout << en << endl;
  
  string t = s.substr(st,n-st-en);
  //cout << t;
  
  ans += st/2;
  ans += en/2;
  ans += ((st+en)/2)*(k-1);
  
  int l = t.size();
  int now=1,are=0;
  char nowc = t[0];
  
  rep(i,1,l){
    if(nowc == t[i]) now++;
    else {
      are += now/2;
      now = 1;
      nowc = t[i];
         }
  }
  
  are += now/2;
  ans += are*k;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#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 K, X; cin >> K >> X;
    rrep (i, X-K+1, X+K-1) {
        cout << i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
using namespace std;
int main(){
    int N;
    int sa=0;
    int mx=-1;
    int mn=114514;
    string S;
    cin >> N;
    cin >> S;
    REP(i,N){
        if(S[i]=='('){
            sa++;
        }else{
            sa--;
        }
        if(sa>mx){mx=sa;}
        if(sa<mn){mn=sa;}
    }
    if(sa>0){
        //cout << S<<endl;
        REP(i,sa){S.insert(S.size(),")");}
       //cout << S<<endl;
        mx=-1;
        mn=114514;
        sa=0;
        REP(i,S.size()){
            if(S[i]=='('){
                sa++;
            }else{
                sa--;
            }
            if(sa>mx){mx=sa;}
            if(sa<mn){mn=sa;}
        }
        REP(i,-mn){cout << "(";}
        cout << S;
        REP(i,-mn){cout << ")";}
        
       
    }else if(sa==0){
        if(S[0]=='('){
            cout << S;
        }else{
            sa= max(-1*mn,mx);
            REP(i,sa){cout << "(";}
            cout << S;
            REP(i,sa){cout << ")";}
        }
    }else{
        REP(i,-1*sa){S.insert(0,"(");}
        //REP(i,-1*sa){cout << "(";}
        mx=-1;
        mn=114514;
        sa=0;
        REP(i,S.size()){
            if(S[i]=='('){
                sa++;
            }else{
                sa--;
            }
            if(sa>mx){mx=sa;}
            if(sa<mn){mn=sa;}
        }
        REP(i,-1*mn){cout << "(";}
        cout << S;
        REP(i,-1*mn){cout << ")";}
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int cnt = 0;
	while (b <= a) {
		cnt++;
		b *= 2;
	}
	while (c <= b) {
		cnt++;
		c *= 2;
	}
	if (cnt <= k) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

long long a, b, c, d, e, f, g;

int main() {
    scanf("%lld %lld %lld %lld %lld %lld %lld", &a, &b, &c, &d, &e, &f, &g);
    long long ans1 = 0, ans2 = 0;
    ans1 += d / 2 * 2 + e / 2 * 2;
    ans1 += a / 2 * 2;
    ans1 += min({a % 2, d % 2, e % 2}) * 3;
    ans2 = 3 + (d - 1) / 2 * 2 + (e - 1) / 2 * 2;
    ans2 += (a - 1) / 2 * 2;
    if (!a || !d || !e) ans2 = 0;
    printf("%lld\n", max(ans1, ans2) + b);
    return 0;
}

Measured memory_bytes: 256