akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include <iosfwd>
#include <sstream>
#include<stdio.h>
using namespace std;
#define _dg cout << "debug" << endl;
int main(){
    int a,b;
    cin >> a >> b;
    if(b%a==0){
        cout << a+b << endl;
    } else{
        cout << b-a << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int n=0;bool b=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')b=1;c=getchar();}
	while(c>='0'&&c<='9')n=(n<<3)+(n<<1)+(c^48),c=getchar();
	return b?-n:n;
}
string s,t;
int n;
main()
{
	cin>>s>>t;
	n=s.size();
	for(int i=0;i<n;++i)
	{
		if(s[i]!=t[i]){puts("No");return 0;}
	}
	puts("Yes");
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

const int maxn = 212345;

vector<int> G[maxn];
int n, a[maxn];

int main() {
  scanf("%d", &n);
  FOR(i, 1, n) scanf("%d", a + i);
  FOR(i, 1, n) G[a[i]].eb(i);
  int have = 0, last = 0;
  FOR(i, 1, n) {
    for (auto j : G[i]) if (j > last) {
      last = j;
      have++;
      break;
    }
    if (have == i - 1) break;
  }
  if (have == 0) puts("-1");
  else printf("%d", n - have);
}


Measured memory_bytes: 12288
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0;cin>>n;
  lvector A(n,0);
  map<ll,ll> mp;
  rep(i,n) {
    cin>>A[i];
    mp[A[i]]++;
  }
  for(auto p:mp) ans+=p.second*(p.second-1)/2;
  rep(k,n) {
    ll num=mp[A[k]];
    ll val=max(0ll,ans-(num-1));
    print(val);
  }
  return 0;
}

Measured memory_bytes: 11136
# B - Some Sums
n,a,b = [int(i) for i in input().split()]
count_list = []
for j in range(1,n+1):
    num = sum([int(k) for k in str(j)])
    if a<= num <=b:
        count_list.append(j)


        

    
print(sum(count_list))



Measured memory_bytes: 3296
#include <iostream>

using namespace std;

int main()
{
  char str[10];
  cin >> str;
  if ((str[0] == '7') || (str[1]=='7') || (str[2] == '7') )
  {
    cout << "Yes";
    return 0;
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }

  void __solve(Scanner cin) {
	  int N = cin.nextInt();
	  int K = cin.nextInt();
	  String s = cin.next();
	  String ans = "";
	  for( int i = 0; i < N; ++i ) {
		  if( i + 1 == K ) {
			  ans += (char)(s.charAt(i) - 'A' + 'a');
		  }
		  else {
			  ans += s.charAt(i);
		  }
	  }
	  System.out.println(ans);
  }

}


Measured memory_bytes: 21332
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
    int64_t N,K;
    cin >> N >> K;
    int32_t Ai[200001];
    int64_t Aiused[200001];
    int32_t realstate[200000];

    for(int i=1;i<=N;++i){
        cin>> Ai[i];
        Aiused[i]=-1;
        realstate[i-1]=0;
    }
    int64_t mod=K+1;
    int64_t offset=0;

    Aiused[1] = 0;
    realstate[0] = 1; 
    int32_t jump=Ai[1];
    int64_t i;
    for(i=1;i<=K;i++){
        if(Aiused[jump] < 0){
            Aiused[jump] = i;
            realstate[i] = jump;/*current city*/
            jump= Ai[jump];/*next city*/
        }
        else{
            offset = Aiused[jump];
            mod = i - offset;
            break;
        }
//        cout<<i<<"city"<<realstate[i]<<"next"<<jump<<endl;
    }
/*
cout<<Ai[jump]<<endl;
cout<<i<<endl;
cout<<mod<<endl;
cout<<offset<<endl;
*/
    uint64_t valnum = offset + ((K-offset) % mod);

    cout<< realstate[valnum] <<endl;
}



Measured memory_bytes: 6748
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];
    sort(v.rbegin(), v.rend());
    priority_queue<pii> pq;
    pq.push({v[1], v[0]});
    pq.push({v[1], v[0]});
    ll ans = v[0];
    for(int i = 2; i < n; i++){
        pii p = pq.top();   pq.pop();
        ans += p.first;
        pq.push({v[i], p.first});
        pq.push({v[i], p.second});
    }
    cout << ans << endl;
    return 0;
}

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

int rem[1000000];

void solve(int x, int y){
  int a, b;
  memset(rem, -1, sizeof(rem));
  for (int i = 0; ; i++) {
    if (rem[x] != -1) {
      if (x == 0) {
        a = i - 1; b = 0;
      } else {
        a = rem[x]; b = i - rem[x];
      }
      break;
    }
    rem[x] = i;
    x *= 10;
    x %= y;
  }
  cout << a << " " << b << endl;
}

int main(void) {
  int x, y;
  while (cin >> x >> y, x && y) {
    solve(x, y);
  }
  return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 1e6;
bool sieve[N + 1];

int main() {
  sieve[0] = sieve[1] = true;
  FOR(i, 2, N + 1){
    if (sieve[i]) continue;
    for(int j = i * 2; j < N  + 1; j += i) {
      sieve[j] = true;
    }
  }

  int a, d, n;
  while(cin >> a >> d >> n, a | d | n) {
    int cnt = 0;
    int m = 0;
    while(cnt < n) {
      if (!sieve[a + d * m]) cnt++;
      m++;
    }
    m--;
    cout << a + d * m << endl;
  }
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define int long long

int N, W;
int w[100], v[100];
int dp[101][100001];

signed main() {
  cin >> N >> W;
  for(int i=0; i<N; i++) cin >> w[i] >> v[i];

  for(int i=0; i<=N; i++) for(int j=0; j<=N*1000; j++) dp[i][j] = 1LL<<31;

  dp[0][0]=0;
  for(int i=0; i<N; i++) for(int j=0; j<=N*1000; j++) {
    if(j-v[i] >=0) dp[i+1][j] = min(dp[i][j-v[i]] + w[i], dp[i][j]);
    else           dp[i+1][j] = dp[i][j];
  }

  int ans = 0;
  for(int i=0; i<=N*1000; i++) if(dp[N][i] <= W) ans = i;
  
  printf("%lld\n", ans);
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;
typedef long long ll;

int main() {

    string T;
    cin >> T;
    rep(i,T.size()) cout << (T[i] == '?' ? 'D' : T[i]);
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
  int n;
  long long a[200005] = {0};
  long long sum = 0;
  long long ans = 0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum = sum + a[i];
    sum = sum % 1000000007;
    //cout << sum << ' ';
  }
  //cout << endl << endl;
  for(int i=0;i<n-1;i++){
    sum -= a[i];
    if(sum < 0) sum+= 1000000007;
    long long tmp = (long long)a[i] * (long long)sum;
    tmp = tmp % 1000000007;
    ans += tmp;
    ans = ans % 1000000007;
    //cout << sum << ' ' << ans << endl;
  }
  if(ans < 0) ans += 1000000007;
  cout << ans;

  // long long sum2 = 0;
  // for(int i=0;i<n-1;i++){
  //   for(int j=i+1;j<n;j++){
  //     sum2 = sum2 + a[i] * a[j];
  //     sum2 = sum2 % 1000000007;
  //   }
  // }
  // //1000000000
  // cout << sum2 << endl;
  return 0;
}


Measured memory_bytes: 5172
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }


int main() {
	vector<int> a(3);
	REP(i, 3) {
		cin >> a[i];
	}
	SORT(a);
	put(a[0] + a[1]);
	return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

fn main() {
    let mut S = String::new();
    std::io::stdin().read_line(&mut S).unwrap();
    let S = S.trim();
    if S.eq("Sunny") {
        println!("Cloudy");
    } else if S.eq("Cloudy") {
        println!("Rainy");
    } else {
        println!("Sunny");
    }
}


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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

class mint{
    ll n;
public:
    mint(ll m = 0){
        n = ((m % MOD) + MOD) % MOD;
    }
    mint operator-() const {
        return mint(-n);
    }
    mint& operator+=(const mint& m){
        n += m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator-=(const mint& m){
        n += MOD - m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& m){
        n *= m.n;
        n %= MOD;
        return *this;
    }
    mint operator+(const mint& m) const{
        mint res(*this);
        res += m;
        return res;
    }
    mint operator-(const mint& m) const{
        mint res(*this);
        res -= m;
        return res;
    }
    mint operator*(const mint& m) const{
        mint res(*this);
        res *= m;
        return res;
    }
    mint pow(ll t) const{
        if(t == 0) return mint(1);
        mint m = pow(t>>1);
        m *= m;
        if(t & 1 == 1) m *= *this;
        return m;
    }
    // for prime modulo
    mint inv() const{
        return pow(MOD-2);
    }
    mint& operator/=(const mint& m){
        (*this) *= m.inv();
        n %= MOD;
        return *this;
    }
    mint operator/(const mint& m) const{
        mint res(*this);
        res /= m;
        return res;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.n;
        return os;
    }
};

ll N,K;
ll a[100];
mint dp[100][100001];

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> a[i];
    for(int j=0;j<=K;j++){
        if(j <= a[0]) dp[0][j] = mint(1);
        else mint(0);
    }
    for(int i=1;i<N;i++){
        for(int j=0;j<=K;j++){
            if(j == 0){
                dp[i][j] = mint(1);
                continue;
            }
            dp[i][j] = dp[i][j-1] + dp[i-1][j];
            if(j-a[i]-1 >= 0) dp[i][j] -= dp[i-1][j-a[i]-1];
        }
    }
    cout << dp[N-1][K] << endl;
    return 0;
}

Measured memory_bytes: 78336
from itertools import product

s = tuple(map(int, tuple(input())))

options = (-1, 1)

for op1, op2, op3 in product(options, repeat=3):
    if (s[0] + s[1] * op1 + s[2] * op2 + s[3] * op3) == 7:
        _op1 = "+" if op1 == 1 else "-"
        _op2 = "+" if op2 == 1 else "-"
        _op3 = "+" if op3 == 1 else "-"
        print(s[0], _op1, s[1], _op2, s[2], _op3, s[3], "=7", sep="")
        exit()



Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>

using namespace std;
int main()
{
    int N,K;
    cin >> N >> K;
    vector<bool> OK(N,false);
    for(int i=0; i<K; i++)
    {
        int num;
        cin >> num;
        for(int j=0; j<num; j++)
        {
            int a;
            cin >> a;
            OK[a-1] = true;
        }
    }

    int sum = 0;
    for(auto ok: OK)
    {
        if(!ok)
            ++sum;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3620
class OR_seg:
    def __init__(self,n,init_val,ide_ele = 0):
        # set_val
        self.ide_ele = ide_ele
        self.n = n
        self.num = 2 ** (self.n - 1).bit_length()
        self.seg = [self.ide_ele] * 2 * self.num
        for i in range(n):
            self.seg[i + self.num - 1] = init_val[i]
            # built
        for i in range(self.num - 2, -1, -1):
            self.seg[i] = self.seg[2 * i + 1] | self.seg[2 * i + 2]

    def update(self,k, x):
        k += self.num - 1
        self.seg[k] = x
        while k + 1:
            k = (k - 1) // 2
            self.seg[k] = self.seg[2 * k + 1] | self.seg[2 * k + 2]

    def add(self,k, x):
        k += self.num - 1
        self.seg[k] += x
        while k + 1:
            k = (k - 1) // 2
            self.seg[k] = self.seg[2 * k + 1] | self.seg[2 * k + 2]



    def query(self,p, q):
        if q <= p:
            return self.ide_ele
        p += self.num - 1
        q += self.num - 2
        res = self.ide_ele
        while q - p > 1:
            if p & 1 == 0:
                res |= self.seg[p]

            if q & 1 == 1:
                res |= self.seg[q]
                q -= 1
            p = p // 2
            q = (q - 1) // 2

        res = res | self.seg[p]|self.seg[q]

        return res
def bit_count(x): #立ってるビットの本数を出力
    n = 0
    while x:
        n += 1
        x &= x-1

    return n

alpha_small_dict = {chr(i):i-97 for i in range(97, 97+26)} #辞書ver
n = int(input())
S = input()
init = [2**alpha_small_dict[x] for x in S]
#print(init)
seg = OR_seg(n,init)
q = int(input())
for i in range(q):
    x,y,z = input().split()
    x,y = int(x),int(y)
    #print(x,y,z)
    if x == 1:
        num = alpha_small_dict[z]
        seg.update(y-1,2**num)
    else:
        z = int(z)
        ans = seg.query(y-1,z)
        print(bit_count(ans))

Measured memory_bytes: 79892
N = int(input())
s = [int(input()) for _ in range(N)]
flag = True

for si in s:
    flag &= si%10==0

S = sum(s)

if flag:
    print(0)
elif S%10!=0:
    print(S)
else:
    ans = 0
    
    for si in s:
        if (S-si)%10!=0:
            ans = max(ans, S-si)
    
    print(ans)

Measured memory_bytes: 38256
# D-Knapsack 1
N,W = map(int,input().split())
Weight = [0 for _ in range(N)]
Value = [0 for _ in range(N)]
for i in range(N):
    Weight[i],Value[i] = map(int,input().split())

dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(N):
    # あらゆる合計重量sum_wに対して品物iを入れるべきか計算する
    for sum_w in range(W+1):
        # i番目を選ぶ場合
        if sum_w - Weight[i] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - Weight[i]] + Value[i])

        #　i番目を選ばない場合
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])

print(dp[N][W])

Measured memory_bytes: 171912
import java.awt.Point;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner sc = new Scanner(System.in);
		int c = 1;
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			Point[] v = new Point[n];
			for (int i = 0; i < n; i++) {
				v[i] = new Point(sc.nextInt(), sc.nextInt());
			}
			int sum = 0;
			for (int i = 0; i < n - 1; i++) {
				sum += ep(v[i], v[i + 1]);
			}
			sum += ep(v[n - 1], v[0]);
			System.out.print(c + " ");
			double ans = Math.abs(1.0 * sum / 2.0);
			System.out.println(ans);
			c++;
		}
	}

	public static int ep(Point a, Point b) {
		return a.x * b.y - a.y * b.x;
	}
}

Measured memory_bytes: 12000
N,M = map(int,input().split())
PY = [list(map(int,input().split()))+[i] for i in range(M)]

num = [0]*N
ans = [""]*M

PY.sort(key = lambda x:x[1])

for p,y,i in PY:
    num[p-1] += 1
    ans[i] = str(p).zfill(6) + str(num[p-1]).zfill(6)

for a in ans:
    print(a)


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

int main(){
    int N,X,Y;cin>>N>>X>>Y;
    X--;
    Y--;
    vector<vector<int>> connect(N,vector<int>(0));
    for(int i=0;i<N-1;i++){
        connect[i].push_back(i+1);
        connect[i+1].push_back(i);
    }
    connect[X].push_back(Y);
    connect[Y].push_back(X);
    vector<int> count(N,0);
    for(int i=0;i<N;i++){
        queue<int> q;q.push(i);
        vector<int> check(N,-1);
        check[i]=0;
        int c=1;
        while(q.size()!=0){
            int a=q.front();
            q.pop();
            for(int j=0;j<connect[a].size();j++){
                if(check[connect[a][j]]==-1){
                    q.push(connect[a][j]);
                    check[connect[a][j]]=check[a]+1;
                    count[check[connect[a][j]]]++;
                }
            }
        }
    }
    for(int i=1;i<N;i++)cout<<count[i]/2<<endl;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
	
int main(){
	ll n,m;
	cin>>n>>m;
	char a[n][m];
	int b[n+1][m+1];
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	for(int i = 0;i<n+1;i++)
	{
		for(int j=0;j<m+1;j++)
		{
			if(i == 1 && j ==1)
				b[i][j] = 1;
			else if(i==0 || j==0)
				b[i][j] = 0;
			else if(a[i-1][j-1] == '.')
				b[i][j] = (b[i-1][j]+b[i][j-1])%mod;
			else
				b[i][j] = 0;
		}
	}
	cout<<b[n][m]<<endl;
	return 0;
}


Measured memory_bytes: 8512
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<int> A;
    set<int> p;
    // set<int> m;
    //iより小さくてAj+j =?
    //iより大きくてAj-j=?
    for(int i = 0;i < N;i++){
        int a;cin>>a;
        A.push_back(a);
        p.insert(a+i+1);
        p.insert(a-i-1);
        // m.insert(a-i-1);
    }
    vector<int> pl, ml;
    for(int a : p){
        pl.push_back(a);
    }
    // for(int a : m){
    //     ml.push_back(a);
    // }
    sort(pl.begin(), pl.end());
    // sort(ml.begin(), ml.end());
    map<int,int> pd, md;
    for(int i = 0;i < pl.size();i++){
        pd[pl[i]] = i;
    }
    // for(int i = 0;i < ml.size();i++){
    //     md[ml[i]] = i;
    // }

    ll res = 0;
    vector<int> api(p.size(),0);
    for(int i = 0;i < N;i++){
        res += api[pd[-A[i]+i+1]];
        api[pd[A[i]+i+1]]++;
    } 
    // vector<int> ami(m.size(),0);
    // for(int i = N-1;i >= 0;i--){
    //     res += ami[md[-A[i]-i-1]];
    //     ami[md[A[i]-i-1]]++;
    // }
    cout<<res<<endl;
    

}

Measured memory_bytes: 48280
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

import math
ans = 0
for i in range(N):
  p = P[i]
  q = Q[i]
  for j in range(i):
    if P[i] > P[j]:
      p -= 1
    if Q[i] > Q[j]:
      q -= 1
  ans += (p-q)*(math.factorial(N-i-1))
print(abs(ans))

Measured memory_bytes: 9164
#include <iostream>
#include<string>
using namespace std;
int main(){

    int n=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='+'){
            n++;
        }else{
            n--;
        }
    }

    cout<<n<<endl;



return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
 int N;
 cin>>N;
 int ac=0,wa=0,tle=0,re=0;
 for(int i=0;i<N;i++){
   string s;
   cin>>s;
   if(s=="AC"){ac++;}
   if(s=="WA"){wa++;}
   if(s=="TLE"){tle++;}
   if(s=="RE"){re++;}
 }
 cout<<"AC x "<<ac<<endl;
 cout<<"WA x "<<wa<<endl;
 cout<<"TLE x "<<tle<<endl;
 cout<<"RE x "<<re<<endl;
 return 0;
}

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

int main() {
    int h,w,k;
    cin >> h>>w>>k;
    vector<vector<string>> c(h,vector<string>(w));
    vector<string> nyuuryoku(h);
    rep(i,h){
        cin >> nyuuryoku[i];
    }
    rep(i,h){
        rep(j,w){
            c[i][j]=nyuuryoku[i].substr(j,1);
        }
    }

    int ans =0;

    for(int bit_tate=0; bit_tate<(1<<h); bit_tate++){
        for(int bit_yoko=0; bit_yoko<(1<<w); bit_yoko++){
            int hantei=0;
            rep(i,h){
                rep(j,w){
                    if(c[i][j]=="#"&&(bit_tate&(1<<i))&&(bit_yoko&(1<<j))){
                        hantei++;
                    }
                }
            }
            if(hantei==k){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> P(N);
    REP(i, N) { cin >> P.at(i); }

    int now_min = P[0];
    int ans = 1;
    FOR(i, 1, N) {
        if (now_min > P[i]) {
            ans++;
            now_min = P[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

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

    int n;
    cin >> n;

    int cnt = 0;
    int si = 0;
    for (int i = 1; i <= 1000; i++)
    {
        cnt += i;
        si++;
        if (n == cnt)
            break;
    }

    if (n != cnt)
    {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl
         << si + 1 << endl;

    int t[1100][1100];

    cnt = 1;
    for (int i = 0; i < si; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            t[i][j] = cnt;
            cnt++;
        }
    }

    for (int i = 0; i < si; i++)
    {

        cout << si;

        for (int j = 0; j < i; j++)
        {
            cout << " " << t[i][j];
        }

        for (int j = i; j < si; j++)
        {
            cout << " " << t[j][i];
        }

        cout << endl;
    }

    cout << si;

    cnt = 2;
    for (int i = 0; i < si; i++)
    {
        cout << " " << cnt * (cnt - 1) / 2;
        cnt++;
    }

    cout << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;


ll N, M, Q, A, B, C;

string s;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> s;
	N = (s[0]-'0')*10 + (s[1]-'0');
	M = (s[2]-'0')*10 + (s[3]-'0');
	//cout << N << ' ' << M << '\n';
	if (N > 12 && M > 12){
		cout << "NA";
	}
	else if (N > 12 && M == 0){
		cout << "NA";
	}
	else if (N > 12 && M <= 12){
		cout << "YYMM";
	}
	else if (N == 0 && M > 12){
		cout << "NA";
	}
	else if (N <= 12 && M > 12){
		cout << "MMYY";
	}
	else if (N == 0 && M == 0){
		cout << "NA";
	}
	else if (N <= 12  && M == 0){
		cout << "MMYY";
	}
	else if (N == 0 && M <= 12){
		cout << "YYMM";
	}
	else if (N <= 12 && M <= 12){
		cout << "AMBIGUOUS";
	}
	cout << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
#include <vector>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

typedef vector<int> vi;
typedef long long ll;

int main(){
    int n;
    while(cin >> n && n){
        vi v(n+1);
        rep(i,n){
            int x; cin >> x;
            v[i+1] = x;
            if(i!=0) v[i+1]+=v[i];
        }
        // rep(i,n+1){
        //     cout << v[i] << endl;
        // }
        ll ans=-(1<<30);
        for(int l=0; l<n; l++){
            for(int r=l+1; r<=n; r++){
                ans = max<ll>(ans, v[r]-v[l]);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1200
import copy
n = int(input())
x = list(map(int,input().split()))
a = copy.deepcopy(x)
x.sort()
for i in range(n):
    if x[int(n/2)-1]<a[i]:
        print(x[int(n/2)-1])
    else:
        print(x[int(n/2)])


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

using namespace std;

int main() {
  int n,m,x;
  cin >> n >> m >> x;
  vector<vector<int>> a(n,vector<int>(m));
  vector<int>c(n);
  
  for(int i=0; i<n; i++){
    cin >> c[i];
  	for(int j=0; j<m; j++){
    	cin >> a[i][j];
    }
  }
  
  int ans = 12345678;
  int all = 1<<n;
  
  
  for(int mask = 0; mask < all; mask++){
  	vector<int>level(m);
    int cost = 0;
    for(int i=0; i<n;i++){
    	if((mask>>i)&1){
        	cost += c[i];
          for(int j=0; j < m; j++){
          	level[j] += a[i][j];
          }
        }
    }
    
      bool ok=true;
      for(int j = 0; j < m; j++){
        if(level[j] < x) ok = false;
      }
      if(ok) ans = min(ans,cost);
   }
  
    if(ans == 12345678) cout << -1 << endl;
    else cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3532
rect :: [String] -> [String]
rect (h:w:_) = (\(x:y:_) -> replicate x $ replicate y '#') $ [read h, read w] 

main=do
    xs <- fmap (map words . lines) getContents
    mapM putStrLn . map unlines . map rect $ takeWhile (\(x:xs) -> x/="0") xs


Measured memory_bytes: 4652
#include<stdio.h>
#include<stdlib.h>


long long count = 0;

void merge(int arr[],int l,int m,int r)
{
	int n1 = m-l + 1;
	int n2 = r-m;
	
	int L[n1],R[n2];
	
	for(int i=0; i<n1; i++)
	{
		L[i] = arr[l + i];
	}
	for(int j=0; j<n2 ;j++)
	{
		R[j] = arr[m + 1 + j];
	}
	
	int i=0;
	int j=0;
	int k=l;
	
	while(i<n1 && j<n2)
	{
		if(L[i] <= R[j])
		{
			arr[k] = L[i];
			i++;
		}
		else{
			arr[k] = R[j];
			j++;
			count+= (n1)-i;
		}
		k++;
	}
	
	while(i<n1)
	{
		arr[k] = L[i];
		i++;
		k++;
	}
	
	while(j<n2)
	{
		arr[k] = R[j];
		j++;
		k++;
	}
	
}

void mergeSort(int arr[],int l,int r)
{
	if(l<r)
	{
		int m = (l+r)/2;
		mergeSort(arr,l,m);
		mergeSort(arr,m+1,r);
	
		merge(arr,l,m,r);
	}
}


int main()
{
	int input,tc;
	int arr[200010];
	
	scanf("%d",&tc);getchar();
	for(int i=0;i<tc;i++)
	{
		scanf("%d",&input);
		arr[i] = input;
	}
	
	mergeSort(arr,0,tc-1);
	
//	for(int i=0;i<tc;i++)
//	{
//		printf("%d ",arr[i]);
//	}
//	puts("");
	printf("%lld\n",count);
	return 0;
}


Measured memory_bytes: 3364
import java.util.Scanner;
import java.io.PrintWriter;

class Main {
    static int distanceInteger(int n, int d, int[][] x) {
        int diff_sum, diff, sqrt, count = 0;
        for (int i = 0; i < n; i ++) {
            for (int j = i + 1; j < n; j ++) {
                diff_sum = 0;
                for (int l = 0; l < d; l ++) {
                    diff = x[i][l] - x[j][l];
                    diff_sum += diff * diff;
                }
                sqrt = sqrtInteger(0, diff_sum, diff_sum);
                if (sqrt * sqrt == diff_sum) count ++;
            }
        }
        return count;
    }

    static int sqrtInteger(int left, int right, int target) {
        if (left >= right) return left;
        int mid = (left + right) / 2;
        int midSquare = mid * mid;
        if (midSquare == target) return mid;
        if (midSquare < target) return sqrtInteger(mid + 1, right, target);
        return sqrtInteger(left, mid - 1, target);
    }



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

        int n = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());

        int[][] x = new int[n][d];
        for (int i = 0; i < n; i ++) {
            for (int j = 0; j < d; j ++) {
                x[i][j] = Integer.parseInt(sc.next());
            }
        }

        out.println(distanceInteger(n, d, x));
        out.flush();
    }
}


Measured memory_bytes: 22612
//@source: 
//@create: 19:03:31 Sunday 02/08/2020
//@author: nghethuat102
#include <bits/stdc++.h>
using namespace std;

#define len(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define discrete(x) sort(all(x), x.erase(unique(all(x)), x.end())

void solve() {
    int k;
    cin >> k;
    vector<int> b(k, 0);
    queue<int> q;
    q.push(7 % k);
    b[7 % k] = 1;
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        int x = (u * 10 + 7) % k;
        if (b[x] == 0) {
            b[x] = b[u] + 1;
            q.push(x);
        }
    }
    if (b[0] == 0) {
        cout << "-1\n";
    } else {
        cout << b[0] << "\n";
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    for (int it = 1; it <= t; ++it) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 7160
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

use rand::Rng;


fn main() {
    input! {
        D: usize,
        C: [i32; 26],
        S: [[i32; 26]; D],
    }

    let score = |sol: &Vec<i32>| -> i32 {
        let mut sat: i32 = 0;
        let mut last = vec![0; 26];
        for (d, v) in sol.iter().enumerate() {
            let j: usize = (v - 1) as usize;
            last[j] = d + 1;
            for i in 0..26 {
                sat -= (d + 1 - last[i]) as i32 * C[i];
            }
            sat += S[d][j];
        }

        return sat;
    };

    let mut ans:Vec<i32> = vec![1; D];
    // let mut last = vec![0; 26];
    // for d in 0..D {
    //     let mut ma = 0;
    //     let mut mai = 0;
    //     for j in 0..26 {
    //         let a = (d + 1 - last[j]) as i32 * C[j] + S[d][j];
    //         if a > ma {
    //             ma = a;
    //             mai = j;
    //         }
    //     }
    //     last[mai] = d + 1;
    //     ans.push((mai+1) as i32);
    // }

    let mut rng = rand::thread_rng();
    let mut s = score(&ans);
    for _ in 0..350000 {
        let c = rng.gen_range(1, 27);
        let d = rng.gen_range(0, D);
        let b = ans[d];
        ans[d] = c;
        let ss = score(&ans);
        if ss > s{
            s = ss;
        }else{
            ans[d] = b;
        }
    }

    for c in ans {
        println!("{}", c);
    }
}


Measured memory_bytes: 2712
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

ans=0
for i in range(N):
  ans+=B[A[i]-1]
  if i>0:
    if A[i]==A[i-1]+1:
      ans+=C[A[i]-2]

print(ans)

Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
mod = 10**9+7

pos = {}
neg = {}
n = 1
pos[0] = 1
neg[0] = 1
for i in range(1, 500000):
    n *= i
    n %= mod
    pos[i] = n
    neg[i] = pow(n, mod-2, mod)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from collections import Counter
primes = prime_factorize(M)
c = Counter(primes)
primes = list(set(primes))
leng = len(primes)
ans = 1
for i in range(leng):
    p = primes[i]
    n = c[p]
    ans *= pos[N+n-1]*neg[n]*neg[N-1]
    ans %= mod

print(ans)


Measured memory_bytes: 208344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    int n; cin >> n;
    string ans = "APPROVED";
    for(int i = 0;i < n;i++){
        int x; cin >> x;
        if(x % 2 == 0){
            if(x % 5 != 0 && x % 3 != 0){
                ans = "DENIED";
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    if(s1[s1.length()-1]==s2[0] && s2[s2.length()-1]==s3[0]){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,m;
	cin>>n>>m;
	ll cnt=0;
	ll cnt1=0;
	if(n==1){
		cnt=9;
		cnt1=0;
	}
	else if(n==2){
		cnt=99;
		cnt1=10;
	}
	else{
		cnt=999;
		cnt1=100;
	}
	ll s[6],c[6];
	for(ll i=0;i<m;i++){
		cin>>s[i]>>c[i];
		s[i]--;
		if(s[i]==0&&c[i]==0&&n!=1){
			cout<< -1;
			return 0;
		}
		s[i]+=3-n;
	}
	for(ll j=cnt1;j<=cnt;j++){
		ll ch[3];
		ll now=j;
		for(ll i=0;i<3;i++){
			ch[2-i]=now%10;
			now/=10;
		}
		bool ans=true;
		for(ll i=0;i<m;i++){
			if(ch[s[i]]!=c[i]){
				ans=false;
			}
		}
		if(ans){
			cout << j;
			return 0;
		}
	}
	cout << -1;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
int main()
{
    fastio();
   
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,sum=0;
        cin>>n;
        ll a[n];
        map<ll,ll> m;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            m[a[i]]++;
            sum+=a[i];
        }
        ll q;
        cin>>q;
        while(q--)
        {
            ll x,y;
            cin>>x>>y;
            ll diff = y-x;
            sum+= diff*m[x];
            m[y]+=m[x];
            m[x]=0;
            cout<<sum<<endl;
        }

    }
    
}

Measured memory_bytes: 10296
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int cnt = 0;
    for (int i=a; i<=b; ++i) {
        if (c % i == 0) {
            cnt ++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1164
import Data.List (foldl')
import Control.Monad (replicateM)
import qualified Data.Set as S

data Status = Status {
  end :: Char,
  history :: S.Set String
} deriving Show

status :: String -> Status
status s = Status (last s) (S.singleton s)

game :: String -> Status -> Maybe Status
game "" _ = Nothing
game w (Status c h)
  | head w == c = if S.member w h
                  then Nothing
                  else Just $ Status (last w) (S.insert w h)
  | otherwise = Nothing

doGames :: [String] -> Maybe Status
doGames (s:ss) = foldl' (\a b-> a >>= game b) (Just (status s)) ss

main = do
  n <- read <$> getLine :: IO Int
  ws <- replicateM n getLine
  case doGames ws of
    Nothing -> putStrLn "No"
    _ -> putStrLn "Yes"


Measured memory_bytes: 636
k,n=map(int,input().split())
l=list(map(int,input().split()))
s=0
a=[]
for i in range(0,n-1):
    a.append(l[i+1]-l[i])
a.append(k-l[-1]+l[0])
a.sort()
s=sum(a)
s-=a[-1]
print(s)
    

Measured memory_bytes: 25840
#include <iostream>
#include <string>

using namespace std;

int main(){
  string A,B; cin>>A>>B;

  if(A.size()>B.size()){
    cout<<"GREATER"<<endl; return 0;
  }
  else if(A.size()<B.size()){
    cout<<"LESS"<<endl; return 0;
  }
  else{
    for(int i=0;i<A.size();i++){
      if((A[i]-'0')>(B[i]-'0')){
        cout<<"GREATER"<<endl; return 0;
      }
      else if((A[i]-'0')<(B[i]-'0')){
        cout<<"LESS"<<endl; return 0;
      }
    }
  }

  cout<<"EQUAL"<<endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int x;
	cin >> x;
	printf("%d\n", 10 - x / 200);
	return 0;
}

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

#define SZ(x) (((int)x.size()))

using namespace std;

const int maxn = 110;
int n, m, val, a[maxn][maxn], mat[maxn];
bool mark[maxn];
vector<int> vec[maxn][maxn], tmp;
unordered_set<int> adj[maxn];

bool dfs(int x)
{
	if (mark[x])
		return 0;
	mark[x] = 1;
	for (auto u : adj[x])
	{
		if (mat[u] == -1 || dfs(mat[u]))
		{
			mat[u] = x;
			return 1;
		}
	}
	return 0;
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> val;
			val--;
			vec[i][val / m].push_back(val + 1);
			adj[val / m].insert(i);
		}
	}
	for (int i = 0; i < m; i++)
	{
		memset(mat, -1, sizeof mat);
		for (int j = 0; j < n; j++)
		{
			memset(mark, 0, sizeof mark);
			dfs(j);
		}
		for (int j = 0; j < n; j++)
		{
			a[j][i] = vec[j][mat[j]].back();
			vec[j][mat[j]].pop_back();
			if (SZ(vec[j][mat[j]]) == 0)
				adj[mat[j]].erase(j);
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			cout << a[i][j] << " ";
		cout << endl;
	}
	for (int i = 0; i < m; i++)
	{
		tmp.clear();
		for (int j = 0; j < n; j++)
			tmp.push_back(a[j][i]);
		sort(tmp.begin(), tmp.end());
		for (int j = 0; j < n; j++)
			a[j][i] = tmp[j];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			cout << a[i][j] << " ";
		cout << endl;
	}
	return 0;
}


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

int main()
{
    int r, d;
    vector<ll> x(11);
    cin >> r >> d >> x[0];
    rep(i,10) x[i+1] = (ll)r*x[i] -d;

    rep(i,10) cout << x[i+1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
int n = 3005;
vector<int> a(n);
vector<vector<ll>> dp(n,vector<ll>(n,0));
vector<vector<bool>> flg(n,vector<bool>(n,false));

ll dfs(int l,int r){
    if(l==r){
      if((n-1)%2==0){
        flg.at(l).at(r) = true;
        return dp.at(l).at(r) = a.at(r);
      }else{
        flg.at(l).at(r) = true;
        return dp.at(l).at(r) = -a.at(l);
      }
    }
    if(!flg.at(l).at(r-1)){
      dp.at(l).at(r-1) = dfs(l,r-1);
      flg.at(l).at(r-1) = true;
    }
    if(!flg.at(l+1).at(r)){
      dp.at(l+1).at(r) = dfs(l+1,r);
      flg.at(l+1).at(r) = true;
    }
  if((n-1-r+l)%2 == 0){
    dp.at(l).at(r) = max(dp.at(l).at(r-1)+a.at(r),dp.at(l+1).at(r)+a.at(l));
  }else{
    dp.at(l).at(r) = min(dp.at(l).at(r-1)-a.at(r),dp.at(l+1).at(r)-a.at(l));
  }
  return dp.at(l).at(r);
}                         
 
int main() {
  cin >> n;
  rep(i,n) cin >> a.at(i);
  cout << dfs(0,n-1) << endl;
 
  return 0;
}




Measured memory_bytes: 72448
from math import gcd
n, m = map(int, input().split())
alst = list(map(int, input().split()))
loop = m // gcd(n, m)
alst = alst * loop
ans = 0
for i in range(0, loop * n, m):
  ans += max(alst[i:i+m]) - min(alst[i:i+m])
print(ans)


Measured memory_bytes: 12844
#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

bool judge(double x[2], double y[2]) {
	double cross = x[0] * y[1] - y[0] * x[1];
	if(cross >= 0) return true;
	else return false;
}

int main() {
	double x1, y1, x2, y2, x3, y3, xp, yp;
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF) {
		double ax[2], ay[2];
		ax[0] = x2 - x1;
		ay[0] = y2 - y1; 
		ax[1] = xp - x1;
		ay[1] = yp - y1;
		double bx[2], by[2];
		bx[0] = x3 - x2;
		by[0] = y3 - y2;
		bx[1] = xp - x2;
		by[1] = yp - y2;
		double cx[2], cy[2];
		cx[0] = x1 - x3;
		cy[0] = y1 - y3;
		cx[1] = xp - x3;
		cy[1] = yp - y3;
		if(judge(ax, ay) && judge(bx, by) && judge(cx, cy) || !judge(ax, ay) && !judge(bx, by) && !judge(cx, cy)) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1228
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    ll n1=n;
    ll ans=0;
    while(n1){
        ans+=n1%10;
        n1/=10;
    }
    if(n%ans==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
 int main(){
    int n,k; cin >> n >> k;
    double sum=0;
    for(int i=1;i<=n;i++){
        int t=0;
        while(k>i*pow(2,t)){
            t++;
        }
        sum+=1.0/(n*pow(2,t));
    }
    
  printf("%.12f\n",sum);
 }


Measured memory_bytes: 256