akhauriyash/Code-Regression huggingface dataset:
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    string s; cin >> s;
    int cnt = 0;
    for(int i = 1; i < n; i++){
        cnt += s[i] == s[i - 1];
    }
    cout << min(n - 1, cnt + k * 2) << '\n';
}


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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
void solve(){
    int n,k;
    ll ans=0;
    cin>>n>>k;
    if(k==0){
        cout<<1LL*n*n<<endl;
        return;
    }
    rep(b,k+1,n+1){
        for(int j=0;j<n;j+=b){
            if(j+b-1<=n)
                ans+=b-k;
            else ans+=max(0,n-(j+k)+1); 
        }
    }
    cout<<ans;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;

  int x[n];
  for(int i=0;i<n;i++) cin >> x[i];

  int y[100];
  for (int i=0;i<100;i++) y[i] = 0;

  for(int i=0;i<100;i++){
    for (int j=0;j<n;j++){
      y[i] += (i-x[j]) * (i-x[j]);
    }
  }

  int min = y[0];
  for (int i=0;i<100;i++){
    if (min > y[i]) min = y[i];
  }
  cout << min;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define FOR(i, n) for(int i = 0;i <n;i++)
#define RFOR(i, n) for(int i = n;i >= 0;i--)
#define REP(i, m, n) for(int i = m;i < n;i++)
#define RREP(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999

using namespace std;
int main(int argc, char const *argv[])
{
  string a,b,c;
  cin >>a>>b>>c;
  cout<<a[0]<<b[0]<<c[0]<<endl;
return 0;

}


Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
A_minus = {}
for i in range(n):
    minus_temp = i+1-A[i]
    if minus_temp in A_minus:
        A_minus[minus_temp]+=1
    else:
        A_minus[minus_temp]=1
ans = 0
for i in range(n):
    plus_temp = i+1+A[i]
    if plus_temp in A_minus:
        ans += A_minus[plus_temp]

print(ans)

Measured memory_bytes: 40364
#Nはお札の枚数、Yは合計金額
N,Y = map(int,input().split())

yukiti = 10000
higuti = 5000
noguti = 1000
re_yukiti = -1
re_higuti = -1
re_noguti = -1

for i in range(N+1):
    for j in range(N+1-i):
        k = N - i - j
        amount = yukiti*i + higuti*j + noguti*k
        if amount == Y:
            re_yukiti = i
            re_higuti = j
            re_noguti = k
            break

print(re_yukiti,re_higuti,re_noguti)

Measured memory_bytes: 3064
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i64 = read();
    let q: i64 = read();
    let mut tree = HashMap::new();
    tree.insert(1, vec![]);
    for _ in 0..(n - 1) {
        let a: i64 = read();
        let b: i64 = read();
        let min = std::cmp::min(a, b);
        let max = std::cmp::max(a, b);
        {
            let entry = tree.entry(min).or_insert(vec![]);
            entry.push(max);
        }
        tree.entry(max).or_insert(vec![]);
    }
    let mut add_values = HashMap::new();
    for _ in 0..q {
        // operation vertex
        let p: i64 = read();
        // add value
        let x: i64 = read();
        let entry = add_values.entry(p).or_insert(0);
        *entry += x;
    }
    let mut ans = HashMap::new();
    get_values(&tree, &add_values, 1, 0, n, &mut ans);
    let mut ans_vec = vec![];
    for i in 1..(n + 1) {
        match ans.get(&i) {
            Some(&v) => {
                ans_vec.push(v);
            }
            None => {
                ans_vec.push(0);
            }
        }
    }
    println!(
        "{}",
        ans_vec
            .iter()
            .map(|i| i.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}
fn get_values(
    tree: &HashMap<i64, Vec<i64>>,
    add_values: &HashMap<i64, i64>,
    vertex: i64,
    plus_val: i64,
    max: i64,
    ans: &mut HashMap<i64, i64>,
) {
    let mut plus_val = plus_val;
    if vertex == max + 1 {
        return;
    }
    match add_values.get(&vertex) {
        Some(i) => plus_val += *i,
        None => {}
    }
    ans.insert(vertex, plus_val);
    match tree.get(&vertex) {
        Some(vec) => {
            for &vert in vec {
                get_values(&tree, &add_values, vert, plus_val, max, ans)
            }
        }
        None => {}
    }
}


Measured memory_bytes: 65272
import java.util.Scanner;
        
        public class Main {
        	public static void main(String[] args) {
        		Scanner in = new Scanner(System.in);
        		String str = in.next();
        		if( Character.isUpperCase( str.charAt( 0 ) ) ) {
        		    System.out.println( "A" );
        		}
        		else {
        		    System.out.println( "a" );
        		}
        	}
        }

Measured memory_bytes: 35732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

    string ans = "";
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }
    while(n!=0){
        int r = n%2;
        if(r<0){r += 2;}
        n = (n-r)/(-2);
        ans += to_string(r);
    }

    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}


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

int main()
{ 
  int n, k ;
  cin >> n >> k ;
  int calcu = 1 ;
  for(int i = 0 ; i < n ; i++)
  {
    if(calcu * 2 > calcu + k)
    {
      calcu += k ;
    }
    else
    {
      calcu *= 2 ;
    }
  }

  cout << calcu << endl ;
}


Measured memory_bytes: 256
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()



sys.setrecursionlimit(200005)


def main():
    X = iRaw()
    a = 100
    year= 0
    while a<X:
        a = int(a*1.01)
        year+=1
    return year

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 68240
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int cnt = 0;
        a = a - c;
        while (a - (b + c) >= 0) {
            a = a - (b + c);
            cnt++;
        }
        System.out.println(cnt);
    }
}


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

const int cnMaxAry = 1000033;

long long fnStrToLL(string sKey)
{
  int iElm;
  int iBase = 1;
  long long llKey = 0;
  for (int i = sKey.size() - 1; i >= 0; i--)
  {
    switch (sKey[i])
    {
      case  'A': iElm = 1;
                 break;
      case  'C': iElm = 2;
                 break;
      case  'G': iElm = 3;
                 break;
      case  'T': iElm = 4;
                 break;
      default:   iElm = 0;
    }
    llKey += iBase * iElm;
    iBase *= 5;
  }
  return llKey;
}

int fnHash1(long long a_llKey) { return (a_llKey % cnMaxAry); }
int fnHash2(long long a_llKey) { return (1 + (a_llKey % (cnMaxAry - 1))); }

void fnDic(string stasDic[])
{
  int iCmdCnt;
  cin >> iCmdCnt;

  for (int i = 0; i < iCmdCnt; i++)
  {
    string sCmd;
    string sKey;
    cin >> sCmd >> sKey;

    long long llKey = fnStrToLL(sKey);
    int iCnt = 0;
    for (iCnt = 0; ;iCnt++)
    {
      int ix = (fnHash1(llKey) + iCnt * fnHash2(llKey)) % cnMaxAry;
      if (stasDic[ix] == sKey)
      {
        if (sCmd[0] == 'i')
          break;
        else if (sCmd[0] == 'f')
        {
          cout << "yes" << endl;
          break;
        }
      }
      else if (stasDic[ix].size() == 0)
      {
        if (sCmd[0] == 'i')
        {
          stasDic[ix] = sKey;
          break;
        }
        else if (sCmd[0] == 'f')
        {
          cout << "no" << endl;
          break;
        }
      }
    }
  }
}

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

  static string stasDic[cnMaxAry];
  fnDic(stasDic);
  
  return 0;
}

Measured memory_bytes: 21944
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n, k;
    cin >> n >> k;
    ll arry[100010] = {0};
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        arry[a] += b;
    }

    ll sum = 0;
    rep(i, 100001){
        if(sum < k && sum + arry[i] >= k){
            cout << i;
            break;
        }
        sum += arry[i];
    }
    return 0;
}

Measured memory_bytes: 1024
import heapq
N, M = map(int, input().split())
A_B_list = [ [0] for _ in range(M)]
for _ in range(N):
    A, B = map(int, input().split())
    if A > M:
        continue
    else:
        A_B_list[A - 1].append(B)
ans = 0
hq = []
for A_B in A_B_list:
    for B in A_B:
        heapq.heappush(hq, -B)
    ans += -heapq.heappop(hq)
print(ans)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

ll root5(ll x5) {
  ll sign = 1;
  if (x5 == 0) return 0;
  if (x5 < 0) {
    sign *= -1;
    x5 *= -1;
  }
  ll x = pow(x5, 0.2);
  if (x * x * x * x * x == x5) return sign * x;
  return sign* (x + 1);
}

int main2() {
  const ll X = nextLong();

  for (ll A = 0; A <= 1000; A++) {
    ll B5 = A*A*A*A*A - X;
    ll B = root5(B5);
    if (B*B*B*B*B == B5) {
      cout << A << " " << B << endl;
      return 0;
    }
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 4164
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

typedef long long ll;

int main() {
	double a, b, x;
	cin >> a >> b >> x;
	x /= a;
	double ans;
		if (a * b / 2 >= x) {
			//半分以下の時
			double edge = x * 2 / b;
			ans = atan(b / edge);
		}
		else {
			//それ以外の時
			double husoku = a * b - x;
			double edge = husoku * 2 / a;
			ans = atan(edge / a);
		}
		cout << setprecision(12) << ans / (2 * acos(-1)) * 360.0 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
bool visit[1000005];
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	ll n,w1;
  	cin>>n>>w1;
  	ll a[n],w[n];
  	For(i,n)cin>>w[i]>>a[i];
  	ll ans[w1+1];
  	memset(ans,0LL,sizeof(ans));
  	For(i,n)
  	{
  		for(int j=w1-w[i];j>=0;j--)
  		{
  			ans[j+w[i]]=max(ans[j+w[i]],ans[j]+a[i]);
  		}
  	}
  	cout<<ans[w1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
//  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 <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#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);
    //-------------------------------
    int x;cin>>x;
    if(x<1200)
        cout<<"ABC"<<endl;
    else
        cout<<"ARC"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
list=input().split()
if 1 <=  int(list[0]) and int(list[0]) <= 10000000000 and 1 <=  int(list[1]) and int(list[1]) <= 10000000000:
    d=int(list[0])/int(list[1])
    r=int(list[0])-int(list[1])*int(d)
    print("{0} {1} {2:.5f}".format(int(d), r,d))
else:
    print("ERROR")


Measured memory_bytes: 5612
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
const ll maxn = 1e5 + 101;
const ll inf=1e18;
ll fast_mul(ll a,ll b,ll mod){//快速乘法a*b%mod，因为在代码里面运算时，乘法会炸long long
    ll ans = 0;
    ll flag=1;
    if(a<0) a*=-1,flag*=-1;
    if(b<0) b*=-1,flag*=-1; 
    while(b){
        if(b&1)
            ans = (ans+a)%mod;
        a = (a+a)%mod;
        b >>= 1;
    }
    if(flag==-1) return -ans;
    else return ans;
}
int main() {
    ll n;
    scanf("%lld",&n);
    ll ans=1;
    ll flag0=0;
    ll exd=0;
    for(ll i=1;i<=n;++i){
        ll x;
        scanf("%lld",&x);
        if(ans==0) continue;
        if(x==0) flag0=1;
        if(inf/ans<x) exd=1;
        else ans*=x;
    }
    if(flag0){
        puts("0");
    }
    else if(exd){
        puts("-1");
    }
    else{
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3768
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static List<long> P = new List<long>();
        static List<long> All = new List<long>();
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
            int N = (int)l[0];
            long X = l[1];
            All.Add(1);
            P.Add(1);

            for (var i = 0; i < N; i ++)
            {
                All.Add(All[i] * 2 + 3);
                P.Add(P[i] * 2 + 1);
            }

            Console.WriteLine(Calc(N, X));
        }

        static long Calc(int N, long X)
        {
            if (N == 0) return X <= 0 ? 0 : 1;
            else if (X <= 1 + All[N - 1]) return Calc(N - 1, X - 1);
            else return P[N - 1] + 1 + Calc(N - 1, X - 2 - All[N - 1]);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,X;
int M[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X;
	FOR(i,N) cin>>M[i], X-=M[i];
	sort(M,M+N);
	int ret=N;
	while(X>=M[0]) ret++,X-=M[0];
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

typedef long long int ll;

int main(){
    int N;
    cin >> N;
    vector<int> L;

    for(int i=0;i<N;i++){
        int Li;
        cin >> Li;
        L.emplace_back(Li);
    }

    sort(L.begin(),L.end(),greater<int>());
    for(auto v : L){
        //printf("[]%d\n",v);
    }

    int ans=0;

    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            for(int k=j+1;k<N;k++){
                int a=L[i], b=L[j], c=L[k];
                if(abs(b-c)<a && a<b+c){
                    ans++;//printf("い:%d,%d,%d\n",a,b,c);
                }
            }
        }
    }  

    cout << ans << endl;

}


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

int main(){
  int a,b;
  int wa,sa,seki;
  
  cin>>a>>b;
  
  wa=a+b;
  sa=a-b;
  seki=a*b;
  
  int ans;
  ans=max(wa,max(sa,seki));
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<map>
#include<math.h>
#include<queue>
#include<string.h>
#include<algorithm>
using namespace std;
int a[10];
int main()
{
    scanf("%d%d%d",&a[1],&a[2],&a[3]);
    int w=0;
    sort(a+1,a+4);
    if(a[2]==a[1]&&a[2]!=a[3])w=1;
    else if(a[2]==a[3]&&a[2]!=a[1])w=1;
    if(w)printf("Yes\n");
    else printf("No\n");
}

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


loop{ 
  a,op,b = STDIN.gets.split
  a=a.to_i 
  op=op.to_s
  b=b.to_i
  
  case op 
  when '+'
    puts a + b
  when '-'
    puts a - b
  when '*'
    puts a * b 
  when '/'  
    puts a / b
  when '?'
    break
  end
}

Measured memory_bytes: 8652
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

/*
LV1   BPPPB
LV2  BBPPPBPBPPPBB
LV3 BBBPPPBPBPPPBBPBBPPPBPBPPPBBB
*/
long long count(int N) {
    if (N == 1) return 5;
    else return 3 + 2 * count(N-1);
}
long long countP(int N) {
    if (N == 1) return 3;
    else return 1 + 2 * countP(N-1);
}

long long res = 0;
void solve(int N, long long X){
    if (N == 1) {
        if (X == 2) res += 1;
        if (X == 3) res += 2;
        if (X >= 4) res += 3;
        return;
    }
    
    if (X == 1) return;
    if (X <= count(N) / 2){
        solve(N-1, X-1);
    } else if (X == count(N) / 2 + 1){
        res += countP(N-1) + 1;
    } else if (X > count(N) / 2 + 1 && X < count(N)){
        res += countP(N-1) + 1;
        solve(N-1, X - count(N-1) - 2);
    } else res += countP(N);
};
int main() {
    int N; cin >> N;
    long long X; cin >> X;
    solve(N,X);
    cout << res << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	int goFast(int[] a) {
		int len = a.length;
		int mid = len / 2;

		int ans = -1;
		int bestDist = Integer.MAX_VALUE;

		for (int i = 0; i < a.length;) {
			int j = i;
			while (j < a.length && a[i] == a[j]) {
				j++;
			}

			if (j - i > 1) {
				if (i <= mid && mid < j) {
					return a[i];
				}
				int dist = Math.min(Math.abs(mid - (j - 1)), Math.abs(mid - i));
				if (dist < bestDist) {
					bestDist = dist;
					ans = a[i];
				}
			}

			i = j;
		}

		if (ans != -1) {
			return ans;
		}

		return a[0];
	}

	int go(int[] a) {
		while (a.length > 1) {
			int[] b = new int[a.length - 2];
			for (int i = 0; i < b.length; i++) {
				b[i] = a[i] + a[i + 1] + a[i + 2];
				if (b[i] <= 1) {
					b[i] = 0;
				} else {
					b[i] = 1;
				}
			}
			a = b;
		}
		return a[0];
	}

	int solve(int[] perm) {
		int n = perm.length / 2 + 1;

		int high = 2 * n - 1; // ans <= high
		int low = 0; // ans > 0

		while (high - low > 1) {
			int mid = (low + high) >> 1;
			int[] tmp = new int[perm.length];
			for (int i = 0; i < perm.length; i++) {
				tmp[i] = perm[i] <= mid ? 0 : 1;
			}
			// if (go(tmp) == 0) {
			if (goFast(tmp) == 0) {
				high = mid;
			} else {
				low = mid;
			}
		}
		return high;
	}

	static int get(int mask, int i) {
		return (mask >> i) & 1;
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		// int[] wtf = { 0, 1, 1, 0, 1, 0, 0 };

		// System.err.println(goFast(wtf));

		// for (int n = 3; n <= 15; n += 2) {
		// for (int mask = 0; mask < (1 << n); mask++) {
		// int[] tst = new int[n];
		// for (int i = 0; i < n; i++) {
		// tst[i] = get(mask, i);
		// }
		//
		// if (go(tst) != goFast(tst)) {
		// throw new AssertionError(Arrays.toString(tst));
		// }
		// }
		// }

		int n = nextInt();
		int[] a = new int[2 * n - 1];
		for (int i = 0; i < 2 * n - 1; i++) {
			a[i] = nextInt();
		}
		out.println(solve(a));
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 35276
#include <iostream>
#include <algorithm>

using namespace std;

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

  for(int i=0;i<t;i++){
    int n,k;
    cin >> n >> k;
    int x[100000+10]={};
    for(int j=0;j<n;j++) cin >> x[j];
    int d[99999+10]={};
    for(int j=1;j<n;j++) d[j-1]=x[j]-x[j-1];
    sort(d,d+n-1);

    int sum=0;
    for(int j=0;j<n-k;j++) sum+=d[j];
    cout << sum << endl;
  }
  return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,flag=1;
	cin >> n;
	string s,ss[101];
	char front,last;
	cin >> s;
	ss[1]=s;
	last=s[s.size()-1];
	for(int i=2;i<=n;i++)
	{
		cin >> s;
		ss[i]=s;
		front=s[0];
		if(front!=last) flag=0;
		last=s[s.size()-1];
	}
	if(!flag)
	{
		cout << "No";
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(ss[i]==ss[j])
			{
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=3e5;
const int inf=1e9;
int main(){
	int a,b,c,d;cin>>a>>b>>c>>d;
	while(true){
		c -= b;
		if(c <= 0){ cout<<"Yes"<<endl; break; }
		a -= d;
		if(a <= 0){ cout<<"No"<<endl; break; }
	}
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int ans = 0;
    int ac_min = Math.min(A, C);
    ans += ac_min;
    A -= ac_min;
    C -= ac_min;
    int bc_min = Math.min(B, C);
    ans += (2 * bc_min);
    B -= bc_min;
    C -= bc_min;
    if (B > 0) {
      ans += B;
    }
    if (C > 0) {
      ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
static const int MAXW = 10000;

struct Item {
  int value, weight;
};

int solve_knapsack(vector<Item> items, int maxw) {
  int max_values[MAXW + 1] = {0};
  int pre[MAXW + 1] = {0};
  for (auto item : items) {
    for (int j = 0; j <= maxw; j++) {
      max_values[j] = j < item.weight ? pre[j] :
        max(pre[j - item.weight] + item.value, pre[j]);
    }
    swap(pre, max_values);
  }

  return pre[maxw];
}

int main() {
  int nitem, maxw;
  vector<Item> items;
  cin >> nitem >> maxw;
  for (int i = 0; i < nitem; i++) {
    int value, weight;
    cin >> value >> weight;
    items.push_back(Item{value, weight});
  }

  cout << solve_knapsack(items, maxw) << endl;
}

Measured memory_bytes: 3228
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;

LL gcd(LL a, LL b)
{
	return b == 0?a:gcd(b,a%b);
}

LL acm(LL a,LL b)
{
	return a / gcd(a,b) * b;
}

int main()
{
	LL n,m;
	cin >> n >> m;
	LL ans = acm(n,m);
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 256
import bisect
n,m=map(int,input().split())
k=[[] for _ in range(n)]
p=[0 for _ in range(m)]
y=[0 for _ in range(m)]
for i in range(m):
	a,b = map(int,input().split())
	y[i] = b
	p[i] = a
	k[a-1].append(b)
for i in range(n):
	k[i].sort()
ansl = []
for i in range(m):
	d1 = str(p[i]).zfill(6)
	d2 = str(bisect.bisect_right(k[p[i]-1], y[i])).zfill(6)
	ansl.append(d1+d2)
print("\n".join(ansl))

Measured memory_bytes: 33652
N = int(input())
A = [0]*N
B = [0]*N

for n in range(N):
    A[n],B[n] = map(int,input().split())

A.sort()
B.sort()
if N % 2 == 1:
    print(B[N//2]-A[N//2]+1)
else:
    Am = (A[N//2]+A[N//2-1])/2
    Bm = (B[N//2]+B[N//2-1])/2
    print(int((Bm-Am)*2)+1)

Measured memory_bytes: 25448
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ll N,K;cin>>N>>K;
  ll i,j,k,l;
  // 前処理
  COMinit();
  ll ans;
  repn(i,K){
    if(i>N-K+1) cout<<0<<endl;
    else{
      ll tmp1,tmp2;
      tmp1 = COM(N-K+1,i);
      tmp2 = COM(K-1,i-1);
      ans = tmp1 * tmp2 %MOD;
      cout<<ans<<endl;
    }
  }
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

#define int long long

const int MAX_N = 100010;

class segTree{
    public:
        int n, dat[4 * MAX_N];
        void init(int n_, int value, int dat_b[4 * MAX_N] = NULL){
            n = 1;
            while(n < n_) n *= 2;
            rep(i,2 * n){
                dat[i] = value;
                if(dat_b != NULL) dat_b[i] = value;
            }
        }
        void output(int a[4 * MAX_N]){
            show("print");
            range(i,1,n * 2) cout << (a[i] == INT_MAX ? 0 : a[i]) << ' ';
            cout << endl;
        }
};

class starrySky : public segTree{
    private:
        int query(int a, int b, int k, int l, int r){
            if(b <= l || r <= a) return 0;
            if(a <= l && r <= b) return dat[k] + dat_add[k];

            int vl = query(a, b, k * 2, l, (l + r) / 2);
            int vr = query(a, b, k * 2 + 1, (l + r) / 2, r);
            return max(vl, vr) + dat_add[k];
        }
        void add(int a, int b, int k, int l, int r, int x){
            if(b <= l || r <= a) return;
            if(a <= l && r <= b){
                dat_add[k] += x;
            }else{
                add(a, b, k * 2, l, (l + r) / 2, x);
                add(a, b, k * 2 + 1, (l + r) / 2, r, x);
                dat[k] = max(dat[k * 2] + dat_add[k * 2], dat[k * 2 + 1] + dat_add[k * 2 + 1]);
            }
        }
        void init(int n_){ segTree::init(n_,0,dat_add); }
    public:
        int dat_add[4 * MAX_N];
        starrySky(int n){ init(n); }
        int query(int a, int b){ return query(a, b, 1, 0, n); }
        void add(int s, int t, int x){ add(s, t, 1, 0, n, x); }
        void add(int i, int x){ add(i, i + 1, 1, 0, n, x); }
};


signed main(){
    long long n, h;
    cin >> n >> h;


    starrySky seg(n); //?????????????????????
    priority_queue<pair<long long, int>> q; //??????????????????pos
    long long cur = h, ans = 0;
    rep(i,n - 1){
        long long damage, heal;
        cin >> damage >> heal;
        q.push(make_pair(heal, i));

        seg.add(i + 1, cur);
        cur -= damage;
        while(cur <= 0){
            pair<long long, int> use = q.top(); q.pop();
            long long maxHP = seg.query(use.second + 1, i + 2); //????????°??????????????¨??°?????§?????????????????§

            if(maxHP + use.first > h){ //??????????????????????¶????????????§?????????????????????????????´
                q.push(make_pair(h - maxHP, use.second));
                continue;
            }

            long long can_use = (h - maxHP) / use.first;
            long long require = ceil((-1.0 * cur + 1) / use.first);
            long long used = min(can_use, require);
            ans += used;
            cur += used * use.first;

            seg.add(use.second + 1, i + 2, used * use.first);
            q.push(use);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9032
n = int(input())
a = [int(i) for i in input().split()]
pos = [i for i in a if i >= 0]
neg = [i for i in a if i < 0]
cntp = len(pos)
cntn = len(neg)
lst = []

if pos and neg:
    for i in range(1,cntp):
        lst.append((neg[0],pos[i]))
        neg[0] -= pos[i]
    for i in range(1,cntn):
        lst.append((pos[0],neg[i]))
        pos[0] -= neg[i]
    lst.append((pos[0],neg[0]))
    maxv = pos[0]-neg[0]
elif pos:
    pos.sort()
    for i in range(1,cntp-1):
        lst.append((pos[0],pos[i]))
        pos[0] -= pos[i]
    lst.append((pos[cntp-1],pos[0]))
    maxv = pos[cntp-1]-pos[0]
else:
    neg.sort(reverse=True)
    for i in range(1,cntn):
        lst.append((neg[0],neg[i]))
        neg[0] -= neg[i]
    maxv = neg[0]
print(maxv)
for x,y in lst: print(x,y)

Measured memory_bytes: 24932
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    bool ok=false;
    while(!ok&&n>=0){
        if(n%7==0) ok=true;
        n-=4;
    }
    Yes(ok);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
use std::io::{BufRead, Read};

pub struct Scanner<R>
where
    R: BufRead,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: BufRead,
{
    pub fn new(reader: R) -> Self {
        Scanner { reader: reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut sc = Scanner::new(stdin);

    let n: usize = sc.next();
    let v: Vec<u8> = (0..n).map(|_| sc.next()).collect();
    let mut sv = v.clone();
    sv.sort();
    let mut count: i32 = 0;
    let mut answer: bool = true;
    for i in 0..n {
        if v[i] != sv[i] {
            count += 1;
            if count >= 3 {
                answer = false;
                break;
            }
        }
    }
    println!("{}", if answer { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
S = input()
S_l = []
for i in range(len(S)):
    S_l.append(S[i:i+1])
#print(S_l)

E = [S_l[i] for i in range(len(S)) if i%2 == 1]
O = [S_l[i] for i in range(len(S)) if i%2 == 0]
#print(E)
#print(O)

odd = ["R", "U", "D"]
even = ["L", "U", "D"]

ans = 0
for i in O:
    if i in odd:
        ans = ans
    else:
        ans += 1

for i in E:
    if i in even:
        ans = ans
    else:
        ans += 1

if ans == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import math
N = int(input())

min_num = 1000000000000000000000
for i in range(int(math.sqrt(N))):
    if N%(i+1) == 0:
        root = (i+1)+(N/(i+1))-2
        if min_num > root:
            min_num = root
print(int(min_num))


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

//https://atcoder.jp/contests/abc120/tasks/abc120_d

const int nm = 1e5;
int n, m, e[nm][2];
long long c, ans[nm];

//union-find
int par[nm], des[nm];
int root(int v) {
	if (par[v] == v)
		return v;
	return root(par[v]);
}
void unite(int x, int y) {
	int rx = root(x);
	int ry = root(y);
	if (rx == ry)
		return;
	c -= (long long) (des[rx] + 1) * (des[ry] + 1);
	if (des[ry] > des[rx])
		swap(rx, ry);
	par[ry] = rx;
	des[rx] += des[ry] + 1;
}
void initUF() {
	for (int i = 0; i < nm; i++)
		par[i] = i;
}

int main() {
	initUF();
	cin >> n >> m;
	for (int i = 0; i < m; i++)
		cin >> e[i][0] >> e[i][1];

	c = (long long) n * (n - 1) / 2;

	for (int i = 0; i < m; i++) {
		ans[m - 1 - i] = c;
		unite(e[m - 1 - i][0], e[m - 1 - i][1]);
	}
	for (int i = 0; i < m; i++)
		cout << ans[i] << endl;
}


Measured memory_bytes: 3712
#include <stdio.h>

int main(){
	int i, j;
	for(i = 0;i < 9;++i){
		for(j = 0;j < 9;++j){
			printf("%dx%d=%d\n", i + 1, j + 1, (i + 1) * (j + 1));
		}
	}
	return 0;
}

Measured memory_bytes: 924
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define repvin(V,N) for(int i = 0; i < N; i++) {int tmp; cin >> tmp; V.push_back(tmp);} int dummmmmmmmy

using namespace std;

int main(){

    int n;
    cin >> n;

    int ans = 0;

    rep(i,n){
        int tmp;
        cin >> tmp;

        while(tmp % 2 == 0){
            ans++;
            tmp = tmp / 2;
        }    
    }

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  while(1){
    int n,ans=0,sum=0;
    cin>>n;
    if(n==0)break;
    for(int i=1;i<=500;i++){
      sum=i;
      for(int j=i+1;j<=500;j++){
	sum+=j;
	if(sum==n)ans++;
	if(sum>n)break;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3012
// https://atcoder.jp/contests/abc136/tasks/abc136_c
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// ll lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n) cin >> v[i];
    REP(i, n - 1) {
        if (v[i] > v[i + 1]) {
            v[i + 1]++;
        }
        if (v[i] > v[i + 1]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string x;
    cin >> x;
    int cnt_s = 0;
    int cnt_t = 0;
    rep(i, 0, x.size()) {
        if (x[i] == 'S') cnt_s++;
        else {
            cnt_t++;
            if (cnt_s > 0) {
                cnt_s--;
                cnt_t--;
            }
        }
    }
    cout << cnt_s + cnt_t << endl;
    return 0;
}


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

int main()
{
    int n, a, b;
    int i;
    int cut, judge, count = 0;
    
    cin >> n >> a >> b;
    
    for(i = 1; i <= n; i++) {
        
        cut = i;
        judge = 0;
        
        while(cut != 0) {
            judge = judge + (cut % 10);
            cut = cut / 10;
        }
        
        if((a <= judge) && (judge <= b)) {
            count = count + i;
        }
    }
    
    cout << count << "\n";
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        int N = Utils.ReadInts()[0];
        int[] S = Utils.ReadInts();

        bool result = Solve(N, S);

        Utils.ReturnYesOrNo(result);
    }

    private static bool Solve(int n, int[] vals)
    {
        Array.Sort(vals, IntDisComparetor.Instance);
        List<int> slimes = new List<int>();
        slimes.Add(vals[0]);
        vals[0] = int.MaxValue;
        int cnt = 0;
        for(int slimeNum = 1; slimeNum < vals.Length;)
        {
            cnt++;
            int index = 0;
            for(int i = 0; i < slimeNum; i++)
            {
                int item = slimes[i];
                index = Utils.FindFirstIndex(vals, p => p < item, index + 1);
                if (index < 0) return false;

                slimes.Add(vals[index]);
                vals[index] = int.MaxValue;

            }
            slimes.Sort(IntDisComparetor.Instance);
            slimeNum = slimes.Count;
        }
        return (cnt == n);
    }
}

static class Utils
{
    public static int[] ReadInts()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }

    public static int FindFirstIndex<T>(IList<T> source, Func<T, bool> func, int start)
    {
        for(int i = start; i < source.Count; i++)
        {
            if (func(source[i]))
            {
                return i;
            }
        }
        return -1;
    }

    public static void ReturnYesOrNo(bool result)
    {
        Console.WriteLine(result ? "Yes" : "No");
        Console.ReadLine();
    }
}

class IntDisComparetor : IComparer<int>
{
    public static IComparer<int> Instance { get; } = new IntDisComparetor();
    private IntDisComparetor()
    {

    }
    public int Compare(int x, int y)
    {
        return Comparer<int>.Default.Compare(y, x);
    }

}

Measured memory_bytes: 42768
N = int(input())
words = []
for i in range(N):
    words.append(input())

result = 'Yes'
used = []
last_char = ''
for word in words:
    if not used:
        used.append(word)
        last_char = word[-1]
        continue
    if word[0] != last_char or word in used:
        result = 'No'
        break
    used.append(word)
    last_char = word[-1]

print(result)

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

int main(){
  int n, a[3][3];
  bool appear[3][3];

  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> a[i][j];
    }
  }
  cin >> n;
  int b[n];
  for(int i=0; i<n; i++) cin >> b[i];

  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      appear[i][j] = false;
      for(int k=0; k<n; k++){
        if(a[i][j] == b[k]) appear[i][j] = true;
      }
    }
  }
  string ans = "No";
  for(int i=0; i<3; i++){
    if(appear[i][0] and appear[i][1] and appear[i][2]) ans = "Yes";
  }
  for(int i=0; i<3; i++){
    if(appear[0][i] and appear[1][i] and appear[2][i]) ans = "Yes";
  }

  if(appear[0][0] and appear[1][1] and appear[2][2]) ans = "Yes";
  if(appear[0][2] and appear[1][1] and appear[2][0]) ans = "Yes";

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256