akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <climits>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
using namespace std;
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define fi first
#define se second
#define ii pair<int, int>
#define ll long long
#define endl "\n"
long double pi = 6.28318530717958623200/2.0;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("Test.inp", "r", stdin);
	//freopen("Test.out", "w", stdout);
	int n;
	cin >> n;
	cout << pi * 2 * n;
	return 0;
}

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

int main() {
  int N, i, count;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s; 
    
    if (s == "Y")
      count++;
   } 
  
   if (count > 0)
     cout << "Four" << endl;
  
   else
     cout << "Three" << endl;
}


Measured memory_bytes: 256
N = gets.to_i

num = [1, 2, 3, 4, 5, 6, 7, 8, 9]
result = 0

num.each do |i|
  if N % i == 0
    a = N/i
    if a.to_s.chars.length == 1
      result += 1
    end
  end
end

if result > 0
  puts 'Yes'
else
  puts 'No'
end

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

int arr[20];
int dp[20][160][2];
int getsum(int ind,int n,int sum, int flag){
	if(ind == n) return sum;
	if(dp[ind][sum][flag]!=-1) return dp[ind][sum][flag]; 
	int limit = 9;
	if(!flag) limit = arr[ind];
	int ans  = -1;
	for(int i=0;i<=limit;i++){
		if(flag || i<arr[ind]) ans = max(ans,getsum(ind + 1, n, sum + i, 1));
		else ans  = max(ans, getsum(ind + 1, n, sum + i, 0));
	}
	return dp[ind][sum][flag] = ans;
}

int main() {

//	int t;
//	cin>>t;
//	while(t--){
		long long a;
		cin>>a;
		
		string aa = to_string(a);
		for(int i=0;i<20;i++) for(int j=0;j<160;j++) for(int k=0;k<2;k++) dp[i][j][k]=-1;
		
		for(int i=0;i<aa.size();i++) arr[i] = aa[i] - '0';
		long long ans = getsum(0,aa.size(),0, 0);
		cout<<ans<<endl;
//	}

}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

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

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }


int main() {
  long long n, x, m; cin>>n>>x>>m;
  unordered_set<long long> app1, app2;
  long long ans = 0;

  vector<long long> loop;
  int loop_start = -1, loop_cnt = 0;
  long long loop_sum = 0;

  for (long long i = 0; i < n; i++) {
    app1.emplace(x);
    ans += x;
    x = x * x;
    x %= m;
    if (app1.find(x) != app1.end()) {
      loop_start = i+1;
      break;
    }
  }

  if (loop_start != -1) {
    for (long long i = loop_start; i < n; i++) {
      loop.emplace_back(x);
      app2.emplace(x);
      loop_sum += x;
      ++loop_cnt;
      x = x * x;
      x %= m;
      if (app2.find(x) != app2.end()) {
        break;
      }
    }
  }

  if (loop_cnt != 0) {
    long long d = (n - loop_start) / loop_cnt;
    long long r = (n - loop_start) % loop_cnt;
    ans += loop_sum * d;
    rep(i, r) {
      ans += loop[i];
    }
  }

  print(ans);

  return 0;
}

Measured memory_bytes: 7532
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]

dxy=[(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]
def bombcount(hi,wi):
  cnt=0
  for x,y in dxy:
    
      
    if 0<=hi+x<=h-1 and 0<=wi+y<=w-1:
      if s[hi+x][wi+y]=="#":
        
        cnt+=1
  return cnt
      
for i in range(h):
  for j in range(w):
    
    
    if s[i][j]==".":
      s[i][j]=str(bombcount(i,j))
      
for i in range(h):
  print("".join(s[i]))



Measured memory_bytes: 3188
#include <iostream>


using namespace std;


int main()
{
  long long x, ans;

  cin >> x;
  ans = x / 11 * 2;
  if (x%11 <= 6 and x%11 > 0) ans += 1;
  else if (x%11 > 6) ans += 2;
  cout << ans << endl;
  
  return 0;
}


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

int main(){
	int N,x;
	cin >> N >> x;
	if(N==2){
		if(x==2){
			cout << "Yes" << endl;
			for(int i=1;i<=3;i++)cout << i << endl;
			return 0;
		}
		cout << "No" << endl;
		return 0;
	}
	
	if(x==1 || x==2*N-1){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	
	N=2*N-1;
	vector<int> ans(N,0);
	
	if(x>2){
		ans[N/2]=x;
		ans[N/2-1]=x-1;
		ans[N/2+1]=x+1;
		ans[N/2+2]=x-2;
		
		int pos=0;
		for(int i=1;i<=N;i++){
			if(x-2<=i && i<=x+1)continue;
			while(ans[pos]!=0){
				pos++;
			}
			ans[pos]=i;
		}
	}
	else{
		ans[N/2]=x;
		ans[N/2-1]=x+1;
		ans[N/2+1]=x-1;
		ans[N/2+2]=x+2;
		
		int pos=0;
		for(int i=1;i<=N;i++){
			if(x-1<=i && i<=x+2)continue;
			while(ans[pos]!=0){
				pos++;
			}
			ans[pos]=i;
		}
	}
	for(int i=0;i<N;i++)cout << ans[i] << endl;
	return 0;	
}

Measured memory_bytes: 2304
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

main() {
	long long int n, m, k ;
	char str[5];
	scanf("%lld%lld%lld",&k, &n,&m);

	if (change_plus(n-k) >= change_plus(m - k)) { printf("B"); }
	else { printf("A"); }

	
}

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

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	
	string ans = "No";
	for (int i = 1; i <= 9; i++) {
		if (n % i == 0) {
			int d = n / i;
			if (1 <= d && d <= 9) {
				ans = "Yes";
				break;
			}
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d", &a,&b);
	if (a < b)
		printf("a < b\n");
	else if (a>b)
		printf("a > b\n");
	else
		printf("a == b\n");
	return 0;
}

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

int main(){
    int n,l,sum=0; cin>>n>>l;

    vector<int> taste(n);

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

        taste[i] = l + i; 

        sum += taste[i];
    }

    int check = 10000,ans=0;

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

        //if(abs(sum - (sum - taste[i] )) < check);

        if( abs(taste[i]) < check){
            check = abs(taste[i]);

            ans = sum - taste[i];

        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
 
int main(){
  string s;
  cin>>s;
  vector<int> count(3);
  for(int i=0;i<3;i++){
    if(s.at(i)=='a'){
      count.at(0)+=1;
    }else if(s.at(i)=='b'){
      count.at(1)+=1;
    }else{
      count.at(2)+=1;
    }
  }
  bool can=true;
  for(int i=0;i<3;i++){
   if(count.at(i)!=1){
     can=false;
     cout<<"No"<<endl;
     break; 
   }
  }
  if(can){
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from heapq import heappush, heappop
from math import sqrt
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

ans = 10**18
N = int(input())
for i in range(1, int(sqrt(N))+2):
    if N%i == 0:
        ans = min(ans, i + N//i - 2)
print(ans)

Measured memory_bytes: 40556
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;
const long long P = 1000000007;

int _pow(int x, int n) {
  int i = n;
  int ret = 1;
  while(i != 0) {
    ret *= x;
    i--;
  }
  return ret;
}

int main() {
  int n,m;
  cin >> n >> m;
  long long ans = (1800*m+100*n)*_pow(2,m);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long LL;
int main()
{
	LL N;
	scanf("%lld",&N);
	LL h,n;
	int flag=0;
	for(h=1;h<=3500;h++)
	{
		for(n=1;n<=3500;n++)
		{
			LL FZ=N*h*n;
			LL FM=(4*h*n-n*N-h*N);
			if(FM>0 && FZ%FM==0)
			{
				flag=1;
				printf("%lld %lld %lld\n",h,n,FZ/FM);
				break;
			}
		}
		if(flag)
			break;
	}
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++(i))
#define REP(i,n) FOR(i,0,n)

#define dump(x) cerr << #x << " = " <<(x)<<endl;
#define debug(x) cerr << #x << " = " <<(x) << "(L" << __LINE__ << ")" << __FILE__ << endl;

#define BIT_ON(x,b) ((x)|=(b))
#define BIT_OFF(x,b) ((x)&=~(b))
#define BIT_IS_ON(x,b) (((x)&(b))==(b))


using namespace std;

int main(void){
  int x, y, i;
  cin >> x >> y;
  string temp;
  vector<string> image(x+2);
  image[0] = "#"; for(i=0; i< y+1; i++) image[0] += "#";
  image[x+1] = "#"; for(i=0; i< y+1; i++) image[x+1] += "#";

  for(i=1; i<x+1; i++){
    image[i] = "#";
    cin >> temp;
    image[i] += temp;
    image[i] += "#";
  }
  for(i=0; i<x+2; i++){
    cout << image[i] << endl;
  }



  
  return 0;
}


Measured memory_bytes: 256
using System;

namespace ALDS1_3_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int n = int.Parse(strs[0]);
            int q = int.Parse(strs[1]);
            Queue Q = new Queue();

            for (int i = 0; i < n; ++i)
            {
                string[] strs1 = Console.ReadLine().Split(' ');
                Process input = new Process();
                input.name = strs1[0];
                input.time = int.Parse(strs1[1]);
                Q.enqueue(input);
            }

            int time = 0;

            while (n > 0)
            {
                Process output = Q.dequeue();
                if (output.time <= q)
                {
                    time += output.time;
                    Console.WriteLine("{0} {1}", output.name, time);
                    n--;
                }
                else
                {
                    time += q;
                    output.time -= q;
                    Q.enqueue(output);
                }
            }
//            Console.ReadLine();
        }

        struct Process
        {
            public string name;
            public int time;
        }

        class Queue
        {
            Process[] Q;
            int MAX = 100000;

            public Queue()
            {
                Q = new Process[MAX];
                initialize();
            }

            int head;
            int tail;
            void initialize()
            {
                head = 0;
                tail = 0;
            }

            private bool isEmpty()
            {
                return head == tail;
            }

            private bool isFull()
            {
                return head == (tail + 1) % MAX;
            }

            public void enqueue(Process x)
            {
                if (isFull())
                {
                    Console.WriteLine("???????????????????????¨??????");
                    Console.ReadLine();
                }

                Q[tail] = x;
                if (tail + 1 == MAX)
                {
                    tail = 0;
                }
                else
                {
                    tail++;
                }
            }

            public Process dequeue()
            {
                Process ans = new Process();
                if (isEmpty())
                {
                    Console.WriteLine("??¢????????????????????¨??????");
                    Console.ReadLine();
                    return ans;
                }
                ans = Q[head];
                if (head + 1 == MAX)
                {
                    head = 0;
                }
                else
                {
                    head++;
                }
                return ans;
            }
        }
    }
}

Measured memory_bytes: 12248
#!/usr/bin/env python3


def reachable(start, target, lst):

    current = set()
    current.add(start)

    for moves in lst:
        candidates = set()
        for x in current:
            candidates.add(x + moves)
            candidates.add(x - moves)
        current = candidates

    return target in current


def main():
    s = input()
    sa = input().split(' ')
    x = int(sa[0])
    y = int(sa[1])

    x_list = []
    y_list = []
    moves = 0
    move_x = True
    lst = x_list
    for cmd in s:
        if cmd == 'F':
            moves += 1
        else:
            # cmd == 'T'
            if moves != 0:
                lst.append(moves)
            moves = 0
            move_x = not move_x
            lst = x_list if move_x else y_list
    if moves != 0:
        lst.append(moves)

    if s[0] == 'F':
        x -= x_list[0]
        x_list = x_list[1:]

    if reachable(0, x, x_list) and reachable(0, y, y_list):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main(){
    int a;
    cin >> a;
    int b[a];
    for(int i = 0;i < a;i++){
        cin >> b[i];
    }
    for(int j = a-1;j >= 0;j--){
        if(j == 0){ 
        cout << b[j] <<endl;
        continue;
        }
        cout << b[j] << " ";
    }
}


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

int main(){
  int h, w;
  cin >> h >> w;
  string s[h];
  list_input(s, h)
  rep(i, w+2) cout << "#";
  cout << endl;
  rep(i, h){
    cout << "#" << s[i] << "#" << endl;
  }
  rep(i, w+2) cout << "#";
  cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>

const int mod=1e9+7;

int n;
int f[2005];

int dfs(int sum)
{
    if(!sum)return 1;
    if(f[sum])return f[sum];
    for(int i=3;i<=sum;i++)
        f[sum]=(f[sum]+dfs(sum-i))%mod;
    return f[sum];
}

int main()
{
    scanf("%d",&n);
    printf("%d\n",dfs(n));
    return 0;
}

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

int main() {
    int n, counter = 0;
    string s;
    cin >> n;
    cin >> s;
    for(int i = 1; i < n; ++i){
        if(s[i]=='E'){
            ++counter;
        }
    }
    int ans = counter;
    for(int i = 1; i < n; ++i){
        if(s[i-1]=='W' && s[i]=='W'){
            ++counter;
        }else if(s[i-1]=='E' && s[i]=='E'){
            --counter;
        }if(counter < ans){
            ans = counter;
        }
    }

cout << ans << "\n";
return 0;
}


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

using namespace std;

void solve() {
    int n;
    int x = 0, xmax = 0;
    cin >> n;
    char c;
    for (int i = 0; i < n; ++i) {
        cin >> c;
        if (c  == 'I') {
            ++x;
        } else {
            --x;
        }
        if (x > xmax)
            xmax = x;
    }
    cout << xmax;

}

int main() {

    solve();
    return 0;
}



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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// 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;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	ll s , c ;
	cin >> s >> c;
	
	ll ans = 0;
	if(c < s * 2){
		ans = c / 2;
	}else if(c < s * 2 + 4){//sをcにすることはできない
		ans = s;
	}else{
		//cをsにしたほうがいい。c4でsccを一つ作れる
		ans = s;
		c -= s * 2;
		ans += c / 4;
	}
	
	cout << ans << endl;

}


Measured memory_bytes: 256
import copy

N,M = map(int, input().split())
jisho = [[] for i in range(N)]
for i in range(M):
    val = input().split()
    for j in val[1:]:
        jisho[int(j)-1].append(i)

p = list(map(int, input().split()))

sw = []
def create_ki(data):
    if len(data) == N:
        sw.append(data)
        return
    tmp = copy.copy(data)
    tmp.append(0)
    create_ki(tmp)
    tmp2 = copy.copy(data)
    tmp2.append(1)
    create_ki(tmp2)

create_ki([])

ans = 0
for val in sw:
    num = 0
    sw2 = [0]*M
    for i in val:
        if i == 0:
            num += 1
            continue
        data = jisho[num]
        for j in data:
            sw2[j] += 1
        num += 1
    cn = 0
    for j in sw2:
        if j % 2 != p[cn]:
            break
        cn += 1
    if cn == M:
        ans += 1

print(ans)

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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)

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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MAX = 100005;

ll dp[MAX];
int n, k;
vector<int> v;

ll solve(int pos) {
	if(pos == n-1) return 0;
	if(pos >= n) return LINF;
	if(dp[pos] != -1) return dp[pos];

	ll res = LINF;
	FOR(i,1,k+1) {
		if(pos+i >= n) continue;
		res = min(res, abs(v[pos] - v[pos+i]) + solve(pos+i));
	}

	return dp[pos] = res;
}

int main() { _
	cin >> n >> k;
	v.resize(n);
	FOR(i,0,n) cin >> v[i];

	memset(dp, -1, sizeof(dp));

	cout << solve(0) << endl;
	return 0;
}


Measured memory_bytes: 12168
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <random>
#define INF 1000000007
using namespace std;

int main(void){
	string s,t;
	cin >> s >> t;
	for(int i=0; i<t.length(); i++){
		for(int j=0; j<t.length(); j++){
			if(s[j]!=t[(i+j)%t.length()])break;
			else if(j+1==t.length()){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    readLine()
    val a = readLine()!!.split(" ").map { it.toLong() }
    val negativeCount = a.count { it < 0L }
    val min = a.map { Math.abs(it) }.min()!!
    var sum = a.map { Math.abs(it) }.sum()
    println(if (negativeCount % 2 == 0) sum else sum - 2 * min)
}

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

int main(){
  int a , b ; 
  cin >> a >> b ; 
  
  int s = b -a ; 
  int left = 1 ; 
  int right = 1 ; 
  for(int i= 2 ; i <= 999 ; i++){
    right += i ; 
    //cout << left << " " << right << endl ; 
    if( right - left  == s){
      cout << left - a << endl; 
      return 0 ; 
    }
    left += i ;
  }
  
}

Measured memory_bytes: 3636
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        // Your code here!
        int N = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
　　　　int max = a.Max();
        int sum = 0;
        int count = 0;
        for(int i = 0; i < N; i++)
        {
            if(a[i] == max)
            {
                if(count == 0)
                {
                    count++;
                    continue;
                }
                else
                {
                    sum += a[i];
                }
            }
            else
            {
                sum += a[i];
            }
        }
        
        if(max < sum) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int x, y, z, t;
	cin >> x >> y >> z;
	t = x;
	x = y;
	y = t;
	t = x;
	x = z;
	z = t;
	cout << x << " " << y << " " << z << endl;

	return 0;
}


Measured memory_bytes: 3612
n = int(input())
argList = list(map(int, input().split()))
ret = argList[0]
#print(argList[0])
for i in range(1,len(argList)):
    #print(min(argList[i-1],argList[i]))
    ret += min(argList[i-1],argList[i])
ret += argList[-1]
#print(argList[-1])
print(ret)

Measured memory_bytes: 9160
#include <iostream>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main(void){
  int A,B;
  cin >> A >> B;
  if((A+B)%2 == 0){
    cout << (A+B)/2 << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string S[100];
int Dur[100],ans;
int main()
{
  int N;
  cin>>N;
  for(int i=0;i<N;i++)
    cin>>S[i]>>Dur[i];
  string X;
  cin>>X;
  for(int i=N-1;i>=0;i--)
  {
    ans+=Dur[i];
    if(S[i]==X)
    {
      cout<<ans-Dur[i];
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())

div = [0]*1000
ans = 1
for j in range(1,N+1):
    n = j
    for i in range(2,n+1):
        while n % i == 0:
            div[i] += 1
            n //= i

for num in div:
    ans *= (num+1)

print(ans % (10**9 + 7))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define l long 
#define ll long long 
#define ld long double 
#define MOD 1000000007
#define MAX_N 10004
#define f first 
#define s second 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const ll inf=1e18;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll dig_dp[MAX_N][100];
    l x=0,d,y;
    string num;
    cin>>num;
    cin>>d;
    for(l i=0;i<MAX_N;i++)
    {
        for(l j=0;j<100;j++)
        {
            dig_dp[i][j]=0;
        }
    }
    for(l i=0;i<MAX_N;i++)
    {
        for(l j=0;j<d;j++)
        {
            if(i==0)
            {
                for(l dig=0;dig<10;dig++)
                {
                    if((dig-j)%d==0)
                        dig_dp[i][j]++;
                }
            }
            else 
            {
                for(l dig=0;dig<10;dig++)
                {
                    x=(j-dig)%d;
                    if(x<0)
                        x+=d;
                    dig_dp[i][j]=(dig_dp[i][j]+dig_dp[i-1][x])%MOD;
                }
            }
        }
    }
    x=0;
    ll ans=0;
    reverse(num.begin(),num.end());
    for(l i=num.size()-1;i>=0;i--)
    {
        for(l j=0;j<num[i]-'0';j++)
        {
            y=(d-x-j)%d;
            if(y<0)
                y+=d;
            if(i>0)
                ans=(ans+dig_dp[i-1][y])%MOD;
            else if(y==0)
                ans=(ans+1)%MOD;
        }
        x=(x+num[i]-'0')%d;
        if(x<0)
            x+=d;
    }
    if(x!=0)
        ans=(ans-1)%MOD;
    if(ans<0)
        ans+=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 11472
#include <bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<(long long)(n);i++)
#define REPS(i,n) for(long long i=1;i<=(long long)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    ll N;
    cin >> N;
    ll A[N];
    REP (i, N) {
        cin >> A[i];
    }

    map<ll, ll> ball;
    REPS (i, N) {
        ball[i] = 0;
    }
    REP (i, N) {
        ball[A[i]]++;
    }
    ll combination = 0;
    REPS (i, N) {
        combination += ball[i]*(ball[i]-1)/2;
    }
    REP (i, N) {
        ll tmp = combination;
        if (ball[A[i]] >= 1) {
            tmp -= ball[A[i]]*(ball[A[i]]-1)/2;
        }
        if (ball[A[i]] >= 2) {
            tmp += (ball[A[i]]-1)*(ball[A[i]]-2)/2;
        }
        cout << tmp << endl;
    }
}

Measured memory_bytes: 16640
#include <iostream>
#include <sstream>
#include <string>
#include <stdio.h>

using namespace std;

string intArrayToString(int* ary, int ary_size);
void insert_sort(string ary, int ary_size);

int main()
{
	string str;
	getline(cin, str);
	stringstream ss_size(str);
	int ary_size;
	ss_size >> ary_size;

	getline(cin, str);
        cout << str << endl;

	insert_sort(str, ary_size);

    return 0;
}

void insert_sort(string ary, int ary_size) {
	// pram div into int array
	stringstream ss(ary);
	string buff;
	int* tar_ary = new int[ary_size];
	int cnt = 0;

	while (getline(ss, buff, ' ')) {
		stringstream num_ss(buff);
		num_ss >> tar_ary[cnt];
		cnt++;
	}

	for (int i = 1; i < ary_size; i++) {
		int v = tar_ary[i];
		int cnt = 0;
		for (int j = i - 1; j >= 0 && tar_ary[j] > v; j--) {			
			tar_ary[j + 1] = tar_ary[j];
			cnt = j;
			tar_ary[cnt] = v;
		}
		cout << intArrayToString(tar_ary, ary_size) << endl;
	}
	delete(tar_ary);

	return;
}

string intArrayToString(int* ary, int ary_size) {
	string str = "";
	for (int i = 0; i < ary_size; i++) {
		if (i == ary_size - 1) {
			str += to_string(ary[i]);
		}
		else {
			str += to_string(ary[i]) + " ";
		}
	}
	return str;
}

Measured memory_bytes: 3252
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
	int n;

	std::cin >> n;

	std::vector<int> score(n);

	for (int i = 0; i < n; i++) {
		std::cin >> score[i];
	}

	std::vector<int> total(100 * 100 + 1, 0);

	total[score[0]] = 1;

	for (int i = 1; i < n; i++) {
		for (int j = total.size() - 1; j >= 0; j--) {
			if (total[j] != 0) {
				total[j + score[i]] = 1;
			}
		}
		total[score[i]] = 1;
	}

	int max = 0;

	for (int i = 0; i < total.size(); i++) {
		if (total[i] != 0 && i % 10 != 0) {
			max = i;
		}
	}

	std::cout << max << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a) for(int i = 0; i < (a); i++)
using namespace std;
signed main()
{
    while(true)
    {
        int x, y; cin >> x >> y;
        if(x == 0 && y == 0) break;
        cout << min(x, y) << " " << max(x, y) << endl;
    }
}


Measured memory_bytes: 3084
N=input()

L={}
for start in range(1,10):
    for end in range(1,10):
        t=0
        if start==end:
            n=start
            if n<=N: t+=1

        n=start*10**1+end
        if n<=N: t+=1

        for i in range(10):
            n=start*10**2+i*10**1+end
            if n<=N:
                t+=1

        for i in range(10):
            for ii in range(10):
                n=start*10**3+i*10**2+ii*10**1+end
                if n<=N:
                    t+=1

        for i in range(10):
            for ii in range(10):
                for iii in range(10):
                        n=start*10**4+i*10**3+ii*10**2+iii*10**1+end
                        if n<=N: t+=1


        for i in range(10):
            for ii in range(10):
                for iii in range(10):
                    for iiii in range(10):
                        n=start*10**5+i*10**4+ii*10**3+iii*10**2+iiii*10**1+end
                        if n<=N: t+=1
        L[(start,end)]=t
    

ans=0

for start in range(1,10):
    for end in range(1,10):
        ans+=L[(start,end)]*L[(end,start)]

print ans

Measured memory_bytes: 33128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

    public static void main(String[] args) throws IOException {
        // write your code here

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(reader.readLine());
        System.out.println(Math.PI*2*n);
        //System.out.println(2*3.14*n);

    }
}


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

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

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N;
  cin >> N;
  ll a[N+1];
  vector<vll> multi(N+1);
  repi(i, 1, N+1) cin >> a[i];

  repi(i, 1, N+1){
    for(ll n=2*i;n<=N;n+=i) multi[n].push_back(i);
  }
  for(ll i=N;i>0;i--){
    for(ll m: multi[i]) a[m] ^= a[i];
    // debug(a);
  }
  ll ans = 0;
  repi(i, 1, N+1) ans += a[i];

  cout << ans << endl;
  repi(i, 1, N+1){
    if(a[i]){
      cout << i << (ans > 1 ? ' ' : '\n');
      ans--;
    }
  }
  return 0;
}


Measured memory_bytes: 35456
line = list(input())

ans = [line[0]]

if len(line)==1:
    print(1)
else:
    skip_flag=False
    for i in range(1,len(line)):
        if skip_flag:
            skip_flag=False
            continue
        # print(i)
        if line[i]==ans[-1]:
            if i==len(line)-1:
                ans[-1]=ans[-1]+line[i]
            else:
                ans.append(line[i]+line[i+1])
            skip_flag=True
        else:
            ans.append(line[i])
            skip_flag=False
    # print(ans)
    print(len(ans))

Measured memory_bytes: 9408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

ll power(ll a, ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a);
        a = (a*a);
        b >>= 1;
    }
    return prod;
}
bool comp(pair<int,int> a , pair<int,int> b)
{
		if(a.ff != b.ff)
			return a.ff < b.ff;
		return a.ss > b.ss;
}
int main(){

	int n;
	cin >> n;
	pair<string , int> p[n];
	map<string ,int> m;
	int arr[n] = {0};
	for(int i = 0 ; i < n ;i++)
	{
		cin >> p[i].ff >> p[i].ss;
		m[p[i].ff] = i;
	}
	arr[0] = p[0].ss;
	for(int i = 1 ; i < n ; i++)
	{
		arr[i] = arr[i-1] + p[i].ss;
	}
	string s;
	cin >> s;
	cout << arr[n-1] - arr[m[s]];
 	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include "/usr/local/include/cxx_pretty_print/cxx_pretty_print.hpp"

using namespace std;
/* type aliases */
using i32 = int32_t; using ui32 = uint32_t; using i64 = int64_t; using ui64 = uint64_t; using i128 = __int128;
using f32 = float;   using f64  = double;   using f80 = long double;
using PII = pair<i32, i32>; using PLL = pair<i64, i64>; using PFF = pair<f32, f32>; using PDD = pair<f64, f64>;
using VB  = vector<bool>;   using VS  = vector<string>;
using VI  = vector<i32>;    using VL  = vector<i64>;    using VF  = vector<f32>;    using VD  = vector<f64>;
using VVI = vector<VI>;     using VVL = vector<VL>;     using VVF = vector<VF>;     using VVD = vector<VD>;
using VPI = vector<PII>;    using VPL = vector<PLL>;    using VPF = vector<PFF>;    using VPD = vector<PDD>;
/* constants */
constexpr i64 mod = 1000000007;                                // 10^9+7
constexpr i64 inf = 9000000000000000000;                       // 9*10^18
/* macros */
#define MAX(c)        *max_element(ALL(c))
#define MIN(c)        *min_element(ALL(c))
#define SIZE(c)       (i64)((c).size())                        // unsined int (size_t) -> int64_t
#define ALL(c)        (c).begin(), (c).end()
#define RALL(c)       (c).rbegin(), (c).rend()
#define REP(i, n)     for (i64 i=0; i<(i64)(n); ++i)           // 0 to n-1
#define REPD(i, n)    for (i64 i=(i64)(n)-1; i>=0; --i)        // n-1 to 0
/* debug */
#define debug(x)      cerr << #x << ": " << (x) << '\n'
#define debugvec(v)   for (size_t _ = 0; _ < (v).size(); ++_) {cerr << #v << '[' << _ << "]: " << (v)[_] << '\n';}
/* useful output */
auto print = [](auto x) {cout << (x) << '\n';};
template <class T> void printvec(T v, string sep=" ", string end="\n") {REP(i, SIZE(v)-1) cout << v[i] << sep; cout << v[SIZE(v)-1] << end;}
/* useful input */
VS splitstr(string s, char delim=' ') {VS v; string buf; stringstream ss{s}; while (getline(ss, buf, delim)) v.push_back(buf); return v;}




void Main() {
    i32 l, r, d;
    cin >> l >> r >> d;
    print(r / d - (l - 1) / d);
}


signed main() {
    cin.tie(nullptr);                                         // cin と cout の tie を切り高速化
    cout << fixed << setprecision(15);                        // 浮動小数点数が 1e-006 のように表示されることを防ぐ
    Main();
}

Measured memory_bytes: 3600
import sys
from collections import Counter

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    S = list(in_s())
    N = len(S)
    cnt = Counter(S)

    ans = N * (N - 1) // 2 + 1

    orda = ord('a')
    for c in range(orda, orda + 26):
        c = chr(c)
        n = cnt[c]
        ans -= n * (n - 1) // 2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10776
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Edge
{
public:
    int to, cost;
    Edge(int to0, int cost0){
        to = to0;
        cost = cost0;
    }
};

int main()
{
    int n, m, k, p;
    cin >> n >> m >> k >> p;

    vector<vector<Edge> > edges(n+1);
    for(int i=0; i<m; ++i){
        int x, y, w;
        cin >> x >> y >> w;
        edges[x].push_back(Edge(y, w));
        edges[y].push_back(Edge(x, w));
    }

    vector<int> mail(n+1, -1), delivery(n+1, -1);
    for(int i=0; i<k; ++i){
        int s, t;
        cin >> s >> t;
        mail[s] = i;
        delivery[t] = i;
    }

    vector<vector<vector<int> > > dp(n+1, vector<vector<int> >(1<<k, vector<int>(1<<k, INT_MAX)));
    multimap<int, tuple<int, int, int> > mm;
    dp[p][0][0] = 0;
    mm.insert(make_pair(0, make_tuple(p, 0, 0)));
    while(!mm.empty()){
        int cost = mm.begin()->first;
        int curr, isMail, isDelivery;
        tie(curr, isMail, isDelivery) = mm.begin()->second;
        mm.erase(mm.begin());
        if(dp[curr][isMail][isDelivery] < cost)
            continue;

        for(const Edge& e : edges[curr]){
            int to = e.to;
            int cost2 = cost + e.cost;
            int isMail2 = isMail;
            int isDelivery2 = isDelivery;

            if(mail[to] != -1)
                isMail2 |= 1 << mail[to];
            if((isMail2 & (1 << delivery[to])) && delivery[to] != -1)
                isDelivery2 |= 1 << delivery[to];

            if(cost2 < dp[to][isMail2][isDelivery2]){
                dp[to][isMail2][isDelivery2] = cost2;
                mm.insert(make_pair(cost2, make_tuple(to, isMail2, isDelivery2)));
            }
        }
    }

    int ans = INT_MAX;
    for(int i=1; i<=n; ++i)
        ans = min(ans, dp[i].back().back());
    if(ans < INT_MAX)
        cout << ans << endl;
    else
        cout << "Cannot deliver" << endl;

    return 0;
}

Measured memory_bytes: 22912
<?php

while (($line = trim(fgets(STDIN))) !== '') {
    for ($i = 0, $len = strlen($line); $i < $len;) {
        if ($line[$i] === '@') {
            echo str_repeat($line[$i + 2], $line[$i + 1]);
            $i += 3;
        } else {
            echo $line[$i];
            $i++;
        }
    }
    echo PHP_EOL;
}

Measured memory_bytes: 6572
{-# OPTIONS_GHC -O #-}

import Control.Monad
import Data.List
import Data.Foldable

main=do
    a1@[a11,a12,a13] <- map read.words<$>getLine :: IO[Int]
    a2@[a21,a22,a23] <- map read.words<$>getLine :: IO[Int]
    a3@[a31,a32,a33] <- map read.words<$>getLine :: IO[Int]

    putStrLn $ if (and [chk a1 a2, chk a2 a3, chk a1 a3,
     chk [a11,a21,a31] [a12,a22,a32],
     chk [a12,a22,a32] [a13,a23,a33],
     chk [a11,a21,a31] [a13,a23,a33]])
        then "Yes"
        else "No"

chk :: [Int]->[Int]->Bool
chk as bs =
    (\[a,b,c] -> a==b && b==c) $ zipWith (-) as bs

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

ll a,b,c,d,n,m,k;

string s;

int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin>>n;
  vector<ll> v(4,0);
  rep(i,n){
    cin>>s;
    if(s=="AC") v[0]++;
    else if(s=="WA") v[1]++;
    else if(s=="TLE") v[2]++;
    else if(s=="RE") v[3]++;
  }
  cout<<"AC x "<<v[0]<<endl;
  cout<<"WA x "<<v[1]<<endl;
  cout<<"TLE x "<<v[2]<<endl;
  cout<<"RE x "<<v[3]<<endl;

  return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000

//aのb乗
int beki(int a,int b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}


//aの逆元
int gyakugen(int a){
	return beki(a,modulo-2);
}

struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		
		int b=gyakugen(kaijou[n]);
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
};

int func(int r,int c){
	combi C(r+c+100);
	
	int ret = 0;

	
	
	for(int i=0;i<=c;i++){
		int temp = C.combination(r+i+1,i+1);
		ret = mod(ret + temp);
	}
	
	return ret;
	
}


int main(){

	int r1,r2,c1,c2;
	cin>>r1>>c1>>r2>>c2;
	int ans = func(r2,c2);
	ans = mod(ans - func(r1-1,c2));
	ans = mod(ans - func(r2,c1-1));
	ans = mod(ans + func(r1-1,c1-1));
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 16664
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int a, b;
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> a >> b >> s;
    bool flag = false;
    if ((int)s.size() == a + b + 1) {
      flag = true;
      rep(i, 0, a + b + 1) {
        if (i == a) {
          if (s[i] == '-') flag = true;
          else {
            flag = false;
            break;
          }
        } else {
          int t = s[i] - '0';
          if (t < 0 || 9 < t) {
            flag = false;
            break;
          }
        }
      }
    }
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n,k;
    cin >> n >> k;
    deque<ll> v(n);
    rep(i,n) cin >> v[i];
    ll ans = 0;
    rep(i,min(k+1,n+1)){
        rep(j,min(k+1,n+1) - i){
            vector<ll> minu;
            ll now = 0;
            rep(l,i) now += v[l], minu.push_back(v[l]);
            rep(m,j) now += v[n - 1 - m], minu.push_back(v[n - 1  - m]);
            sort(minu.begin(),minu.end());
            rep(l, min( int(minu.size()), k -  i - j )){
                if(minu[l] < 0){
                    now -= minu[l];
                }
            }
            ans = max(now,ans);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
	string str;
	cin >> str;
	
	for (string::reverse_iterator rit = str.rbegin(); rit != str.rend(); rit++) {
		cout << *rit;
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 2960
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x[] = new int [3];
		int max,min;
        for(int i = 0; i < 3; i++){
        	x[i] = stdIn.nextInt();
        }
		stdIn.close();

		for (int i = 0; i < x.length - 1; i++) {
            for (int j = i + 1; j < x.length; j++) {
            	max = Math.max(x[i], x[j]);
            	min = Math.min(x[i], x[j]);
            	if (min != x[i]) {
            		x[i] = min;
            		x[j] = max;
            	}
            }
        }
        out_put(x);

	}

	private static void out_put(int array[]){

        System.out.printf("%d", array[0]);

        for(int i = 1; i < array.length; i++){
            System.out.printf(" %d", array[i]);
        }
        System.out.printf("%n");
    }

}



Measured memory_bytes: 26236
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskS solver = new TaskS();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskS {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] ints = in.nextLine().chars().map(i -> i - '0').toArray();
            for (int mask = 0; mask <= (1 << 3) - 1; mask++) {
                int sum = ints[0];
                String s = Integer.toString(ints[0]);
                for (int i = 0; i < 3; i++) {
                    sum += ((mask >> i) & 1) == 1 ? ints[i + 1] : -ints[i + 1];
                    s += ((mask >> i) & 1) == 1 ? '+' : '-';
                    s += Integer.toString(ints[i + 1]);
                }
                if (sum == 7) {
                    out.println(s + "=7");
                    return;
                }
            }
        }

    }

    static class InputReader {
        final InputStream is;
        final byte[] buffer = new byte[1024];
        int curCharIdx;
        int nChars;

        public InputReader(InputStream is) {
            this.is = is;
        }

        public int read() {
            if (curCharIdx >= nChars) {
                try {
                    curCharIdx = 0;
                    nChars = is.read(buffer);
                    if (nChars == -1) {
                        return -1;
                    }
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return buffer[curCharIdx++];
        }

        public String nextLine() {
            return nextLine(16);
        }

        public String nextLine(int size) {
            int c = read();
            while (c == '\n' || c == '\t' || c == '\r') {
                c = read();
            }
            if (c == -1) {
                return null;
            }
            StringBuilder sb = new StringBuilder(size);
            while (c != -1 && c != '\n' && c != '\t' && c != '\r') {
                sb.appendCodePoint(c);
                c = read();
            }
            return sb.toString();
        }

    }
}



Measured memory_bytes: 38908
#include<iostream>
#include<algorithm>
using namespace std;
main()
{
	string s;
	cin >> s;
	long long int n, x;
	cin >> n;
	bool rev = false;
	string pref="", suf="";
	while(n--)
	{
		cin >> x;
		if(x == 1)
		{
			if(rev == false)
			rev = true;
			else
			rev = false;
		}
		else
		{
			long long int  f;
			char c;
			cin >> f >> c;
			if(f == 1)
			{
				if(rev == true)
				suf+=c;
				else
				pref+=c;
			}
			else
			{
				if(rev == true)
				pref+=c;
				else
				suf+=c;
			}
		}
	}
if(rev == false)
{
	reverse(pref.begin(), pref.end());
	cout << pref << s << suf;
}
else
{
	reverse(suf.begin(), suf.end());
	reverse(s.begin(), s.end());
	cout << suf << s << pref;
	}	
	
	return 0;
}

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

int main()
{
	int n, a;
	int max, min;

	long int sum = 0;

	cin >> n;

	for (int i = 0; i < n; i++){
		cin >> a;

		if (i == 0){
			max = a;
			min = a;
			sum += a;
			continue;
		}

		if (max < a)
			max = a;

		if (min > a)
			min = a;

		sum += a;
	}
	cout << min << " " << max << " " << sum << endl;

	return 0;
}

Measured memory_bytes: 3104