akhauriyash/Code-Regression huggingface dataset:
const val MOD = 1000000007L

fun main(args: Array<String>) {
    val (X, Y) = listOfInt()
    var s = X + Y
    if (s % 3 != 0) {
        println(0)
        return;
    }
    s /= 3
    val x = X - s
    val y = Y - s
    if (x < 0 || y < 0) {
        println(0)
        return;
    }
    val ans = FermatCombination(x + y).combine(x + y, x).toString()
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

class FermatCombination(size: Int) {
    var factrial = LongArray(size + 1)
    var inverse = LongArray(size + 1)
    init {
        factrial[0] = 1
        inverse[0] = 1
        for (i in 1 .. size) {
            factrial[i] = factrial[i - 1] * i % MOD
            inverse[i] = pow(factrial[i], MOD.toInt() - 2) % MOD
        }
    }
    fun combine(n: Int, k: Int): Long {
        if (n < k || n < 0 || k < 0) return 0
        return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD
    }
    fun pow(x: Long, n: Int): Long {
        var x = x
        var n = n
        var ans: Long = 1
        while (n > 0) {
            if (n and 1 == 1) {
                ans = ans * x % MOD
            }
            x = x * x % MOD
            n = n shr 1
        }
        return ans
    }
}


Measured memory_bytes: 50264
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		//		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			System.out.println((numA - 1) * (numB - 1));

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int count = 0;
			for (int i = 1; i <= numN; i++) {
				if (i % 2 == 0) {
					continue;
				}
				int wk = i;
				Map<Integer, Integer> wkMap = new HashMap<Integer, Integer>();
				for (int j = 2; j < i;) {
					if (wk % j == 0) {
						wk /= j;
						wkMap.put(j, wkMap.get(j) == null ? 1 : wkMap.get(j) + 1);
					} else {
						j++;
					}
				}
				int wkRes = 1;
				for (Integer val1 : wkMap.values()) {
					wkRes *= (val1 + 1);
				}
				if (wkRes == 8) {
					count++;
				}
			}

			System.out.println(count);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB2() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int count = 0;
			int wkRes = 1;
			for (int i = 1; i <= numN; i++) {
				if (i % 2 == 0) {
					continue;
				}
				if (numN % i == 0) {
					wkRes++;
				}

			}
			if (wkRes == 8) {
				count++;
			}

			System.out.println(count);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		String wkS;
		long count = 0;

		try {
			scanner = new Scanner(System.in);
			wkS = scanner.next();
			count = scanner.nextLong();
			String wk = wkS;
			if (count <= wkS.length()) {
				wk = wkS.substring(0, (int) count);
			}
			for (int i = 0; i < wk.length(); i++) {
				if (wk.charAt(i) != '1') {
					System.out.println(wk.charAt(i));
					return;
				}
			}
			System.out.println(1);
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 21460
def resolve():
    import sys
    def max2(a: int, b: int):
        """
        入力された2つの整数a,bの大きいほうを返す
        Parameters
        ----------
        a, b : int
            比較したい整数
        Returns
        -------
        a or b : int
            大きいほうの整数
        """
        if a >= b:
            return a
        else:
            return b
    
    readline = sys.stdin.readline
 
    s = readline()
    t = readline()
 
    # 配るDP
    # dp[i + 1][j + 1]はsのi文字目までとtのj文字目までのLCSの長さ
    # LCS=最長共通部分列問題
    dp = [[0] * (len(t) + 1) for _ in [0] * (len(s) + 1)]
 
    for i in range(len(s)):
        for j in range(len(t)):
            if s[i] == t[j]:
                dp[i + 1][j + 1] = max2(dp[i + 1][j + 1], dp[i][j] + 1)
            dp[i + 1][j + 1] = max2(dp[i + 1][j + 1], dp[i + 1][j])
            dp[i + 1][j + 1] = max2(dp[i + 1][j + 1], dp[i][j + 1])
 
    # LCSを求めたDPから部分文字列を復元
    res = []
    i, j = len(s), len(t)
    while i > 0 and j > 0:
        if dp[i][j] == dp[i - 1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j - 1]:
            j -= 1
        else:
            res.append(s[i - 1])
            i -= 1
            j -= 1
    print(''.join(res[::-1]))
 
 
resolve()


Measured memory_bytes: 139080
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int N;
  string S;
  cin>>N>>S;
  int check=0;
  if(N%2) check++;
  else{
    rep(i,0,N/2){
      if(check) break;
      if(S[i]!=S[i+N/2]){
        check++;
        break;
      }
      
    }
  }
  cout<<(check?"No":"Yes");
      
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200000 + 5;

int a[maxn];

int main(){
    int n;
    cin >> n;
    int sum = 0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum ^=a[i];
    }
    for(int i=0;i<n;i++){
        printf("%d ",sum^a[i]);
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef vector<int>vint;
typedef pair<int,int>pint;


signed main(){
    int N,p[100]={0},r[100];

    cin>>N;
    rep(i,N*(N-1)/2){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--;b--;
        if(c>d)p[a]+=3;
        else if(c<d)p[b]+=3;
        else{
            p[a]++;p[b]++;
        }
    }

    vector<pint>vec(N);
    rep(i,N)vec[i]=pint(p[i],i);
    sort(all(vec));reverse(all(vec));

    int tmp=0;
    rep(i,N){
        if(i&&vec[i-1].first!=vec[i].first)tmp=i;
        r[vec[i].second]=tmp;
    }

    rep(i,N)cout<<r[i]+1<<endl;
    return 0;
}

Measured memory_bytes: 1200
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(C - (A - B), 0) << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

vector<ll> A;
ll N,M,V,P;

bool check(int p){
    if(N-p <= P) return true;
    vector<ll> v;
    for(int i=0;i<N;i++){
        if(v.size() >= N-P) break;
        if(i==p) continue;
        v.push_back(A[i]);
    }
    ll ap = A[p] + M;
    if(ap < v.back()) return false;
    ll ac = 0;
    for(auto &e : v) ac += min(M,ap-e);
    if(ac >= (V-P) * M) return true;
    else return false;
}

int main(){
    cin >> N >> M >> V >> P;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    int sp = -1;
    int ep = N-1;
    while(ep-sp > 1){
        int p = (ep+sp) / 2;
        if(check(p)){
            ep = p;
        }else{
            sp = p;
        }
    }
    cout << N-ep << endl;
    return 0;
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n, x, y;
    cin >> n >> x >> y;

    vector<vector<int>> dist(n + 1);

    dist[1].pback(2);

    rep(i, n - 2){
        dist[i + 2].pback(i + 3);
        dist[i + 2].pback(i + 1);;
    }

    dist[n].pback(n - 1);

    dist[x].pback(y);
    dist[y].pback(x);

    vector<int> count(n);

    for(int i = 1; i <= n; i++){

        vector<int> tmpdist(n + 1, INT_MAX);
        
        queue<pair<int,int>> q;

        q.push(mpair(i, 0));

        while(!q.empty()){
            int node = q.front().first;
            int d = q.front().second;

            if(d < tmpdist[node]){
                tmpdist[node] = d;

                rep(j, dist[node].size()){
                    q.push(mpair(dist[node][j], d + 1));
                }
            }

            q.pop();
        }

        for(int j = 1; j <= n; j++){
            count[tmpdist[j]]++;
        }

    }

    for(int i = 1; i < n; i++){
        assert(count[i] % 2 == 0);
        cout << count[i] / 2 << endl;
    }


    return 0;
}


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

public class Main {
  Scanner sc;

  class Pair {
    int f;
    int s;

    Pair(int f_, int s_) {
      f = f_;
      s = s_;
    }
  }

  void run() {
    for ( ;; ) {
      int n = ni();

      if ( n == 0 ) {
        break;
      }

      char[][] strs = new char[n][];
      for ( int i = 0; i < n; ++i ) {
        strs[ i ] = sc.next().toCharArray();
      }

      // phase 1
      int[] story = new int[n];
      for ( int i = 0; i < n; ++i ) {
        int idx = -1;
        for ( int j = 0; j < strs[ i ].length; ++j ) {
          if ( strs[ i ][ j ] == '.' ) {
            idx = j;
          }
        }
        story[ i ] = idx;
        if ( idx == -1 ) {
          continue;
        }
        strs[ i ][ idx ] = '+';
      }

      // phase 2
      for ( int i = 0; i < n; ++i ) {
        for ( int j = i + 1; j < n; ++j ) {
          if ( story[ i ] > story[ j ] )
            break;
          if ( story[ i ] == story[ j ] ) {
            for ( int k = i + 1; k < j; ++k ) {
              strs[ k ][ story[ i ] ] = '|';
            }
            break;
          }
        }
      }

      // phase 3
      for ( int i = 0; i < n; ++i ) {
        for ( int j = 0; j < strs[ i ].length; ++j ) {
          if ( strs[ i ][ j ] == '.' ) {
            strs[ i ][ j ] = ' ';
          }
        }
      }

      for ( int i = 0; i < n; ++i ) {
        System.out.println( new String( strs[ i ] ) );
      }
    }
  }

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

  int ni() {
    return sc.nextInt();
  }

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

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 71420
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=5e5+1;
int main()
{
    FASTINOUT;
    int x,m;
    cin>>x>>m;
    int p;
    string c;
    set<int>st;
    set<int>wr;
    map<int,int>mp;
    int acep=0,pen=0;
    for (int i=0;i<m;i++){
        cin>>p;
        cin>>c;
        if (c=="AC" &&st.find(p)==st.end()){
            acep++;
            st.insert(p);
        }
        else{
            if (st.find(p)==st.end()){
                pen++;
                wr.insert(p);
                mp[p]++;
            }
        }
    }
    for (auto i=wr.begin();i!=wr.end();i++){
        if (st.find(*i)==st.end()){
            pen-=mp[*i];
        }
    }
    cout<<acep<<" "<<pen<<endl;
    return 0;
}


Measured memory_bytes: 6144
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        
        Set<Integer> brokensteps = new HashSet<Integer>();
        for(int i = 0;i < m;i++){
            brokensteps.add(scanner.nextInt());
        }
        scanner.close();

        long[] dp;
        dp = new long[n+1];
        dp[0] = 1;

        for(int i = 1;i < n+1;i++){
            if(brokensteps.contains(i)){
                dp[i] = 0;
                continue;
            }

            if(i == 1){
                dp[i] = 1;
                continue;
            }

            dp[i] = (dp[i-1] + dp[i-2]) % ((long)(Math.pow(10,9)) + 7);

        }

        System.out.println(dp[n]);




    }
}

Measured memory_bytes: 63400
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int ar[3];
cin>>ar[0]>>ar[1]>>ar[2];
sort(ar,ar+3);
int a=ar[0],b=ar[1],c=ar[2];
int ans=0;
ans+=c-b;
a+=c-b;
b=c;
ans+=(b-a+1)/2;
a+=((b-a+1)/2)*2;
if(a>b)
++ans;
cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

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

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

int nextInt()
{
    int y = 0;
    char c = getchar();
    while ('0' <= c && c <= '9')
    {
        y = 10 * y + c - '0';
        c = getchar();
    }
    return y;
}

long long max(long long a, long long b)
{
    if (a > b) return a;
    return b;
}

long long min(long long a, long long b)
{
    if (a < b) return a;
    return b;
}

int n;
int a[500000];

signed main()
{
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    cin >> n;
    long long ans = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    long long cnt = 0;
    for (int i = 0; i <= n; i++)
    {
        if (a[i] == 0)
        {
            ans += cnt / 2;
            cnt = 0;
        }
        cnt += a[i];
    }
    cout << ans;
}


Measured memory_bytes: 640
x,n=map(int,input().split())
p=list(map(int,input().split()))
temp=100
for i in range(x-51,x+51):
    a=abs(x-i)
    if a<temp and i not in p:
        temp=a
        ans=[i]
    if a==temp and i not in p:
        ans+=[i]
print(min(ans))

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/e.in", "r", stdin);
//  freopen("../IO/e.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

constexpr int P = 1000'000'007;

int64_t gcd(int64_t a, int64_t b) {
  while (b != 0) {
    tie(a, b) = make_pair(b, a % b);
  }
  return a;
}

void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;
  int z = 0;
  map<pair<int64_t, int64_t>, int> m1;
  for (int i = 0; i < n; ++i) {
    int64_t x, y;
    in >> x >> y;
    if (x == 0 && y == 0) {
      ++z;
      continue;
    }
    if (y < 0) {
      x = -x;
      y = -y;
    }
    int64_t g = gcd(abs(x), abs(y));
    x /= g;
    y /= g;
    m1[{x, y}]++;
  }
  vector<int> p2(1, 1);
  while (p2.size() < n + 100) {
    p2.push_back(p2.back() * 2 % P);
  }
  int64_t res = 1;
  for (auto &[x, y] : m1) {
    auto [a, b] = x;
    int64_t a1 = -b, b1 = a;
    if (b1 <= 0) {
      a1 = -a1;
      b1 = -b1;
    }
    res *= (p2[y] + p2[m1[{a1, b1}]] - 1);
    res %= P;
    m1[{a1, b1}] = 0;
    m1[{a, b}] = 0;
  }
  out << (z + res + P - 1) % P << '\n';
}


Measured memory_bytes: 28704
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
int  pow(int x,int n) {int res=1; while(n){if(n&1) res=(res*x);x=(x*x);n>>=1;}return res;}
 struct solve{
 	int wt, val;
 };
 
int max_wt(struct solve* arr,int W, int n ){
	int dp[n+1][W+1];

	for(int i=0;i<=W;i++){
		dp[1][i]=0;
	}
	dp[1][arr[1].wt] = arr[1].val;
	
	for(int i=2;i<=n;i++){
		for(int w=0;w<=W;w++){
			dp[i][w]= 0 + dp[i-1][w];
			if(w >= arr[i].wt)
			dp[i][w]=max(dp[i][w], arr[i].val + dp[i-1][w-arr[i].wt]);
		}
	}	
	return *max_element(dp[n], dp[n]+W+1);

}

int32_t main()
{
	//paawan9s
	FIO;
	int n, W; cin>>n>>W;
	mk(arr, n+1, solve );
	for(int i=1;i<=n;i++){
		cin>>arr[i].wt>>arr[i].val;
	}

	cout<< max_wt(arr, W, n);

	return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int takahashi =0;
  for (int i=0; i < s.size(); i++){
      if (s.at(i)=='+'){
          takahashi+=1;
      }else{
          takahashi-=1;
      }
  }
  cout << takahashi << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"

	"math"
)

type (
	Practice struct {
		No    int
		cnt   int
		bonus int
	}
	PS []Practice
)

var N, G, C, B int

func main() {
	fmt.Scan(&N, &G)
	var PA PS
	for i := 0; i < N; i++ {
		fmt.Scan(&C, &B)
		PA = append(PA, Practice{No: i + 1, cnt: C, bonus: B})
	}
	sort.Sort(PA)
	var mins []int
	for i := 0; i < len(PA); i++ {
		mins = append(mins, f(PA[i:], 0, 0))
	}
	min := math.MaxInt64
	for i := 0; i < len(mins); i++ {
		if mins[i] > 0 && mins[i] <= min {
			min = mins[i]
		}
	}
	fmt.Println(min)
}

func f(PA PS, sum int, cnt int) int {
	if len(PA) == 0 {
		return -1
	}

	v := (PA[0].No * 100) * PA[0].cnt
	w := v + PA[0].bonus
	for i := 0; i < PA[0].cnt; i++ {
		if sum+(PA[0].No*100)*(i+1) >= G {
			return cnt + (i + 1)
		}
	}
	if sum+w >= G {
		return cnt + PA[0].cnt
	} else {
		min := math.MaxInt64
		for i := 1; i < len(PA); i++ {
			n := f(PA[i:], sum+w, cnt+PA[0].cnt)
			if n > 0 && n < min {
				min = n
			}
		}
		return min
	}
	return -1
}

func (p PS) Len() int           { return len(p) }
func (p PS) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }
func (p PS) Less(i, j int) bool { return p[i].No > p[j].No }


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string s;
int zx=2147483647,zd=-2147483647;
int main(){
	getline(cin,s);
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C')
		{
			zx=min(zx,i);
		}
		if(s[i]=='F')
		{
			zd=max(zd,i);
		}
	}
	if(zx<zd)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

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

using namespace std;

#define ll long long;

const int N=1e6+5;

vector<int> v;

int n,ans,tc,q,m,a[N],k;

char s1[N],s2[N];

int main(){
    scanf("%d%d",&n,&k);
    int curr=1;
    for(int i=0; ;i++){
        if (curr>=k)
            return !printf("%d\n",i);
        curr+=n-1;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int i, j, k, work, N, A[1000];
  

  scanf("%d", &N);
  
  for(i=0;i<N;i++){
    scanf("%d", &A[i]);
  }
  
  
  for(i=1;i<=N;i++){

    for(k=0; k<N; k++){
      printf("%d",A[k]);
      if(k<N-1) printf(" ");
    }

    printf("\n");
    work=A[i];  
    j=i-1;
    while(j>=0 && A[j]>work){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=work;
  }
  return 0;
}

  

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int n;
	cin>>n;
	int x;
	int cnt = 0;
	for(int i=1; i<=n; i++)
	{
		cin>>x;
		if(i%2!=0)
			if(x%2!=0)
				cnt++;
	}
	cout<<cnt<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(15) << std::fixed;
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    precise
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll a;
        string b;
        cin>>a>>b;
        ll d=(b[0]-'0')*100 + (b[2]-'0')*10 + (b[3]-'0');
        //cout<<b<<" "<<d<<endl;
        ll ans=a*d/100;
        cout<<ans<<endl;
    }
    return 0;
}


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

#define li long int

int main() 
{
	li n,q,lin,rin,k=0,ans;
	string s;
	
    vector<li> v;
	
	cin>>n>>q;
	cin>>s;
	
	v.push_back(0);
	for(li i=0;i<n-1;i++)
	{
		if(s[i]=='A')
		{
			if(s[i+1]=='C')	
			{
				k++;
			}	
		}
	    v.push_back(k);
	}
	v.push_back(k);

	/*for(int i=0;i<v.size();i++)
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
	*/
	for(li i=0;i<q;i++)
	{
	    cin>>lin>>rin;
	    ans=v[rin-1]-v[lin-1];
	    cout<<ans<<"\n";
	    
	}
	
	
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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



int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int n;
    cin >>n;
    vector<int> s(n);

    bool dp[10100]={};
    fill(dp,dp+10100,false);

    dp[0]=true;

    rep(i,n){
        cin>>s[i];
        for(int j=10000;j>=0;--j){
            if(dp[j]==true){
                dp[j+s[i]]=true;
                if((j+s[i])%10!=0)chmax(ans,j+s[i]);
            }
        }
    }
    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A);
  for (int i = 0; i < A; i++) {
    cin >> a.at(i);
  }
  vector<int> b(B);
  for (int i = 0; i < B; i++) {
    cin >> b.at(i);
  }
  int min = *min_element( a.begin(), a.end() ) + *min_element( b.begin(), b.end() );
  for (int i = 0; i < M; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    if (a.at(x - 1) + b.at(y - 1) - c < min) {
      min = a.at(x - 1) + b.at(y - 1) - c;
    }
  }
  cout << min << endl;
}


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

int main(){
	int n,a[20001] = {},b[20001] = {};
	cin >> n;
	for(int i = 0;i < n;i++){
		int p;
		cin >> p;
		a[p] += i;
		b[p - 1] += i;
	}
	for(int i = 1;i <= n;i++) a[i] += a[i - 1] + 1;
	for(int i = n - 1;i >= 0;i--) b[i] += b[i + 1] + 1;
	for(int i = 1;i <= n;i++) cout << (i == 1 ? "" : " ") << a[i];
	cout << endl;
	for(int i = 0;i < n;i++) cout << (!i ? "" : " ") << b[i];
	cout << endl;
}

Measured memory_bytes: 768
N = int(input())
S = input()
count = 0
D = 3


def find_number(digits, series):
    global count
    if digits > 1:
        for i in range(0, 10):
            if str(i) in series:
                idx = series.index(str(i))
                find_number(digits - 1, series[idx+1:])
    elif digits == 1:
        for j in range(0, 10):
            if str(j) in series:
                count += 1
    return count


print(find_number(D, S))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return (dividend / divisor);
}

// 因数分解
inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

//階乗
inline ll factorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

inline ll vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) { // 発見できたとき
        return 1;
    }
    else { // 発見できなかったとき
        return 0;
    }
}

int main(){
    ll a, b;
    cin >> a >> b;
    
    cout << lcm(a, b) << endl;
    return 0;
    
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int puls = 0;

            char[] sign = Console.ReadLine().ToCharArray();

            foreach(var x in sign)
            {
                if(x == '+')
                {
                    puls++;
                }
                else
                {
                    puls--;
                }
            }
            Console.WriteLine(puls);
            
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

typedef long double lld;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-7)
#define INF (1e9 + 1)
#define PI (acos(-1))

int X, A;

int main()
{
	cin >> X >> A;
	if (X < A) {
		cout << 0 << endl;
		return 0;
	}
	cout << 10 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

vector<int> par(10e5, 0);
vector<int> ans(10e5, -1);
vector<int> depth(10e5, -1);
vector<vector<int>> t(10e5);

void dfs(int p, int v) {
    if (p == -1) {
        ans[v] = 0;
        depth[v] = 0;
    } else if (ans[v] == -1 || depth[v] < depth[p] + 1) {
        depth[v] = depth[p] + 1;
        ans[v] = p + 1;
    }
    if (par[v] > 1) { par[v]--; return; }
    for (int i = 0; i < (int)t[v].size(); i++) {
        dfs(v, t[v][i]);
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    int a, b;
    for (int i = 0; i < n - 1 + m; i++) {
        cin >> a >> b;
        a--; b--;
        t[a].push_back(b);
        par[b]++;
    }
    int root = 0;
    for (int i = 0; i < n; i++) if (par[i] == 0) { root = i; break; }
    dfs(-1, root);
    for (int i = 0; i < n; i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 43776
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
    const ll num=10000000000;
    ll n,m,rem,c=1;
    cin>>n>>m;
    vector<pair<ll,ll>>id(m);
    for(ll i=0;i<m;i++){
        ll p,y;
        cin>>p>>y;
        id[i]=make_pair(p*num+y,i);
    }
    sort(id.begin(),id.end());
    rem=id[0].first/num;
    for(ll i=0;i<m;i++){
        ll k=id[i].first/num;
        if(k==rem){
            id[i].first=(id[i].first/num)*num+c;
            c++;
        }else{
            c=1;
            id[i].first=(id[i].first/num)*num+c;
            c++;
            rem=id[i].first/num;
        }
    }
    for(ll i=0;i<m;i++){
        swap(id[i].first,id[i].second);
    }
    sort(id.begin(),id.end());
    for(ll i=0;i<m;i++){
        id[i].second=(id[i].second%num)+(id[i].second/num)*1000000;
    }
    for(ll i=0;i<m;i++){
        cout<<setw(12)<<setfill('0')<<id[i].second<<"\n";
    }
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
 
#define rep(i, n) for (ll i=0;i<(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(x) (x).begin(),(x).end()
 
using namespace std;
//using ll=long long;
typedef long long ll;
typedef pair<ll, ll> pi;

ll h,w;
ll ans;
//vector<char> masu;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>h>>w;
  char c;
  vector<string> masu(h);
  vector<bool> v[10000];
  ll dp[h][w];

  //v.resize(h);
  rep(i,h){
    cin >> masu[i];
    rep(j,w){
      if(masu[i][j]=='#') v[i].push_back(false);
      else v[i].push_back(true);
    }
  }
  
  ans = 1000000000;
  rep(i, w){
    rep(j, h){
      dp[j][i] = ans;
    }
  }
  dp[0][0] = 0;
  
  rep(i, w){
    rep(j, h){
      if(j<h-1) {
	if(!v[j+1][i] && v[j][i]){
	  chmin(dp[j+1][i], dp[j][i]+1);
	}
	else chmin(dp[j+1][i], dp[j][i]);
      }
      if(i<w-1){
	if(!v[j][i+1] && v[j][i]){
	  chmin(dp[j][i+1], dp[j][i]+1);
	}
	else chmin(dp[j][i+1], dp[j][i]);
      }
    }
  }

  ans = dp[h-1][w-1];
  
  if(v[0][0]==0) ans++;
  // if(masu[0][0]=='.' && masu[h-1][w-1]=='.') ans--;
  // if(ans<0) ans=0;
  
  cout << ans << endl;
}


Measured memory_bytes: 768
#include<stdio.h>

int main(void) {
	int m, f, r;
	char d[10000];
	int cnt = 0, i;
	int flag = 1;
	
	do {
		scanf("%d %d %d", &m, &f, &r);
		
		if(m == -1 && f == -1 && r == -1) {
			flag = 0;
		} if(m == -1 || f == -1) {
			d[cnt] = 'F';
		} else if(m + f >= 80) {
			d[cnt] = 'A';
		} else if(m + f >= 65 &&  m + f < 80) {
			d[cnt] = 'B';
		} else if(m + f >= 50 &&  m + f < 65) {
			d[cnt] = 'C';
		} else if(m + f >= 30 &&  m + f < 50) {
			if(r >= 50) {
				d[cnt] = 'C';
			} else {
				d[cnt] = 'D';
			}
		} else if(m + f < 30) {
			d[cnt] = 'F';
		}
		
		cnt++;
	} while(flag);
	
	for(i = 0; i < cnt-1; i++) {
		printf("%c\n", d[i]);
	}
	
	return 0;
}

Measured memory_bytes: 608
from collections import Counter
N = int(input())
C = sorted(list(Counter(map(int, input().split())).values()))

rest = N
removed = 0
for K in range(1, N + 1):
    d = K - removed
    while C and C[- 1] > rest//d:
        rest -= C[- 1]
        C.pop()
        removed += 1
        d -= 1
    print(rest//d)


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


int main(){


    string s,t;
    cin>>s>>t;


    long long int ans=0;

    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i])
            ans++;
    }

    cout<<ans<<endl;





    return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int D;

ll dfs(int len, int cur, ll dif) {
	if (cur == len - 1 - cur) {
		if (dif != D) {
			return 0;
		} else {
			int c = 0;
			rep(i, 10) {
				if (!(i == 0 && cur == 0)) {
					++c;
				}
			}
			return c;
		}
	}

	if (cur * 2 + 1 > len) {
		return (dif == D);
	}

	ll res = 0;
	int la = -10;
	for (int x = -9; x <= 9; ++x) {
		assert(len - 1 - cur >= cur);
		ll ad = x * (TEN(len - 1 - cur) - TEN(cur));
		if (dif + ad <= D) {
			la = x;
		}
	}

	{
		int c = 0;
		rep(i, 10) {
			int j = i + la;
			if (j >= 0 && j < 10) {
				if (!(i == 0 && cur == 0)) {
					++c;
				}
			}
		}
		ll ad = la * (TEN(len - 1 - cur) - TEN(cur));
		res += dfs(len, cur + 1, dif + ad) * c;
	}
	{
		int c = 0;
		rep(i, 10) {
			int j = i + la +1;
			if (j >= 0 && j < 10) {
				if (!(i == 0 && cur == 0)) {
					++c;
				}
			}
		}
		ll ad = (la + 1) * (TEN(len - 1 - cur) - TEN(cur));
		res += dfs(len, cur + 1, dif + ad) * c;		
	}
	return res;
}

int main() {
	cin >> D;
	ll ans = 0;
	for (int i = 1; i <= 18; ++i) {
		ans += dfs(i, 0, 0ll);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        cout << "Bad";
    }else{
        cout << "Good";
    }
    return 0;
}

Measured memory_bytes: 764
import bisect

w, h = map(int, raw_input().split())

pw = []
for i in range(w):
    pw.append(int(raw_input()))

ph = []
for i in range(h):
    ph.append(int(raw_input()))

cost = sum(pw) * (h + 1) + sum(ph) * (w + 1)

phc = sorted(ph)
pwc = sorted(pw)

for i in range(w):
    index = bisect.bisect_left(phc, pw[i])
    cost -= pw[i] * index

for i in range(h):
    index = bisect.bisect_right(pwc, ph[i])
    cost -= ph[i] * index

print cost

Measured memory_bytes: 15088
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n,l;
	cin>>n>>l;
	vector<string> v(n);
	rep(i,n) cin>>v[i];
	sort(ALL(v));
	rep(i,n) cout<<v[i];
	cout<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import copy
import sys

MOD = 1000000007  # type: int


def debug(s):
    print(s)


def solve(N: int, K: int, a: "List[int]"):
    dp = [[0] * (K + 1) for _ in range(N + 1)]
    dp[0][0] = 1
    for i in range(1, N + 1):
        ai = a[i - 1]
        dp[i][0] = 1
        for k in range(1, K + 1):
            c = dp[i - 1][k] + dp[i][k - 1]
            if k - ai - 1 >= 0:
                c -= dp[i - 1][k - ai - 1]
            dp[i][k] = c % MOD
            # debug(f"{i} kids share {k} candies: => {dp[i][k]}")
    return dp[N][K]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, K, a))


if __name__ == "__main__":
    main()


Measured memory_bytes: 117744
import math

N,K=list(map(int, input().split()))

b=0

for i in range(K,N+2):
  a=1/2*i*(N-i+1+N)-1/2*i*(i-1)+1
  
  b+=a%(10**9+7)
  
print(int(b%(10**9+7)))

Measured memory_bytes: 9188
int main(){
  char str[1000];
  int i,cp;
  int sum;
  int judge=1;
  while(1){
    if(!judge){
      break;
    }
    sum=0;
    for(i=0;;i++){
      scanf("%c",&str[i]);
      if(str[i]=='\n'){
	break;
      }
      if(str[0]=='0'){
	judge=0;
	break;
      }
      cp=str[i]-'0';
      sum+=cp;
    }
    if(judge)printf("%d\n",sum);
  }
  return 0;
}



Measured memory_bytes: 2104
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner in  = new Scanner(System.in);
        int n = in.nextInt();
        int steps = in.nextInt();
        if(n==0){
            System.out.println(0);
            return;
        }
        int []arr = new int[n];
        for(int i=0;i<n;i++)arr[i] = in.nextInt();
        int []dp = new int[n];
        dp[0] = 0;
        for(int i=1;i<n;i++){
            dp[i] = Integer.MAX_VALUE;
            for(int k=1;k<=steps;k++){
                if((i-k)>=0){
                    dp[i] = Math.min(dp[i],(Math.abs(arr[i]-arr[i-k]))+dp[i-k]);
                }
            }
        }
        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 48764
#include<bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
using namespace std;
int grid[1050][1050];
int n,m;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=(1<<n)-1;i++){
		for(int j=1;j<=(1<<m)-1;j++){
			if(lowbit(i)==lowbit(j))
				cout<<1;
			else
				cout<<0;
		}
		cout<<endl;
	}
}


Measured memory_bytes: 1280
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		f.Println(err)
	}
	return a
}

func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func main() {

	sc.Split(bufio.ScanWords)

	num := scanInt()
	cards := scanSlice(num)

	sort.Ints(cards)

	var a, b int
	cnt := 0

	for i := num - 1; i >= 0; i-- {
		if cnt%2 == 0 {
			a += cards[i]
		} else if cnt%2 != 0 {
			b += cards[i]
		}
		cnt++
	}

	res := a - b

	f.Println(res)

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
    ll k, s = 0;
    cin >> k >> s;
    int count;
    for(ll x = 0; x <= k; x++) {
        for(ll y = 0; y <= k; y++) {
            ll z = s - x - y;
            if(0 <= z && z <= k) {
                count++;
            }
        }
    }
  	cout << count;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char array[8][8];
    int i, j;

    for(i=0; i<8; i++){
        scanf("%s", array[i]);
    }

    printf("90\n");
    for(j=0; j<8; j++){
        for(i=7; i>=0; i--){
            printf("%c", array[i][j]);
        }
        printf("\n");
    }

    printf("180\n");
    for(i=7; i>=0; i--){
        for(j=7; j>=0; j--){
            printf("%c", array[i][j]);
        }
        printf("\n");
    }

    printf("270\n");
    for(j=7; j>=0; j--){
        for(i=0; i<8; i++){
            printf("%c", array[i][j]);
        }
        printf("\n");
    }
return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n+1);
  for(int i = 1; i <= n; i++){
    cin >> a.at(i);
    a.at(i) += a.at(i-1);
  }
  
  long long dif = pow(10, 18);
  for(int i = 1; i < n; i++){
    dif = min(dif, abs(a.at(i) - a.at(n) + a.at(i)));
  }
  
  cout << dif << endl;
}

Measured memory_bytes: 4836
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  if(n%2 == 0 or n%5 == 0) {
    cout << -1;
    return 0;
  }
  ll rem = 7;
  ll ct = 1;
  for(ll i = 0; i < (ll)1.5e7; i++) {
    if(rem%n == 0) {
      cout << ct << endl;
      return 0;
    }
    rem*=10;
    rem+= 7;
    rem%=n;
    ct++;
  }
  cout << -1 << endl;
  return 0;
} //good night.

Measured memory_bytes: 3636