Problem:
Problem C: Round And Round
Problem
長さ$N$の数列$A=${$a_{1},a_{2},a_{3},...,a_{n}$}が与えられる。
$a_{i}$ ($i=1,2,3,...,n$)は、$i$で初期化されているものとする。
以下の二種類のクエリを合計$Q$回処理せよ。
数列$A$の先頭から$k$番目の要素の値を出力する。
数列$A$の先頭から$k$と$k+1$番目を境界に二つの数列をスワップする。
詳しくはサンプル入出力を参考にせよ。
Input
入力は以下の形式で与えられる。
$N$ $Q$
$query_1$
$query_2$
...
$query_Q$
各クエリは以下の二種類のいずれかの形式で与えられる。
クエリ$0$
$0$ $k$
数列$A$の先頭から$k$番目の要素の値を出力する。
クエリ$1$
$1$ $k$
数列$A$の先頭から$k$と$k+1$番目を境界に二つの数列をスワップする。
入力はすべて整数で与えられる。
$1$行目に$N$, $Q$が空白区切りで与えられる。
$2$行目以降の$Q$行にクエリが改行区切りで与えられる。
各クエリ内の数値は全て空白区切りである。
Constraints
入力は以下の条件を満たす。
$2 \leq N \leq 10^9 $
$1 \leq Q \leq 10^5 $
各クエリについて、入力は以下の条件を満たす。
クエリ$0$
$1 \leq k \leq N $
クエリ$1$
$1 \leq k \leq N-1 $
Output
各クエリ$1$に対し値を一行に出力せよ。
Sample Input 1
5 4
1 2
0 2
1 1
0 3
Sample Output 1
4
1
長さ$5$の数列$A=[1,2,3,4,5]$が与えられる
$1$番目のクエリで $[1,2,3,4,5]$ -> $[1,2] [3,4,5]$ -> $[3,4,5] [1,2]$ -> $[3,4,5,1,2]$ と数列が変化する。
$2$番目のクエリで先頭から$2$番目の要素の値である$4$を出力する。
$3$番目のクエリで $[3,4,5,1,2]$ -> $[3] [4,5,1,2]$ -> $[4,5,1,2] [3]$ -> $[4,5,1,2,3]$ と数列が変化する。
$4$番目のクエリで先頭から$3$番目の要素の値である$1$を出力する。
Sample Input 2
4 4
1 2
1 1
0 1
0 4
Sample Output 2
4
3
Sample Input 3
10 6
1 1
0 1
1 9
0 5
1 1
0 10
Sample Output 3
2
5
1

Submitted solutions:

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

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

	ll N,Q;
	cin>>N>>Q;
	ll x=0;
	for(int q=0;q<Q;q++){
		int t,k;
		cin>>t>>k;
		if(t==1){
			x+=k;
			x%=N;
		}
		else{
			cout<<(x+k-1)%N+1<<endl;
		}
	}
}
accuracy: 1
time_ms: 20
memory_kb: 3584
final_rank: 7

code_snippet: #include <bits/stdc++.h>


using namespace std;
//make -f ../makefile SRC=
/*
*/


//------------------------------------------------------------------------------
bool DEBUG = false;
const int INF = 1000000000;

const int MAX_N = 100;
//static int vect[MAX_N];

//------------------------------------------------------------------------------
int solve(int N)
{
    //--------------------------------------------------------------------------
    // base cases:
    //--------------------------------------------------------------------------
    // init:
    //sort(vect, vect+N);
    //memset(S0, 0L, sizeof(S0));
    //--------------------------------------------------------------------------
    // compute:
    

    //--------------------------------------------------------------------------
    
    //--------------------------------------------------------------------------
    // report:
    return -1;
}

//------------------------------------------------------------------------------
void test()
{

}

//------------------------------------------------------------------------------
int main()
{
    //test(); return 0;
    //DEBUG = true;
    //--------------------------------------------------------------------------
    int N, Q, type, k, num;
    num = scanf("%d %d ", &N, &Q);
    int first = 0;
    for (int q=0; q<Q; ++q)
    {
        num = scanf("%d %d ", &type, &k);
        if (type == 0) printf("%d\n", (first+k-1)%N + 1);
        else if (type == 1) first = (first+k)%N;
    }
    //--------------------------------------------------------------------------
    return 0;
}
//------------------------------------------------------------------------------
accuracy: 1
time_ms: 10
memory_kb: 3612
final_rank: 6

code_snippet: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    int o = 0;
    while (q--) {
        int t, x;
        cin >> t >> x;
        if (t == 0) {
            x -= 1;
            cout << (o + x) % n + 1 << "\n";
        } else {
            o += x;
            o %= n;
        }
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3456
final_rank: 5

code_snippet: #include <iostream>
#include <map>
using namespace std;

int main() {
	int top=1;
	int n,q;
	cin>>n>>q;
	for(int i=0;i<q;i++){
		int a,b;
		cin>>a>>b;
		if(a==0){
			int t=n-top+1;
			if(t>=b){
				cout<<top+b-1<<endl;
			}else{
				cout<<b-t<<endl;
			}
		}else if(a==1){
			int t=n-top+1;
			if(t>b){
				top=top+b;
			}else{
				top=b-t+1;
			}
		}
	//	cout<<"top="<<top<<endl;
	}
	return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 3104
final_rank: 10

code_snippet: #include <iostream>
using namespace std;

int main(){
    int n, q;
    cin >> n >> q;
    int top = 0;
    while(q--){
        int op, k;
        cin >> op >> k;
        if(op == 0){
            cout << (top+k-1)%n + 1 << '\n';
        }else{
            top += k;
            top %= n;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 3472
final_rank: 8

code_snippet: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;
typedef unsigned int ull;
typedef pair<ll,int> pil;
const ll ll_INF = 0x3f3f3f3f3f3f3f3f;
const int int_INF = 0x3f3f3f3f;
const double EPS = 1e-7;
#define R register
#define _max(a,b)  ((a)>(b)?(a):(b))
#define _min(a,b)  ((a)<(b)?(a):(b))
#define _abs(a)    ((a)> 0 ?(a):-(a))
#define _swap(a,b) ((a)^=(b)^=(a)^=(b))
#define _eql(x,y)  (_abs((x) - (y))<EPS)

const int MX = 1000010;
ll _r() {
    ll x = 0, f = 1;
    char c = getchar();
    while (c > '9' || c < '0') { if (c == '-')f = -1; c = getchar(); }
    while (c >= '0' && c <= '9')x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    return f==-1?-x:x;
}
void Init() {

}

void solve() {

}
int main() {
    //freopen("data.in", "r", stdin);
    //freopen("data.out", "w", stdout);
    ll n=_r(),q=_r();
    ll head=0;
    while(q--){
        ll ope=_r(),k=_r();
        if(ope)
            head=(head+k)%n;
        else
            printf("%lld\n",(head+(k-1))%n+1);
    }

#ifdef VSC
    getchar();
#endif
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3228
final_rank: 4

code_snippet: #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n, q; cin >> n >> q;
    int ofs = 0;
    while (q--) {
        int op, k; cin >> op >> k;
        if (op == 0) cout << (ofs + k - 1) % n + 1 << endl;
        if (op == 1) ofs = (ofs + k) % n;
    }
    return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 3132
final_rank: 17

code_snippet: /*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,q,a,b,now=1;
  cin >> n >> q;
  while(q--) {
    cin >> a >> b;
    if(!a) {
      if(now+b-1>n) {
        cout << now+b-1-n << "\n";
      }
      else {
        cout << now+b-1 << "\n";
      }
    }
    else {
      if(now+b>n) {
        now=now+b-n;
      }
      else {
        now=now+b;
      }
    }
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3224
final_rank: 2

code_snippet: #include <iostream>

using namespace std;

int main()
{
  int N, Q;
  int op, k;
  int index = 0;
  
  cin >> N >> Q;
  while (Q--) {
    cin >> op >> k;
    if (op == 0) {
      int element = (index + k) % N;
      element ? cout << element << endl : cout << N << endl;
    } else if (op == 1) {
      index = (index + k) % N;
    }
  }
}
accuracy: 1
time_ms: 80
memory_kb: 3116
final_rank: 15

code_snippet: /*  -*- coding: utf-8 -*-
 *
 * 3041.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, q;
  scanf("%d%d", &n, &q);

  int h = 0;
  while (q--) {
    int op, k;
    scanf("%d%d", &op, &k);

    if (op == 0) {
      k--;
      printf("%d\n", (h + k) % n + 1);
    }
    else
      h = (h + k) % n;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3224
final_rank: 2

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP(i,n) for(ll i =0;i<n;++i)

int main(){
  int n,q;
  cin>>n>>q;
  int pos=1;
  REP(i,q){
      int t;cin>>t;
      int k;cin>>k;
     
      if(t==0){
           int tar;
            if(pos+k-1>n)tar=pos+k-1-n;
            else tar=pos+k-1;
            cout<<tar<<endl;
      }else{
          k++;
        int tar;
        if(pos+k-1>n)tar=pos+k-1-n;
        else tar=pos+k-1;
        pos=tar;
      }
  }
}
accuracy: 1
time_ms: 80
memory_kb: 3104
final_rank: 10

code_snippet: #include <iostream>
using namespace std;
int main() {
	int n,q,p=1,c,x;
	cin>>n>>q;
	for(int i=0;i<q;i++){
		cin>>c>>x;
		if(!c)cout<<((p+x-1)%n==0? n:(p+x-1)%n)<<endl;
		else {p=(p+x)%n; if(p==0)p=n;}
	}
	return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 3120
final_rank: 16

code_snippet: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define repi(n) for(int i=0; i<(n); ++i)
#define repj(n) for(int j=0; j<(n); ++j)
#define repk(n) for(int k=0; k<(n); ++k)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << endl;
#define qp(f) [](auto i){return f;}
using LL=long long;
using VI=vector<int>;
using VL=vector<LL>;
using VS=vector<string>;
using VVI=vector<vector<int>>;
using PII=pair<int, int>;
const int inf = (int)1e9;
const LL MOD = 1000000007;
const double pi = acos(-1.0);
template<class T>T Sort(T & a) { sort(a.begin(), a.end()); return a; }
template<class T>T ReSort(T& a) { sort(a.rbegin(), a.rend()); return a; }
template<class T>T Reverse(T& a) { reverse(a.begin(), a.end()); return a; }
template<class T>void Unique(T& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template<class T>auto Max(T a) { return *max_element(a.begin(), a.end()); }
template<class T>auto Min(T a) { return *min_element(a.begin(), a.end()); }
template<class T, class U>int Count(T a, U c) { return count(a.begin(), a.end(), c); }
template<class T, class U>U Sum(T a, U init = 0) { return accumulate(a.begin(), a.end(), init); }
template<class T>T Age(T a, T b) { return (a + b - 1) / b; }
template<class T>T gcd(T n, T m) { return m == 0 ? n : gcd(m, n % m); }
template<class T>T lcm(T n, T m) { return n / gcd(n, m) * m; }
struct SORT {}SOrt;
template<class T> T operator |(T v, SORT s) {
	return Sort(v);
}
char Snum[] = "0123456789";


/* MOD */
LL modpow(LL a, LL n, LL _MOD = MOD) {
	LL re = 1;
	while (n > 0) {
		if (n & 1)re = re * a % _MOD;
		a = a * a % _MOD; n >>= 1;
	}
	return re;
}
LL modinv(LL n, LL _MOD = MOD) {
	return modpow(n, _MOD - 2, _MOD);
}
struct Modl {
	LL val = 0;
	Modl(LL v = 0)noexcept :val(v% MOD) { if (val < 0)v += MOD; }
	operator LL() { return val; }
};
Modl operator-(const Modl & a) { Modl r; r.val = a.val ? MOD - a.val : 0; return r; }
Modl operator+(const Modl & a, const Modl & b) { Modl r(a.val + b.val); return r; }
Modl operator-(const Modl & a, const Modl & b) { Modl r(a.val - b.val); return r; }
Modl operator*(const Modl & a, const Modl & b) { Modl r(a.val * b.val); return r; }
Modl operator/(const Modl & a, const Modl & b) { Modl r(a.val * modinv(b.val, MOD)); return r; }

Modl operator+(const Modl & a, const int& b) { Modl r(a.val + LL(b)); return r; }
Modl operator-(const Modl & a, const int& b) { Modl r(a.val - LL(b)); return r; }
Modl operator*(const Modl & a, const int& b) { Modl r(a.val * LL(b)); return r; }
Modl operator/(const Modl & a, const int& b) { Modl r(a.val * modinv(LL(b), MOD)); return r; }

Modl operator+(const Modl & a, const LL & b) { Modl r(a.val + b); return r; }
Modl operator-(const Modl & a, const LL & b) { Modl r(a.val - b); return r; }
Modl operator*(const Modl & a, const LL & b) { Modl r(a.val * b); return r; }
Modl operator/(const Modl & a, const LL & b) { Modl r(a.val * modinv(b, MOD)); return r; }

Modl operator+(const int& a, const Modl & b) { Modl r(LL(a) + b.val); return r; }
Modl operator-(const int& a, const Modl & b) { Modl r(LL(a) - b.val); return r; }
Modl operator*(const int& a, const Modl & b) { Modl r(LL(a) * b.val); return r; }
Modl operator/(const int& a, const Modl & b) { Modl r(LL(a) * modinv(b.val, MOD)); return r; }

Modl operator+(const LL & a, const Modl & b) { Modl r(a + b.val); return r; }
Modl operator-(const LL & a, const Modl & b) { Modl r(a - b.val); return r; }
Modl operator*(const LL & a, const Modl & b) { Modl r(a * b.val); return r; }
Modl operator/(const LL & a, const Modl & b) { Modl r(a * modinv(b.val, MOD)); return r; }
Modl pow(Modl a, int n) { Modl r(modpow(a, n)); return r; }
Modl pow(Modl a, LL n) { Modl r(modpow(a, n)); return r; }

/* RANGE */
namespace RangeNS {
	template<typename T>class Range {
		const T start_, stop_, step_;
	public:
		Range(const T& start, const T& stop, const T& step) : start_{ start }, stop_{ stop }, step_{ step } {assert(!(step_ == 0 || (start_ > stop_ && step_ > 0) || (start_ < stop_ && step_ < 0))); }
		class iterator {
			T value_; const T start_, stop_, step_;
		public:
			iterator(T value, T step, T start, T stop) : value_{ value }, step_{ step }, start_{ start }, stop_{ stop } {}
			iterator operator++() { value_ = std::min(std::max(start_, stop_), std::max(std::min(start_, stop_), value_ + step_)); return *this; }
			T & operator*() { return value_; }
			const T* operator->() { return &value_; }
			bool operator==(const iterator & rhs) { return value_ == rhs.value_; }
			bool operator!=(const iterator & rhs) { return value_ != rhs.value_; }
		};
		iterator begin() const { return iterator(start_, step_, start_, stop_); }
		iterator end() const { return iterator(stop_, step_, start_, stop_); }
		explicit operator vector<T>() const { vector<T>t; for (T i = start_; i < stop_; i += step_)t.push_back(i); return t; }
	};
	template <typename T, typename Func, typename FuncType> class Range2 {
		using Itr = typename T::iterator; Itr begin_, end_; Func f_;
	public:
		Range2(T& v, Func f) : begin_{ v.begin() }, end_{ v.end() }, f_{ f } {}
		class iterator {
		public:
			//typedef std::forward_iterator_tag iterator_category;
			iterator(Itr itr, Func f) : itr_{ itr }, f_{ f } {}
			iterator operator++() { ++itr_; return *this; }
			FuncType operator*() { return f_(*itr_); }
			bool operator==(iterator rhs) { return rhs.itr_ == itr_; }
			bool operator!=(iterator rhs) { return rhs.itr_ != itr_; }
		private:
			Itr itr_; Func f_;
		};
		iterator begin() const { return iterator(begin_, f_); }
		iterator end() const { return iterator(end_, f_); }
		operator vector<FuncType>() const { vector<FuncType>t; for (Itr i = begin_; i != end_; ++i)t.push_back(f_(*i)); return t; }
	};
}
template<typename T> RangeNS::Range<T> range(const T & stop) { return RangeNS::Range<T>(T{ 0 }, stop, T{ 1 }); }
template<typename T> RangeNS::Range<T> range(const T & start, const T & stop) { return RangeNS::Range<T>(start, stop, T{ 1 }); }
template<typename T> RangeNS::Range<T> range(const T & start, const T & stop, const T & step) { return RangeNS::Range<T>(start, stop, step); }
template<typename _T> ostream& operator << (ostream & ostr, const vector<_T> & v) {
	if (v.size() == 0) { ostr << ""; return ostr; }ostr << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++)ostr << " " << *itr; return ostr;
}
template<typename T> ostream& operator << (ostream & ostr, const RangeNS::Range<T> & r) { ostr << vector<T>(r); return ostr; }
template<typename T, typename Func, typename FuncType> ostream& operator << (ostream & ostr, const RangeNS::Range2<T, Func, FuncType> & r) { ostr << vector<FuncType>(r); return ostr; }
template<class T, class Func> auto operator | (T & v, Func f) { RangeNS::Range2<T, Func, decltype(f(*v.begin()))>r(v, f); return r; }
template<class T, class Func> auto operator | (T && v, Func f) { RangeNS::Range2<T, Func, decltype(f(*v.begin()))>r(v, f); return r; }

/* INPUT */
struct inputter_Str {
	vector<string> inputbuffer;
	string operator [](int n) { while (inputbuffer.size() <= n) { string s; cin >> s; inputbuffer.push_back(s); }return inputbuffer[n]; }
	operator string() { return this[inputbuffer.size()]; }
}; inputter_Str in;
struct inputter_Int {
	int operator [](int n) { return stoi(in[n]); }
	operator int() { return stoi(string(in)); }
}; inputter_Int ini;
struct inputter_LL {
	LL operator [](int n) { return stoll(in[n]); }
	operator int() { return stoll(string(in)); }
}; inputter_LL inl;
struct inputter_Double {
	double operator [](int n) { return stod(in[n]); }
	operator int() { return stold(string(in)); }
}; inputter_Double ind;
VI invi(int n, int m) { VI v(m); for (int i = 0; i < m; ++i)v[i] = ini[n + i]; return v; }
VL invl(int n, int m) { VL v(m); for (int i = 0; i < m; ++i)v[i] = inl[n + i]; return v; }
int Suminvi(int n, int m) { return Sum(invi(n, m), 0); }LL Suminvl(int n, int m) { return Sum(invl(n, m), 0LL); }
int Maxinvi(int n, int m) { return  Max(invi(n, m)); }LL Maxinvl(int n, int m) { return Max(invl(n, m)); }
int Mininvi(int n, int m) { return  Min(invi(n, m)); }LL Mininvl(int n, int m) { return Min(invl(n, m)); }

/* OUTPUT */
struct boolswitch { string t, f; boolswitch(string tr, string fa) :t(tr), f(fa) {} }yes("yes", "no"), Yes("Yes", "No"), YES("YES", "NO"), Yay("Yay!", ":(");
struct divizer { string s; divizer(string s_) :s(s_) {} }spc(" "), nosp("");
struct outputter {
	bool flag = false; boolswitch bs; divizer di;
	outputter(bool f, boolswitch b, divizer d) :flag(f), bs(b), di(d) {}
	template<class T>outputter operator ,(T o) {
		if (flag)cout << di.s; cout << o;
		outputter t(true, bs, di); return t;
	}
	outputter operator ,(double o) {
		if (flag)cout << di.s; printf("%.20f", o);
		outputter t(true, bs, di); return t;
	}
	outputter operator ,(bool o) {
		if (flag)cout << di.s; cout << (o ? bs.t : bs.f);
		outputter t(true, bs, di); return t;
	}
	template<class T> outputter operator ,(vector<T> o) {
		if (flag)cout << di.s;
		for (int i = 0; i < (int)o.size(); ++i)cout << o[i] << (i == (int)o.size() - 1 ? "" : di.s);
		outputter t(true, bs, di); return t;
	}
	template<class T, class U> outputter operator ,(pair<T, U> o) {
		if (flag)cout << di.s;
		cout << "[" << o.first, ", " << o.second << "]";
		outputter t(true, bs, di); return t;
	}
	outputter operator ,(outputter o) { cout << '\n'; return o; }
	outputter operator ,(boolswitch b) { outputter t(flag, b, di); return t; }
	outputter operator ,(divizer d) { outputter t(flag, bs, d); return t; }
}out(false, Yes, spc);

/* ANSWER */
struct Answer {
	int mini = INT_MAX, maxi = INT_MIN, sumi = 0;
	LL minl = LLONG_MAX, maxl = LLONG_MIN, suml = 0LL;
	double mind = DBL_MAX, maxd = DBL_MIN, sumd = 0.;
	int count = 0;
	void operator =(int n) { mini = min(mini, n); maxi = max(maxi, n); sumi += n; count++; }
	void operator =(LL n) { minl = min(minl, n); maxl = max(maxl, n); suml += n; count++; }
	void operator =(double n) { mind = min(mind, n); maxd = max(maxd, n); sumd += n; count++; }
}ans;

int re(int n, int f, int k) {
	return (f + k > n) ? f + k - n : f + k;
}

int main() {
	int n = ini[0], Q = ini[1];
	int first = 1;
	rep(i, Q) {
		int q; cin >> q;
		if (q == 0) {
			int k; cin >> k;
			out, re(n, first, k - 1), out;
		}
		else {
			int k; cin >> k;
			first = re(n, first, k);
		}
	}
}
accuracy: 1
time_ms: 80
memory_kb: 3236
final_rank: 18

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    int n, q, sum=0;
    cin >> n >> q;
    REP(i,q){
        int c, k;
        cin >> c >> k;
        if(c==0){
            cout << (sum+k-1)%n+1 << endl;
        }
        else {
            sum = (sum+k)%n;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 3104
final_rank: 10

code_snippet: #include <cstdio>

int main() {
  int N, Q;
  scanf("%d %d", &N, &Q);

  int ofs = 0;
  for (int i = 0; i < Q; ++i) {
    int q, k;
    scanf("%d %d", &q, &k);
    if (q == 0) {
      int res = (ofs+k) % N;
      if (res == 0) res = N;
      printf("%d\n", res);
    } else if (q == 1) {
      ofs += k;
      if (ofs >= N) ofs -= N;
    }
  }
}
accuracy: 1
time_ms: 10
memory_kb: 2760
final_rank: 1

code_snippet: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int n,q;
    cin >> n >> q;
    int ind = 0;
    rep(_,q){
        int a,b;
        cin >> a >> b;
        if(a){//swap
            ind = (ind+b)%n;
        }else{//cout
            b--;
            cout << (ind+b)%n+1 << endl;
        }
    }
}
accuracy: 1
time_ms: 80
memory_kb: 3100
final_rank: 9

code_snippet: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    long long N, Q;
    cin >> N >> Q;
    long long sum = 0;
    for (int i = 0; i < Q; i++) {
        int t, k;
        cin >> t >> k;
        if (t == 1) {
            sum += k;
            sum %= N;
        } else {
            cout << (sum + k - 1) % N + 1 << endl;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 3104
final_rank: 10

code_snippet: #include<iostream>
#include<vector>
using namespace std;

void swap( int* a, int k, int n )
{
    int* b = new int[k];
    int* c = new int[n-k];

    for( int i = 0; i < k; i++ )
        b[i] = a[i+1];
    for( int i = 0; i < n - k; i++ )
        c[i] = a[i+k+1];
    for( int i = 1; i <= n - k; i++ )
        a[i] = c[i-1];
    for( int i = n - k + 1; i <= n; i++ )
        a[i] = b[i-n+k-1];
    delete b, c;
}

int main()
{
    int n, q, k, query;

    cin >> n >> q;

    int a[n+1];
    for( int i = 1; i <= n; i++ )
        a[i] = i;

    for( int i = 0; i < q; i++ )
    {
        cin >> query >> k;
        if( query )
            swap( a, k, n );
        if( !query )
            cout << a[k] << endl;
    }

    return 0;
}
accuracy: 0.6774193548387096
time_ms: 180
memory_kb: 334760
final_rank: 20

code_snippet: #include<iostream>
#include<vector>
using namespace std;

void swap( int* a, int k, int n )
{
    int b[k], c[n-k];
    for( int i = 0; i < k; i++ )
        b[i] = a[i+1];
    for( int i = 0; i < n - k; i++ )
        c[i] = a[i+k+1];
    for( int i = 1; i <= n - k; i++ )
        a[i] = c[i-1];
    for( int i = n - k + 1; i <= n; i++ )
        a[i] = b[i-n+k-1];
}

int main()
{
    int n, q, k, query;

    cin >> n >> q;

    int a[n+1];
    for( int i = 1; i <= n; i++ )
        a[i] = i;

    for( int i = 0; i < q; i++ )
    {
        cin >> query >> k;
        if( query )
            swap( a, k, n );
        if( !query )
            cout << a[k] << endl;
    }

    return 0;
}
accuracy: 0.6774193548387096
time_ms: 120
memory_kb: 3196
final_rank: 19

code_snippet: #include<iostream>
using namespace std;

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

    int cur = 0;
    int op, k;

    while(q-- > 0){
        cin >> op >> k;
        if(op == 0){
            cout << (cur+k-1)%n+1 << endl;
        }else{
            cur = (cur+k)%n;
        }
    }

    return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 3112
final_rank: 14