akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();

        Set<Character> set = new HashSet<Character>();

        for (char ch: S) {
            if (set.contains(ch)) {
                System.out.println("no");
                System.exit(0);
            }
            set.add(ch);
        }
        System.out.println("yes");

        return;
    }

}

Measured memory_bytes: 22736
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;

typedef long long ll;
ll mod = 1000000007;

int main() {
    int n,m;
    scanf("%d %d",&n,&m);
    vector<pair<int,int>> pairs;
    for (int i = 0; i < n; i++) {
        int a,b;
        scanf("%d %d",&a,&b);
        pairs.emplace_back(a,-b);
    }
    sort(pairs.begin(),pairs.end());
    int ans = 0;
    int cnt = 0;
    priority_queue<int> que;
    for (int j = 1; j <= m; j++) {
        while (pairs[cnt].first <= j && cnt < pairs.size()) {
            que.push(-pairs[cnt].second);
            cnt++;
        }
        if (!que.empty()) ans += que.top(), que.pop();
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1908
S=input()
N=len(S)
OK=[0]*N
for i in range(N):
    if (i+1)%2==0:
        if S[i]=="L" or S[i]=="U" or S[i]=="D":
            OK[i]=1
        else :
            OK[i]=0
    else :
        if S[i]=="R" or S[i]=="U" or S[i]=="D":
            OK[i]=1
        else :
            OK[i]=0
print("Yes" if sum(OK)==N else "No")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
  int n,x,l,i;
	int d=0;
	int cnt=1;
	cin>>n>>x;
	for(i=0;i<n;i++){
		cin>>l;
		d+=l;
		if(d<=x)cnt++;
	}

	cout<<cnt<<endl;
}

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

typedef long long ll;
const int N = 2e5 + 77;
const ll mod = (int)1e9 + 7;
const ll inf = (ll)1e15 + 77;

int main()
{
  ll n, k, a[405], sum[405] = {0};
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++)
    scanf("%lld", a + i), sum[i] = sum[i - 1] + a[i];
  vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, inf));
  for (ll len = 1; len <= n; len++)
  {
    for (ll start = 1; start <= n; start++)
    {
      ll end = min(n, start + len - 1);
      if (start == end)
      {
        dp[start][end] = 0;
        continue;
      }
      for (ll k = start; k < end; k++)
      {
        dp[start][end] = min(dp[start][end], dp[start][k] + dp[k + 1][end] + sum[end] - sum[start - 1]);
      }
    }
  }
  printf("%lld", dp[1][n]);
  return 0;
}

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

int main() {
  int c[9];
  for (int i = 0; i < 9; i++) cin >> c[i];
  int dif = c[3] - c[0]; string res = "Yes";
  for (int i = 1; i < 3; i++) {
    if (c[i + 3] - c[i] != dif) res = "No";
  }
  dif = c[6] - c[0];
  for (int i = 1; i < 3; i++) {
    if (c[i + 6] - c[i] != dif) res = "No";
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
const int MAXN = 234567;
bool a[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        int tmp;
        scanf("%d", &tmp);
        a[i] = (tmp == i);
    }
    int ans = 0;
    for (int i = 1; i < N; i++) {
        if (a[i] && a[i + 1]) {
           ans++;
           a[i] = a[i + 1] = false;
        }
    }
    for (int i = 1; i <= N; i++) {
        if (a[i]) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  string t(s);
  reverse(t.begin(),t.end());
  for(char &c:t){
    if(c=='b') c='d';
    else if(c=='d') c='b';
    else if(c=='p') c='q';
    else if(c=='q') c='p';
  }
  cout<<(s==t?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 512
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int a, b; readV(a, b);

  auto c = 0;
  foreach (i; a..b+1) {
    auto s = i.to!string, t = s.dup;
    t.reverse();
    if (s == t) ++c;
  }

  writeln(c);
}


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

int main() {
    long long n, k, ret = 4*(1e18);
    std::cin >> n >> k;
    std::vector<long long> x(n), y(n);
    for (auto i = 0ll; i < n; i++) std::cin >> x[i] >> y[i];

    for (auto i = 0ll; i < n; i++) {
        for (auto j = i; j < n; j++) {
            for (auto l = j; l < n; l++) {
                for (auto m = l; m < n; m++) {
                    auto lx = std::min({x[i], x[j], x[l], x[m]}),
                        ux = std::max({x[i], x[j], x[l], x[m]}),
                        ly = std::min({y[i], y[j], y[l], y[m]}),
                        uy = std::max({y[i], y[j], y[l], y[m]});
                    
                    auto count = 0ll;
                    for (auto k = 0ll; k < n; k++) {
                        if (lx <= x[k] && x[k] <= ux && ly <= y[k] && y[k] <= uy) count++;
                    }

                    if (count >= k) ret = std::min(ret, (ux - lx) * (uy - ly));
                }
            }
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

char detClass(int pm, int pe, int pj)
{
	
	int mean = pm + pe + pj;
	if((pm == 100) | (pe == 100) | (pj == 100)) {
		return 'A';
	} else if( (pm + pe) >= 180) {
		return 'A';
	} else if( mean >= 240) {
		return 'A';
	} else if( mean >= 210) {
		return 'B';
	} else if( (mean >= 150) && ((pm >= 80) | (pe >= 80))) {
		return 'B';
	} else {
		return 'C';
	}
}

int main()
{
	int n, pm, pe, pj = 0;
	
	while(true) {
		std::cin >> n;
		if(n == 0) {
			break;
		}
		for(int i = 0; i < n; i++) {
			std::cin >> pm >> pe >> pj;
			std::cout << detClass(pm,pe,pj) << std::endl;
		}
	}
	return 0;	
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}
// end of Template
int a[3];
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[0]+a[1]<<newl;

}


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

template<typename T>
vector<T> compress(vector<T> A){
    sort(A.begin(), A.end());
    A.erase(unique(A.begin(), A.end()), A.end());
    return A;
}

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

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

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

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

    bool same(int x, int y){ return find(x) == find(y); }
    int size(int x){ return sz[find(x)]; }
};

int main(){
    int N, M;
    cin >> N >> M;
    int64_t INF = 2e9;
    vector<int64_t> xs = {-INF, INF}, ys = {-INF, INF};
    auto add = [&](int64_t x, int64_t y){
        xs.push_back(x);
        xs.push_back(x+1);
        ys.push_back(y);
        ys.push_back(y+1);
    };

    vector<int64_t> A(N), B(N), C(N), D(M), E(M), F(M);
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i] >> C[i];
        add(A[i], C[i]);
        add(B[i], C[i]);
    }
    for(int i=0; i<M; i++){
        cin >> D[i] >> E[i] >> F[i];
        add(D[i], E[i]);
        add(D[i], F[i]);
    }
    xs = compress(xs);
    ys = compress(ys);
    auto find_x = [&](int a)->int{ return upper_bound(xs.begin(), xs.end(), a) - xs.begin() - 1; };
    auto find_y = [&](int a)->int{ return upper_bound(ys.begin(), ys.end(), a) - ys.begin() - 1; };

    int xsz = xs.size(), ysz = ys.size();
    bitset<6100> under[6100], right[6100];
    for(int i=0; i<N; i++){
        A[i] = find_x(A[i]);
        B[i] = find_x(B[i]);
        C[i] = find_y(C[i]);
        for(int x=A[i]+1; x<=B[i]; x++) right[x][C[i]] = 1;
    }
    for(int i=0; i<M; i++){
        D[i] = find_x(D[i]);
        E[i] = find_y(E[i]);
        F[i] = find_y(F[i]);
        for(int y=E[i]+1; y<=F[i]; y++) under[D[i]][y] = 1;
    }
    auto encode = [&](int i, int j){ return i*ysz+j; };
    UnionFind uf(xsz*ysz);
    for(int i=0; i<xsz-1; i++) for(int j=0; j<ysz-1; j++){
        if(!under[i][j]) uf.unite(encode(i, j), encode(i+1, j));
        if(!right[i][j]) uf.unite(encode(i, j), encode(i, j+1));
    }

    auto fail = [](){
        cout << "INF" << endl;
        exit(0);
    };
    int cow = encode(find_x(0), find_y(0));
    int64_t ans = 0;
    for(int i=0; i<xsz; i++) for(int j=0; j<ysz; j++) if(uf.same(cow, encode(i, j))){
        if(i == 0 || i==xsz-1 || j==0 || j==ysz-1) fail();
        int64_t dx = xs[i+1] - xs[i], dy = ys[j+1] - ys[j];
        ans += dx*dy;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int zero_odd = 0, zero_even = 0, one_odd = 0, one_even = 0;
    char str[100001];

    cin >> str;

    for (int i = 0; str[i] != '\0'; i++) {
        if (str[i] == '1') {
            if (i%2 == 0) {one_odd++;}
            else {one_even++;}
        } else {
            if (i%2 == 0) {zero_odd++;}
            else {zero_even++;}
        }
    }

    cout << min(zero_odd, zero_even) + min(one_odd, one_even);

}

Measured memory_bytes: 384
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if 500 * a + 100 * b + 50 * c == X:
                ans += 1
print(ans)

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

const int MOD = 998244353;
const int MAXN = 305;

char s[MAXN];
int n, k, nxt[MAXN], dp[MAXN][MAXN][MAXN];

int main(){	
	scanf("%s %d", s, &k);
	n = strlen(s);
	k = min(n, k);
	
	for(int i = n; i >= 0; i--){
		if(i == n)nxt[i] = i;
		else if(s[i] == '0')nxt[i] = i;
		else nxt[i] = nxt[i + 1];
	}
	
	for(int i = n; i >= 0; i--)
	for(int j = n; j >= 0; j--)
	for(int r = 0; r <= k; r++){
		if(i == n){
			if(j == 0)dp[i][j][r] = 1;
			else dp[i][j][r] = 0;
		}else{
			if(s[i] == '0'){
				dp[i][j][r] = dp[i + 1][j][r];
				if(r > 0 && j + 1 <= n)dp[i][j][r] = (dp[i][j][r] + dp[i][j + 1][r - 1]) % MOD;
			}else{
				dp[i][j][r] = dp[i + 1][j][r];
				if(j >= nxt[i] - i)dp[i][j][r] = (dp[i][j][r] + dp[(nxt[i] == n ? n : nxt[i] + 1)][j - (nxt[i] - i)][r]) % MOD;
			}
		}
	}
	
	printf("%d\n", dp[0][0][k]);
	
	return 0;
}


Measured memory_bytes: 112716
fn read() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().unwrap()
}

fn main() {
    let a = read();
    let b = read();
    let h = read();

    println!("{}", (a + b) * h / 2);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <functional>

using namespace std;

int main()
{
    int H, W;
    cin>>H>>W;
    vector<string> S(H);
    for (string &s: S)
        cin>>s;

    vector<vector<bool>> V(H, vector<bool>(W));
    long long ans = 0;

    for (int p=0; p<2; p++)
    for (int y=0; y<H; y++)
    for (int x=0; x<W; x++)
    if (!V[y][x])
    {
        int b = 0;
        int w = 0;

        function<void(int, int)> f = [&](int x, int y)
        {
            if (((x+y+p)%2==0) ^ (S[y][x]=='.'))
                return;

            if (V[y][x])
                return;

            V[y][x] = true;
            if (S[y][x]=='#')
                b++;
            else
                w++;

            for (int d=0; d<4; d++)
            {
                int dx = d==0 ? 1 : d==1 ? -1 : 0;
                int dy = d==2 ? 1 : d==3 ? -1 : 0;
                int tx = x + dx;
                int ty = y + dy;
                if (0<=tx && tx<W && 0<=ty && ty<H)
                    f(tx, ty);
            }
        };

        f(x, y);
        ans += (long long)b*w;
    }
    cout<<ans<<endl;
}


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

int n;
int g[20][20];
int res = 0;
int main(){
    cin >> n;
    for(int i = 0;i<n;i++){
        for(int j = 0;j < n;j++){
            g[i][j] = -1;
        }
    }
    for(int i = 0;i<n;i++){
        int num;
        cin >> num;
        for(int j = 0;j<num;j++){
            int a,b;
            cin >> a >> b;
            --a;
            g[i][a] = b;
        }
    }
    int i = 0;
    int index1 = 0;
    for(i = 0;i < 1<<n;i++){
        vector<int> d(20);
        for(int j = 0;j<n;j++){
            if(i>>j&1) d[j] = 1;
        }
        bool ok = true;
        for(int j = 0;j<n;j++){
            if(d[j]){
                for(int k = 0;k<n;k++){
                    if(g[j][k] == -1) continue;
                    if(g[j][k] != d[k]){
                        ok = false;
                        break;
                    }
                }
            }
        }
        if(ok) {
            res = max(res,__builtin_popcount(i));
        }
                
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

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


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf_char=vector<vector<char>>;
using Graf_int=vector<vector<int>>;
#define MAX 100000

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> s(m),c(m);
    rep(i,m){
        cin >> s[i] >> c[i];
    }
    vector<int> num(n,-1);
    rep(i,m){
        if(num[s[i]-1]!=-1){
            if(num[s[i]-1]!=c[i]){
                cout << -1 << endl;
                return 0;
            }
        }
        else{
            num[s[i]-1]=c[i];
            if(s[i]-1==0&&c[i]==0&&n>1){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    rep(i,n){
        if(n>1&&i==0&&num[i]==-1){
            cout << 1;
        }else if(num[i]==-1){
            cout << 0;
        }else{
            cout << num[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-

import sys
import os

#input_text_path = __file__.replace('.py', '.txt')
#fd = os.open(input_text_path, os.O_RDONLY)
#os.dup2(fd, sys.stdin.fileno())

a, b = list(map(int, input().split()))
if a > b:
    print('a > b')
elif a == b:
    print('a == b')
else:
    print('a < b')

Measured memory_bytes: 7576
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}


signed main() {
	int n, a, b=1,ans=1;
	cin >> n;
	ans = modpow(3, n);
	rep(i, n) {
		cin >> a;
		if (a % 2 == 0) {
			b *= 2;
		}
	}
	cout << ans-b << endl;
}


Measured memory_bytes: 384
# ABC154e


def main():
    import sys
    import math
    input = sys.stdin.readline
    sys.setrecursionlimit(10 ** 6)
    # 再帰関数を使わない限りPypyで出すこと

    n = int(input())
    ns = str(n)
    k = int(input())
    keta = len(ns)

    if keta < k:
        print(0)
        exit(0)

        # dp[i+1][smaller][j]=i桁目までで、未満フラグをsmaller、0の個数j
    dp = [[[0]*(keta+1) for i in range(2)]
          for j in range(keta + 1)]

    dp[0][0][0] = 1

    for i in range(keta):
        for smaller in range(2):
            for j in range(i+1):
                for x in range(10 if smaller == 1 else int(ns[i])+1):
                    # if i == 0 and x == 0:
                    #    continue
                    dp[i + 1][1 if smaller == 1 or x < int(ns[i])
                              else 0][j if x != 0 else j+1] += dp[i][smaller][j]
    # print(dp)
    # print(dp[keta][0][keta-k])
    #print(dp[keta][1][keta - k])
    print(dp[keta][0][keta-k]+dp[keta][1][keta - k])


if __name__ == '__main__':
    main()


Measured memory_bytes: 42096
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, A[10005];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> N;
    REP(i, N) cin >> A[i];

    int ans = 0;
    REP(i, N) {
        while (A[i] % 2 == 0) {
            A[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#define ll long long
#define lowbit(x) (x&-x)
using namespace std;
const int N = 23, mod = 1e9+7;
int a[N], p[1<<N], f[2][1<<N];
void add(int & x, int y)
{
	x += y;
	if(x>=mod)
	{
		x -= mod;
	}
	return;
}
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 0; i <= n; i++)
	{
		p[1<<i] = i;
	}
	f[0][0] = 1;
	for(int i = 1; i <= n; i++)
	{
		int o = (i&1);
		for(int j = 1; j <= n; j++)
		{
			scanf("%d", &a[j]);
		}
		for(int s = 1; s < (1<<n); s++)
		{
			int sum = 0;
			for(int ss = s; ss; ss -= lowbit(ss))
			{
				if(a[p[lowbit(ss)]+1])
				{
	                add(sum, f[o^1][s^lowbit(ss)]);
	            }
			}
			f[o][s] = sum;
		}
	}
	printf("%d\n", f[n&1][(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 28928
MOD = 998244353

n = int(input())
A = [int(input()) for _ in range(n)]

S = sum(A)
memo0 = [0] * (S+1)
memo1 = [0] * (S+1)
memo0[0] = 1
memo1[0] = 1


# なんで大きい方から小さくしていくのか
def dp0():
    for i in range(n):
        for s in range(S, A[i]-1, -1):
            memo0[s] = (memo0[s] + memo0[s-A[i]]*2) % MOD


# 辺を2グループにわけるDP
def dp1():
    for i in range(n):
        for s in range(S, A[i]-1, -1):
            memo1[s] = (memo1[s] + memo1[s-A[i]]) % MOD


dp0()
dp1()
# 実装方法を変える
ans = pow(3, n, MOD)
# 解から三角形が存在しない通りを引く
for l in range(0, S//2+1):
    ans = (ans - memo0[l]*3) % MOD
# 引きすぎた分を引く
if S % 2 == 0:
    ans = (ans + memo1[S//2]*3) % MOD


print(ans)


Measured memory_bytes: 42520
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 131072
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 2147483647;
//__gcd(a,b), __builtin_popcount(a);

int n;
ll dat[MAX*2], add[MAX*2];
void init(int m){
	n = 1;
	while(n < m)n *= 2;
	for(int i = 0;i < 2*n;i++)dat[i] = INF;
	for(int i = 0;i < 2*n;i++)add[i] = -1;
}

void lazy_update(int k){
	if(add[k] == -1)return;
	if(k < n-1){
		add[k*2+1] = add[k];
		add[k*2+2] = add[k];
	}
	add[k] = -1;
}

ll update(int a, int b, int x, int k, int l, int r){
	if(add[k] != -1)dat[k] = add[k];
	if(r <= a || b <= l)return dat[k];
	if(a <= l && r <= b){
		add[k] = dat[k] = x;
		lazy_update(k);
		return dat[k];
	}
	lazy_update(k);
	ll vl = update(a, b, x, k*2+1, l, (l+r)/2);
	ll vr = update(a, b, x, k*2+2, (l+r)/2, r);
	dat[k] = min(vl, vr);
	return dat[k];
}

ll find(int a, int b, int k, int l, int r){
	if(r <= a || b <= l)return INF;
	if(a <= l && r <= b){
		if(add[k] != -1){
			dat[k] = add[k];
		}
		lazy_update(k);
		return dat[k];
	}
	if(add[k] != -1)dat[k] = add[k];
	lazy_update(k);
	ll vl = find(a, b, k*2+1, l, (l+r)/2);
	ll vr = find(a, b, k*2+2, (l+r)/2, r);
	return min(vr, vl);
}

int main(){
	int m, q, c, s, t, x;
	scanf("%d%d", &m, &q);
	init(m);
	while(q--){
		scanf("%d", &c);
		if(c == 0){
			scanf("%d%d%d", &s, &t, &x);
			update(s, t+1, x, 0, 0, n);
		}else{
			scanf("%d%d", &s, &t);
			ll ans = find(s, t+1, 0, 0, n);
			printf("%lld\n", ans);
		}
	}
	return 0;
}



Measured memory_bytes: 7308
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const int maxn = 3005;
ll dp[maxn][maxn][4];
int good[maxn][maxn];
int main() {
#ifdef LOCAL
    freopen("in1.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
#endif

    ll r, c, k;
    cin >> r >> c >> k;
    for(int i = 0; i < k; i++){
        ll x, y, z;
        cin >> x >> y >> z;
        good[x][y] = z;
    }
//    for(int i = 1; i <= c + 1; i++){
//        for(int j = 0; j <= 3; j++) {
//            dp[r + 1][i][j] = 0;
//        }
//    }
//    for(int i = 1; i <= r + 1; i++){
//        for(int j = 0; j <= 3; j++) {
//            dp[i][c + 1][j] = 0;
//        }
//    }




        for(int j = r; j >= 1; j--){

            for(int q = c; q >= 1; q--){for(int i = 0; i <= 3; i++){
                if(i > 0 and good[j][q] > 0){
                    dp[j][q][i] = max(dp[j+1][q][3] , dp[j][q+1][i-1]) + good[j][q];
                    dp[j][q][i] = max(dp[j][q][i] , dp[j+1][q][3]);
                    dp[j][q][i] = max(dp[j][q][i] , dp[j][q+1][i]);
                }
                else {
                    dp[j][q][i] = max(dp[j+1][q][3] , dp[j][q+1][i]);
                }
            }
        }
    }

    ll ans = dp[1][1][3];
//    ll ans = -1;
//    for(int i = 0; i < 4; i++){
//        ans = max(ans , dp[1][1][i]);
//    }
//    ll tmp[6][6];
//    memset(tmp, -1, sizeof(tmp));
//    for(int i = 1; i <= 2; i++){
//        for(int j = 1; j <= 5; j++){
//            for(int q = 0; q <= 3; q++){
//                tmp[i][j] = max(tmp[i][j] , dp[i][j][q]);
//            }
//        }
//    }
    //cout << dp[1][2][1] ;
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 320444
A, B = map(int,input().split())

Amin = A/0.08
if Amin != int(Amin):
  Amin = int(Amin)+1
else:
  Amin = int(Amin)

Bmin = B/0.1
if Bmin != int(Bmin):
  Bmin = int(Bmin)+1
else:
  Bmin = int(Bmin)

rangea = set(range(Amin,int((A+1)/0.08),1))
rangeb = set(range(Bmin,int((B+1)/0.10),1))

intersection = rangea & rangeb

if len(intersection)==0:
  print(-1)
else:
  print(min(intersection))

Measured memory_bytes: 3064
import sys
input = lambda: sys.stdin.readline().rstrip()

x, y = map(int, input().split())
for i in range(x + 1):
    a = i
    b = x - i
    if 2*a + 4*b == y:
        print("Yes")
        sys.exit()
    #print(a, b)
print("No")


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

int main(){
	int C[6] = {500, 100, 50, 10, 5, 1};	// 0:500円 1:100円 2:50円 3:10円 4:5円 5:1円
	int price;
	int change = 1000;
	int coin = 0;
	
	for(;;){
		change = 1000;
		coin = 0;
		cin >> price;
		if(price == 0)	break;
		change -= price;
	
		for(int i = 0; i < 6; i++){
			coin += change / C[i];
			change %= C[i];
		}
	
		cout << coin << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    multiset<ll> st;

    rep(i,n) {
        if (st.empty()) st.insert(a[i]);
        else {
            auto itr = st.lower_bound(a[i]);
            if (itr == st.begin()) st.insert(a[i]);
            else {
                --itr;
                st.erase(itr);
                st.insert(a[i]);
            }
        }
    }

    cout << st.size() << '\n';
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = std::pair<int, int>;

int main(int argc, char *argv[])
{
    int N, M, C;
    std::cin >> N >> M >> C;

    std::vector<int> B(M);
    for (int i = 0; i < M; i++) {
        std::cin >> B[i];
    }

    int A[N][M];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            std::cin >> A[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int tmp = 0;
        for (int j = 0; j < M; j++) {
            tmp += A[i][j] * B[j];
        }
        tmp += C;
        if (tmp > 0) {
            ans++;
        }
    }

    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <functional>
#include <stdlib.h>
#include <climits>
#include <iomanip>
#include <complex>
#include <cmath>
using namespace std;
signed main(void)
{
	int n;
	int a[2][100];
	cin >> n;
	int tmp;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		if (i == 0)a[0][i] = tmp;
		else a[0][i] = a[0][i - 1] + tmp;
	}
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		if (i == 0)a[1][i] = tmp;
		else a[1][i] = a[1][i - 1] + tmp;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int now;
		if (i != 0) now = a[0][i] + (a[1][n - 1] - a[1][i - 1]);
		else now = a[0][i] + a[1][n - 1];
		if (now > ans)ans = now;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> S;
    REP(i, S.size() - 1) {
        if (S[i] == S[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    REP(i, S.size() - 2) {
        if (S[i] == S[i + 1] || S[i] == S[i + 2] || S[i + 1] == S[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

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

int main() {
  string input;
  cin >> input;
  
  map<string, int> day;
  day["SUN"] = 0;
  day["MON"] = 1;
  day["TUE"] = 2;
  day["WED"] = 3;
  day["THU"] = 4;
  day["FRI"] = 5;
  day["SAT"] = 6;
  
  cout << 7 - day.at(input) << endl;
}

Measured memory_bytes: 256
// ALDS1_1_D	Maximum profit
// 2018.3.20

#include <stdio.h>

int main (void){

  int i, n, max, min, R;
  max = 1 - 1000000000;

  scanf("%d\n", &n);
  scanf("%d\n", &min);

  for(i = 2; i <= n; i++)
    {
      scanf("%d\n", &R);
      if(max < R - min){ max = R - min;}
      if(min > R){ min = R;}
    }
  printf("%d\n", max);
  return 0;
}



Measured memory_bytes: 2092
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF (1<<29)
 
int N, M;
vector<int> s, d;
int dp[110][1<<15];
int cost[1<<15];
 
int calc(int S, int D)
{
    return abs(cost[S] - D);
}
 
int solve(int m, int S)
{
    if (m == M) return 0;
   
    int &res = dp[m][S];
    if (res != -1) return res;
   
    res = INF;
    res = min(res, solve(m + 1, S) + calc(S, d[m]));    
    for (int i = 0; i < N; i++) {
        if (S >> i & 1) continue;
        res = min(res, solve(m, S|(1<<i)));    
    }
    return res;
}
 
void calc_cost()
{
    for (int i = 0; i < (1<<N); i++) {
        cost[i] = 0;
        for (int j = 0; j < N; j++) {
            if (i >> j & 1) {
                cost[i] += s[j];
            }
        }
    }
}
 
int main()
{
    while (cin >> N >> M, (N | M)) {
        s.clear(); s.resize(N);
        d.clear(); d.resize(M);
 
        for (int i = 0; i < N; i++) {
            cin >> s[i];
        }
 
        for (int i = 0; i < M; i++) {
            cin >> d[i];
        }
 
        sort(d.begin(), d.end());
     
        calc_cost();
        memset(dp, -1, sizeof(dp));
        cout << solve(0, 0) << endl;
    }
    return 0;
}

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

class disjointset {

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

	void makeset(int x) {
		p[x] = x;
		rank[x] = 0;
	}

	bool same(int a, int b) {
		return findset(a) == findset(b);
	}

	void unite(int a, int b) {
		link(findset(a), findset(b));
	}

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

	int findset(int x) {
		if (p[x] == x)
			return x;
		else
			return p[x] = findset(p[x]);
	}

};

int main() {
	int n, q;
	cin >> n >> q;
	disjointset DS = disjointset(n);
	for (int i = 0; i < q; i++) {
		int cmd, x, y;
		cin >> cmd >> x >> y;
		if (cmd == 0) {
			DS.unite(x, y);
		} else {
			cout << DS.same(x, y) << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3180
from math import gcd
import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)

K = int(input())

ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += gcd(gcd(i,j), k)
print(ans)


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

int main(){
    int n = 0;
    string s;
    while (cin >> s){
        bool f = 1;
        for (int i = 0, j = s.size() - 1; i < j; i++, j--){
            if (s[i] != s[j]){
                f = 0; break;
            }
        }
        n += f;
    }
    cout << n << endl;
}

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

int main(){
    long long n,k;
    cin>>n>>k;
    long long ans = 0;
    if(n>=k) {
        long long N=n/k;
        ans+=N*N*N;
        if(k%2==1){
            cout<<ans<<endl;
            return 0;
        }
        long long a=k/2;
            long long A=(a<=n%k?n/k+1:n/k);
            ans+=A*A*A;
    }
    else{
        if(k%2==0&&n>=k/2)++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

string S;
string T;

int nxt[100010][26];

void chmin(int &a,int b){
  if(a>b) a=b;
}

int main(){
  cin>>S;
  cin>>T;
  int N=S.size();
  int M=T.size();

  for(int i=0;i<=N;i++) for(int j=0;j<26;j++) nxt[i][j]=N;
  for(int i=N-1;i>=0;i--){
    for(int j=0;j<26;j++){
      chmin(nxt[i][j],nxt[i+1][j]);
    }
    nxt[i][S[i]-'a']=i;
  }

  for(int i=0;i<M;i++){
    if(nxt[0][T[i]-'a']==N){
      cout<<-1<<endl;
      return 0;
    }
  }

  ll ans=0;
  ll v=0;
  int now=0;
  for(int i=0;i<M;i++){
    if(nxt[now][T[i]-'a']<N){
      now=nxt[now][T[i]-'a']+1;
      if(i==M-1){
        v=now;
        break;
      }
      if(now==N){
        ans++;
        now=0;
      }
    }else{
      now=0;
      ans++;
      i--;
    }
  }

  cout<<ans*N+v<<endl;

  return 0;
}


Measured memory_bytes: 10752
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
#include <atcoder/all>
using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int max2 (int a, int b) { return max(a, b); }
int e () { return -1; }
int v;
bool chk (int x) { return x < v; }

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, q; cin >> n >> q;
    vector<int> vec(n);
    rep (i, n) cin >> vec[i];
    segtree<int, max2, e> seg(vec);
    rep (_, q) {
        int t, a, b; cin >> t >> a >> b;
        if (t == 1) {
            a--;
            seg.set(a, b);
        } else if (t == 2) {
            a--;
            cout << seg.prod(a, b) << "\n";
        } else if (t == 3) {
            a--; v = b;
            cout << seg.max_right<chk>(a) + 1 << "\n";
        }
    }
    /***************************************************/
    /* Submit this code from the browser if using ACL! */
    /***************************************************/
    return 0;
}


Measured memory_bytes: 6116
#include <bits/stdc++.h>
using namespace std;
int n;
string s[1005];
int main()
{
    scanf("%d %*d", &n);
    for (int i = 1; i <= n; i++)
        cin >> s[i];
    sort(s + 1, s + n + 1);
    for (int i = 1; i <= n; i++)
        cout << s[i];
    return 0;
}

Measured memory_bytes: 256
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine();
        var num = ToInt32(input);
        var sub = ToInt32(input.Substring(1, 2));
        if (sub <= 11 *(num / 100)) WriteLine((num / 100) * 100 + 11 * (num / 100));
        else WriteLine((num / 100 + 1) * 100 + 11 * (num / 100 + 1));
    }
}

Measured memory_bytes: 11220
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

// AC
public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0; i<n; i++){
			double x1=sc.nextDouble();
			double y1=sc.nextDouble();
			double x2=sc.nextDouble();
			double y2=sc.nextDouble();
			double x3=sc.nextDouble();
			double y3=sc.nextDouble();

			double a1=2*(x2-x1);
			double b1=2*(y2-y1);
			double c1=x1*x1-x2*x2+y1*y1-y2*y2;
			double a2=2*(x3-x1);
			double b2=2*(y3-y1);
			double c2=x1*x1-x3*x3+y1*y1-y3*y3;

			double x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
			double y=(c1*a2-c2*a1)/(a1*b2-a2*b1);

			double r=Math.sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y));
			println(String.format("%.3f %.3f %.3f", x, y, r));
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 12000
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N = input()
    N = str(N)
    Sa = N.count("A")
    if Sa == 1 or Sa == 2:
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
	main()

Measured memory_bytes: 38256
// SeeAlso: https://atcoder.jp/contests/abc154/tasks/abc154_e
// https://atcoder.jp/contests/abc154/submissions/10009856

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int k;
string n;


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

    int l = n.size();

    ll dp[105][4][2];
    memset(dp, 0, sizeof(dp));

    dp[0][0][0] = 1;

    FOR(i, 1, l+1) {
        rep(j, k+1) {
		    if(n[i - 1] == '0'){
				dp[i][j][0] = dp[i - 1][j][0];
				dp[i][j][1] = dp[i - 1][j][1];
				if(j > 0){
					dp[i][j][1] += 9*dp[i - 1][j - 1][1];
				}
			}else if(j > 0){
				dp[i][j][0] = dp[i - 1][j - 1][0];
				dp[i][j][1] = 9*dp[i - 1][j - 1][1] + dp[i - 1][j][0] + dp[i - 1][j][1] + (n[i - 1] - '1')*dp[i - 1][j - 1][0];
			}else{
				dp[i][j][0] = 0;
				dp[i][j][1] = dp[i - 1][j][0] + dp[i - 1][j][1];
			}
		}
    }

    ll ans = dp[l][k][0] + dp[l][k][1];
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>

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

using namespace std;



int main () {
  std::cin.tie(0); // tie
  std::ios::sync_with_stdio(false); // sync

  list<int> data;
  list<int>::iterator it;
  int key, n, i;
  string command;
  
  cin >> n;
  rep(i,n) {
    cin >> command;
    if (command == "insert") {
      cin >> key;
      data.push_front(key);
    } else if (command == "delete") {
      cin >> key;
      it = data.begin();
      while(it != data.end()) {
	if (*it == key) {
	  data.erase(it);  break;
	}
	it++;
      }
    } else if (command == "deleteFirst") {
      data.pop_front();
    } else if (command == "deleteLast") {
      data.pop_back();
    }
  }
  
  it = data.begin();
  while (it != data.end()) {
    cout << *it;
    it++;
    if (it != data.end()) cout << " ";
  }
  cout << endl;
  
  return 0;
}
  

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 90000000000000000;
int PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

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

    UnionFind(int N):par(N),rank(N){
        for(int i = 0;i < N;i++){
          par[i] = i;
          rank[i] = 0;
        }
    }

    int root(int x){
       while(x != par[x]){
        x =  par[x] = par[par[x]];
       }
       return x;
    }

    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)return;
        if(rank[x] > rank[y]){
          par[y] = rx;
        }
        if(rank[x] < rank[y]){
          par[rx] = ry;
        }else{
          par[ry] = rx;
          if(rank[x] == rank[y]){
            rank[rx]++;
          }
        }
    }

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


int main(){
  int N,M;cin >> N >> M;
  vector<int> P(N);
  for(int i = 0;i < N;i++){
    cin >> P[i];P[i]--;
  }
  UnionFind U(N);
  for(int i = 0;i < M;i++){
    int a,b;cin >> a >> b;
    a--;b--;
    U.unite(P[a],P[b]);
  }
  int ans = 0;
  for(int i = 0;i < N;i++){
    if(U.same(i,P[i])){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408