akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> vs(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> vs[i];
    }

    vector<int> ans(n + 1, 0);
    for (int i = n; i >= 1; i--)
    {
        int sum = 0;
        for (int j = i * 2; j <= n; j += i)
        {
            sum += ans[j];
        }
        if (sum % 2 != vs[i])
        {
            ans[i] = 1;
        }
        else
        {
            ans[i] = 0;
        }
    }

    vector<int> ones;
    for (int i = 1; i <= n; i++)
    {
        if (ans[i] == 1)
        {
            ones.push_back(i);
        }
    }
    cout << ones.size() << endl;
    for (auto& one : ones)
    {
        if (one != ones[0])
        {
            cout << " ";
        }
        cout << one;
    }
    if (!ones.empty())
    {
        cout << endl;
    }
}


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

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

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int kaizyo(int x){
    if(x==1)return x;
    else return x*kaizyo(x-1);
}

typedef struct Point{
    int x;
    int y;
} P;

int main() {
    int n; 
    while(cin>>n){
    if(n==0)return 0;
    int i=1;
    ll ans=0;
    while(n>0){
        if(i!=2 && i%2==0){
            i++;
            continue;
        }else if(isPrime(i)){
            ans+=i;
            n--;   
        }
        i++;
    }
    cout<<ans<<endl;
    }
    

    return 0;
}



Measured memory_bytes: 3088
N=int(input())
a_list=[int(i) for i in input().split()]
b_list=[int(i) for i in input().split()]

count=0
for i in range(N):
    if a_list[i]<b_list[i]:
        c=b_list[i]-a_list[i]
        count+=a_list[i]
        a_list[i]=0
        if a_list[i+1]<c:
            count+=a_list[i+1]
            a_list[i+1]=0
        else:
            a_list[i+1]-=c
            count+=c
    else:
        a_list[i]-=b_list[i]
        count+=b_list[i]
print(count)

Measured memory_bytes: 18624
#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++)

int main(){
  long int N;
  cin>>N;
  for(long int h=1;h<=3500;h++){
    for(long int n=1;n<=3500;n++){
      long int x=4*h*n-N*n-N*h;
      long int y=N*h*n;
      if( x && y%x==0)
        {long int w=y/x;
          if(w<0){continue;}
      cout<<h<<" "<<n<<" "<<w<<endl;
      return 0;}
    }
  }
}

Measured memory_bytes: 256
nt = input().split(' ')
N = int(nt[0])
T = int(nt[1])

cc = [[0, 0] for x in range(N)]
for i in range(N):
    c = input().split(' ')
    cc[i][0] = int(c[0])
    cc[i][1] = int(c[1])

min_cost = -1
for c1, c2 in sorted(cc):
    if c2 <= T:
        min_cost = c1
        break

print (min_cost if min_cost != -1 else 'TLE')

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

long int knapsack(long int W, long int wt[], long int b[], long int n) {
	// Tabela
	long int V[n + 1][W + 1];

	// inicializando a primeira linha e a primeira coluna com 0
	for(int w = 0; w <= W ; w++) {
		V[0][w] = 0;
	}
	for(int i = 1; i <= n ; i++) {
		V[i][0] = 0;
	}

	for(int i = 1; i <= n ; i++) {
		for(int w = 1; w <= W ; w++) {
			// elemento pode fazer parte da solução
			if(wt[i - 1] <= w) {
				// max
				if((b[i - 1] + V[i - 1][w - wt[i - 1]]) > V[i - 1][w]) {
					V[i][w] = b[i - 1] + V[i - 1][w - wt[i - 1]];
				} else {
					V[i][w] = V[i - 1][w];
				}
			} else {
				V[i][w] = V[i - 1][w];
			}
		}
	}

	// Retorna o valor máximo colocado na mochila
	return V[n][W];
}

int main(int argc, char * argv[]) {
	// Capacidade máxima da mochila: W
	// Número de elementos: n
  long int n, W;
	cin >> n >> W;

	// Vetor com os valores (benefícios) de cada elemento: b[]
	// Vetor com os pesos de cada elemento: wt[]
  long int wt[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> wt[i] >> b[i];
  }
	// Obter o máximo valor que pode ser colocado na mochila
	long int max_value = knapsack(W, wt, b, n);

	cout << max_value << endl;

	return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    string s;
    cin >> s;             

    if (s[0] == s[2] && s[0] == s[1] && s[0] == 'R') cout << 3 << "\n"; else
    if (s[0] == s[1] && s[0] == 'R') cout << 2 << "\n"; else
    if (s[1] == s[2] && s[1] == 'R') cout << 2 << "\n"; else
    if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cout << 1 << "\n"; else
        cout << 0 << "\n";
}

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

int N;
string S;
int cn = 0;

int main(){
  cin >> N;
  cin >> S;

  int i = 0;
  while(i+2 < N){
    if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') cn++;
    i++;
  }

  cout << cn << endl;
  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

static const ll MAX_N = 100001;
static const ll MAX_M = 200001;

ll a[100001] = {};
ll b[100001] = {};
int main() {
	ll n, h; cin >> n >> h;
	ll maxA = 0;
	rep(i, 0, n) {
		ll A, B; cin >> A >> B;
		a[i] = A;
		b[i] = B;
		maxA = max(A, maxA);
	}
	sort(b, b + n);
	reverse(b, b + n);
	ll cnt = 0;
	rep(i, 0, n) {
		if (b[i] >= maxA) {
			h -= b[i];
			cnt++;
			if (h <= 0) {
				cout << cnt << endl;
				return 0;
			}
		}
		else {
			break;
		}
	}
	if (h % maxA == 0) {
		cnt += h / maxA;
	}
	else {
		cnt += h / maxA + 1;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int a[N];
int main(){
int n,k;
scanf("%d%d",&n,&k);
while(k--){
	int m;
	scanf("%d",&m);
	for(int i=1;i<=m;i++){
		int d;
		scanf("%d",&d);
		a[d]++;
	}
}int res=0;
for(int i=1;i<=n;i++){
	if(a[i]==0)res++;
}
printf("%d",res);
return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define LiangJiaJun main
#define ll long long
using namespace std;
ll x,a,b,c,ans;
int LiangJiaJun(){
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int k=0;k<=c;k++)
                if(i*500+j*100+k*50==x)++ans;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
import collections
MOD = 2019

def mod(n):         
  return n % MOD

def modpow(a, n):   #mod(a**n)を高速で求める
    res = 1  
    digit = len(str(bin(n))) - 2
    for i in range(digit):
      if (n >> i) & 1:
        res *= mod(a)
        res = mod(res)
      a = mod(a**2)
    return mod(res)

s = input()
lst = []
n = 0
for i in range(len(s)):
  n += mod(int(s[len(s)-i-1])*modpow(10, i))
  lst.append(mod(n))
lst.append(0)
lst.sort()
ans = 0
counter = 1
stock = lst[0]
for i in range(1, len(lst)):
  if stock == lst[i]:
    counter += 1
  else:
    ans += counter*(counter - 1)//2
    counter = 1
    stock = lst[i]
if counter >= 2:
  ans += counter*(counter - 1)//2
print(ans)

Measured memory_bytes: 84124
#include <stdio.h>
#include <math.h>

int main(void){
 int H1, H2, M1, M2, K;
 scanf("%d %d %d %d %d\n",&H1,&M1,&H2,&M2,&K);
 
 printf("%d\n", (H2*60+M2-K)-(H1*60+M1));
 return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;

int n,a[maxn],mx,cnt;
bool fail;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	sort(a+1,a+n+1),mx=a[n]; 
	if(a[n]-a[1]>1)return puts("No"),0;
	if(a[1]==a[n])if(mx==n-1||2*mx<=n)return puts("Yes"),0;
	if(a[n]!=a[1])
	{
		for(cnt=1;a[cnt]==a[1];cnt++);cnt--;
		if(cnt>a[1])return puts("No"),0;
		mx-=cnt,n-=cnt;
		if(mx*2<=n)return puts("Yes"),0;
	}
	return puts("No"),0;
}

Measured memory_bytes: 768
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int main(){
  int n,x,y;cin>>n>>x>>y;

  printf("%d %d\n",min(x,y),max(0,x+y-n));
  return 0;
}





Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    ans = 0
    for i in range(60):
        one = 0
        for a in A:
            if a & (1 << i):
                one += 1
        ans = (ans + one * (N - one) * (1 << i)) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 136636
m,n=map(int,input().split())
a=[]
b=[]
for _ in range(m):
    a.append(map(int, input().split()))
for _ in range(n):
    b.append(int(input()))
for ai in a:
    sum = 0
    for index, mi in enumerate(ai):
        sum += mi*b[index]
    print(sum)



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

int G[100][100];

signed main(){

  int n,m; cin >> n >> m;
  for(int i = 0; i < m; i++){
    int a,b; cin >> a >> b;
    a--; b--;
    G[a][b] = G[b][a] = 1;
  }

  vector<int> v;
  for(int i = 0; i < n; i++) v.push_back(i);
  int ans = 0;
  do{
    for(int i = 0; i < n-1; i++){
      if(G[ v[i] ][ v[i+1] ] == 0) break;
      if(i == n-2) ans++;
    }
  }while( next_permutation(v.begin()+1,v.end()) );
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def dfs(v, n, graph, visited):
    visited[v] = True
    for v2 in range(n):
        if not graph[v][v2]:
            continue
        if visited[v2]:
            continue
        dfs(v2, n, graph, visited)


n, m = [int(v) for v in input().split()]
graph = [[False] * n for i in range(n)]
a = []
b = []
for i in range(m):
    v1, v2 = [int(v) for v in input().split()]
    v1 -= 1
    v2 -= 1
    a.append(v1)
    b.append(v2)
    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True

ans = 0
for i in range(m):
    graph[a[i]][b[i]] = False
    graph[b[i]][a[i]] = False

    visited = [False] * n
    dfs(0, n, graph, visited)
    if False in visited:
        ans += 1

    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String ans = "";
        int cnt = 0;
        String kari = "";
        for (int i = 0; i < n; i++) {
            char c = s.charAt(i);
            if (c == ')') { // )
                if (cnt == 0) {
                    ans = "(" + ans + ")";
                } else {
                    kari = kari + ")";
                    cnt--;
                    if (cnt == 0) {
                        ans = ans + kari;
                        kari = "";
                    }
                }
            } else {// (
                cnt++;
                kari = kari + "(";

            }
            if (i == n - 1) {
                ans += kari;
                String tmp = "";
                for (int j = 0; j < cnt; j++) {
                    tmp = tmp + ")";
                }
                ans = ans + tmp;

            }

        }
        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 20948
time = [int(input()) for i in range(5)]
ten_time = 0
smallest_mod = 10
for i in range(5):
    div,mod = divmod(time[i],10)
    if 0 < mod < smallest_mod:
        smallest_mod = mod
    if mod != 0:
        ten_time += div + 1
    else:ten_time += div
print(ten_time * 10 - 10 + smallest_mod)

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

int main(){
    Long x;
    cin >> x;
    Long cnt = 0;
    Long init = 100;
    while(init < x){
        Long add = init /100;
        init += add;
        cnt++;
    }
    cout << cnt;
    return 0;
}

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

bool solve(string& str) {
    int n = str.size();
    map<char, int> M;
    for (auto ch: str)
        M[ch]++;
    for (auto p: M) {
        if (p.second % 2 == 1)
            return false;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    string str;
    cin >> str;
    if (solve(str))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}




void oneCase () {
    string s;
    cin >> s;
    int l = 0;
    int r = int(s.size()) - 1;
    while (s[l] != 'A') {
        ++l;
    }
    while (s[r] != 'Z') {
        --r;
    }
    cout << r - l + 1 << "\n";
}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>	
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main() {
    IO;
    int a, b, x, y, r, c, ans;
    cin >> a >> b;
    x = a / 1000, y = b / 1000, r = (a / 100) % 10, c = (b / 100) % 10;
    ans = (y - x - 1) * 10 + 10 - r + c + 1;
    if (a > (a / 100) * 100 + ((a / 1000) % 10) * 10 + (a / 10000))
        ans--;
    if (b < (b / 100) * 100 + ((b / 1000) % 10) * 10 + (b / 10000))
        ans--;
    printf("%d\n", ans);
   // system("pause");
    return 0;
}

Measured memory_bytes: 3728
# include <bits/stdc++.h>
# define rr register
const int N=100010,INF=0x3f3f3f3f;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
int main(void){
	std::string x;
	std::cin>>x;
	x=" "+x;
	if(x[5]==x[6]&&x[3]==x[4]){
		puts("Yes");
	}else{
		puts("No");
	}
	return 0;
}


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

int n, ans = 0;

void check(array<int, 10> v) {
  long long p = 1;
  for (int i = 0; i < n; i++) {
    p *= v[i];
  }
  if (p%2 == 0) {
    ans++;
  }
  return;
}

void dfs(array<int, 10> v, int cnt) {
  if (cnt == n) {
    check(v);
    return;
  }
  int tmp = v[cnt];
  dfs(v, cnt + 1);
  v[cnt] = tmp - 1;
  dfs(v, cnt + 1);
  v[cnt] = tmp + 1;
  dfs(v, cnt + 1);
  v[cnt] = tmp;
  return;
}

int main() {
  cin >> n;
  array<int, 10> v;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  dfs(v, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
vector<int> a[MAXN];
int n,root=-1;
int dfs(int x,int fa){
    int res=0;
    int flag=0;
    for(int i=0;i<a[x].size();i++){
        if(a[x][i]==fa)
            continue;
        int res1=dfs(a[x][i],x);
        if(res1==0&&flag==1)
            res++;
        if(res1==0&&flag==0)
            flag=1;
        res+=res1;
    }
    return res;
}
int main(){
    SF("%d",&n);
    int u,v;
    for(int i=1;i<n;i++){
        SF("%d%d",&u,&v);
        a[u].push_back(v);
        a[v].push_back(u);
    }
    for(int i=0;i<n;i++)
        if(a[i].size()>=3){
            root=i;
            break;
        }
    if(root==-1){
        PF("1");
        return 0;
    }
    PF("%d",dfs(root,-1));
}


Measured memory_bytes: 9984
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
int main()
{

	ios_base::sync_with_stdio(false);
    
	
    ll X;
    cin>>X;
    int count;
    ll K;
    count = (X/500)*1000;
    //cout<<count<<"\n";
    K = X-(500*(X/500));
   // cout<<X<<"\n";
    //cout<<K;
    count=count+((K/5)*5);
    cout<<count<<"\n";

    return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

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

int h, w, sx, sy, cnt, arrow;
char s[12][12];
bool flag[12][12];
char ans[105];
int ok[4][4];

bool ava(int x, int y) {
	return (x >= 1 && y >= 1 && x <= h && y <= w);
}

bool dfs(int x, int y, int arrow, int remain) {
	if (remain == 0) return 1;
	flag[x][y] = 0;
	for (int k = 0; k < 4; k ++) if (ok[arrow][k]) {
		int tx = x;
		int ty = y;
		while (ava(tx + dx[k], ty + dy[k])) {
			if (flag[tx + dx[k]][ty + dy[k]]) {
				ans[cnt - remain + 1] = k;
				if (dfs(tx + dx[k], ty + dy[k], k, remain - 1)) {
//					printf("%d %d %d\n", tx + dx[k], ty + dy[k], remain - 1);
					return true;
				}
				break;
			}
			tx += dx[k];
			ty += dy[k];
		}
	}
	flag[x][y] = 1;
	return false;
}

int main() {
	scanf("%d%d", &h, &w);
	for (int i = 1; i <= h; i ++) scanf("%s", s[i] + 1);
	ok[0][0] = ok[0][1] = ok[0][3] = 1;
	ok[1][0] = ok[1][1] = ok[1][2] = 1;
	ok[2][1] = ok[2][2] = ok[2][3] = 1;
	ok[3][0] = ok[3][2] = ok[3][3] = 1;
	for (int i = 1; i <= h; i ++)
		for (int j = 1; j <= w; j ++) {
			if (s[i][j] == 'o') {
				flag[i][j] = true;
				cnt ++;
			} else if (s[i][j] != '.') {
					if (s[i][j] == 'U') arrow = 3;
					if (s[i][j] == 'D') arrow = 1;
					if (s[i][j] == 'L') arrow = 2;
					if (s[i][j] == 'R') arrow = 0;
					sx = i;
					sy = j;
				}
		}
	dfs(sx, sy, arrow, cnt);
	for (int i = 1; i <= cnt; i ++) {
		if (ans[i] == 0) ans[i] = 'R';
		if (ans[i] == 1) ans[i] = 'D';
		if (ans[i] == 2) ans[i] = 'L';
		if (ans[i] == 3) ans[i] = 'U';
	}
	printf("%s\n", ans + 1);
	return 0;
}

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

using namespace std;

int main() {
	int a, b;

	cin >> a >> b;
	if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a < b) {
		cout << "a < b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}

	return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>


using namespace std;

int main() {
    int n;
    cin >> n;
    vector <int> v(n);
    for (int i = 0; i < v.size(); ++i) {
        cin >> v[i];
    }
    int ans = 0;
    for (int i = 0; i < v.size(); ++i) {
        int j;
        for (j = i; j < v.size(); ++j) {
            if (v[j] != v[i]) break;
        }
        int len = j - i;
        ans += len / 2;
        i = j - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t N, X[100];
    intmax_t P[100] = {}, ans = 0;

    scanf("%jd", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%jd", &X[i]);
    }

    for (size_t i = 1; i <= 100; i++) {
        for (size_t j = 0; j < N; j++) {
            P[i - 1] += (X[j] - i) * (X[j] - i);
        }
    }

    ans = P[0];
    for (size_t i = 1; i < 100; i++) {
        if (P[i] < ans)
            ans = P[i];
    }

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        ITP1_2_C(args);
    }

    public static void ITP1_2_C(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int tmp;
        if (a > b) {
            tmp = a;
            a = b;
            b = tmp;
        }
        if (b > c) {
            tmp = b;
            b = c;
            c = tmp;
        }
        if (a > b) {
            tmp = a;
            a = b;
            b = tmp;
        }
        System.out.println(String.format("%d %d %d", a, b, c));
    }
}



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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
template<typename T>
void pr(T a){
  cout<<a<<endl;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  //ll a;cin>>a;
  //ll a,b;cin>>a>>b;
  //ll a,b,c;cin>>a>>b>>c;
  //ll a,b,c,d;cin>>a>>b>>c>>d;
  string s,t;cin>>s>>t;
  cout<<t<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

string op[100010];
vector<int> G[100010];
int x,y;

int dfs(int v,int d,int t,int prv){
	int ret = d % 2 ? INF : -INF;
	int num = op[v][4] == 'X' ? x : y;
	if(v){
		if(op[v][3] == '&') t &= num;
		else if(op[v][3] == '|') t |= num;
		else t ^= num;
	}
	for(int to : G[v]){
		if(to == prv) continue;
		if(d % 2) chmin(ret,dfs(to,d + 1,t,v));
		else chmax(ret,dfs(to,d + 1,t,v));
	}
	return abs(ret) == INF ? t : ret;
}

signed main(){
	int n,m;
	cin >> n >> m;
	for(int i = 1;i < n;i++) cin >> op[i];
	for(int i = 0;i < n - 1;i++){
		int u,v;
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	map<vector<int>,int> ans;
	vector<int> vec = {1,2,3};
	do{
		x = y = 0;
		for(int i = 0;i < 3;i++){
			x = x * 2 + vec[i] / 2;
			y = y * 2 + vec[i] % 2;
		}
		int t = dfs(0,0,0,-1);
		for(int i = 0;i < 3;i++){
			ans[vec] += (t >> i & 1) << vec[2 - i];
		}
	}while(next_permutation(all(vec)));
	for(int i = 0;i < m;i++){
		cin >> x >> y;
		int ind[4] = {-1,-1,-1,-1},p[20] = {};
		for(int j = 0;j < 20;j++){
			p[j] = (x >> j & 1) * 2 + (y >> j & 1);
			chmax(ind[p[j]],j); 
		}
		vector<int> vec = {1,2,3};
		sort(all(vec),[&](int a,int b){
			return ind[a] > ind[b];
		});
		int a = ans[vec],ret = 0;
		for(int j = 0;j < 20;j++){
			ret += (a >> p[j] & 1) << j;
		}
		cout << ret << endl;
	}
}


Measured memory_bytes: 21928
// Exhaustive Search
#include <stdio.h>

int solve(int, int);

int n, A[2000];

int main(){
  int i, q, m[2000];

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

  for(i=0; i < q; i++){
    if(solve(0, m[i]))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(i, m){
  if(m == 0){
    return 1;
  }
  if(i >= n){
    return 0;
  }
  if(solve(i+1, m) || solve(i+1, m-A[i]))return 1;
}



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

#pragma warning(disable : 4996)

using namespace std;

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

	while (true)
	{
		scanf("%d", &n);
		scanf("%d", &m);
		scanf("%d", &c);

		if (n == 0 && m == 0 && c == 0) { break; }

		vector<vector<long double> > dp(n + 1, vector<long double>(n * m + 1, 0.0L));

		dp[0][0] = 1.0L;

		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= n * m; j++)
			{
				for (int k = 1; k <= m && j - k >= 0; k++)
				{
					dp[i][j] += dp[i - 1][j - k] / m;
				}
			}
		}

		long double ret = 0.0L;

		for (int i = 0; i <= n * m; i++)
		{
			ret += dp[n][i] * (i - c < 1 ? 1 : i - c);
		}

		printf("%.20Lf\n", ret);
	}

	return 0;
}

Measured memory_bytes: 3416
#include <string.h>
int main()
{
  char s[1001], t[1001];
  scanf("%s %s", s, t);
  int i, j;
  int tlen = strlen(t);
  int ans = tlen;
  int cnt;
  for (i = 0; s[i + tlen - 1] != '\0'; i++)
  {
    cnt = 0;
    for (j = 0; t[j] != '\0'; j++)
    {
      if (s[i + j] != t[j])
        cnt++;
    }
    if (cnt < ans)
      ans = cnt;
  }
  printf("%d", ans);
}

Measured memory_bytes: 1728
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

 
int main(int argc, char *argv[]){
    int N, A[200000];
    int max1, max1n, max2;

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

    max1 = 0;
    max2 = 0;

    for(int i=0; i<N; i++){
        if(A[i] >= max1){
            max2 = max1;
            max1 = A[i];
            max1n = i;
        }
        else if(A[i] >= max2){
            max2 = A[i];
        }
    }

    for(int i=0; i<N; i++){
        if(i != max1n){
            printf("%d\n", max1);
        }
        else{
            printf("%d\n", max2);
        }
    }

 
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a == 1)
		a += 13;
	if (b == 1)
		b += 13;
	if (a > b)
		cout << "Alice" << "\n";
	else if (a < b)
		cout << "Bob" << "\n";
	else
		cout << "Draw" << "\n";
}

Measured memory_bytes: 3636
//20200517 B
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k=sc.nextInt();
      	sc.nextLine();
		String s=sc.nextLine();
		int l=s.length();
		if(l<=k){
			System.out.println(s);
		}else{
			System.out.println(s.substring(0,k)+"...");
		}
	}
}


Measured memory_bytes: 27044
// inputに入力データ全体が入る
function Main(input) {

  // 1行目がinput[0], 2行目がinput[1], …に入る
  var input1 = input.split("\n");
  // var count = 0
  var i = input1[0]

  const data =
  {
    SUN: 7,
    MON: 6,
    TUE: 5,
    WED: 4,
    THU: 3,
    FRI: 2,
    SAT: 1
  }


  // //文字列から10進数に変換するときはparseIntを使います
  // // var a = parseInt(i[0], 10);
  // // var b = parseInt(i[1], 10);
  // // var c = parseInt(i[2], 10);
  // var i1 = i.map(v => parseInt(v, 10))


  // console.log(input1[0])
  // // console.log(input1[0], i, i1, i1.some(v => v % 2 !== 0))

  // var count1 = 0
  // while (!i1.some(v => v % 2 !== 0)) {
  //   i1 = i1.map(v => v / 2)
  //   count1++
  // }

  // console.log(a,b,a + b, (a + b) % 2)
  // var s = a + b + c

  //出力
  console.log(data[i]);
}



//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22080
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll N=305;
double dp[N][N][N],prob[N][N][N];
int main()
{
	ll n,i,j;
	cin >> n;
	ll arr[n];
	ll mini=LLONG_MAX;
	ll one=0,two=0,three=0;
	ll a=0,b=0,c=0;
	for(i=0;i<n;i++)
	{
		cin >> arr[i];
		if(arr[i]==3)
			c++;
		else if(arr[i]==2)
			b++;
		else
			a++;
	}
	prob[a][b][c]=1;
	for(three=n;three>=0;three--)
	{
		for(two=n;two>=0;two--)
		{
			for(one=n;one>=0;one--)
			{
				if(one+two+three > n || (one==0 && two==0 && three==0))
					continue;
				
				double pwaste=(double)(n-(one+two+three))/(double)n;
				double dp_waste = pwaste/(1-pwaste);
				dp[one][two][three]+=dp_waste * prob[one][two][three];
				if(one!=0)
				{
					double w=(double) one / (one+two+three);
					prob[one-1][two][three]+=prob[one][two][three]*w;
					dp[one-1][two][three]+=dp[one][two][three]*w;
				}
		
				if(two!=0)
				{
					double w=(double) two / (one+two+three);
					prob[one+1][two-1][three]+=prob[one][two][three]*w;
					dp[one+1][two-1][three]+=dp[one][two][three]*w;
				}
				
				if(three!=0)
				{
					double w=(double) three / (one+two+three);
					prob[one][two+1][three-1]+=prob[one][two][three]*w;
					dp[one][two+1][three-1]+=dp[one][two][three]*w;
				}
			}
		}
	}
	cout<<setprecision(12);
	cout<<(dp[0][0][0]+a+2*b+3*c)<<"\n";
	
}

Measured memory_bytes: 438528
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <string>
#include <map>
using namespace std;


int main (int argc, char const *argv[])
{
    int a,b; cin>>a>>b;
    cout<<(b+a-3)/(a-1)<<endl;
    return 0;
}

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

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

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    ll x, d, k;
    cin >> x >> k >> d;
    if (abs(x)/d >= k) {
        cout << abs(x) - k * d << endl;
        return 0;
    }
    if (x > 0) {
        ll cnt = x / d;
        x -= cnt * d;
        k -= cnt;
    } else {
        ll cnt = (abs(x) / d) + 1;
        x += cnt * d;
        k -= cnt;
    }
    k %= 2;
    if (k == 0) {
        cout << abs(x) << endl;
    } else {
        cout << abs(x - d) << endl;
    }
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
int main()
{
   char a[10000000];
   char b[10000000];
   int s=0;
   gets(a);
   gets(b);
   int len=strlen(a);
   for(int n=0;n<len;n++)
   {
   	if(a[n]!=b[n])
   	s=s+1;
   }
   printf("%d",s);
   return 0;
}

Measured memory_bytes: 1972
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
//#define EPS 0.000000001
using namespace std;


#define EPS 0.00000001

struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{
		return x != p.x? x < p.x: y < p.y;
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}

	double x,y;
};

struct Circle{
	void set(double arg_x,double arg_y,double arg_r){
		center.x = arg_x;
		center.y = arg_y;
		r = arg_r;
	}

	Point center;
	double r;
};



typedef vector<Point> Polygon;
typedef Point Vector;

int U_W,U_H,S_A,S_B,S_AB;


double Heron(double a,double b,double c){

	double s = (a+b+c)/2;

	return sqrt(s*(s-a)*(s-b)*(s-c));
}

double calc_S(Circle A,Circle B){

	double dist = sqrt((A.center.x-B.center.x)*(A.center.x-B.center.x)+
			(A.center.y-B.center.y)*(A.center.y-B.center.y));

	if(dist > A.r+B.r+EPS){ //そもそも円が交わっていない

		return 0;

	}else if(dist+A.r+EPS < B.r){ //AがBに含まれている場合

		return A.r*A.r*M_PI;

	}else if(dist+B.r+EPS < A.r){ //BがAに含まれている場合

		return B.r*B.r*M_PI;
	}

	double theta_A = acos((A.r*A.r+dist*dist-B.r*B.r)/(2*A.r*dist));
	double theta_B = acos((B.r*B.r+dist*dist-A.r*A.r)/(2*B.r*dist));

	double S_1 = A.r*A.r*theta_A;
	double S_2 = B.r*B.r*theta_B;
	double S_3 = 2*Heron(A.r,B.r,dist);

	return (S_1+S_2)-S_3;
}

void func(){

	double r_A = sqrt((double)(S_A)/M_PI);
	double r_B = sqrt((double)(S_B)/M_PI);
	double H = U_H;
	double W = U_W;

	if(2*r_A > H+EPS || 2*r_A > W+EPS || 2*r_B > H+EPS || 2*r_B > W+EPS){ //どちらかの円が長方形に収まらないなら不可
		printf("impossible\n");
		return;
	}

	bool FLG = false;
	Circle A,B;

	if(r_A < r_B){
		FLG = true;
		swap(r_A,r_B);
	}

	A.set(r_A,r_A,r_A);
	B.set(W-r_B,H-r_B,r_B);

	if(calc_S(A,B) > S_AB+EPS){
		printf("impossible\n");
		return;
	}

	double L = 0,R = 1,mid,t;

	for(int loop = 0; loop < 100; loop++){

		mid = (L+R)/2;
		t = mid;

		Circle TMP;
		TMP.set((1-t)*A.center.x+t*B.center.x,(1-t)*A.center.y+t*B.center.y,B.r);

		if(calc_S(A,TMP) < S_AB){

			R = mid;
		}else{
			L = mid;
		}
	}
	B.set((1-L)*A.center.x+L*B.center.x,(1-L)*A.center.y+L*B.center.y,B.r);

	if(FLG){

		swap(A,B);
	}
	printf("%.10lf %.10lf %.10lf %.10lf %.10lf %.10lf\n",A.center.x,A.center.y,A.r,B.center.x,B.center.y,B.r);
}


int main(){

	while(true){

		scanf("%d %d %d %d %d",&U_W,&U_H,&S_A,&S_B,&S_AB);
		if(U_W == 0 && U_H == 0 && S_A == 0 && S_B == 0 && S_AB == 0)break;

		func();
	}

	return 0;
}



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

using namespace std;

char getGrade(int mid, int term, int reex) {
    int sum = mid + term;
    char grade;
    if (mid == -1 || term == -1) {
        grade = 'F';
    } else if (sum >= 80) {
        grade = 'A';
    } else if (sum >= 65) {
        grade = 'B';
    } else if (sum >= 50) {
        grade = 'C';
    } else if (sum >= 30) {
        if (reex >= 50) grade = 'C';
        else grade = 'D';
    } else if (sum < 30) {
        grade = 'F';
    }

    return grade;
}

int main() {
    int mid, term, reex;
    while (1) {
        cin >> mid >> term >> reex;
        if (mid == -1 && term == -1 && reex == -1) break;
        cout << getGrade(mid, term, reex) << endl;
    }
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b;
  cin>>a>>b;
  if((a==1&&b==2)||(a==2&&b==1))
    cout<<3<<endl;
  else if((a==1&&b==3)||(a==3&&b==1))
    cout<<2<<endl;
  else if((a==3&&b==2)||(a==2&&b==3))
    cout<<1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	ll a[n+1], pref[n+1] = {0};
	for(int i=1;i<=n;i++)
	{
	    cin>>a[i];
	    if(i==1) pref[1] = a[1];
	    else if(i&1) pref[i] = pref[i-2] + a[i];
	}
	//for(auto it:pref) cout<<it<<' '; cout<<'\n';
	ll dp[n+1] = {0};
	dp[1] = 0;
	for(int i=2;i<=n;i++)
	{
	    if(i&1) dp[i] = max(dp[i-1],dp[i-2]+a[i]);
	    else dp[i] = max(dp[i-2]+a[i],pref[i-1]);
	}
	//for(auto it:dp) cout<<it<<' '; cout<<'\n';
	cout<<dp[n];
	
	
	return 0;
}


Measured memory_bytes: 8264
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 500000;
int N;
int A[MAX_N+1];
int B[MAX_N+1];
ll dp[2];
ll acum[MAX_N+1];

//x^nをmodのもとで計算する
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow((x*x) % mod, n/2, mod);
  if (n & 1) res = (res*x) % mod;
  return res;
}

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

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

  rep(i, 1, N) {
    B[i] = B[i-1] ^ A[i];
  }

  ll ans = 0;
  if (B[N] != 0) {
    int X = B[N];
    dp[1] = 1;
    for (int i = N-1; i >= 0; --i) {
      if (B[i] == 0) {
        dp[0] = mod(dp[0]+dp[1], MOD);
      }
      if (B[i] == X) {
        dp[1] = mod(dp[0]+dp[1], MOD);
      }
    }
    ans = dp[1];
  } else {
    vector<Pii> vp;
    acum[0] = 1;
    for (int i = 1; i <= N; ++i) {
      if (B[i] != 0) {
        vp.push_back(Pii(B[i], i));
        acum[i] = acum[i-1];
      } else {
        acum[i] = acum[i-1] + 1;
      }
    }
    sort(all(vp));

    for (int i = 0; i < len(vp); ++i) {
      vector<int> v;
      v.push_back(vp[i].sc);
      while (i+1 < len(vp) && vp[i].fi == vp[i+1].fi) {
        v.push_back(vp[i+1].sc);
        ++i;
      }

      dp[0] = 1; dp[1] = 0;
      for (int j = len(v)-1; j >= 0; --j) {
        dp[1] = mod(dp[1]+dp[0], MOD);
        ll lb = (j == 0 ? 0 : v[j-1]);
        ll ub = v[j];
        ll zeroNum = acum[ub] - acum[lb];
        dp[0] = mod(dp[0] + dp[1]*zeroNum, MOD);
      }

      ans = mod(ans+dp[1], MOD);
    }

    ans += mod_pow(2, acum[N]-2, MOD);
  }


  cout << mod(ans, MOD) << endl;

  return 0;
}


Measured memory_bytes: 13424
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
using namespace std;

int main(){
  int a,b,c; cin >> a >> b >> c;
  if(a<c&&c<b) cout <<"Yes"<< endl;
  else if(b<c&&c<a) cout <<"Yes"<< endl;
  else cout <<"No"<<endl;
}

Measured memory_bytes: 764
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, W = sc.nextInt()
    val w, v = new Array[Int](N)
    (0 until N) foreach { i =>
      val _w, _v = sc.nextInt()
      w(i) = _w
      v(i) = _v
    }

    val dp = Array.fill(N+1, W+1)(0L)
    var i = 0
    while (i < N) {
      var j = 0
      while (j < W) {
        if (j+1-w(i) >= 0)
          dp(i+1)(j+1) =
            (dp(i)(j+1-w(i)) + v(i)) max dp(i)(j+1)
        else
          dp(i+1)(j+1) = dp(i)(j+1)
        j += 1
      }
      i += 1
    }

    println(dp(N)(W))
  }

}

Measured memory_bytes: 145848
INF = 1e+9
import sys
sys.setrecursionlimit(int(INF))

N, A, B, C = map(int, input().split())
l = list()
for n in range(N):
  l.append(int(input()))
  
def dfs(depth, a, b, c):
    if depth == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
    branch1 = dfs(depth+1, a+l[depth], b, c) + 10
    branch2 = dfs(depth+1, a, b+l[depth], c) + 10
    branch3 = dfs(depth+1, a, b, c+l[depth]) + 10
    branch4 = dfs(depth+1, a, b, c)
    return min(branch1, branch2, branch3, branch4)
print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pii pair<int,int> 
using namespace std;
int a[200001];
int b[200001];
int v[200001];
int main() {
    int n;
    cin >> n;
    for(int i = 1; i<= n ; i++){
        cin >> a[i];
        b[a[i]]=i;
    }
    for(int i = 1; i<= n ; i++){
        if(i > b[a[i]-1]){
        v[a[i]] = v[a[i]-1]+1;
        }else{v[a[i]]=1;}
    }
    int m = 0;
    for(int i = 1; i<= n ; i++){
        if(v[i]>m)m=v[i];
    }
    cout  << n - m;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "../../../debug_print.hpp"
#else
#define debug(...)
#endif
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}



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

    vector<int>a(3);
    scan(a);
    sort_(a);
    if((a[0]==a[1]||a[1]==a[2]) && a[0]!=a[2]){
        print("Yes");
    }else{
        print("No");
    }


    return 0;
}

Measured memory_bytes: 256