akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using T = tuple<lint, lint, lint>;

lint n, m;
vector<T> city;

int main() {
    cin >> n >> m;
    city.resize(m);

    for(lint i = 0; i < m; i++) {
        lint p, y;
        cin >> p >> y;
        city[i] = T(p, y, i);
    }
    sort(city.begin(), city.end());

    lint ord = 1;
    lint prev = -1;
    for(auto &e : city) {
        lint p = get<0>(e);
        if(p == prev)  ord++;
        else           ord = 1;
        get<1>(e) = ord;
        prev = p;
    }

    auto city_greater = [](T x, T y){ return get<2>(x) < get<2>(y); };
    sort(city.begin(), city.end(), city_greater);
    for(auto &e : city) {
        lint p, y, i;
        tie(p, y, i) = e;
        printf("%06d%06d\n", p, y);
    }
}

Measured memory_bytes: 3840
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
cost = [abs(A[i+1] - A[i]) for i in range(N+1)]
cost0 = sum(cost)

for i in range(1, N+1):
    if (A[i] - A[i-1]) * (A[i+1] - A[i]) > 0:
        print(cost0)
    elif (A[i-1] - A[i]) * (A[i+1] - A[i-1]) >= 0:
        print(cost0 - 2 * abs(A[i-1] - A[i]))
    else:
        print(cost0 - 2 * abs(A[i+1] - A[i]))

Measured memory_bytes: 14176
from collections import deque, defaultdict

S = int(input())


def f(x):
    if (x % 2 == 0):
        return x // 2
    else:
        return 3 * x + 1


d = defaultdict(int)
ans = deque()
ans.append(S)
# print(f(S, ans))
for i in range(1, 10**6):
    ans.append(f(ans[i - 1]))

for i, v in enumerate(ans):
    d[v] += 1
    if (d[v] == 2):
        print(i + 1)
        break

Measured memory_bytes: 11636
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  if(s[n-1]=='s'){
    cout<<s<<"es";
    return 0;
  }
  cout<<s<<'s';
return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cout<<"square1001"<<endl;
}





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

using namespace std;
using ll = long long;

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

  int n, m;
  cin >> n >> m;

  vector<vector<int>> graph(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  vector<int> ans(n, -1);

  ans[0] = 0;
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int e : graph[v]) {
      if (ans[e] == -1) {
        ans[e] = v + 1;
        q.push(e);
      }
    }
  }

  cout << "Yes\n";
  for (int i = 1; i < n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 10168
n,m,x,y=map(int,input().split())
xi=list(map(int,input().split()))
yi=list(map(int,input().split()))
xi.sort()
yi.sort()
z=yi[0]
war=1
if(xi[n-1]>=yi[0]):
    print('War')
else:
    for z in range(xi[n-1]+1,yi[0]+1):
        if(z>x and z<=y):
            war=0
            break
    if(war):
        print('War')
    else:
        print('No War')

Measured memory_bytes: 3064
# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())


def bf(graph: list):
    neg = -10**16
    n = len(graph)
    dist = [neg]*n
    dist[0] = 0
    
    hasUpdate = True
    cnt = 0
    cur = neg
    while hasUpdate:
        hasUpdate = False
        cnt += 1
        
        for frm, node in enumerate(graph):
            for cost, to in node:
                bef = dist[to]
                dist[to] = max(dist[to], dist[frm] + cost)
                
                # 更新されたならupdateをTrueに
                if dist[to] != bef:
                    hasUpdate = True
        
        if cnt == n-1:
            cur = dist[-1]
            
        if cnt == n:
            if dist[-1] == cur:
                return dist[-1]
            else:
                return "inf"
        
    return dist[-1]
                

n,m = li()

graph = [[] for _ in range(n)]
for i in range(m):
    a,b,c = li()
    a -= 1
    b -= 1
    graph[a].append((c,b))
    
ans = bf(graph)
print(ans)

Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.InputMismatchException;


public class Main {
	
	private static int[][] cache;
	private static int[] r;
	private static int[] c;
	

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

		int n = sc.nextInt();
		r = new int[n];
		c = new int[n];

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

		// ボトムアップ型１、メモリ節約
		cache = new int[n][];
		for (int i = 0; i < n; i++) {
			cache[i] = new int[n - i];
			Arrays.fill(cache[i], Integer.MAX_VALUE);
			cache[i][i - i] = 0;  // cache[行][列 - 行]
		}

		for (int l = 1; l < n; l++) {
			for (int i = 0; i + l < n && i < n; i++) {
				int j = i + l;
				for (int k = 0; k < l; k++) {
					cache[i][j - i] = Math.min(cache[i][j - i], cache[i][i + k - i] + r[i] * r[i+k+1] * c[j] + cache[i + k + 1][j - (i + k + 1)]);
				}
			}
		}
		int ret = cache[0][n -1 - 0];
		
		System.out.println(ret);
		
		sc.close();
	}

	@SuppressWarnings("unused")
	private static class Scanner {
		InputStreamReader isr;
		BufferedReader br;
		StreamTokenizer st;

		private Scanner() {
		}

		Scanner (InputStream in) {
			isr = new InputStreamReader(in);
			br = new BufferedReader(isr);
			st = new StreamTokenizer(br);
		}

		String next() throws RuntimeException  {
			try {
				if (st.nextToken() != StreamTokenizer.TT_WORD) {
				}
			} catch (IOException e) {
				throw new IllegalStateException();
			}

			return st.sval;
		}

		int nextInt() throws RuntimeException {
			try {
				if (st.nextToken() != StreamTokenizer.TT_NUMBER) {
					throw new InputMismatchException();
				}
			} catch (IOException e) {
				throw new IllegalStateException();
			}

			return (int)st.nval;
		}

		void close() {
		}
	}
}

Measured memory_bytes: 19876
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    if (A[0] > 0) {
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    ll prev = A.back();
    rrep(i, N, 0) {
        if (A[i] >= prev) {
            ans += A[i];
        }
        else if (prev - A[i] >= 2) {
            cout << -1 << endl;
            return 0;
        }
        prev = A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;

int n;
int mod = 1e9 + 7;

int main() {
    cin >> n;
    long long sum_plus = 0, sum_minus = 0;
    long long cnt_plus = 0, cnt_minus = 0;
    bool odd = false;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        sum_plus += a; sum_minus += a;
        if (odd) {
            if (sum_plus <= 0) {
                cnt_plus += 1 - sum_plus;
                sum_plus = 1;
            }
            if (sum_minus >= 0) {
                cnt_minus += sum_minus + 1;
                sum_minus = -1;
            }
        } else {
            if (sum_plus >= 0) {
                cnt_plus += 1 + sum_plus;
                sum_plus = -1;
            }
            if (sum_minus <= 0) {
                cnt_minus += 1 - sum_minus;
                sum_minus = 1;
            }
        }
        odd = !odd;
    }
    cout << min(cnt_plus, cnt_minus) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };



int main() {

	double t, x;
	cin >> t >> x;

	cout << fixed << setprecision(12) << t / x << endl;

	return 0;
}

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

int main(){
  int i = 0, n;
  double h[10000];

  while(cin >> h[i]){
    i++;
  }
  n = i;
  sort(h, h + n);

  cout << h[n - 1] - h[0] << endl;
}

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

const int maxn = 1e5 + 3, maxm = 12;

int n;
double dp[maxn][maxm], pr[maxn][maxm];

int main() {
    while(scanf("%d", &n) != EOF) {
        if(n == 0)
            return 0;
        memset(dp, 0, sizeof(dp[0]) * (n + 1));
        memset(pr, 0, sizeof(pr[0]) * (n + 1));
        pr[0][0] = 1.0;
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < maxm - 1; ++j) {
                dp[i + 1][j + 1] += (dp[i][j] + pr[i][j]) * pow(0.5, j);
                pr[i + 1][j + 1] += pr[i][j] * pow(0.5, j);
            }
            for(int j = 0; j < maxm; ++j) {
                dp[i + 1][0] += dp[i][j] * (1.0 - pow(0.5, j));
                pr[i + 1][0] += pr[i][j] * (1.0 - pow(0.5, j));
            }
        }
        printf("%.8f\n", std::accumulate(dp[n], dp[n] + maxm, 0.0));
    }
    return 0;
}



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

int main() {
	double left, right;
	int Lleft[4] = {0, 0, 0, 0};
	int Lright[4] = {0, 0, 0, 0};
	while (cin >> left >> right) {
		if (left >= 1.1) Lleft[0]++;
		else if (left >= 0.6) Lleft[1]++;
		else if (left >= 0.2) Lleft[2]++;
		else if (left >= 0.0) Lleft[3]++;
		if (right >= 1.1) Lright[0]++;
		else if (right >= 0.6) Lright[1]++;
		else if (right >= 0.2) Lright[2]++;
		else if (right >= 0.0) Lright[3]++;
	}
	for (int i = 0; i < 4; i++) {
		cout << Lleft[i] << " " << Lright[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    ios::sync_with_stdio(false);
    ll q;
    cin >> q;
    ll bsum = 0;
    ll asumsmall = 0;
    ll asumlarge = 0;
    multiset<ll> asmall;
    multiset<ll> alarge;
    ll xx, aa, bb;
    cin >> xx >> aa >> bb;
    asmall.insert(aa);
    asumsmall += aa;
    bsum += bb;
    for (int i = 1; i < q; ++i) {
        ll x;
        cin >> x;
        if (x == 1) {
            ll a, b;
            cin >> a >> b;
            bsum += b;
            if (*asmall.rbegin() > a) {
                asmall.insert(a);
                asumsmall += a;
                if (asmall.size() > alarge.size() + 1) {
                    ll atemp = *asmall.rbegin();
                    alarge.insert(atemp);
                    asmall.erase(prev(asmall.end()));
                    asumlarge += atemp;
                    asumsmall -= atemp;
                }
            } else //(*alarge.begin() < a)
            {
                alarge.insert(a);
                asumlarge += a;
                if (alarge.size() > asmall.size() + 1) {
                    ll atemp = *alarge.begin();
                    asmall.insert(atemp);
                    alarge.erase(alarge.begin());
                    asumlarge -= atemp;
                    asumsmall += atemp;
                }
            }
        } else if (x == 2) {
            ll ret1 = bsum;
            ll ret2 = bsum;
            ll mode1 = *asmall.rbegin();
            ll mode2 = *alarge.begin();
            ret1 += asumlarge - mode1 * alarge.size();
            ret1 += mode1 * asmall.size() - asumsmall;
            ret2 += asumlarge - mode2 * alarge.size();
            ret2 += mode2 * asmall.size() - asumsmall;
            if (ret1 < ret2 || (ret1 == ret2 && mode1 < mode2) || alarge.size() == 0) {
                cout << mode1 << " " << ret1 << "\n";
            } else {
                cout << mode2 << " " << ret2 << "\n";
            }
        }
    }
    return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n; cin >> n;
  vector<LL> b(n - 1);
  LL sum = 0;
  rep(i, n - 1) {
    cin >> b[i];
  }
  
  vector<LL> a(n, 0);
  a[0] = b[0];
  for (int i = 1; i < n - 1; i ++) {
    a[i] = min(b[i-1], b[i]);
  }
  a[n - 1] = b[n - 2];
  rep(i, n) sum += a[i];

  cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		long[] t = new long[n];
		for(int i = 0; i < n; i++) t[i] = sc.nextLong();
		
		long res = t[0];
		
		for(int i = 1; i < n; i++) {
			res = lcm(t[i],res);
		}
		out.println(res);
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static int lcm(int a, int b) {
		return (a * b) / gcd(a, b);
	}
	
	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long p = 100;
		long ans = 0;
		
		while(true) {
			if(p < x) {
				p = p + (p/100);
				ans++;
			}
			else {
				break;
			}
		}
		
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 35816
#include<iostream>
#include<cstdio>

int main()
{
  int a, b;
  while(std::cin >> a >> b, a + b != 0 ){
  for(int i = 0 ; i < a;  i++) {
  for(int j = 0;  j < b ; j++) {
  printf("#");
  }
  printf("\n");
  }
  printf("\n");}
}

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

int main(){
  int n;
  int a[111];
  
  cin >> n;
  
  rep(i, n) cin >> a[i];
  rep(i, n) {
    if (i) cout << " ";
    cout << a[(n-1)-i];
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3100
use proconio::{input, fastout};

#[fastout]
fn main() {
  input!{
    N: i32,
    K: i32,
    A: [i32; N]
  }
  for i in K..N {
      println!("{}",if A[i as usize] > A[(i-K) as usize] {"Yes"}else{"No"});
  }
}


Measured memory_bytes: 4848
#include <iostream>
#include <vector>

using namespace std;

int main() {
  //input
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i<n; i++){
    cin>>a[i];
  }
  
  //solve
  int ans= 0;
  while(true){
    bool OK = true;
    for (int i = 0; i<n; i++){
      if (a[i] % 2 == 0){
        a[i] /= 2;
      }else{
        OK = false;
        break;
      }
    }
    if(OK){
      ans ++;
    }else{
      break;
    }
  }

  //output
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int a[10001];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    sort(a+0,a+n+1);
    int ans=0;
    for(int i=n;i>=n-m+1;i--)
    ans+=a[i];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;
map<ll, ll>m;
vector<ll>v;
ll n, x, mod, s, len, st, ans = 0ll;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(10);
	cin >> n >> x >> mod;
	v.pb(x);
	m[x] = 1ll;
	s = x % mod;
	st = n + 1ll;
	for (ll i = 2ll; i <= n; i++) {
		s = (s * s) % mod;
		if (m.find(s) != m.end()) {
			st = m[s];
			len = i - m[s];
			break;
		}
		m[s] = i;
		v.pb(s);
	}
	for (ll i = 1ll, cnt; i <= 1ll * v.size(); i++) {
		if (i < st) {
			ans += v[i - 1ll];
			continue;
		}
		cnt = ((n - st + 1ll) / (len));
		cnt += (((n - st + 1ll) % (len) > i - st) ? 1ll : 0ll);
		ans += (v[i - 1ll] * cnt);
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6680
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong arr[200005];
llong dp[200005];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    for (int i = 0; i < n; i++) {
        if (arr[i] == 1) {
            dp[1] = 1;
        }
        else if (dp[arr[i] - 1] > 0) {
            dp[arr[i]] = dp[arr[i] - 1] + 1;
        }
    }

    llong mv = 0;
    for (int i = 1; i <= n; i++) {
        mv = max(mv, dp[i]);
    }

    if (mv == 0) cout << -1 << endl;
    else cout << n - mv << endl;

    return 0;
}


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC088C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] c = new int[3, 3];

            for (int i = 0; i < 3; i++)
            {
                var input = ReadInts;
                for (int j = 0; j < 3; j++)
                {
                    c[i, j] = input[j];
                }
            }

            int a1 = c[0, 0];
            int a2 = c[0, 1];
            int a3 = c[0, 2];

            bool ans = true;
            for (int i = 0; i < 2; i++)
            {
                int d1 = c[i + 1, 0] - a1;
                int d2 = c[i + 1, 1] - a2;
                int d3 = c[i + 1, 2] - a3;
                if (d1 != d2 || d1 != d3) ans = false;
            }

            if (ans) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13268
s = input()
t = input()
memo = {}
ans = 'Yes'
for i in range(len(s)):
    if s[i] in memo:
        if t[i] != memo[s[i]]:
            ans = 'No'
            break
    else:
        memo[s[i]] = t[i]
a = list(memo.values())
b = list(set(a))
if len(b) != len(a):
    ans = 'No'
print(ans)

Measured memory_bytes: 9416
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ld long double
typedef pair<ll,ll> P;
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
int main()
{
   ll n,w,i,a,b,j;
   cin>>n>>w;
   vector<pair<ll,ll>> V;
   for(i=0;i<n;i++)
   {
       cin>>a>>b;
       V.push_back(make_pair(a,b)); 
   }
   sort(V.begin(),V.end());
   ll DP[100001];
   for(i=0;i<=100000;i++)
   DP[i]=INT_MAX;
   DP[0]=0;
   for(i=0;i<n;i++)
   {
       for(j=100000;j>=0;j--)
       {
           if(j>=V[i].second)
           {
               DP[j]=min(DP[j],DP[j-V[i].second]+V[i].first);
           }
       }   
   }
   for(i=100000;i>=0;i--)
   {
       //cout<<DP[i]<<" ";
       if(DP[i]<=w)
       {
           cout<<i<<endl;
           break;
       }
   } 
   //cout<<i<<endl;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(10);
    int n;
    string s;
    cin >> n >> s;
    string ans = "Yes";
    if (n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    rep(i, 0, n / 2) if (s[i] != s[i + n / 2]) ans = "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    a=sorted([random.randint(0,5) for _ in range(n)])[::-1]
    return n,a

show_flg=False
show_flg=True

s=input()
n=len(s)//2
ans=0
for i in range(n):
    if s[i]!=s[-1-i]:
        ans+=1
print(ans)


Measured memory_bytes: 40812
# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load in 

import numpy as np # linear algebra
#import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

# Input data files are available in the "../input/" directory.
# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory

import os
#print(os.listdir("../input"))

import sys
#def input():
#    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(1000000)
'''
from operator import itemgetter
a = [(1, "c", 1), (1, "b", 3), (2, "a", 0), (1, "a", 2)]
print(sorted(a))  # 0 番目の要素でソート、先頭の要素が同じなら 1 番目以降の要素も見る
print(sorted(a, key=itemgetter(0)))  # 0 番目の要素だけでソート
print(sorted(a, key=itemgetter(0, 2)))  # 0 番目と 2 番目の要素でソート
print(sorted(a, key=lambda x: x[0] * x[2]))  # 0 番目の要素 * 2 番目の要素でソート
print(sorted(a, reverse=True))  # 降順にソート
a.sort()  # 破壊的にソート、sorted() よりも高速
'''

test_data1 = '''\
8
6
3
1
2
7
4
8
5
'''

test_data2 = '''\
6
3
2
5
1
4
6
'''

test_data3 = '''\
4
1
3
2
4
'''
td_num=3

def GetTestData(index):
    if index==1:
        return test_data1
    if index==2:
        return test_data2
    if index==3:
        return test_data3
    
if False:
    with open("../test.txt", mode='w') as f:
        f.write(GetTestData(td_num))
    with open("../test.txt") as f:
        #print(f.readlines())
        #print(f.read())
        # Start Input code ---------------------------------------
        n=int(f.readline())
        p=[0]*n
        for i in range(n):
            p[i]=int(f.readline())
        # End Input code ---------------------------------------
else:
    n=int(input())
    p=[0]*n
    for i in range(n):
        p[i]=int(input())
    # End Input code ---------------------------------------

a=[0]*n
cnt=1
ans=0
for i in range(n):
    a[p[i]-1]=i
#print('n,p=',n,p,a)
for i in range(n):
    if i==0:
        pre=a[0]
    else:
        if a[i]>pre:
            cnt+=1
        else:
            ans=max(ans,cnt)
            cnt=1
    ans=max(ans,cnt)
    pre=a[i]
print(n-ans)


Measured memory_bytes: 29852
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

#define MAX_N 7000000
int x[MAX_N], sum[MAX_N + 1];
vector<int>prime;
int n;

void PrimeCheckerDiv2(int c) {
	for (int i = 2; i < c; i++) {
		for (int j = 2; j <= sqrt(i); j++) {
			if (i%j == 0) { goto E; }
		}
		prime.push_back(i);
	E:;
	}
}

void TheSumPrimesDiv2(int d) {
	sum[0] = 0;
	for (int i = 1; i <= d; i++) {
		sum[i] = prime[i - 1] + sum[i - 1];
	}
}

void ThePrimesConsecutiveDiv2(int e) {
	for (int i = 1; i <= e; i++) {
		for (int j = i; j < e; j++) {
			if (sum[j] - sum[i - 1] >= MAX_N) { break; }
			x[sum[j] - sum[i - 1]]++;
		}
	}
}

int main() {
	PrimeCheckerDiv2(MAX_N);
	TheSumPrimesDiv2(prime.size());
	ThePrimesConsecutiveDiv2(prime.size());
	while (true) {
		cin >> n;
		if (n == 0) { break; }
		cout << x[n] << endl;
	}
}

Measured memory_bytes: 33688
#include <stdio.h>
#include <math.h>
int main(void){
    double x,h;
    
    while(1){
        scanf("%lf\n%lf\n",&x,&h);
        if(x==0&&h==0)break;
        
        printf("%lf\n",2*x*sqrt(pow((x/2),2)+pow(h,2))+pow(x,2));
    }
    
    return 0;
}



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


const int maxn=2e5+10;

int n,m;
char s[200005];

int main()
{
	cin>>(s+1);
	int len=strlen(s+1),ans=0;
	for( int i=1;i<=len;i++ )
	{
		if( s[i]=='?' ) s[i]='D';
	} 
	cout<<s+1<<endl; 
} 

Measured memory_bytes: 3788
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll N;
    cin >> N;
    vector<ll>A(N), B(N, 0);
    for(ll i = 0; i < N; i++){
        cin >> A[i];
        if(i % 2 == 0)B[0] += A[i];
        else B[0] -= A[i];
    }
    for(ll i = 0; i < N; i++){
        if(i)B[i] = A[i-1] * 2 - B[i-1];
        cout << B[i];
        if(i + 1 == N)cout << endl;
        else cout << " ";
    }


    return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void push(int);
int pop(void);

int top, S[1000];

int main(){
  int x,y;
  char s[100];
  top = 0;

  while( scanf("%s",s) != EOF ){
    if( s[0] == '+' ){
      x = pop();
      y = pop();
      push(x+y);
    }
    else if( s[0] == '-' ){
      y = pop();
      x = pop();
      push(x-y);
    }
    else if( s[0] == '*' ){
      x = pop();
      y = pop();
      push(x*y);
    }
    else {
      push(atoi(s));
    }
  }

  printf("%d\n",pop());
  return 0;
}

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}



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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    string s; cin >> s;
    int ans = 0;
    int cnt = 0;
    REP(i, s.size()) {
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C' ) {
            cnt++;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;    

    return 0;
}

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

int n, c[16];
char s[16];

void dfs(int i) {
  if (i == n) {
    cout << s << "\n";
  } else {
    int o = 0;
    for (int j = 0; j < i; ++j) {
      if (c[j]) {
        ++o;
      }
    }
    for (int j = 0; j <= o; ++j) {
      s[i] = 'a' + j;
      ++c[j];
      dfs(i + 1);
      --c[j];
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  dfs(0);
  return 0;
}

Measured memory_bytes: 1536
/*
Rathin Bhargava
IIIT Bangalore

*/
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  ll a,b,c;
  cin >> a >> b >> c;
  ll cnt = 0;
  if(c > b) 
  {
    cnt += 2*b;
    c -= b;
    if(a < c)
    {
      cnt += a+1;
    }
    else cnt += c;
  }
  else
  {
    cnt += c + b;
  }

  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 256
class Node:
    def __init__(self, id):
        self.id = id
        self.left = None
        self.right = None
        self.parent = None

    def isRoot(self):
        return self.parent is None

    def preorder(self, arr):
        arr.append(str(self.id))
        if self.left is not None:
            self.left.preorder(arr)
        if self.right is not None:
            self.right.preorder(arr)

    def inorder(self, arr):
        if self.left is not None:
            self.left.inorder(arr)
        arr.append(str(self.id))
        if self.right is not None:
            self.right.inorder(arr)

    def postorder(self, arr):
        if self.left is not None:
            self.left.postorder(arr)
        if self.right is not None:
            self.right.postorder(arr)
        arr.append(str(self.id))

def insert(root, z):
    y = None
    x = root
    while x is not None:
        y = x
        if z.id < x.id:
            x = x.left
        else:
            x = x.right

    z.parent = y

    if z.id < y.id:
        y.left = z
    else:
        y.right = z


m = int(input())
root = None

for i in range(m):
    arr = input().split()
    if arr[0] == 'print':
        arr = []
        root.inorder(arr)
        print('', ' '.join(arr))
        arr = []
        root.preorder(arr)
        print('', ' '.join(arr))
        continue

    id = int(arr[1])
    if root is None:
        root = Node(id)
        continue

    insert(root, Node(id))



Measured memory_bytes: 146392
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int t = sc.nextInt();
    
    int count = 0;
    if (n >= x) {
      count = n / x;
      n = n % x;
    }
    
    if (n > 0)
      count++;
    
    System.out.println(count*t);
  }
}

Measured memory_bytes: 35688
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

#[inline]
#[allow(dead_code)]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
#[allow(dead_code)]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

macro_rules! eprint(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = write!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! eprintln(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! dbg {
    ($val:expr) => {
        // Use of `match` here is intentional because it affects the lifetimes
        // of temporaries - https://stackoverflow.com/a/48732525/1063961
        match $val {
            tmp => {
                eprintln!(
                    "[{}:{}] {} = {:#?}",
                    file!(),
                    line!(),
                    stringify!($val),
                    &tmp
                );
                tmp
            }
        }
    };
}

fn main() {
    input! {
        n: usize,
        a_v: [u64; n],
    }

    let mut b_v: Vec<_> = a_v
        .iter()
        .enumerate()
        .map(|(i, &a)| a as i64 - (i as i64 + 1))
        .collect();

    b_v.sort();

    let b = b_v[b_v.len() / 2];

    let answer = b_v
        .iter()
        .map(|b_i| (b_i - b).abs())
        .fold(0, |acc, x| acc + x);
    println!("{}", answer);
}


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

using namespace std;

int main(){
	int N, X;
	scanf("%d%d", &N, &X);
	
	int temp = 0;
	for(int i = 0; i < N; i ++){
		int y;
		scanf("%d", &y);
		temp += y;
		if(temp > X){
			printf("%d", i+1);
			return 0;
		}
	}
	printf("%d", N+1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int N=1e9;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k,s;
    cin >> n >> k >> s;
    REP(i,k) cout << s << ' ';
    REP1(i,k,n-1) cout << s%N+1 << " \n"[i==n-1];
    return 0;
}

Measured memory_bytes: 1280
import java.awt.*;
import java.io.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.util.Map;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[][] dp = new int[n][3];
        dp[0][0] = sc.nextInt();
        dp[0][1] = sc.nextInt();
        dp[0][2] = sc.nextInt();
        int x;
        for (int i = 1; i < n; i++) {
            x = sc.nextInt();
            dp[i][0] = Integer.max(dp[i - 1][1] + x, dp[i - 1][2] + x);

            x = sc.nextInt();
            dp[i][1] = Integer.max(dp[i - 1][0] + x, dp[i - 1][2] + x);

            x = sc.nextInt();
            dp[i][2] = Integer.max(dp[i - 1][0] + x, dp[i - 1][1] + x);
        }
        x = dp[n - 1][0];
        if (x < dp[n - 1][1]) x = dp[n - 1][1];
        if (x < dp[n - 1][2]) x = dp[n - 1][2];
        System.out.println(x);
    }
}



Measured memory_bytes: 95780
#include<bits/stdc++.h>
using namespace std;
int n,w;
long long memo[110][100010];
pair<int,long long>obj[110]; /// first w::: second value

long long go(int ind,int sofar)
{
    if(sofar>=w or ind>=n) return 0;
    if(memo[ind][sofar]!=-1) return memo[ind][sofar];

    long long x=0,y=0;
    if(obj[ind].first+sofar<=w) x = obj[ind].second+go(ind+1,sofar+obj[ind].first);
    y = go(ind+1,sofar);
    return memo[ind][sofar] = max(x,y);
}

int main()
{
    cin>>n>>w;
    for(int i = 0;i<n;i++) cin>>obj[i].first>>obj[i].second;

    memset(memo,-1,sizeof memo);
    long long ans = go(0,0);
    cout<<ans<<endl;
}


Measured memory_bytes: 86144
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

S =  list(sys.stdin.readline().rstrip())

ans = 0

for s in S:
    if s == "+":
        ans += 1
    else:
        ans -= 1

print(ans)

Measured memory_bytes: 64364
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i;
  string s,t,r;
  cin >> s >> t;
  r=s;
  for(i='a';i<='z';i++){
    s=r;
    s+=i;
    if(s==t){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 3628
using System;

class Program
{
    static void Main()
    {
        int d = 100000;
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            d = (int)Math.Ceiling(d * 1.05 / 1000) * 1000;
        }
        Console.WriteLine(d);
    }
}

Measured memory_bytes: 9016
N,M = map(int, input().split())
s1 = []
s2 = []
flg = True
for i in range(M):
  n1,n2 = map(int,input().split())
  s1.append(n1)
  s2.append(n2)
for i in range(1000):
  flg = True
  num = [int(x) for x in list(str(i))]
  if len(num) == N:
    for j in range(M):
      if s2[j] != num[s1[j] - 1]:
        flg = False
    if flg:
      print(i)
      exit()
print(-1)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	long long int N;
	scanf("%lld", &N);
	long long int h, n;
	for (h = 1; h <= 3500; h++)
	{
		for (n = 1; n <= 3500; n++)
		{
			if (4 * h*n - N*n - N*h > 0)
			{
				if ((N*h*n) % (4 * h*n - N*n - N*h) == 0)
				{
					printf("%lld %lld %lld\n", h, n, (N*h*n) / (4 * h*n - N*n - N*h));
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    long N;
    cin >> N;
    vector<long> a, b;
    long x;
    for (size_t i = 0; i < N+1; ++i) {
        cin >> x;
        a.push_back(x);
    }
    for (size_t i = 0; i < N; ++i) {
        cin >> x;
        b.push_back(x);
    }

    long r = 0;
    long l;
    for (size_t i = 0; i < N; ++i) {
        if (a[i] >= b[i]) {
            r += b[i];
        }
        else {
            r += a[i];
            l = b[i] - a[i];
            if (a[i+1] >= l) {
                r += l;
                a[i+1] -= l;
            }
            else {
                r += a[i+1];
                a[i+1] = 0;
            }
        }
    }
    cout << r << endl;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N;
bool V;

int main(void){
	//IO("test.in", "test.out");
	V = false;
	scanf("%d", &N);
	for(int i = 0; i < N; i++)
		if(i * 7 <= N && (N - i * 7) % 4 == 0) V = true;
	if(V) printf("Yes\n");
	else printf("No\n");
}

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

using namespace std;

char L[100005];
const long long MOD = 1e9+7;
int N;
long long memo[100005][2];

long long dp(int i, int same_so_far){
	if(i == 0){
		return 1;
	}else if(memo[i][same_so_far] != -1){
		return memo[i][same_so_far];
	}else if(same_so_far){
		if(L[i-1] == '1'){
			return memo[i][1] = (dp(i-1, 0) + 2*dp(i-1, 1)) % MOD;
		}else if(L[i-1] == '0'){
			return memo[i][1] = dp(i-1, 1);
		}else{
			throw;
		}
	}else{
		return memo[i][0] = 3*dp(i-1, 0) % MOD;
	}
}

int main(){
	scanf(" %s", L);
	
	N = strlen(L);
	
	reverse(L, L+N);
	memset(memo, -1, sizeof(memo));
	printf("%d", dp(N, 1));
}


Measured memory_bytes: 4992
#include <iostream>
#include <set>
#include <list>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std; 

int
main(int argc, char const *argv[])
{
    int64_t n, l;
    cin >> n >> l;
    int64_t ans;

    ans = (l + l + n - 1) * n / 2;

    if ((l + n - 1) < 0 && (l < 0)) {
	ans = ans - (l + n - 1);
    } else if (l > 0) {
	ans = ans - l;
    }

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


Measured memory_bytes: 256
/*input
4
((()))
((((((
))))))
()()()
*/

#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>;

bool check(vector<P> s) {
  int h = 0;
  for (P p: s) {
    int b = h+p.first;
    if (b < 0) return false;
    h += p.second;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  vector<P> ls, rs;
  int total = 0;
  rep(i, n) {
    string s;
    cin >> s;
    int h = 0, b = 0;
    for (char c: s) {
      if (c == '(') ++h;
      else --h;
      b = min(b, h);
    }
    if (h > 0) ls.emplace_back(b, h);
    else rs.emplace_back(b-h, -h);
    total += h;
  }
  sort(ls.rbegin(), ls.rend());
  sort(rs.rbegin(), rs.rend());
  if (check(ls) && check(rs) && total == 0) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 18720