akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(20) << x << endl
const int MOD = 1e9 + 7;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 1e-8;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

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

  string s;
  int x, y;
  cin >> s;
  cin >> x >> y;
  bool is_first = true;
  bool is_x = true;
  vector<vector<bool>> dpx(s.size() + 10, vector<bool>(20000, false)), dpy(s.size() + 10, vector<bool>(20000, false));
  dpx[0][10000] = true;
  dpy[0][10000] = true;
  int move = 0;
  VI vec_move;
  rep(i, s.size()) {
    if(s[i] == 'F') move++;
    else {
      vec_move.push_back(move);
      move = 0;
    }
    if(i == s.size() - 1) vec_move.push_back(move);
  }
  rep(i, vec_move.size()) rep(j, 20000) {
    int m = vec_move[i];
    if(i % 2 == 0) {
      if(i == 0 && j + m < 20000) {
        dpx[i + 1][j + m] = dpx[i + 1][j + m] | dpx[i][j];
      }
      else {
        if (j + m < 20000) dpx[i + 1][j + m] = dpx[i + 1][j + m] | dpx[i][j];
        if (j - m >= 0) dpx[i + 1][j - m] = dpx[i + 1][j - m] | dpx[i][j];
      }
      dpy[i + 1][j] = dpy[i][j];
    }
    else {
      if (j + m < 20000) dpy[i + 1][j + m] = dpy[i + 1][j + m] | dpy[i][j];
      if (j - m >= 0) dpy[i + 1][j - m] = dpy[i + 1][j - m] | dpy[i][j];
      dpx[i + 1][j] = dpx[i][j];
    }
  }

  string ans = dpx[vec_move.size()][x + 10000] & dpy[vec_move.size()][y + 10000] ? "Yes" : "No";
  out(ans);

  return 0;
}


Measured memory_bytes: 43324
import sys
sys.setrecursionlimit(10**7)
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, x, t = map(int, input().split())
    r = ceil(n / x) * t
    print(r)

if __name__ == '__main__':
    main()


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

int main()
{
	int t, n, m;

	cin >> t;
	
	while (t > 0) {
		cin >> n;
		m = 0;

		for (int i = 0; i < n; i++) {
			int s, f;
			cin >> s >> f;

			m += f - s;
		}

		if (m >= t)
			cout << "OK" << endl;
		else
			cout << t - m << endl;

		cin >> t;
	}

	return 0;
}



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

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
    }

    std::sort(a.begin(),a.end());

    
    int alice = 0;
    int bob = 0;
    for(int i = 0; i < n; i++){
        if(i%2 == 0) alice += a[i];
        else bob += a[i];
    }

    std::cout << abs(alice - bob);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int A[200];

int main()
{
	int N, ans = 0;

	cin >> N;
	rep(i, N) cin >> A[i];

	while (true) {
		rep(i, N) {
			if (A[i] % 2 != 0) goto END;
			A[i] /= 2;
			if (i == N - 1) ans++;
		}
	}

	END:

	cout << ans << endl;

	return 0;
}


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

namespace abc122
{
    class B
    {
        static void Main(string[] args)
        {
            string S = Input.Str();

            int count = 0;
            int maxCount = 0;
            for (int i = 0; i < S.Length; i++)
            {
                switch (S[i]) {
                    case 'A':
                    case 'T':
                    case 'G':
                    case 'C':
                        count++;
                        maxCount = Math.Max(maxCount, count);
                        break;
                    default:
                        count = 0;
                        break;
                }
            }

            Console.WriteLine(maxCount);
        }

        /** Input Class */
        internal static class Input
        {
            /** input int */
            public static int Int() => int.Parse(Console.ReadLine());

            /** input str */
            public static string Str() => Console.ReadLine();

            /** input array of int */
            public static int[] IntArray() => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            /** input array of string */
            public static string[] StrArray() => Input.Str().Split(' ');

            /** input array of char */
            public static char[] CharArray() => Input.Str().ToCharArray();

            public static char Char() => Input.CharArray().First();
        }
    }
}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

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

REP(i,s.size()){
  int diff=((s[i]-'A')+n)%26;
 s[i]=diff+'A';
}
cout<<s<<endl;
}

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

using namespace std;

multiset< string > S; 
multiset< string > :: iterator it; 

int A, B, C; 
string ns; 

int main() {

	cin >> A >> B >> C; 

	for(int i=1; i<=A; ++i) S.insert("a"); 
	for(int i=1; i<=B; ++i) S.insert("b"); 
	for(int i=1; i<=C; ++i) S.insert("c"); 

	while(1) {
		if(S.size() == 1) break; 
		it = S.begin(); 
		ns = (*it);
		S.erase(it); 
		it = S.end(); 
		--it; 
		ns = ns + (*it); 
		S.erase(it); 
		S.insert(ns); 
	}

	it = S.begin();
	ns = (*it); 
	cout << ns << endl; 

	return 0; 

}

Measured memory_bytes: 256
N,K,Q = map(int,input().split())
L = [0 for n in range(N)]

for i in range(Q):
  A = int(input())
  L[A-1] += 1

for j in range(N):
  if K - (Q-L[j]) > 0:
    print("Yes")
  else: 
    print("No")

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

using namespace std;

int main()
{
    int ans=0;
    vector<int> N(3);
    for(int i=0; i<3; i++)
    {
        cin >> N.at(i);
    }

    sort(N.begin(),N.end());
    if((N.at(2)-N.at(0))%2 == (N.at(2)-N.at(1))%2 )
        ans = (N.at(1)-N.at(0))/2 + (N.at(2) - N.at(1));
    else
        ans += (N.at(2)-N.at(0))/2 +(N.at(2) - N.at(1))/2 + 2;
    
    cout << ans << endl;

    return 0;    
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
long long g(long long p){
    long long x=1;
    for(int i=mod-2;i>0;i/=2){
        if(i%2)x=x*p%mod;
        p=p*p%mod;
    }
    return x;
}
int main(){
    int n,k;
    cin>>n>>k;
    long long x=1,y=1,ans=1;
    for(int i=1;i<=min(n-1,k);i++){
        x=(x*(n-i+1))%mod*g(i)%mod;
        y=(y*(n-i))%mod*g(i)%mod;
        ans=(ans+x*y)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}
template <typename Val>
void show_vec(vector<Val> v){
  cout<<endl;
  rep(i,v.size()){
    cout<<v.at(i)<<" ";
  }
  cout<<endl;
}

template <typename Val,typename Number>
void count_vector(vector<Val>* A,vector<pair<Number,Val>>*R){
  sort(A->begin(),A->end());
  int count = 1;
  rep(i,A->size()){
    if(i<A->size()-1){
      if(A->at(i)==A->at(i+1))count++;
      else{
        R->emplace_back(count,A->at(i));
        count = 1;
      }
    }else{
      R->emplace_back(count,A->at(i));
    }
  }
}


//---------------------------------------------------------------
int main(){
  int A,B,K;
  string ans ="NG";
  cin>>K;
  cin>>A>>B;
  REP(i,A,B+1){
    if(i%K==0)ans = "OK";
  }



  cout<<ans<<endl;



}


Measured memory_bytes: 3580
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner s = new Scanner(System.in);
		double a,b,c,d,e,f;

		double x,y;
	
		while(s.hasNext()){
			 a = s.nextInt();
			 b = s.nextInt();
			 c = s.nextInt();
			 d = s.nextInt();
			 e = s.nextInt();
			 f = s.nextInt();
			
			 y = (c*d-f*a)/(b*d-e*a);
			 x = (c-b*y)/a;
			 System.out.printf("%.3f %.3f\n",x,y);

			
		}
		


	}
}

Measured memory_bytes: 26364
X = gets.to_i
a = b = -1
５ = []
while 0
	a += 1
	a5 = a**5
	５[a] = a5
	if b = ５.bsearch_index{|b5| a5 <=> b5+X }
		break
	end
	if b = ５.bsearch_index{|b5| X <=> b5+a5 }
		b = -b
		break
	end
end
puts"#{a} #{b}"


Measured memory_bytes: 14536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define REP(i, x, n) for((i)=(x); (i)<(n); (i)++)
#define RREP(i, x, n) for((i)=(n)-1; (i)>=x; (i)--)
#define FOR(i, n) for((i)=0; (i)<(n); (i)++)
#define RFOR(i, n) for((i)=(n)-1; (i)>=0; (i)--)

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

        ll n, ans = 0, e, mxe;
        cin >> n;
        for (ll i=2; i * i <= n; i++) {
                e = 0;
                mxe = 0;
                while (n % i == 0) {
                        n /= i;
                        e++;
                        if (mxe < e) {
                                mxe = e;
                                e = 0;
                                ans++;
                        }
                }
        }
        if (n != 1) ans++;
        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 3664
import java.util.*;

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

    int n = sc.nextInt();
    int count = 0;
    int tmpColor = -1;
    int ans = 0;

    for (int i=0; i < n; i++) {
      int color = sc.nextInt();

      if (color == tmpColor) {
        count++;
      } else {
        count = 0;
      }

      if (count % 2 == 1) {
        ans++;
      }

      tmpColor = color;
    }

    System.out.println(ans);
  }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  map<int, int> ma;
  rep(i, n) {
    ma[a[i]]++;
  }
  i64 ans = 0;
  each(m, ma) {
    ans += (i64) m.second * (m.second - 1) / 2;
  }
  rep(i, n) {
    int x = ma[a[i]];
    i64 prev = ans;
    ans -= (i64) x * (x - 1) / 2;
    ans += (i64) (x - 1) * (x - 2) / 2;
    cout << ans << endl;
    ans = prev;
  }
}

Measured memory_bytes: 8320
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scn = new Scanner(System.in);
		long s = Long.parseLong(scn.next());
		long c = Long.parseLong(scn.next());

		long countScc = 0;
		if(c - s * 2 >= 0){
			countScc += s;
			countScc += (c - 2*s) / 4;
		}else{
			countScc += c/2;
		}
		System.out.println(countScc);
	}
}

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

typedef long long int ll;

#define mx 305

int h, w, k;
string g[mx];

int res[mx][mx];
int cur;

void remplir(int l){
	int lst = -1;
	for(int i=0;i<w;i++){
		if(g[l][i]=='#'){
			lst = i;
			cur++;
			int x=i;
			while(x>=0 && res[l][x]==0){
				res[l][x] = cur;
				x--;
			}
		}
	}
	if(lst>=0){
		for(int i=lst+1;i<w;i++){
			res[l][i] = res[l][i-1];
		}
	}
}

int main(){
	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		cin>>g[i];
	}
	
	cur = 0;
	
	for (int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			res[i][j] = 0;
		}
	}
	
	for(int i=0;i<h;i++){
		remplir(i);
	}
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(res[i][j]>0){
				int c=i-1;
				while(c>=0 && res[c][j]==0){
					res[c--][j] = res[i][j];
				}
				c = i+1;
				while(c<h && res[c][j] == 0){
					res[c++][j] = res[i][j];
				}
			}
		}
	}
	
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("%d ",res[i][j]);
		}
		printf("\n");
	}
}


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



int main(){
	
	int X;
	cin>>X;
	vector<int> A = {100,101,102,103,104,105};
	vector<bool> dp(X+1,false);
	dp[0] = true;
	
	for(int i=0;i<=X;i++){
		if(dp[i]==false)continue;
		for(int j=0;j<6;j++){
			int k = i+A[j];
			if(k<=X)dp[k]=true;
		}
	}
	
	if(dp[X])cout<<1<<endl;
	else cout<<0<<endl;
	
	return 0;
}

Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = input()

L = [-1] * K
interval = 0
cum = 0
for i in range(N):
    if S[i] == "o" and interval == 0:
        L[cum] = i
        interval = C
        cum += 1
        if cum >= K:
            break
    else:
        interval = max(0, interval - 1)

R = [-1] * K
interval = 0
cum = 0
for i in reversed(range(N)):
    if S[i] == "o" and interval == 0:
        R[-1 - cum] = i
        interval = C
        cum += 1
        if cum >= K:
            break
    else:
        interval = max(0, interval - 1)

for i in range(K):
    if L[i] == R[i]:
        print(L[i] + 1)


Measured memory_bytes: 20528
n = int(input())
a_list = list(map(int,input().split()))
a_list = [0] + a_list + [0]
s = 0
for i in range(len(a_list)-1):
    s += abs(a_list[i+1]-a_list[i])
    
for i in range(0,len(a_list)-2):
    p = s - abs(a_list[i+1] - a_list[i]) - abs(a_list[i+2] - a_list[i+1]) + abs(a_list[i+2] - a_list[i])
    print(p)

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

int need[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int compare(string s, string t) {
    if (s.length() > t.length()) {
        return -1;
    } else if (s.length() < t.length()) {
        return 1;
    } else {
        if (s < t) {
            return 1;
        } else if (s == t) {
            return 0;
        } else {
            return -1;
        }
    }
}

string add(string s, char a) {
    if (s.length() == 0) {
        return string(1, a);
    }
    if (s[0] <= a) {
        return a + s;
    } else if (s.back() >= a) {
        return s + a;
    }
    for (int i = 0; i < (int)s.length(); i++) {
        if (s[i] < a) {
            return s.substr(0, i) + a + s.substr(i + 1);
        }
    }
    return "";
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }

    vector<string> dp(N + 1, "");
    for (int a : A) {
        if (need[a] > N)
            continue;
        if (dp[need[a]] == "") {
            dp[need[a]] = to_string(a);
        } else if (compare(dp[need[a]], to_string(a)) == 1) {
            dp[need[a]] = to_string(a);
        }
    }
    for (int i = 0; i <= N; i++) {
        if (dp[i] == "")
            continue;

        for (int a : A) {
            int nxt = i + need[a];
            if (nxt > N)
                continue;

            string added = add(dp[i], ('0' + a));
            if (dp[nxt] == "") {
                dp[nxt] = added;
            } else if (compare(dp[nxt], added) == 1) {
                dp[nxt] = added;
            }
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 34688
#include <stdio.h>
int main (){
	int a,b,c,d,high;
	scanf("%d %d",&a ,&b);
	c=b-a;//takasa
	high=0;
	for (d=1;d<=c;d++){
		high+=d;
	}
	high-=b;
	printf("%d",high);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <unordered_map>
#include <string>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    unordered_map<char, ll> count;
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        count[s.at(0)]++;
    }

    const string lc = "MARCH";
    ll ans = 0;
    for(int i = 0; i < lc.size(); ++i){
        if(count.count(lc.at(i)) == 0){ continue; }
        for(int j = i + 1; j < lc.size(); ++j){
            if(count.count(lc.at(j)) == 0){ continue; }
            for(int k = j + 1; k < lc.size(); ++k){
                if(count.count(lc.at(k)) == 0){ continue; }
                ans += count.at(lc.at(i)) * count.at(lc.at(j)) * count.at(lc.at(k));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
  int n;
  while (cin >> n && n != 0){
    while (n--){
      int a, b, c;
      cin >> a >> b >> c;
      if (a == 100 || b == 100 || c == 100){
        cout << 'A' << endl;
        continue;
      }
      if (a + b >= 180){
        cout << 'A' << endl;
        continue;
      }
      if (a + b + c >= 240){
        cout << 'A' << endl;
        continue;
      }
      if (a + b + c >= 210){
        cout << 'B' << endl;
        continue;
      }
      if (a + b + c >= 150 && (a >= 80 || b >= 80)){
        cout << 'B' << endl;
        continue;
      }
      cout << 'C' << endl;
    }
  }
}

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

int main(){
    int N,k;
    long long s=0;
    cin >> N;
    //vector<int> v(N);

    for (int i=0;i<N;++i){
        cin >> k;
        s += k-1;
    }
    cout << s << endl;
}

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

int main() {
  int N;
  int ans = 0;
  cin >> N;
  vector<int> tako(N);
  for (int i=0; i < N; i++) {
    cin >> tako.at(i);
  }
  for (int i=0; i < N; i++) {
    for (int j=0; j < N; j++) {
      if (i != j) {
        ans += tako.at(i) * tako.at(j);
      }
    }
  }
  cout << ans / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  
  int dx = tx - sx;
  int dy = ty - sy;
  
  cout << string(dy, 'U') << string(dx, 'R');
  
  cout << string(dy, 'D') << string(dx, 'L');
  
  cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') << 'D';
  
  cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U';
  
  cout << endl;
  

}
             
 

Measured memory_bytes: 3620
a1, a2, a3 = map(int, input().split())

cost1 = abs(a1 - a2) + abs(a2 - a3)
cost2 = abs(a1 - a3) + abs(a3 - a2)
cost3 = abs(a3 - a1) + abs(a1 - a2)

print(min((cost1, cost2, cost3)))

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

using namespace std;
int main(void){
    long long r, d, x;
    cin >> r >> d >> x;
    
    for (int i = 0; i < 10; i++){
        x = r * x - d;
        cout << x << endl;
    }
    
}


Measured memory_bytes: 3664
from collections import deque

def argmax_poss(a):
    if len(a) == 0:
        return []
    all_ = [0]
    max_ = a[0]
    for i in range(1, len(a)):
        if a[i] > max_:
            all_ = [i]
            max_ = a[i]
        elif a[i] == max_:
            all_.append(i)
    return all_

h,w,m = map(int,input().split())
Ms = []

h_scores = [0 for i in range(h)]
w_scores = [0 for i in range(w)]

record = set()

for i in range(m):
  h,w = map(int,input().split())
  record.add((h-1,w-1))
  h_scores[h-1] += 1
  w_scores[w-1] += 1

max_h_poss = argmax_poss(h_scores)
max_w_poss = argmax_poss(w_scores)

out_pos_count = 0 

is_ok = False

for h in max_h_poss:
    for w in max_w_poss:
        if (h,w) not in record:
            is_ok = True
            break
        
if is_ok:
    print(max(h_scores) + max(w_scores))
else:
    print(max(h_scores) + max(w_scores)-1)



Measured memory_bytes: 83840
#include <stdio.h>
int main(void)
{
  int flag=0;
  char str[6];
  
  scanf("%s",str);
  
  if(str[2]==str[3])
    flag++;
  if(str[4]==str[5])
    flag++;
  
  if(flag==2)
    printf("Yes");
  if(flag<2)
    printf("No");
  
  return 0;
}

Measured memory_bytes: 1696
#include<iostream>
#include<algorithm>
#define REP(i, b, e) for ( int i = b; i < e; i++ )
#define rep(i, n) REP(i, 0, n)
using namespace std;
static const int NMAX = 32; // can be more
static const int MMAX = 32; 
int A[NMAX+1], T[MMAX], dp[2][1<<16], ST[MMAX][1<<16];

int getScore(int v){
    int sum = 0;
    rep(i, 16) if ( v & (1<<i)) sum++;
    return sum;
}

int main(){
  int N, M, b;
  int tcase = 0;
  while(1){
      cin >> N >> M;
      if ( N == 0 && M == 0 ) break;
      tcase++;
      rep(i, N+1) A[i] = 0;
      REP(i, 1, N+1) rep(j, 16){
	  cin >> b;      
	  if ( b ) A[i] += (1<<j);
      }
      rep(i, M) T[i] = 0;
      rep(i, M) rep(j, 16){
	  cin >> b;
	  if ( b ) T[i] += (1<<j);
      }

      rep(j, (1<<16)) dp[0][j] = dp[1][j] = -1;
      rep(i, M) rep(j, (1<<16)) ST[i][j] = getScore( T[i] & j );
      dp[0][0] = 0;
      
      rep(i, N) rep(j, (1<<16) ){
	  if ( dp[i%2][j] < 0 ) continue;
	  int nx = (j | A[i+1]);
	  dp[(i+1)%2][nx] = max(dp[(i+1)%2][nx], dp[i%2][j]);
	  rep(k, M){
	      int tx = (nx - (nx & T[k]));
	      dp[(i+1)%2][tx] = max(dp[(i+1)%2][tx], dp[i%2][j] + ST[k][nx]);
	  }
      }
      
      int maxv = 0;
      rep(j, (1<<16)) maxv = max(maxv, dp[N%2][j]);

      cout << maxv << endl;
  }
  return 0;
}

Measured memory_bytes: 9860
#include<bits/stdc++.h>
#define x first
#define y second
#define size(a) (ll)(a).size()

typedef long long ll;
typedef long double ld;

using namespace std;
int n;
string s;


int main()
{
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");


    cin.tie(0);
    ios_base::sync_with_stdio(0);

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max(a * c, max(b * c, max(a * d, b * d)));

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    vector<ll> v(n);
    vector<pair<ll, ll>> res;
    rep(i, n) cin >> v[i];
    sort(ALL(v));
    FOR(i, 1, n-1){
        if(0<v[i]){
            res.emplace_back(v[0], v[i]);
            v[0] -= v[i];
        }else{
            res.emplace_back(v[n-1], v[i]);
            v[n-1] -= v[i];
        }
    }
    res.emplace_back(v[n-1], v[0]);
    cout << v[n-1] - v[0] << endl;
    for(auto x: res) cout << x.first << ' ' << x.second << endl;

}


Measured memory_bytes: 6084
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;

int main()
{
    int k;
    cin >> k;
    queue<ll> que;
    rep(i, 9) que.push(i + 1);

    int count = 0;
    while (true) {
        ll num = que.front();
        que.pop();
        count++;
        if (k == count) {
            cout << num << endl;
            return 0;
        }
        if (num % 10 == 0) {
            que.push(num * 10);
            que.push(num * 10 + 1);
        }
        else if (num % 10 == 9) {
            que.push(num * 10 + 8);
            que.push(num * 10 + 9);
        }
        else {
            que.push(num * 10 + num % 10 - 1);
            que.push(num * 10 + num % 10);
            que.push(num * 10 + num % 10 + 1);
        }
    }
    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	N := oneInt()
	K := oneInt()
	if N == 0 {
		fmt.Println(0)
		return
	}
	fmt.Println(N - K + 1)
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<vector>
#include<cstring>
#define nume first
#define deno second
using namespace std;
typedef pair<int, int> Rational;
const int BUF = 200005;
const int MOD = 1000000007;


int add(int a, int b) {
    return (a + b) % MOD;
}

int sub(int a, int b) {
    return (a + MOD - b) % MOD;
}

int mul(int a, int b) {
    return 1LL * a * b % MOD;
}

int modpow(int p, long long n) {
    if (n == 0) return 1;
    int t = modpow(p, n / 2);
    return n % 2 == 0 ? mul(t, t) : mul(mul(t, t), p);
}

Rational add(Rational a, Rational b) {
    return Rational(add(mul(a.nume, b.deno), mul(b.nume, a.deno)),  mul(a.deno, b.deno));
}

Rational mul(Rational a, Rational b) {
    return Rational(mul(a.nume, b.nume), mul(a.deno, b.deno));
}


int nNode;
vector<int> adj[BUF];

void read() {
    for (int i = 0; i < BUF; ++i) adj[i].clear();

    cin >> nNode;
    for (int i = 0; i < nNode - 1; ++i) {
        int s, t;
        cin >> s >> t;
        --s, --t;
        adj[s].push_back(t);
        adj[t].push_back(s);
    }
}


int getNumSubtreeNode(int node, int node2nSubtreeNode[BUF], map<int, int> edge2nSubtreeNode[BUF]) {
    int &ret = node2nSubtreeNode[node];
    ret = 1;
    
    for (int i = 0; i < adj[node].size(); ++i) {
        int nex = adj[node][i];
        if (node2nSubtreeNode[nex] != -1) continue;
        
        int nexNumSubtreeNode = getNumSubtreeNode(nex, node2nSubtreeNode, edge2nSubtreeNode);
        edge2nSubtreeNode[node][nex] = nexNumSubtreeNode;
        edge2nSubtreeNode[nex][node] = nNode - nexNumSubtreeNode;
        
        ret += nexNumSubtreeNode;
    }
    
    return ret;
}


Rational rec(int node, int childIdx, int nChose, vector< vector<Rational> > &dp, map<int, int> edge2nSubtreeNode[BUF]) {
    if (childIdx == adj[node].size()) {
        return nChose == 2 ? Rational(1, 1) : Rational(0, 1);
    }

    Rational &ret = dp[childIdx][nChose];
    if (ret.nume != -1) return ret;
    ret = Rational(0, 1);

    int nSubtreeNode = edge2nSubtreeNode[node][adj[node][childIdx]];

    // Choose at least one node from node's childIdx-th subtree
    ret = add(ret, mul(rec(node, childIdx + 1, min(nChose + 1, 2), dp, edge2nSubtreeNode),
                       Rational(sub(modpow(2, nSubtreeNode), 1), modpow(2, nSubtreeNode))));
    
    // Choose noting
    ret = add(ret, mul(rec(node, childIdx + 1, nChose, dp, edge2nSubtreeNode), Rational(1, modpow(2, nSubtreeNode))));

    return ret;
}


void work() {
    map<int, int> edge2nSubtreeNode[BUF];
    
    int node2nSubtreeNode[BUF];
    memset(node2nSubtreeNode, -1, sizeof(node2nSubtreeNode));
    getNumSubtreeNode(0, node2nSubtreeNode, edge2nSubtreeNode);

    Rational sum = Rational(0, 1);
    for (int i = 0; i < nNode; ++i) {
        vector<vector<Rational> > dp(adj[i].size(), vector<Rational>(3, Rational(-1, -1)));
        sum = add(sum, rec(i, 0, 0, dp, edge2nSubtreeNode));
    }
    sum.deno = mul(sum.deno, 2);
    
    cout << mul(sum.nume, modpow(sum.deno, MOD - 2)) << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 68212
#include<iostream>
using namespace std;
int main()
{
    int x;
    cin>>x;
    if(x>=400 && x<=599)
    {
        cout<<"8"<<endl;
    }
    else if(x>=600 && x<=799)
    {
        cout<<"7"<<endl;
    }
       else if(x>=800 && x<=999)
    {
        cout<<"6"<<endl;
    }
         else if(x>=1000 && x<=1199)
    {
        cout<<"5"<<endl;
    }
        else if(x>=1200 && x<=1399)
    {
        cout<<"4"<<endl;
    }
       else if(x>=1400 && x<=1599)
    {
        cout<<"3"<<endl;
    }

        else if(x>=1600 && x<=1799)
    {
        cout<<"2"<<endl;
    }
        else if(x>=1800 && x<=1999)
    {
        cout<<"1"<<endl;
    }

 return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N;

int main() {
	cin >> N;
	cout << 3 * N*N << endl;
}

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

L=[]
for i in range(N):
    l=int(input())
    L.append(l)
L=sorted(L, reverse=True)

combs=[]
for b in range(4**N):
    nowlist=[[],[],[],[]]
    for i in range(N):
        mod=b%4
        nowlist[mod].append(L[i])
        b=b//4
    combs.append(nowlist)

#print(combs)

abc=[A,B,C]

ans=float("INF")
for c in combs:
    now=0
    for i in range(3):
        cn=c[i]
        n=abc[i]
        if len(cn)==0:
            break
        now+=(len(cn)-1)*10
        now+=abs(sum(cn)-n)
        if i==2:
            ans=min(ans, now)

print(ans)



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

int n;
int a[101][101];
int flg[101];
int t[101];
int sum = 0;

void visit(){
  int ima = 0;
  int mine = 100000000;
  
  
  for(int k=0;k<n-1;k++) {
    mine = 10000000;
    for(int i=0;i<n;i++) {
      if(flg[i] == 0 && mine > t[i]) {
	mine = t[i];
	ima = i;
      }
    }
    sum += mine;
    flg[ima] = 1;
    
    for(int i=0;i<n;i++) 
      if(a[ima][i] != -1) 
	if(t[i] > a[ima][i] ) t[i] = a[ima][i];
    
    
  }
}

int main() {

  cin >> n;

  for(int i=0;i<n;i++) 
    for(int j=0;j<n;j++) 
      cin >> a[i][j];
  
  for(int i=0;i<n;i++) {
    flg[i] = 0;
    t[i] = 100000000;
  }
  
  t[0] = 0;
  flg[0] = 1;
  for(int i=0;i<n;i++) 
    if(a[0][i] != -1) t[i] = a[0][i];

  visit();

  cout << sum << endl;
 
  return 0; 
  
}

Measured memory_bytes: 1200
N, M = map(int, input().split())
S = input()
T = input()

def gcd(a, b):
  a, b = (a, b) if a >= b else (b, a)
  while b > 0:
    a, b = b, a % b
  return a

g = gcd(N, M)
if S[0::N//g] == T[0::M//g]:
  print(N*M//g)
else:
  print(-1)

Measured memory_bytes: 3316
#include <iostream>
#include <cmath>

#define PI 3.14159265359

using namespace std;

int main(void)
{
    double a, b, c, h, r, s;
    cin >> a >> b >> r;
    s = a * b * sin(PI * r / 180) / 2;
    c = sqrt(a * a + b * b - 2 * a * b * cos(PI * r / 180));
    h = 2 * s / a;
    printf("%f\n%f\n%f\n", s, a + b + c, h);
    return 0;
}

Measured memory_bytes: 1232
def main():
    from heapq import heappush, heappop, heappushpop
    import sys

    input = sys.stdin.readline

    class Median:
        def __init__(self):
            self.b = 0
            self.l = []
            self.sum_l = 0
            self.r = []
            self.sum_r = 0

        def update(self, a: int, b: int) -> None:
            self.b += b

            size = len(self.l) + len(self.r)
            if size % 2 == 0:
                x = heappushpop(self.r, a)
                self.sum_r += a - x
                heappush(self.l, -x)
                self.sum_l += x
            else:
                x = heappushpop(self.l, -a)
                self.sum_l += a + x  # a - (-x)
                heappush(self.r, -x)
                self.sum_r -= x  # += (-x)

        def query(self):
            median = -self.l[0]
            ret = (abs(len(self.l) * median - self.sum_l)
                   + abs(self.sum_r - len(self.r) * median)
                   + self.b)
            return median, ret

    med = Median()
    n = int(input())
    for _ in range(n):
        q = iter(input().rstrip().split())
        if next(q) == '1':
            med.update(*map(int, q))
        else:
            print(*med.query())


if __name__ == '__main__':
    main()


Measured memory_bytes: 74308
from heapq import heappop,heappush
x,y,z,k = (int(i) for i in input().split())
a = [-int(i) for i in input().split()]
b = [-int(i) for i in input().split()]
c = [-int(i) for i in input().split()]
a,b,c = sorted(a),sorted(b),sorted(c)
q,v = [(a[0]+b[0]+c[0],0,0,0)],[(0,0,0)]
for i in range(k):
    p = heappop(q)
    print(-p[0])
    if p[1]+1<x and (p[1]+1,p[2],p[3]) not in v:
        heappush(q,(a[p[1]+1]+b[p[2]]+c[p[3]],p[1]+1,p[2],p[3]))
        v.append((p[1]+1,p[2],p[3]))
    if p[2]+1<y and (p[1],p[2]+1,p[3]) not in v:
        heappush(q,(a[p[1]]+b[p[2]+1]+c[p[3]],p[1],p[2]+1,p[3]))
        v.append((p[1],p[2]+1,p[3]))
    if p[3]+1<z and (p[1],p[2],p[3]+1) not in v:
        heappush(q,(a[p[1]]+b[p[2]]+c[p[3]+1],p[1],p[2],p[3]+1))
        v.append((p[1],p[2],p[3]+1))

Measured memory_bytes: 4596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
//#pragma warning (disable:4996)
using namespace std;

int h, w;
int mp[1500][1500];
int dp[1500][1500];
int main()
{
	while (scanf("%d%d", &h, &w) == 2) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				scanf("%d", &mp[i][j]);
			}
		}

		//int dp[1500][1500];

        int maxwidth=0;

		for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                dp[i][j]=!mp[i][j];
                maxwidth|=dp[i][j];
            }
		}

		for (int i = 1; i < h; i++) {
			for (int j = 1; j < w; j++) {
				if (mp[i][j] == 1 ) {
					dp[i][j] = 0;
				}
				else {
					dp[i][j] = min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
					maxwidth=max(maxwidth,dp[i][j]);
				}
			}
		}
		printf("%d\n",maxwidth*maxwidth);
   }
	return 0;
}


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


int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) {
        cin >> a[i];
    }
    vector<int>cnt(1100000);
    rep(i,n) {
        if(cnt[a[i]] != 0) {
            cnt[a[i]] = 2;
            continue;
        }
        for(int j = a[i];j<=1100000;j += a[i]) {
            cnt[j]++;
        }
    }
    int sum = n;
    rep(i,n) {
        if(cnt[a[i]]>=2)sum--;
    }
    cout << sum << endl;
}



Measured memory_bytes: 8276
#include <iostream>/*{{{*/
#include <iomanip>
#include <string>
#include <map>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <exception>
#include <ctime>
#include <climits>
#include <list>
#include <bitset>
#include <cassert>
using namespace std;
#define rep_n(i, a, b) for (int i=(a); i<(b); i++)
#define rep(i, n) rep_n(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define sc1(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d %d", &a, &b)
#define sc3(a, b, c) scanf("%d %d %d", &a, &b, &c)
typedef long long ll;/*}}}*/

int main() {
    int n;
    sc1(n);

    ll a[n+1];
    a[0]=2, a[1]=1;
    rep_n(i, 2, n+1) {
        a[i] = a[i-1]+a[i-2];
    }

    ll ans=a[n];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, w;
    const int V = 100000;
    cin >> n >> w;
    vector<ll> best(V+1,-1);
    best[0] =0;
    rep(i,0,n) {
        ll ww, v;
        cin >> ww >> v;
        for(int j=V; j>=v;--j) {
            ll can = best[j-v]+ww;
            if(best[j-v]!=-1 && (best[j]==-1 || can<best[j])) {
                best[j] = can;
            }
        }
    }
    ll ans=0;
    rep(i,0,V+1) {
        if(best[i]!=-1 && best[i]<=w) ans=i;
    }
    cout<<ans<<"\n";
}


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

#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0); 
   ull N;
   cin>>N;
   ull four=0;
   ull two=0;
   ull odd=0;
   for (ull i = 0; i < N; i++) {
      int a;
      cin>>a;
      if(a%2==1)odd++;
      if(a%2==0&&a%4!=0)two++;
      if(a%4==0)four++;
   }
   if(two>0)N-=two-1;
   if(four>=N/2)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 512
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            char[] c = Console.ReadLine().ToCharArray();

            for(int i=0;i<c.Length;i++)
            {
                if (c[i] == '+')
                    ans++;
                else
                    ans--;

            }

            Console.WriteLine(ans.ToString());
        }
    }
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    for(int i = 0; i < n; i++)
    {
        if(sum - a[i] <= a[i])
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

struct Tree
{
	int index;
	int a, b;
	vector<Tree*> childlen;
};

int N;
Tree tree[1000];
int X[1000];

int dp[1000][5001];

void dfs(Tree& tree)
{
	if (tree.childlen.empty())
	{
		tree.a = X[tree.index];
		tree.b = 0;
		return;
	}

	for (Tree* c : tree.childlen)
	{
		dfs(*c);
	}

	int x = X[tree.index];
	for (int i = 0; i < tree.childlen.size(); i++)
	{
		for (int j = 0; j <= x; j++)
		{
			dp[i][j] = INT_MAX;
		}
	}

	if (tree.childlen[0]->a <= 5000)
	{
		dp[0][tree.childlen[0]->a] = tree.childlen[0]->b;
	}
	if (tree.childlen[0]->b <= 5000)
	{
		dp[0][tree.childlen[0]->b] = tree.childlen[0]->a;
	}

	for (int i = 0; i < tree.childlen.size() - 1; i++)
	{
		Tree* child = tree.childlen[i + 1];
		for (int j = 0; j <= x; j++)
		{
			if (dp[i][j] < INT_MAX)
			{
				if (j + child->a <= x)
				{
					dp[i + 1][j + child->a] = MIN(dp[i + 1][j + child->a], dp[i][j] + child->b);
				}
				if (j + child->b <= x)
				{
					dp[i + 1][j + child->b] = MIN(dp[i + 1][j + child->b], dp[i][j] + child->a);
				}
			}
		}
	}

	int min = INT_MAX;
	for (int i = 0; i <= x; i++)
	{
		min = MIN(min, dp[tree.childlen.size() - 1][i]);
	}

	if (min == INT_MAX)
	{
		cout << "IMPOSSIBLE" << endl;
		exit(0);
	}

	tree.a = x;
	tree.b = min;
}

signed main()
{
	cin >> N;
	REP(i, N - 1)
	{
		int p;
		cin >> p;
		tree[p - 1].childlen.push_back(&tree[i + 1]);
		tree[i + 1].index = i + 1;
	}
	REP(i, N) cin >> X[i];
	dfs(tree[0]);
	cout << "POSSIBLE" << endl;
}

Measured memory_bytes: 37376
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,l,r) for(int i=(l);i<(r);i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// g++ -std=c++11 prac.cpp 

ll pow_mod(ll n, ll k, ll m){
    if(k==0)    return 1;
    else if(k % 2 == 1) return pow_mod(n, k-1, m) * n%m;
    else {
        ll t = pow_mod(n, k/2, m);
        return t * t % m;
    }
}

int main(){
    ll x=0,y=0,z=0,n,m=0,k,h,sum_a=0,ans=0,sum_b=0,w,sum=0,Max=-1e9-1,cnt=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> n;
    VL a(n),b(n),c(n);
    vector<pair<ll,ll> > vp(n);
 
    rep(i,n){
        cin >> a[i];
        sum_a += a[i];
    }
    rep(i,n){
        cin >> b[i];
        vp[i] = make_pair(a[i],b[i]);
        c[i] = a[i]-b[i];
        sum_b += b[i];
    }
    sort(ALL(c));

    //全ての準備ができていると合計0
    rep(i,n){
        if(c[i] < 0){ break; }
        else if (i==n-1){
            cout << 0 << endl;
            return 0;
        }
    }

    //そもそも準備の合計値が足りない
    if(sum_a < sum_b){
        cout << -1 << endl;
        return 0;
    }
    else{
        int j=0;
        cnt += c[n-1-j];   //過分の中で大きな数をcntに足す。
        ans++;     //変更する個数を増加　（一つはマイナスが存在するので）
        rep(i,n){
            if(c[i] < 0){     //不足分があれば
                ans++;        //変更する個数を増加
                cnt += c[i];  //過分-不足
                if(cnt < 0){  //その結果,過分で補なうことができない場合
                    j++;      //過分のなかで次に大きな数をcntに足す。
                    cnt += c[n-1-j];
                    ans++;
                }
            }
            else{ break; }  //なければ終了
        }
        cout << ans << endl;
        return 0;
    }
}
 


 

Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int A[20];
int B[20];
int C[20];
void Calc(){
	int N = rei();
	for(int i=0;i<N;i++){
		A[i] = rei();
	}
	for(int i=0;i<N;i++){
		B[i] = rei();
	}
	for(int i=0;i<N-1;i++){
		C[i] = rei();
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		ans += B[i];
		if(i != N-1 && A[i] + 1 == A[i+1]){
			ans += C[A[i]-1];
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
		int h,w,n,i,j,ans[100][100],a[10000],d=0;
		scanf("%d%d%d",&h,&w,&n);
		for(i=0;i<n;i++)scanf("%d",&a[i]);
		for(i=0;i<h;i++){
				if(i%2==0){
						for(j=0;j<w;j++){
								if(a[d]-->0)ans[i][j]=d+1;
								if(a[d]==0)d++;
						}
				}else{
						for(j=w-1;j>=0;j--){
								if(a[d]-->0)ans[i][j]=d+1;
								if(a[d]==0)d++;
						}
				}
		}
		for(i=0;i<h;i++){
				for(j=0;j<w;j++){
						printf("%d ",ans[i][j]);
				}puts("");
		}
		return 0;
}


Measured memory_bytes: 256