akhauriyash/Code-Regression huggingface dataset:
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
 
using namespace std;

int main(){

	long long n;
	cin>>n;

	vector<long long> a(n);
	int two[3]={};
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%4 == 0) two[2]++;
		else if(a[i]%2==0) two[1]++;
		else two[0]++;
	}

	vector<int> b;
	for(int i=0;i<3;i++){
		if(two[i]!=0){
			two[i]--;
			b.push_back(1<<i);
			break;
		}
	}

	for(int i=1;i<n;i++){
		bool ok=false;
		for(int j=0;j<3;j++){
			if(two[j]==0) continue;

			if( (b[i-1]*(1<<j))%4==0 ){
				two[j]--;
				b.push_back(1<<j);
				ok=true;
				break;
			}
		}

		if(!ok) break;
	}

	if(b.size()==n){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}


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

int main() {
	int N;
	cin >> N;
	int ma,H,count;
	count=1;
	cin >>H;
	ma=H;
	for(int i=1;i<N;i++){
		cin >>H;
		if(H>=ma){
			ma=H;
			count++;
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<iomanip>

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

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<pair<double, double> > town(n);
  for(int i=0;i<n;i++){
    double x, y;cin>>x>>y;
    town[i]=make_pair(x, y);
  }
  double ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<i;j++){
      pair<double, double> &t1=town[i];
      pair<double, double> &t2=town[j];
      ans += sqrt(pow(t1.first-t2.first, 2)+pow(t1.second-t2.second, 2));
    }
  }
  ans *= double(2)/n;
  cout<<fixed<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  
  if(a>=b){
    if((a-b)%2 == 0){
      printf("%d\n",(a+b)/2);
    }else{
      printf("IMPOSSIBLE");
    }
  }else{
    if((b-a)%2 == 0){
      printf("%d\n",(b+a)/2);
    }else{
      printf("IMPOSSIBLE");
    }
  }
  return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
class SegmentTree{
	T def_value;
	int last_num;
	vector<T> element,lazy;
	vector<bool> lazy_flag;
public:
	SegmentTree(vector<T>& vec,T def):def_value(def){
		int N=vec.size();
		last_num=1;
		while(last_num<N) last_num <<= 1;
		element.resize(2*last_num-1,def);
		lazy.resize(2*last_num-1,0);
		lazy_flag.resize(2*last_num-1,false);

		for(int i=0;i<N;i++){
			element[i+last_num-1] = vec[i];
		}
		for(int i=last_num-2;i>=0;i--){
			element[i] = min(element[2*i+1],element[2*i+2]);
		}
	}
	void Evaluate(int index,int left,int right){
		if(!lazy_flag[index]) return;
		element[index] = lazy[index];
		if(right-left>1){
			lazy[2*index+1] = lazy[index];
			lazy[2*index+2] = lazy[index];
			lazy_flag[2*index+1] = lazy_flag[2*index+2] = true;
		}
		lazy[index] = 0;
		lazy_flag[index] = false;
	}
	void UpdateRange(int left,int right,T x,int index=0,int vleft=0,int vright=-1){
		if(vright<0) vright = last_num;
		Evaluate(index,vleft,vright);

		if(vright<=left || right<=vleft) return;
		if(left<=vleft && vright<=right){
			lazy[index] = x;
			lazy_flag[index] = true;
			Evaluate(index,vleft,vright);
		}
		else{
			UpdateRange(left,right,x,2*index+1,vleft,(vleft+vright)/2);
			UpdateRange(left,right,x,2*index+2,(vleft+vright)/2,vright);
			element[index] = min(element[2*index+1],element[2*index+2]);
		}
	}
	void Update(int index,T x){
		int i=last_num+index-1;
		element[i] = x;
		while(i>0){
			i = (i-1)/2;
			element[i] = element[2*i+1]+element[2*i+2];
		}
	}
	// left<right
	T Find(int left,int right,int index=0,int vleft=0,int vright=-1){
		if(vright<0) vright = last_num;
		if(vright<=left || right<=vleft) return def_value;

		Evaluate(index,vleft,vright);
		if(left<=vleft && vright<=right) return element[index];

		T res_left = Find(left,right,2*index+1,vleft,(vleft+vright)/2);
		T res_right = Find(left,right,2*index+2,(vleft+vright)/2,vright);
		return min(res_left,res_right);
	}
};

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

	auto N=in(),Q=in();
	vector<ll> A(N,(1LL<<31)-1);
	SegmentTree<ll> tree(A,(1LL<<31)-1);

	REP(i,Q){
		int q=in();
		if(q==1){
			int x=in();
			out(tree.Find(x,x+1));
		}
		else{
			int s=in(),t=in(),x=in();
			tree.UpdateRange(s,t+1,x);
		}
	}

	return 0;
}



Measured memory_bytes: 8004
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
 
int main()
{
  ll n,i,j,a,b,m=1e18;
  cin>>n;
  ll arr[n+5];
  for(i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  if(count(arr,arr+n,0))
    cout<<"0";
  else
  {
    unsigned ll p=1;
    for(i=0;i<n;i++)
    {
      if(p>(m)/arr[i])
      {
        cout<<"-1";
        exit(0);
      }
      p*=arr[i];
    }
    if(p<=m)
    cout<<p;
    else
    cout<<"-1";
  }
  return 0;
}


Measured memory_bytes: 4396
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#include<vector>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,first[100010],dep[100010],cnte=-1,cur[100010];
struct edge{
	int to,next,w;
}a[600010];
inline void add(int u,int v,int w){
	a[++cnte]=(edge){v,first[u],w};first[u]=cnte;
	a[++cnte]=(edge){u,first[v],w};first[v]=cnte;
}
vector<int>e[100010];
void getd(int u,int f){
	int i,v;dep[u]=dep[f]+1;
	if(dep[u]&1){
		add(0,u,1);
		if(f) add(u,f,1);
	}
	else{
		add(u,n+1,1);
		if(f) add(f,u,1);
	}
	for(i=0;i<e[u].size();i++) if((v=e[u][i])!=f) getd(v,u);
}
int q[100010],head,tail;
bool bfs(int s,int t){
	int i,u,v;head=0,tail=1;
	for(i=s;i<=t;i++) dep[i]=-1,cur[i]=first[i];
	dep[s]=0;q[0]=s;
	while(head<tail){
		u=q[head++];
		for(i=first[u];~i;i=a[i].next){
			v=a[i].to;if(~dep[v]||!a[i].w) continue;
			dep[v]=dep[u]+1;q[tail++]=v;
		}
	}
	return ~dep[t];
}
int dfs(int u,int t,int lim){
	if(u==t||!lim) return lim;
	int i,v,f,flow=0;
	for(i=cur[u];~i;i=a[i].next){
		v=a[i].to;cur[u]=i;
		if(dep[v]==dep[u]+1&&(f=dfs(v,t,min(lim,a[i].w)))){
			flow+=f;lim-=f;
			a[i].w-=f;a[i^1].w+=f;
			if(!lim) return flow;
		}
	}
	return flow;
}
int dinic(int s,int t){
	int re=0;
	while(bfs(s,t)) re+=dfs(s,t,1e9);
	return re;
}
int main(){
	memset(first,-1,sizeof(first));
	n=read();int i,t1,t2;
	for(i=1;i<n;i++){
		t1=read();t2=read();
		e[t1].push_back(t2);
		e[t2].push_back(t1);
	}
	getd(1,0);
	if(dinic(0,n+1)*2==n) puts("Second");
	else puts("First");
}

Measured memory_bytes: 14464
#include<bits/stdc++.h>
#define endl '\n'
#define eb emplace_back
#define MAX (int)1e5 + 5
#define vi vector<int>
#define pii pair<int,int>
#define ok cerr<<"ok"<<endl
#define bb binary_search
#define all(A) A.begin(),A.end()
#define mp make_pair
#define pb push_back
#define inf INT_MAX/2
#define fi first
#define se second
#define vi vector<int>
#define int  long long 
using namespace std;



int32_t main() {
	int n,x;
	vi v;
	cin >> n;
	for(int i = 0; i<n; i++){
		cin >> x;
		v.pb(x);
	}
	int sum = 0;
	for(int i = 1; i<n; i++){
		if(v[i] < v[i-1]){
			int dif = v[i-1] - v[i];
			sum += dif;
			v[i]+=dif;
		}
	}
	cout << sum << endl;
	return 0;
} 

Measured memory_bytes: 5340
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] array = new int[n];
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            array[i] = Integer.parseInt(sc.next());
            if (min > array[i]) {
                min = array[i];
            }
            if (max < array[i]) {
                max = array[i];
            }
        }
        System.out.println(Math.abs(max - min));
    }
}


Measured memory_bytes: 23764
class DisjointSetUnion():
    def __init__(self, n):
        self.n = n
        self.par_size = [-1] * n

    def merge(self, a, b):
        assert 0 <= a < self.n
        assert 0 <= b < self.n
        x = self.leader(a)
        y = self.leader(b)
        if x == y: return x
        if -self.par_size[x] < -self.par_size[y]: x, y = y, x
        self.par_size[x] += self.par_size[y]
        self.par_size[y] = x
        return x

    def same(self, a, b):
        assert 0 <= a < self.n
        assert 0 <= b < self.n
        return self.leader(a) == self.leader(b)

    def leader(self, a):
        assert 0 <= a < self.n
        x = a
        while self.par_size[x] >= 0:
            x = self.par_size[x]
        while self.par_size[a] >= 0:
            self.par_size[a] = x
            a = self.par_size[a]
        return x

    def size(self, a):
        assert 0 <= a < self.n
        return -self.par_size[self.leader(a)]

    def groups(self):
        leader_buf = [0] * self.n
        group_size = [0] * self.n
        res = [[] for _ in range(self.n)]
        for i in range(self.n):
            leader_buf[i] = self.leader(i)
            group_size[leader_buf[i]] += 1
        for i in range(self.n):
            res[leader_buf[i]].append(i)
        res = [res[i] for i in range(self.n) if res[i]]
        return res

import sys
input = sys.stdin.buffer.readline

N, Q = map(int, input().split())

dsu = DisjointSetUnion(N)
res = []

for _ in range(Q):
    t, u, v = map(int, input().split())
    if t:
        res.append(str(int(dsu.same(u, v))))
    else:
        dsu.merge(u, v)

print('\n'.join(res))

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int R0, W0, C, R;

void solve() {
    rep(i, 100000) {
        int r = R0 + i * R;
        double Y = 1.0 * (r - C * W0) / C;
        if (Y >= 0) {
            cout << i << endl;
            break;
        }
    }
}

int main() {
    while (cin >> R0 >> W0 >> C >> R, R0) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3064
n = int(input())
ans = 0
c_1 = 0
c_2 = 0
c_3 = 0
for _ in range(n):
    tmp = input()
    for i in range(len(tmp)-1):
        if tmp[i:i+2] ==  'AB':
            ans += 1
    if tmp[0] == 'B' and tmp[-1] == 'A':
        c_1 += 1
    elif tmp[0] == 'B':
        c_2 += 1
    elif tmp[-1] == 'A':
        c_3 += 1
if c_1 == 0:
    ans += min(c_2,c_3)
else:
    if c_2 + c_3 > 0:
        ans += c_1 + min(c_2,c_3)
    else:
        ans += c_1 - 1
print(ans)


Measured memory_bytes: 3064
package main

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

func main() {
	n := readi()
	m := readi()

	if n == 1 && m == 1 {
		fmt.Println(1)
		return
	}

	if n == 1 {
		fmt.Println(m - 2)
		return
	}

	if m == 1 {
		fmt.Println(n - 2)
		return
	}

	fmt.Println((n * m) - n - n - m - m + 4)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

// func searchInts(a []int, k int) int {
// 	return binarySearch(len(a), func(i int) bool {
// 		return a[i] >= k
// 	})
// }

func binarySearch(n int, f func(int) bool) int {
	i, j := 0, n
	for i < j {
		h := int(uint(i+j) >> 1)
		if !f(h) {
			i = h + 1
		} else {
			j = h
		}
	}
	return i
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

int main() {
	int N;
	cin >> N;

	unordered_map<int, int> A;
	long long sum = 0;
	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A[a]++;
		sum += a;
	}

	int Q;
	cin >> Q;
	vector<int> B(Q);
	vector<int> C(Q);
	for(int i = 0; i < Q; i++) {
		cin >> B[i] >> C[i];
	}

	long long result = sum;
	for(int i = 0; i < Q; i++) {
		const int b = B[i];
		const int c = C[i];
		
		if(A.find(b) != A.end()) {
			A[c] += A[b];
			result += (c - b) * A[b];
			A[b] = 0;
		}
		
		cout << result << endl;
	}

	return 0;
}


Measured memory_bytes: 7508
h,w=map(int,input().split())
data=[]
count_x=[0]*w
count_y=[0]*h
for i in range(h):
    a_i=input()
    for j in range(w):
        if a_i[j]=="#":
            count_y[i]+=1
            count_x[j]+=1
    data.append(a_i)
for i in range(h):
    if count_y[i]!=0:
        data_i=data[i]
        ans=""
        for j in range(w):
            if count_x[j]!=0:
                ans+=data_i[j]
        print(ans)

Measured memory_bytes: 3064
#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--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int low[101], col[101];

int main(){
    int h, w;
    cin >> h >> w;
    char c[101][101];
    rep(i, h) rep(j, w) cin >> c[i][j];

    int cnt = 0;
    rep(i, h){
        bool flag = true;
        rep(j, w) if (c[i][j] == '#') flag = false;
        if (flag) low[i] = 1;
    }

    rep(j, w){
        bool flag = true;
        rep(i, h) if (c[i][j] == '#') flag = false;
        if (flag) col[j] = 1, cnt++;
    }


    rep(i, h){
        rep(j, w){
            if (!low[i] && !col[j]) cout << c[i][j];
        }
        if(!low[i]) cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
if n == 1:
    ans = a[0] + b[0]
else:
    for i in range(1, n):
        cnt = sum(a[:i]) + sum(b[i-1:])
        ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using i64 = long long;

void no() {
    std::cout << "No" << std::endl;
    exit(0);
}

int main() {
    int n, a, b, c, d;
    std::string s;
    std::cin >> n >> a >> b >> c >> d >> s;
    s = '.' + s;
    while (a != c || b != d) {
        if (a < b) {
            if ((s[b - 1] == '#' || s[b + 1] == '#') && b < d) {
                if (s[b + 1] == '#' && s[b + 2] == '#') no();
                else if (s[b + 1] == '#') b += 2;
                else b++;
            } else {
                if (b - a == 1) {
                    if (s[b + 1] == '#') no();
                    else a += 2;
                } else if (b - a == 2) {
                    if (s[a + 1] == '#') no();
                    else a++;
                }
                else if (s[a + 1] == '#' && s[a + 2] == '#') no();
                else if (s[a + 1] == '#') a += 2;
                else a++;
            }
        } else {
            if (a < c) {
                if (s[a + 1] == '#' && s[a + 2] == '#') no();
                else if (s[a + 1] == '#') a += 2;
                else a++;
            } else {
                if (s[b + 1] == '#' && s[b + 2] == '#') no();
                else if (s[b + 1] == '#') b += 2;
                else b++;
            }
        }
    }
    std::cout << "Yes" << std::endl;

    return 0;
}


Measured memory_bytes: 772
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef pair<int, int> P;
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

string str;
ll ans = 0;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(cin >> str){
		ll t = 0;
		rep(i,str.size()){
			int a = str[i]-'0';
			if(0 <= a && a <= 9) t = t*10+a;
			else{
				if(t != 0){
					ans += t;
					t = 0;
				}
			}
			if(i == str.size()-1 && t != 0) ans += t;
		}
	}
	cout << ans << endl;
}

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

int main() {
  string s;
  int q, t, f;
  char c;
  cin >> s >> q;
  bool isFlip = false;
  deque<char> dq;
  rep(i, s.size()) dq.push_back(s[i]);
  rep(i, q) {
    cin >> t;
    if (t == 1) {
      isFlip = !isFlip;
    } else {
      cin >> f >> c;
      if (f == 1 && !isFlip || f == 2 && isFlip) {
        dq.push_front(c);
      } else {
        dq.push_back(c);
      }
    }
  }
  if (isFlip) {
    rep(i, dq.size()) cout << dq[dq.size() - 1 - i];
    cout << endl;
  } else {
    rep(i, dq.size()) cout << dq[i];
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 896
import sys
input=sys.stdin.readline
n=int(input())
INF=10**9+7
D={}
z=0
import math
for i in range(n):
    a,b=map(int,input().split())
    if a==0:
        if b==0:
            z+=1
        else:
            if (0,1) in D:
                D[(0,1)]+=1
            else:
                D[(0,1)]=1
    elif b==0:
        if (1, 0) in D:
            D[(1,0)] += 1
        else:
            D[(1,0)] = 1
    else:
        if b<0:
            b=-b
            a=-a
        if a>0:
            c=math.gcd(a,b)
            a//=c
            b//=c
            if (a,b) in D:
                D[(a,b)] += 1
            else:
                D[(a,b)] = 1
        else:
            a=-a
            c = math.gcd(a, b)
            a //= c
            b //= c
            a=-a
            if (a, b) in D:
                D[(a, b)] += 1
            else:
                D[(a, b)] = 1
ans=1
p=[1]
for i in range(n):
    temp=(p[-1]*2)%INF
    p.append(temp)
for i in D:
    if not D[i]==0:
        x=i[0]
        y=i[1]
        if x>0:
            if (-y,x) in D:
                temp=D[(-y,x)]
                D[(-y,x)]=0
                ans=(ans*(p[D[i]]+p[temp]-1))%INF
            else:
                ans=ans*p[D[i]]%INF
        else:
            if (y,-x) in D:
                temp=D[(y,-x)]
                D[(y,-x)]=0
                ans=(ans*(p[D[i]]+p[temp]-1))%INF
            else:
                ans=ans*p[D[i]]%INF
if z!=0:
    ans=(z+ans-1)%INF
else:
    ans=(ans-1)%INF
print(ans)



Measured memory_bytes: 123044
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;

  int ans = 180 * (n - 2);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
x = input()
y = []
z = []
n = 0
for i in range(len(x)):
    if x[i] == '\\':
        if n:
            y.append(n)
            n = 0
            if z:
                z.append(-1)
        z.append(i)
    elif x[i] == '/':
        if z:
            while True:
                p = z.pop()
                if p == -1:
                    n += y.pop()
                else:
                    break
            n += i-p
    else:
        pass
if n:
    y.append(n)
for j in range(y.count(0)):
    y.remove(0)
print(sum(y))
print(len(y), *y)




Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define LL long long
#define MOD 1000000007
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int N;
  cin >> N;
  LL sum = 0;
  for (int i = 1; i <= N; ++i)
    {
      int end = (N / i) * i;
      int start = i;
      int num = (end - start) / i + 1;
      sum += (LL)(end + start) * num / 2;
    }
  cout << sum << endl;
  return 0;
}


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

def selection_sort(num_list):
    num_swap = 0
    for i in range(len(num_list)):
        mini = i
        for j in range(i, len(num_list)):
            if num_list[j] < num_list[mini]:
                mini = j
        if i != mini:
            num_list[i], num_list[mini] = num_list[mini], num_list[i]
            num_swap = num_swap + 1
    return num_swap, num_list

def show_list(list):
    i = 0;
    while(i < len(list)-1):
        print(list[i], end=" ")
        i = i + 1
    print(list[i])

num = int(input())
num_list = [int(x) for i, x in enumerate(input().split()) if i < num]
num_swap, num_list = selection_sort(num_list)
show_list(num_list)
print(num_swap)

Measured memory_bytes: 7780
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll N, string S){
  rep(i, S.size()) S.at(i) = (S.at(i) - 'A' + N) % 26 + 'A';
  cout << S << endl;
}

int main() {
  ll N;
    ignore_ret(scanf("%lld",&N));
    string S;
    cin >> S;
  solve(N, S);
  return 0;
}


Measured memory_bytes: 256
//15:40
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;
typedef long long ll;
ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
ll abs(ll a){return(a<0)?-a:a;}

ll gcd(ll a, ll b){
        if(b > a){
                ll tmp = b;
                b = a;
                a = tmp;
        }
        if(b == 0) return a;
        else return gcd(b, a%b);
}
ll lcm(ll a, ll b){
        ll gcdi = gcd(a,b);
        return a/gcdi*(b);
}

#define MOD (1000000000+7)
int s[101];
int main(){
        int N;
        scanf("%d",&N);
        int total = 0;
        for(int i = 0; i < N; i++){
                scanf("%d",s+i);
                total += s[i];
        }
        if(total % 10 != 0){
                printf("%d\n",total);
                return 0;
        }
        sort(s,s+N);
        for(int i = 0; i < N; i++){
                if(s[i] % 10 != 0){
                        printf("%d\n",total-s[i]);
                        return 0;
                }
        }
        puts("0");

}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <sstream>

using namespace std;

int main() {
    int n,m,sum=0,sum2=0;
    cin >> n >> m;
    int k[m],s[m][10],p[m],k2[m];
    for(int i=0;i<m;i++){
      cin >> k[i];
      k2[i]=0;
      for(int j=0;j<k[i];j++){
        cin >> s[i][j];
        k2[i] += (int) pow(2,s[i][j]-1);
      }
    }
    for(int i=0;i<m;i++){
       cin >> p[i];
    }
  
  int a;
    for(int i=0;i<(int)pow(2,n);i++){
      stringstream ss;
     
      ss << bitset<16>(i);
      string sss = ss.str();
      sum=0;
      for(int j=0;j<m;j++){
        a=0;
      stringstream ks;
      ks << bitset<16>(k2[j]);
      string kss = ks.str();
        for(int h=0;h<16;h++){
          if(kss[h]=='1' && sss[h] =='1') a++;
        }
        if(a%2 == p[j] ) sum++;
      }
      if(sum==m) sum2++;
    }
  
  cout << sum2 << endl;
  
  
  
  
 
  
  
}

Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int Mod=998244353;
int n;
#define Maxn 405
int fact[Maxn],inv[Maxn],invfact[Maxn];
int A[Maxn],B[Maxn];
int dp[Maxn][Maxn][Maxn];
int res[Maxn][Maxn];

inline int Fast_Pow(int a,int b){
	int res=1;
	while(b){
		if(b&1)res=1ll*res*a%Mod;
		b>>=1;
		a=1ll*a*a%Mod; 
	}
	return res;
}

inline void rd(int &x){
	x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
}

int main(){
	fact[0]=1;
	for(register int i=1;i<=400;++i)fact[i]=1ll*fact[i-1]*i%Mod;
	inv[0]=inv[1]=1;
	for(register int i=2;i<=400;++i)inv[i]=1ll*(Mod-Mod/i)*inv[Mod%i]%Mod;
	invfact[0]=1;
	for(register int i=1;i<=400;++i)invfact[i]=1ll*invfact[i-1]*inv[i]%Mod;
	dp[0][0][0]=1;
	rd(n);
	int sum1=0,sum2=0,all=0;
	for(register int i=1;i<=n;++i){
		rd(A[i]);rd(B[i]);
		all+=A[i];
	}
	for(register int i=1;i<=n;++i){
	    for(register int j=0;j<=sum2;++j)
	        for(register int k=0;k<=sum1;++k){
	        	dp[i][j][k]=(dp[i][j][k]-dp[i-1][j][k]+Mod)%Mod;
	        	int tmp=1;
	        	for(register int l=0;l<B[i];++l){
	        		dp[i][j+l][k+A[i]]=(dp[i][j+l][k+A[i]]+1ll*tmp*invfact[l]%Mod*dp[i-1][j][k])%Mod;
	        		tmp=1ll*tmp*A[i]%Mod;
				}
			}
		sum1+=A[i];
		sum2+=B[i];
	}
	res[0][0]=1;
	for(register int i=1;i<=n;++i)
	    for(register int j=0;j<=sum1;++j){
	    	res[i][j]=res[i-1][j];
	    	if(j>=A[i])res[i][j]=(res[i][j]-res[i-1][j-A[i]]+Mod)%Mod;
		}
	int Ans=0;
	for(register int i=0;i<=sum2;++i)
	    for(register int j=1;j<=sum1;++j){
	    	int to=Mod-res[n][j];
	    	dp[n][i][j]=1ll*dp[n][i][j]*Fast_Pow(inv[j],i)%Mod;
	    	if(n%2==0)to=(to+1ll*fact[i]*dp[n][i][j])%Mod;
	    	else to=(to-1ll*fact[i]*dp[n][i][j]%Mod+Mod)%Mod;
	    	dp[n][i][j]=to;
		}
	for(register int i=1;i<=sum1;++i)
		for(register int j=sum2;j>=1;--j)
		    dp[n][j][i]=(dp[n][j][i]-dp[n][j-1][i]+Mod)%Mod;
	for(register int i=1;i<=sum2;++i)
	    for(register int j=1;j<=sum1;++j)
		    Ans=(Ans+1ll*dp[n][i][j]*i%Mod*sum1%Mod*inv[j])%Mod; 
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 256896
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    Scanner sc = new Scanner(System.in);

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

    void solve() {
        int H = sc.nextInt();
        int W = sc.nextInt();

        HashMap<Character, Integer> m = new HashMap<>();
        for (int i = 0; i < H; i++) {
            char[] carray = sc.next().toCharArray();
            for (char c : carray) {
                m.put(c, m.containsKey(c) ? m.get(c) + 1 : 1);
            }
        }
        int[] counts = new int[5];
        Arrays.fill(counts, 0);
        for (int v : m.values()) {
            counts[4] += (v / 4);
            v %= 4;
            counts[2] += (v / 2);
            v %= 2;
            counts[1] += v;
        }

        if (W % 2 == 0 && H % 2 == 0) {
            if (counts[1] != 0 || counts[2] != 0) No();
            Yes();
        }

        if (W % 2 == 1 && H % 2 == 1) {
            while (counts[2] < (W - 1)/2 + (H - 1)/2) {
                counts[2] += 2;
                counts[4] -= 1;
            }
            if (counts[1] != 1) No();
            if (counts[2] != (W - 1)/2 + (H - 1)/2) No();
            if (counts[4] != (W - 1)/2 * (H - 1)/2) No();
            Yes();
        }

        int even = (W % 2 == 0) ? W : H;
        int odd = (W % 2 == 1) ? W : H;
        while (counts[2] < even/2) {
            counts[2] += 2;
            counts[4] -= 1;
        }

        if (counts[1] != 0) No();
        if (counts[2] != even/2) No();
        if (counts[4] != (even)/2 * (odd - 1)/2) No();
        Yes();
    }



    void No() {
        System.out.println("No");
        System.exit(0);
    }
    void Yes() {
        System.out.println("Yes");
        System.exit(0);
    }
}
class Utils {
    void swap(int a, int b, int[] array) {
        int c = array[a];
        array[a] = array[b];
        array[b] = c;
    }
    void swap(int a, int b, char[] array) {
        char c = array[a];
        array[a] = array[b];
        array[b] = c;
    }
}

Measured memory_bytes: 23764
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    int count = 0;

    while (a[n-1] > 0) {
      for (int i = 0; i < n; i++) {
        if (a[i]%2 == 0) {
          a[i] /= 2;
        } else {
          System.out.println(count);
          return;
        }
      }
      count++;
    }

  }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN=1e6+69;
const int BASE=2e3;
const int mod = 998244353;
const int INF = 1e9;
int m,k,n,l,q;
map<int,int> check;
int a[MAXN];
int ans[MAXN];
string s;
int luythua(int x, int y){
    if(y==0)return 1;
    if(y==1)return x%mod;
    int k = luythua(x,y/2);
    if(y%2==1)return k*k%mod*(x%mod)%mod;
    return k*k%mod;
}
signed main(){                                                                                                                                                                                                                                                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    m = 100;
    int cnt = 0;
    while(m<n){
        k = m/100;
        m+=k;
        cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 3656
s = input()
if s == "RRR":
    print(3)
elif s == "RRS":
    print(2)
elif s == "SRR":
    print(2)
elif s == "RSS":
    print(1)
elif s == "SRS":
    print(1)
elif s == "SSR":
    print(1)
elif s == "RSR":
    print(1)
else:
    print(0)

Measured memory_bytes: 8976
n=int(input())
v1=map(int,input().split())
v=list(v1)
#価値の低いものから順に平均をとっていけばよい
for i in range(n):
    for j in range(i+1,n):
        if v[i]>v[j]:
            a=v[i]
            v[i]=v[j]
            v[j]=a
for l in range(n-1):
    v2=[]
    a=(v[0]+v[1])/2
    v2.append(a)
    v2=v2+v[2:n]
    v=v2
print(v[0])

Measured memory_bytes: 3064
def main(n, m, cakes)
  return 0 if m == 0

  ans = 0
  [-1, 1].each do |x|
    [-1, 1].each do |y|
      [-1, 1].each do |z|
        cand = cakes.map { |xx, yy, zz| xx * x + yy * y + zz * z }.sort.reverse.take(m).inject(&:+)
        ans = cand if cand > ans
      end
    end
  end
  ans
end

n, m = gets.split(' ').map(&:to_i)
cakes = Array.new(n).map { gets.split(' ').map(&:to_i) }
puts main(n, m, cakes)

Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,m;
ll cx[4]={0,0,1,-1}; char ar[21][21];
ll cy[4]={1,-1,0,0}; ll fl[21][21];
bool check(ll i,ll j){
	if(i>=0&&j>=0&&i<n&&j<m&&ar[i][j]=='.') return 1;
	else return 0;
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>ar[i];
	}

	ll mx=0;
	for(k=0;k<n;k++){
		for(j=0;j<m;j++){
			if(ar[k][j]=='#') continue;
			queue< pair<ll, pair<ll,ll> > > qe;
			qe.push({0,{k,j}}); memset(fl,0,sizeof(fl));
			fl[k][j]=1;
			while(qe.size()>0){
				pair<ll, pair<ll,ll> > p=qe.front();
				qe.pop();
				for(i=0;i<4;i++){
					if(check(p.sc.fs+cx[i],p.sc.sc+cy[i])&&fl[p.sc.fs+cx[i]][p.sc.sc+cy[i]]==0){
						fl[p.sc.fs+cx[i]][p.sc.sc+cy[i]]=1;
						qe.push({p.fs+1,{p.sc.fs+cx[i],p.sc.sc+cy[i]}});
						mx=max(mx,p.fs+1);
					}
				}
			}
		}
	}
	cout<<mx;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
	int n;
	int val[100];
	int changecount = 0;

	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&val[i]);
	}

	int flag = 1;
	while(flag){
		flag = 0;
		for(int i = n - 1; i > 0; i--){
			if(val[i] < val[i - 1]){
				flag = val[i - 1];
				val[i - 1] = val[i];
				val[i] = flag;
				flag = 1;
				changecount++;
			}
		}
	}
	
	printf("%d",val[0]);
	for(int i = 1; i < n; i++){
		printf(" %d",val[i]);
	}
	printf("\n");
	printf("%d\n",changecount);
	return 0;
}


Measured memory_bytes: 2044
#include<stdio.h>
#include<algorithm>
#include<utility>

using namespace std;

int main(void){

	int n, m, k, ans;

	int x[100000],sa[100000];

	scanf("%d %d",&n,&m);

	for (k = 0; k < m; k++) {
		if (k != m - 1) {
			scanf("%d ",&x[k]);
		}else{
			scanf("%d", &x[k]);
		}
	}
	
	sort(x,x+m);

	if (n >= m) {
		printf("0\n");
	}
	else {
		for (k = 0; k < m - 1; k++) {
			sa[k] = x[k + 1] - x[k];
		}
		sort(sa, sa + m);

		ans = x[m - 1] - x[0];

		for (k = 0; k < n - 1; k++) {

			ans = ans - sa[m - 1 - k];
		}

		printf("%d\n",ans);

	}


	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,a=0,b=0,c=0,d=0;
    string s;
    cin>>t;
    while(t--)
    {
        cin>>s;
        if(s=="AC")
            a++;
        if(s=="WA")
            b++;
        if(s=="TLE")
            c++;
        if(s=="RE")
            d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
using namespace std;
struct p
{
    int num;
    char c;
} l[100009];
int main()
{
    int n,k,o=0,sum=0,q[100009],ge=0,max1=0,res,ge1;
    char a[100009];
    scanf("%d%d",&n,&k);
    getchar();
    scanf("%s",a);
    for(int i=0; i<n;)
    {
        int cnt=0;
        l[o].c=a[i];
        char tmp=a[i];
        while(a[i]==tmp&&i<n)
        {
            cnt++;
            i++;
        }
        l[o++].num=cnt;
    }
    for(int i=0; i<o; i++)
    {
        if(l[i].c=='0')
            ge++;
        sum+=l[i].num;
        q[i]=sum;
        //printf("%d\n",sum);
    }
    if(ge<=k)
        printf("%d",n);
    else
    {
        for(int i=0; i<o&&(k-1)*2+i<o; i++)
        {

            if(l[i].c=='0')
            {
                res=q[(k-1)*2+i]-q[i]+l[i].num;
                if(i-1==0)
                {
                    res+=l[0].num;
                }
                else if(i-1>0)
                    res+=q[i-1]-q[i-2];
                if((k-1)*2+i+1<o)
                    res+=q[(k-1)*2+i+1]-q[(k-1)*2+i];
                //printf("%d %d %d %d\n",i,q[i-1]-q[i-2],q[i+1]-q[i],q[i+1]);
                //printf("%d\n",res);
                max1=max(max1,res);
            }
        }
        printf("%d",max1);
    }
    return 0;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {

    public static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) {
        int N = scanner.nextInt();
        int W = scanner.nextInt();
        int value[] = new int[N+1];
        int weights[] = new int[N+1];
        for(int i = 1 ; i<= N ; i++){
            weights[i] = scanner.nextInt();
            value[i] = scanner.nextInt();
        }
        System.out.println(knapsack(N , W , weights,value));


    }
    public static long knapsack(int N , int W , int[] weights , int[] value){
        int maxvalue = N * 1000;
        long dp[][] = new long[N+1][maxvalue + 1];

        for(int v = 0 ; v<= maxvalue ; v++){
            dp[1][v] = Integer.MAX_VALUE;
        }
        dp[1][0] = 0;
        dp[1][value[1]] = weights[1];

        for(int n = 2 ; n<= N ; n++){
            for(int v = 0 ; v<= maxvalue ; v++){
                dp[n][v] = dp[n-1][v];
                if(value[n] > v)
                    continue;
                dp[n][v] = Math.min(weights[n] + dp[n-1][v-value[n]] ,dp[n][v]);
            }
        }
         long max = 0;
         for(int i  = 0 ; i<= maxvalue ; i++){
             if(dp[N][i] <= W){
                 max = i;
             }
         }
        return max;
    }

}



Measured memory_bytes: 127952
#include <stdio.h>

int main(void)
{
    int A, B;
    char op;
    scanf("%d %c %d", &A, &op, &B);
    if (op == '+') {
        printf("%d\n", A + B);
    } else {
        printf("%d\n", A - B);
    }
    return 0;
}


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

class dice{
    public :
    int d[6] ;
    void in(vector<int> &a){
        for(int i=0;i<6;i++) d[i] = a.at(i) ;
    }
    void roll(char c){
        if(c=='N'){
            int sub = d[0] ;
            d[0] = d[1] ;
            d[1] = d[5] ;
            d[5] = d[4] ;
            d[4] = sub ;
        }
        if(c=='S'){
            int sub = d[0] ;
            d[0] = d[4] ;
            d[4] = d[5] ;
            d[5] = d[1] ;
            d[1] = sub ;
        }
        if(c=='E'){
            int sub = d[0] ;
            d[0] = d[3] ;
            d[3] = d[5] ;
            d[5] = d[2] ;
            d[2] = sub ;
        }
        if(c=='W'){
            int sub = d[0] ;
            d[0] = d[2] ;
            d[2] = d[5] ;
            d[5] = d[3] ;
            d[3] = sub ;
        }
    }
    int serch(int n){
        for(int i=0;i<6;i++){
            if(d[i]==n) return i ;
        }
    }
} ;

bool check(dice d1,dice d2,vector<vector<int>> &uall,int u){
    vector<int> a(6) ;
    vector<int> b(6) ;
    for(int i=0;i<6;i++){
        a.at(i) = d1.d[i] ;
        b.at(i) = d2.d[i] ;
    }
    sort(a.begin(),a.end()) ;
    sort(b.begin(),b.end()) ;
    if(a!=b) return false ;
    bool ok = false ;
    if(u==1) d1.roll('N') ;
    if(u==2) d1.roll('W') ;
    if(u==3) d1.roll('E') ;
    if(u==4) d1.roll('S') ;
    if(u==5){
        d1.roll('N') ;
        d1.roll('N') ;
    }
    for(int i=0;i<4;i++){
        if(d1.d[u]==d2.d[u]) break ;
        d2.roll('N') ;
    }
    for(int i=0;i<4;i++){
        if(d1.d[u]==d2.d[u]) break ;
        d2.roll('E') ;
    }
    if(d1.d[u]!=d2.d[u]) return false ;
    for(int i=0;i<4;i++){
        if(d1.d[uall.at(u).at(1)]==d2.d[uall.at(u).at(1)]) break ;
        d2.roll('N') ;
        d2.roll('W') ;
        d2.roll('S') ;
    }
    if(d1.d[uall.at(u).at(1)]==d2.d[uall.at(u).at(1)]&&d1.d[uall.at(u).at(2)]==d2.d[uall.at(u).at(2)]&&d1.d[uall.at(u).at(3)]==d2.d[uall.at(u).at(3)]&&d1.d[uall.at(u).at(4)]==d2.d[uall.at(u).at(4)]) ok = true ;
    return ok ;
}

int main(){
    vector<vector<int>> ufr = 
    {
        {-1,2,4,1,3,-1},
        {3,-1,0,5,-1,2},
        {1,5,-1,-1,0,4},
        {4,0,-1,-1,5,1},
        {2,-1,5,0,-1,3},
        {-1,3,1,4,2,-1},
    } ;
    vector<vector<int>> uall =
    {
        {0,1,2,3,4,5},
        {1,0,3,2,5,4},
        {2,0,1,4,5,3},
        {3,0,4,1,5,2},
        {4,0,2,3,5,1},
        {5,1,3,2,4,0},
    };
    vector<dice> d(2) ;
    for(int i=0;i<2;i++){
        vector<int> a(6) ;
        for(int j=0;j<6;j++) cin >> a.at(j) ;
        d.at(i).in(a) ;
    }
    for(int i=0;i<6;i++){
        if(check(d.at(0),d.at(1),uall,i)){ 
            cout << "Yes" << endl ;
            return 0 ;
        }
    }
    cout << "No" << endl ;
}


Measured memory_bytes: 3172
import java.util.*;
import java.io.*;
import java.math.BigDecimal;

public class Main {	

	private static void solve(){
		//Implement solution here.
		String s = next();
		if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21460
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

// dp[i][j] := 数 j を i 分割する総数
vector<vector<ll>> dp(1010, vector<ll>(1010, 0));
void part_init(){
    dp[0][0] = 1;
    for(int i=1; i<=1005; i++){
        for(int j=0; j<=1005; j++){
            if(0 <= j - i){
                (dp[i][j] = dp[i-1][j] + dp[i][j-i]) %= MOD;
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
}

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

    int n, k; cin>>n>>k;
    n -= k;

    if(n < 0){
        cout << 0 << endl;
        return 0;
    }

    part_init();

    cout << dp[k][n] << endl;

    return 0;
}


Measured memory_bytes: 11204
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int x, y, sum;

int main() {
    while(1) {
        cin >> x >> y >> sum;
        int ans = 0;
        if(x == 0 && y == 0 && sum == 0) break;
        for(int i = 1; i <= 1000; ++i) {
            for(int j = 1; j <= 1000; ++j) {
                int l = i*(100+x)/100;
                int r = j*(100+x)/100;
                if(l+r == sum) {
                    int yl = i*(100+y)/100;
                    int yr = j*(100+y)/100;
                    chmax(ans, yl+yr);
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3104
#include<iostream>
#include<vector>
using namespace std;
const int mod = 1e9 + 7;

// 0 : white
void solve(int u, int par, vector<vector<long long>>& dp, vector<vector<int>>& g)
{
  dp[u][0] = dp[u][1] = 1;
  for (auto v : g[u]) {
    if (v == par) continue;
    solve(v, u, dp, g);
    dp[u][0] *= (dp[v][0] + dp[v][1]) % mod;
    dp[u][1] *= dp[v][0];
    for (int i = 0; i < 2; ++i) dp[u][i] %= mod;
  }

}




int main()
{
  int n, k;
  cin >> n;
  vector<vector<int>> g(n) ;
  vector<vector<long long int>> dp(n, vector<long long int>(2)) ;
  for (int i = 0; i < n - 1; ++i) {
    int x,y;
    cin >> x >> y;
    x--; y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  solve(0, -1, dp, g);

  cout << (dp[0][0] + dp[0][1]) % mod << '\n';

  return 0;
}


Measured memory_bytes: 19584