akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
       var s  = sc.Next();
       int n = s.Length;
       for (int i = 0; i < n; i++)
       {
           if (i % 2 == 0)
           {
               if (s[i] == 'L')
               {
                   Console.WriteLine("No");
                   return;
               }
           }
           else
           {
               if (s[i] == 'R')
               {
                   Console.WriteLine("No");
                   return;
               }
           }
       }
       Console.WriteLine("Yes");
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  bool res = false;
  
  while(A > 0 && C > 0){
    C -= B;
    if(C <= 0){
      res = true;
      break;
    }
    A -= D;
  }
  if(res)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
   vector<int> N(3);
   for(int i=0;i<3;i++){
       cin >> N[i];
   }
    sort(N.begin(), N.end());
    cout << N[2]*10+N[1]+N[0] <<endl;
}

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

int main()
{
while(true) {
int n, m;
vector<int> x, xxx;
scanf("%d%d", &n, &m);
if(n == 0)
break;
x.resize(n);
for(int i = 0; i < n; ++i)
scanf("%d", &x[i]);
for(int i = 0; i < n; ++i) {
xxx.push_back(x[i]);
for(int j = 0; j < n; ++j)
xxx.push_back(x[i] + x[j]);
}
xxx.push_back(0);
sort(xxx.begin(), xxx.end());
int ans = 0;
for(int i = 0; i < xxx.size(); ++i) {
int r = m - xxx[i];
if(r < 0)
continue;
int idx = upper_bound(xxx.begin(), xxx.end(), r) - xxx.begin() - 1;
if(idx < 0)
continue;
ans = max(ans, xxx[i] + xxx[idx]);
}
printf("%d\n", ans);
}
return 0;
}

Measured memory_bytes: 9016
//tree distfromroot and calcparent
//tenka12016-B
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

typedef struct{
int val;
int node;
}sd;

int sdsortfnc(const void *a,const void *b){
if(((sd*)a)->val > ((sd*)b)->val){return -1;}
if(((sd*)a)->val < ((sd*)b)->val){return 1;}
return 0;
}

typedef struct{
    long long st;
    long long fi;
    long long kr;
}rs;

typedef struct{
    long long st;
    long long kz;
}mkj;

int sortfnc(const void *a,const void *b){
if(((rs*)a)->st == ((rs*)b)->st){return 0;}
if(((rs*)a)->st < ((rs*)b)->st){return -1;}
return 1;
}

void makemkj(rs g[],mkj x[],long long n){
    long long i,ms=0,nst=g[0].st;
    for(i=1;i<n;i++){
        if(g[i].st!=g[i-1].st){
            x[nst].kz=i-ms;
            x[nst].st=ms;
            nst=g[i].st;ms=i;
        }
    }
    x[nst].kz=n-ms;
    x[nst].st=ms;
}

int dist[524288],par[524288];
void dfs(int t,int l,int bp,rs g[],mkj x[]){
  int i;
  if(dist[t]<=l){return;}
  dist[t]=l;
  par[t]=bp;
  for(i=x[t].st;i<x[t].st+x[t].kz;i++){
    dfs(g[i].fi,l+1,t,g,x);
  }
}

int main(void){
    int i,j,n,m,k,a,b,c,h,w,r=0,l,t;
    int res=0,num[524288];
    int v[524288],p[524288];
    int arr[524288],ac;
    rs g[524288];
    mkj x[524288];
    sd dat[524288];
    scanf("%d",&n);
    for(i=2;i<=n;i++){
      scanf("%d",&a);
      g[2*i-4].st=i;
      g[2*i-4].fi=a;
      g[2*i-4].kr=1;
      g[2*i-3].st=a;
      g[2*i-3].fi=i;
      g[2*i-3].kr=1;
    }
    qsort(g,2*(n-1),sizeof(g[0]),sortfnc);
    makemkj(g,x,2*(n-1));
    for(i=0;i<=n;i++){
      dist[i]=inf;
      num[i]=-1;
    }
    dfs(1,0,0,g,x);
    for(i=1;i<=n;i++){
      dat[i-1].node=i;
      dat[i-1].val=dist[i];
    }
    qsort(dat,n,sizeof(dat[0]),sdsortfnc);
    for(i=0;i<n;i++){
      w=dat[i].node;
      if(num[w]!=-1){continue;}
      ac=0;
      for(j=x[w].st;j<x[w].st+x[w].kz;j++){
        if(num[g[j].fi]==-1){continue;}
        arr[ac]=num[g[j].fi];
        ac++;
      }
      if(ac==0){
        num[w]=0;
        continue;
      }
      t=-inf;
      qsort(arr,ac,sizeof(int),sortfnckj);
      for(j=0;j<ac;j++){
        t=max(t,arr[j]+j+1);
      }
      num[w]=t;
    }
    printf("%d\n",num[1]);
    return 0;
}


Measured memory_bytes: 27460
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 1; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int x;
    int ans=0;
    cin >> x;
    while(x>=500){
        x-=500;
        ans+=1000;
    }
    
    while(x>=5){
        x-=5;
        ans+=5;
    }
    
    cout << ans;
    
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define MAXN 10000001
#define endl "\n"
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}

int spf[10000001];
void sieve()
{
    spf[1] = 1;
    for (int i = 2; i < MAXN; i++)

        spf[i] = i;

    for (int i = 4; i < MAXN; i += 2)
        spf[i] = 2;

    for (int i = 3; i * i < MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j = i * i; j < MAXN; j += i)

                if (spf[j] == j)
                    spf[j] = i;
        }
    }
}
void solve()
{
    sieve();
    int n;
    cin >> n;
    int ans = 1;
    for (int i = 2; i <= n; i++)
    {
        int re = 1;
        int dd = i;
        while (dd != 1)
        {
            int d = spf[dd];
            int cc = 0;
            while (dd % d == 0)
            {
                dd = dd / d;
                cc++;
            }
            re *= (cc + 1);
        }
    
       // cout << re << " ";
        ans += re * i;
    }

    cout << ans << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 81720
#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-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<string> W(N);
    rep(i, N) cin >> W[i];

    map<string, bool> used;
    string pre = "";
    rep(i, N) {
        if (used[W[i]] || (pre != "" && pre.back() != W[i].front())) {
            puts("No");
            return 0;
        }
        pre = W[i];
        used[W[i]] = true;
    }
    puts("Yes");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
using namespace std;
#define MAX 1000000010

//int dp[1000010];
int ansj, ansi;
int solve(string str){
	
	for(int i = 2;i < str.size();i++){
		if(str.substr(i-1, 2) == "OI"){
			if(str[i-2] == 'J')ansj++;
			if(str[i-2] == 'I')ansi++;
		}
	}
	//cout << "*" << str.size() << endl;
	return 0;
}

int main(){
	int n, m;
	string str;
	while(cin >> str){
		ansj = ansi = 0;
		solve(str);
		cout << ansj << endl << ansi << endl;
	}
	
	return 0;
}
//for(it = a.begin();it != a.end();it++)
/*
20 4 1
12 8 16
*/

Measured memory_bytes: 3128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  int n;
  cin>>n;
  vector<int> a(n+1,0);
  vector<int> ans(n+1,0);
  rep1(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  ll sum=0;
  if(n%2==0){
    int k=n/2;
    rep(i,k){
      sum+=a[n-i]*2;
      sum-=a[i+1]*2;
    }
    sum-=a[k+1];
    sum+=a[k];
  }
  else{
    int k=n/2;
    ll buf1=0;
    ll buf2=0;
    rep(i,k){
      buf1+=a[n-i]*2;
      buf1-=a[i+1]*2;
      buf2+=a[n-i]*2;
      buf2-=a[i+1]*2;
    }
    buf1+=a[n-k];
    buf1-=a[n-k+1];
    buf2-=a[n-k];
    buf2+=a[n-k-1];
    sum=buf1;
    if(buf1<buf2)sum=buf2;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if(a-c>=0){cout<<0<<endl;goto a;}
    else {c=c-a;}
    if(b-c>=0){cout<<c<<endl;}
    else {cout<<"NA"<<endl;}
a:  return 0;  
}



Measured memory_bytes: 3116
import sys
def readQuestion():
    line = sys.stdin.readline()
    sline = line.rstrip()
    [rline,r1line]=sline.split(" ")
    a=int(rline)
    b=int(r1line)
    return a,b 

def solve(a,b):
    x=[]
    y=0
    high=0
    z=0
    u=0
    for i in range(1,1000):
        y+=i
        x.append(y)
    high = b-a
    z=high-1
    u=x[z]-b
    return u
# 全体
def main():
    x,y = readQuestion()
    answer = solve(x, y)
    print(answer)

# mainを呼び出す
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
def main():
    Dy = [1,0,-1,0]
    Dx = [0,-1,0,1]
    
    H, W, K = map(int, input().split())
    A = [input() for _ in range(H)]
    Closed = [[False]*W for _ in range(H)]
    for y, a in enumerate(A):
        for x, aa in enumerate(a):
            if aa=="S":
                ys, xs = y, x
    q = [(ys, xs)]
    Closed[ys][xs] = True
    reachable = [(ys, xs)]
    for _ in range(K):
        q_new = []
        for y_old, x_old in q:
            for dy, dx in zip(Dy, Dx):
                y, x = y_old + dy, x_old + dx
                if not (0<=y<H and 0<=x<W):
                    continue
                if not Closed[y][x] and A[y][x]==".":
                    Closed[y][x] = True
                    reachable.append((y, x))
                    q_new.append((y, x))
        q = q_new
    mi = float("inf")
    for y, x in reachable:
        mi = min(mi, x, y, W-1-x, H-1-y)
    print((mi-1)//K+2)

main()


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

public class Main {
	private static void solve(){
		//Implement solution here.
		int a = ni();
		int b = ni();
		int t = ni();
		System.out.println(b * (t / a));
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll h,n;
    cin>>h>>n;
    ll a,sum=0;
    rep(i,n){
        cin>>a;
        sum+=a;
    }
    if(sum>=h) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);


ll gcd(ll x, ll y) {
	int r = 0;
	if (x<y) swap(x, y);

	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	string S, T;
	cin >> S >> T;
	ll l = lcm(N, M);
	ll g = gcd(N, M);
	int inds = 0;
	int indt = 0;
	while (inds < N && indt < M) {
		if (S[inds] != T[indt]) {
			cout << -1 << endl;
			PAU;
			return 0;
		}
		inds += N / g;
		indt += M / g;
	}
	cout << l << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll a,b,c,d;
  
  cin>>a>>b>>c>>d;
  
  ll ans=0;
  
  ans=max(a*c,b*d);
  
  ans=max({ans,c*b,a*d});
  
  cout<<ans<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
using namespace std;
long n,a[1<<17],b[1<<17],c[1<<17],s[1<<17];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	for(int i=0;i<n;i++)cin>>c[i];
	sort(b,b+n);
	sort(c,c+n);
	int j=0;
	for(int i=0;i<n;i++)
	{
		while(j<n&&b[i]>=c[j])j++;
		s[i]=n-j;
	}
	for(int i=n;i--;)s[i]+=s[i+1];
	long ans=0;
	for(int i=0;i<n;i++)
	{
		ans+=s[upper_bound(b,b+n,a[i])-b];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
using p = pair<int, pair<int, int>>;

int n, m, ans, dis[22][22], mx[] = {0, 0, 1, -1}, my[] = {1, -1, 0, 0};
string in[22];
queue<p> q;

int main(){
    
    cin >> n >> m;
    for(int i = 0; i < n; i++)
        cin >> in[i];
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(in[i][j] == '#')
                continue;
            memset(dis, 0x3f, sizeof dis);
            dis[i][j] = 0;
            q.push({0, {i, j}});
            while(!q.empty()){
                int x = q.front().second.first, y = q.front().second.second; q.pop();
                ans = max(ans, dis[x][y]);
                for(int k = 0; k < 4; k++){
                    int nx = x + mx[k], ny = y + my[k];
                    if(nx >= 0 and nx < n and ny >= 0 and ny < m){
                        if(in[nx][ny] == '.' and dis[x][y] + 1 < dis[nx][ny]){
                            dis[nx][ny] = dis[x][y] + 1;
                            q.push({dis[nx][ny], {nx, ny}});
                        }
                    }
                }
            }
        }
    }
    
    print(ans);
    
    return 0;
}

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


K=sum(B)-sum(A) #操作の回数はK回で確定

# b[j]に+1をa[j]に-1に変換する
Plus_Two=K
Minus_One=K


for i in range(N):
    D=B[i]-A[i]
    if D>0:
        Plus_Two-=(D+1)//2
        Minus_One-=D%2
    else:
        D=-D
        Minus_One-=D

if min(Plus_Two,Minus_One)>=0 and Plus_Two*2-Minus_One==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 73952
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, a[200010], b[200010], c[200010], d[200010];
int cnt1[200010], cnt2[200010];
int ans[200010];

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i], c[a[i]] = i, cnt1[a[i]]++;
	for (int i = 1; i <= n; i++)cin >> b[i], d[b[i]] = i, cnt2[b[i]]++;
	for (int i = 1; i <= n; i++)if (n < cnt1[i] + cnt2[i]) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 1; i <= n; i++)c[i] = max(c[i - 1], c[i]), d[i] = max(d[i - 1], d[i]);
	int ma = 0;
	for (int i = 1; i <= n; i++)ma = max(ma, c[i] - d[i - 1]);
	for (int i = 0; i < n; i++)ans[(i + ma) % n + 1] = b[i + 1];
	cout << "Yes" << endl;
	for (int i = 1; i <= n; i++)cout << ans[i] << " ";
	cout << endl;
}

Measured memory_bytes: 9032
#include<iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    string a, b;
    rep(i, n) a += to_string(m);
    rep(i, m) b += to_string(n);
    if (a < b) {
        cout << a << endl;
    } else {
        cout << b << endl;
    }
}


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

using namespace std;

int main() {
    while (true) {
        int n;
        cin >> n;
        int m;
        cin >> m;
        if (n == 0 && m == 0) break;
        vector<int> x(n);
        for (int i = 0; i < n; ++i) {
            cin >> x[i];
        }
        int ans = 0;
        int now = 0;
        vector<int> dice(m);
        for (int i = 0; i < m; ++i) {
            cin >> dice[i];
        }
        for (int i = 0; i < m; ++i) {
            now += dice[i];
            now += x[now];
            ++ans;
            if (now >= n - 1) {
                cout << ans << '\n';
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3056
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        l: [usize;n]
    }

    /*
    let mut ll = vec![];
    let mut lls = HashSet::new();
    for i in 0..n {
        if lls.get(&l[i]) == None {
            //println!("{}", l[i]);
            lls.insert(l[i]);
            ll.push(l[i])
        }
    }
    */

    //println!("{:?}", ll);

    let mut ans = 0;

    for i in 0..n {
        for j in i + 1..n {
            for k in j + 1..n {
                if l[i] + l[j] > l[k]
                    && l[j] + l[k] > l[i]
                    && l[i] + l[k] > l[j]
                    && l[i] != l[j]
                    && l[j] != l[k]
                    && l[i] != l[k]
                {
                    ans += 1;
                    //println!("{} {} {}", i, j, k);
                }
            }
        }
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2268
n = int(input())
L = []
for i in range(n):
    s = ""
    l = sorted(list(input()))
    for j in range(len(l)):
        s += l[j]
    L.append(s)

dic = {}
for i in range(n):
    if L[i] not in dic:
        dic[L[i]] = 1
    else:
        dic[L[i]] += 1

ans = 0
for v in dic.values():
    ans += v * (v - 1) // 2
print(ans)


Measured memory_bytes: 19512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define fi first
#define sec second
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n; cin >> n;
	vector<ll> a1(n), a2(n);
	for (ll i = 0; i < n; i++)
		cin >> a1[i];
	for (ll i = 0; i < n; i++)
		cin >> a2[i];
	vector<ll> ct1(n + 1), ct2(n + 1);
	for (ll i = 0; i < n; i++)
		ct1[a1[i]]++;
	for (ll i = 0; i < n; i++)
		ct2[a2[i]]++;
	ll f = 0;
	for (ll i = 1; i <= n; i++)
		if (ct1[i] + ct2[i] > n)
		{
			f = 1;
			cout << "No\n";
			break;
		}
	if (f) return 0;
	reverse(a2.begin(), a2.end());
	ll ne = 0, c;
	vector<ll> vec1;
	for (ll i = 0; i < n; i++)
		if (a2[i] == a1[i])
		{
			ne++;
			c = a2[i];
			vec1.push_back(i);
		}
	ll cne = ne;
	vector<ll> vec2;
	for (ll i = 0; i < n; i++)
	{
		if (ne == 0) break;
		if (a1[i] != a2[i] && a1[i] != c && a2[i] != c)
		{
			ne--;
			vec2.push_back(i);
		}
	}
	for (ll i = 0; i < cne; i++)
		swap(a2[vec1[i]], a2[vec2[i]]);
	cout << "Yes\n";
	for (ll i = 0; i < n; i++)
		cout << a2[i] << " ";
	cout << "\n";
	return 0;
}

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i=0;i<N;i++) cin >> H[i];
    vector<vector<int>> g(N);
    for (int i=0;i<M;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    for (int i=0;i<N;i++){
        bool flag = true;
        for (auto u : g[i]) {
            if (H[i] <= H[u]) flag = false;
        }
        if (flag) ans++;
    }

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

Measured memory_bytes: 8744
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
ll stacks = 0;
ll money = 1000;
vector<ll> a(n);
rep(i,n)
cin >> a[i];
for(int i = 0; i < n - 1; i++){
    if(stacks == 0 && a[i + 1] > a[i]){
        ll am = money / a[i];
        stacks += am;
        money -= am * a[i];
    }
    else if(stacks != 0 && a[i] > a[i + 1]){
        money += stacks * a[i];
        stacks = 0;
    }
}
if(stacks)
    money += stacks * a.back();
cout << money << endl;
}

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

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) (v.size())
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

using namespace std;


int main(int argc, char *argv[]) {
    
    LL N, A, B, X;
    cin >> N >> A >> B;
    vector<int> v;
    FOR(i, 0, N) {
        cin >> X;
        v.push_back(X);
    }
    
    LL ans = 0;
    FOR(i, 0, v.size() - 1) {
        LL c = v[i + 1] - v[i];
        ans += min(c * A, B);
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}

Measured memory_bytes: 892
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  cout << "AB" << (n < 1000 ? 'C' : 'D') << endl;
}



Measured memory_bytes: 256
#include<iostream>

int main()
{
	using namespace std;
	int a,b,c,x,y,t;
	int flag=0;
	long int sum=0;
	cin>>a>>b>>c>>x>>y;
	double aver=(a+b)/2;
	if(aver>c)
	{
		t=x-y;
		if(t<0)      //x<y
		{
			t*=-1;
			sum+=x*c*2;
			sum+=t*b;
			if(sum>y*c*2)
			{
				sum=y*c*2;
			}
		}
		else{
			sum+=y*c*2;
			sum+=t*a;
			if(sum>c*x*2)
			{
				sum=c*x*2;
			}
		}
	}
	else
	{
		sum+=a*x+b*y;
		if(sum>c*2*(x<y?y:x))
			sum=c*2*(x<y?y:x);
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
dic = {1:0,2:0,4:0}
for a in A:
    if a % 4 == 0: dic[4] += 1
    elif a % 2 == 0: dic[2] += 1

dic[1] = N - dic[2] - dic[4] + (dic[2] != 0)
if dic[1] <= dic[4]+1: print('Yes')
else: print('No')

Measured memory_bytes: 14224
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void init() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

int main(){
    int n;
    cin >> n;
    map<int, int> mii;
    rep(i,n){
        int x;
        cin >> x;

        mii[x + 1]++;
        mii[x]++;
        mii[x - 1]++;
    }
    int ans = 0;
    int mx = 0;
    for(auto u : mii){
        if(mx < u.second){
            mx = u.second;
            ans = u.first;
        }
    }
    cout << mx << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int max_count=0;
    for (int i=1; i<S.length(); i++){
        int count=0;
        string T=S.substr(0,i);
        string R=S.substr(i);
        for (char j='a'; j<='z'; j++){
            bool foundt=false, foundr=false;
            for (int k=0; k<T.length(); k++) {
                if (T.at(k)==j) foundt=true;
            }
            for (int m=0; m<R.length(); m++) {
                if (R.at(m)==j) foundr=true;
            }
            if (foundt && foundr) count++;
        }
        max_count=max(max_count, count);
    }
    cout << max_count << endl;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    id_and_gate = []
    for m in range(0, M):
        tmp = [int(x) for x in input().split()]
        id_and_gate.append(tmp)

    l = 1
    r = 100000
    for j in range(0, M):
        if id_and_gate[j][0] >= l:
            l = id_and_gate[j][0]
        if id_and_gate[j][1] <= r:
            r = id_and_gate[j][1]

    if l <= r:
        print(r - l + 1)
    else:
        print(0)

if __name__ == "__main__":
    main()


Measured memory_bytes: 21156
N=int(input())
S=[input() for _ in range(N)]

na=0
a=0
b=0
ry=0
for s in S:
  na+=s.count("AB")
  if s[0]=="B" and s[-1]=="A":
    ry+=1
  elif s[0]=="B":
    b+=1
  elif s[-1]=="A":
    a+=1

if a==0 and b==0 and ry!=0:
  print(na+ry-1)
else:
  print(na+ry+1+min(a-1,b-1))

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;
 
int main(){
    string s; cin >> s;
    if(s[0] == '7'||s[1]== '7'||s[2] == '7'){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll a, b, c;
    cin >> a >> b >> c;
    mes(max((ll)0, b+c-a));
    
    


}


Measured memory_bytes: 3584
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;
int A[105];

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	int d,a;
	for(int i=0;i<k;i++)
    {
        scanf("%d",&d);
        for(int j=1;j<=d;j++)
        {
            scanf("%d",&a);
            A[a]++;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(!A[i])
            ans++;
    }
    printf("%d",ans);
	return 0;
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll count(ll n){
    ll s = 1;
    for(ll i = 2 ; i * i <= n ; i++){
        if(n % i == 0){
            ll a = 0 ;
            while(n % i == 0){
                n /= i;
                a++;
            }
            s = s * (a+1) ;
        }
    }
    if(n > 1) s = s * 2;
    return s;
}
int main(){
	int N;
	cin>>N;
	ll ans = 0;
	for(int i=1;i<N;i++){
		ans += (count(i));
	}
	cout<<ans;
	return 0;
}

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

int main()
{
  string n; cin >> n;
  for(int i=0; i<n.size(); i++){
    if(n[i] == '1') n[i] = '9';
  	else if(n[i] == '9') n[i] = '1';
  }
  cout << n << endl;
  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int A[30][200000];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C;
    cin >> N >> C;
    int s[N], t[N], c[N];
    rep(i, N) {
        cin >> s[i] >> t[i] >> c[i];
        c[i]--;
        int j = (s[i]*2)-1;
        while(j < t[i]*2 ){
            A[c[i]][j] = 1;
            j++;   
        }
    }
    int M = 1;
    rep(i, 200000){
        int tmp = 0;
        rep(j, C) {
            //printf("A[%d][%d] = %d\n",j, i, A[j][i]);
            if (A[j][i] == 1) {
                tmp++;
            }
        }
        M = max(M, tmp);
    }
    cout << M << endl;
    return 0;
}


Measured memory_bytes: 24832
def main():
    a, b = map(int, input().split())
    if a == 1:
        a = 14
    if b == 1:
        b = 14
    if a > b:
        print('Alice')
    elif a < b:

        print('Bob')
    else:
        print('Draw')



if __name__ == '__main__':
    main()


Measured memory_bytes: 38480
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

a,b,x=get_i
if a<=x and a+b>=x
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
H, W, D = map(int, input().split())
Board = [0] * (H*W+1)
path = [[0] for _ in range(D)] 
for h in range(H):
    A = list(map(int, input().split()))
    for w in range(W):
        Board[A[w]] = [w+1, h+1]
for i in range(1, D+1):
    d = i % D
    for j in range(i+D, H*W+1, D):
        path[d].append(path[d][(j+(D-1))//D-2] + abs(Board[j][0] - Board[j-D][0]) + abs(Board[j][1] - Board[j-D][1]))

for i in range(int(input())):
    L, R = map(int, input().split())
    d = L % D
    print(path[d][(R+(D-1))//D-1] - path[d][(L+(D-1))//D-1])
    

Measured memory_bytes: 22472
from collections import deque
n,m=map(int,input().split())
X=[]
M=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    X.append([a,b])
    M[a-1].append(b-1)
    M[b-1].append(a-1)
ans=0
for i in range(m):
    a,b=X[i][0],X[i][1]
    M[a-1].remove(b-1)
    M[b-1].remove(a-1)
    q=deque([0])
    visited=[0]*n
    while q:
        s=q.popleft()
        if visited[s]==1:
            continue
        visited[s]=1
        for x in M[s]:
            q.append(x)
    M[a-1].append(b-1)
    M[b-1].append(a-1)
    if sum(visited)!=n:
        ans+=1
print(ans)

Measured memory_bytes: 3444
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int total_row = sc.nextInt();
	    int answer = 0;

	    List<Integer> FirstRowCandy = new ArrayList<Integer>();

	    for (int i = 0; i < total_row; i++) {
	    	int candy = sc.nextInt();
	    	FirstRowCandy.add(candy);
	    }

	    List<Integer> SecondRowCandy = new ArrayList<Integer>();

	    for (int i = 0; i < total_row; i++) {
	    	int candy = sc.nextInt();
	    	SecondRowCandy.add(candy);
	    }

	    for (int i = 0; i < total_row; i++) {
	    	int tmp_answer = 0;

	    	for (int j = 0; j <= i ; j++) {
	    		tmp_answer = tmp_answer + FirstRowCandy.get(j);
	    	}
	    	for (int j = total_row -1; j >= i; j--) {
	    		tmp_answer = tmp_answer + SecondRowCandy.get(j);
	    	}

	    	if (tmp_answer > answer) {
	    		answer = tmp_answer;
	    	}

	    }
	    System.out.println(answer);
	}
}

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

int main() {
  int a,b,c;
   cin >> a >> b >> c;
   if((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5)) cout << "YES" << endl;
   else cout << "NO" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int a;
    int b;
    int c;
    int d;
  
  cin >> a >> b >> c >> d;
  
   int ab = b - a;
   if (ab < 0){
     ab = -ab; 
   }
  
   int bc = c - b;
   if (bc < 0){
    
     bc = -bc;
   }
  
   int ac = c - a;
  
   if (ac < 0){
     
     ac = -ac;
   }
     
    if (ab <= d && bc <= d){
      
       cout << "Yes" << endl;
     
   }else if (ac <= d){
       cout << "Yes" << endl;
      
    }else{
     
      cout << "No" << endl;
   }
   
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = Integer.parseInt(sc.next());
		int g = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());

		if ((100 * r + 10 * g + b) % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 22868
/*  ex5_4
    kosaq   */

#include <stdio.h>
#include <string.h>

int main(void){
    char string[11], *ptr;//入力する文字列とポインタを定義
    int count = 0;//長さを数えるために定義
    int count_max = 0;//最終的に答えとして出力する長さ

    scanf("%s", &string[0]);//文字列を入力
    ptr = &string[0];//ポインタへ代入

    while(*ptr){
        if(*ptr == 'A' || *ptr == 'C' || *ptr == 'G' || *ptr == 'T'){
            count++;//A,C,G,Tの文字が出てきたらcountを１増やす
            if(count_max < count){//countがcount_maxよりも大きくなったら
                count_max = count;//count_maxを更新する
            }
        }
        else{
            count = 0;// A,C,G,T以外の文字が出てきたらcountをリセット
        }
        ptr++;//順番に動かす
    }

    printf("%d\n", count_max);//答えを出力
    return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
using namespace std;

int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    int l1 = s1.length();
    int l2 = s2.length();
    int dp[l1+1][l2+1];
    for (int i=0; i<=l1; ++i){
        for (int j=0; j<=l2; ++j){
            if(i == 0){
                dp[0][j] = j;
            }
            else if(j == 0){
                dp[i][0] = i;
            }
            else {
                dp[i][j] = 0;
            }
        }
    }
    for (int i=0; i<l1; ++i){
        for (int j=0; j<l2; ++j){
            int c = (s1[i] == s2[j]) ? 0 : 1;
            dp[i+1][j+1] = min(dp[i][j] + c, min(dp[i][j+1] + 1, dp[i+1][j] + 1));
        }
    }
    cout << dp[l1][l2] << endl;
    return 0;
}


Measured memory_bytes: 7084
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long N;
  string s;
  long red = 0, blue = 0;
  cin >> N >> s;
  rep(i, N) {
    if (s[i] == 'R') red++;
    else blue++;
  }
  if (red > blue) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
//const LL mod = 1000000007ll;
const int mod_int = 1000000007;

const LL mod = 998244353ll;

LL N,S;
LL A[3000];

LL ans = 0;

void solve(){
	vector<vector<LL>> dp(N+1,vector<LL>(S+1,0));
	dp[0][0] = 1;
	//ばらまく
	for(int i=0;i<N;i++){
		for(int j=0;j<=S;j++){
			dp[i+1][j] = (dp[i+1][j] + dp[i][j]*2LL)%mod;
			if(j+A[i]<=S) dp[i+1][j+A[i]] = (dp[i+1][j+A[i]]+dp[i][j])%mod;
		}
	}
	ans = dp[N][S];
}

int main(){
    cin >> N >> S;
    for(int i=0;i<N;i++) cin >> A[i];

    solve();

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

Measured memory_bytes: 73360
#pragma GCC target ("avx")
#pragma GCC optimize ("unroll-loops")

#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(998244353);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)

// f(L, R) := 和が S になるように配列 A のいくつかの要素を範囲 [L,R] から選ぶ選び方
// 左端の選ぶ値を固定して dp
// 右端に到達したときに 1 ではなく N-R を加算

int N, S;
int A[3000];

ll dp[3000][3000];
ll solve(int n, int s){
	if(s > S) return 0;
	if(s == S) return N-n+1;
	if(n == N) return 0;
	if(dp[n][s] != -1) return dp[n][s];
	return dp[n][s] = (solve(n+1, s)+solve(n+1, s+A[n]))%MOD;
}

signed main(){
	scanf("%d%d", &N, &S);
	rep(i, N) scanf("%d", A+i);

	memset(dp, -1, sizeof(dp));
	ll ans = 0;
	rep(i, N){
		ans += solve(i+1, A[i])*(i+1);
		ans %= MOD;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 70656